From 3010e5ba646f938a856fc286439a3df34ed9a53f Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Thu, 20 Aug 2015 10:09:20 -0700 Subject: [PATCH] Smartsync: Don't fail if there isn't a cookiefile Change-Id: I434a259f43ca9808e88051ac8ba865c519a24702 --- subcmds/sync.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/subcmds/sync.py b/subcmds/sync.py index 6191a3c3..ad0ecdf4 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -905,19 +905,22 @@ class PersistentTransport(xmlrpc.client.Transport): # Python doesn't understand cookies with the #HttpOnly_ prefix # Since we're only using them for HTTP, copy the file temporarily, # stripping those prefixes away. - tmpcookiefile = tempfile.NamedTemporaryFile() - try: - with open(cookiefile) as f: - for line in f: - if line.startswith("#HttpOnly_"): - line = line[len("#HttpOnly_"):] - tmpcookiefile.write(line) - tmpcookiefile.flush() + if cookiefile: + tmpcookiefile = tempfile.NamedTemporaryFile() + try: + with open(cookiefile) as f: + for line in f: + if line.startswith("#HttpOnly_"): + line = line[len("#HttpOnly_"):] + tmpcookiefile.write(line) + tmpcookiefile.flush() - cookiejar = cookielib.MozillaCookieJar(tmpcookiefile.name) - cookiejar.load() - finally: - tmpcookiefile.close() + cookiejar = cookielib.MozillaCookieJar(tmpcookiefile.name) + cookiejar.load() + finally: + tmpcookiefile.close() + else: + cookiejar = cookielib.CookieJar() proxyhandler = urllib.request.ProxyHandler if proxy: