@@ -35,6 +35,7 @@ import re
3535import sys
3636import traceback
3737import logging
38+ import http .cookiejar
3839
3940from argparse import ArgumentParser , RawDescriptionHelpFormatter
4041import datetime as dt
@@ -46,15 +47,6 @@ from textwrap import dedent as msgfmt
4647from tempfile import mktemp
4748import os .path
4849
49- try :
50- import http .cookiejar as cookiejarlib
51- except ImportError :
52- import cookielib as cookiejarlib
53- try :
54- import urllib .request as urlrequest
55- except ImportError :
56- import urllib2 as urlrequest
57-
5850log = logging .getLogger ()
5951
6052def update_from_osm_server (ts , options ):
@@ -72,14 +64,12 @@ def update_from_custom_server(url, seq, ts, options):
7264 extra_request_params = dict (stream = True ,
7365 timeout = options .socket_timeout or None )
7466
75- with rserv .ReplicationServer (url , "osc.gz" , extra_request_params = extra_request_params ) as svr :
76- if options .cookie is not None :
77- # According to the documentation, the cookie jar loads the file only if FileCookieJar.load is called.
78- cookie_jar = cookiejarlib .MozillaCookieJar (options .cookie )
79- cookie_jar .load (options .cookie )
80- opener = urlrequest .build_opener (urlrequest .HTTPCookieProcessor (cookie_jar ))
81- svr .open_url = opener .open
67+ if options .cookie is not None :
68+ cookie_jar = http .cookiejar .MozillaCookieJar (options .cookie )
69+ cookie_jar .load (options .cookie )
70+ extra_request_params ['cookies' ] = cookie_jar
8271
72+ with rserv .ReplicationServer (url , "osc.gz" , extra_request_params = extra_request_params ) as svr :
8373 log .info ("Using replication service at %s" , url )
8474
8575 current = svr .get_state_info ()
0 commit comments