summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2015-08-20 10:09:20 -0700
committerDan Willemsen <dwillemsen@google.com>2015-08-20 10:29:37 -0700
commit3010e5ba646f938a856fc286439a3df34ed9a53f (patch)
tree24ae4bcff8eb49c0e4a046664262bed5cfe3e6df
parentba7bc738c1044b68574a28423751156003400362 (diff)
downloadgit-repo-3010e5ba646f938a856fc286439a3df34ed9a53f.tar.gz
Smartsync: Don't fail if there isn't a cookiefilev1.12.27
Change-Id: I434a259f43ca9808e88051ac8ba865c519a24702
-rw-r--r--subcmds/sync.py29
1 files changed, 16 insertions, 13 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):
905 # Python doesn't understand cookies with the #HttpOnly_ prefix 905 # Python doesn't understand cookies with the #HttpOnly_ prefix
906 # Since we're only using them for HTTP, copy the file temporarily, 906 # Since we're only using them for HTTP, copy the file temporarily,
907 # stripping those prefixes away. 907 # stripping those prefixes away.
908 tmpcookiefile = tempfile.NamedTemporaryFile() 908 if cookiefile:
909 try: 909 tmpcookiefile = tempfile.NamedTemporaryFile()
910 with open(cookiefile) as f: 910 try:
911 for line in f: 911 with open(cookiefile) as f:
912 if line.startswith("#HttpOnly_"): 912 for line in f:
913 line = line[len("#HttpOnly_"):] 913 if line.startswith("#HttpOnly_"):
914 tmpcookiefile.write(line) 914 line = line[len("#HttpOnly_"):]
915 tmpcookiefile.flush() 915 tmpcookiefile.write(line)
916 916 tmpcookiefile.flush()
917 cookiejar = cookielib.MozillaCookieJar(tmpcookiefile.name) 917
918 cookiejar.load() 918 cookiejar = cookielib.MozillaCookieJar(tmpcookiefile.name)
919 finally: 919 cookiejar.load()
920 tmpcookiefile.close() 920 finally:
921 tmpcookiefile.close()
922 else:
923 cookiejar = cookielib.CookieJar()
921 924
922 proxyhandler = urllib.request.ProxyHandler 925 proxyhandler = urllib.request.ProxyHandler
923 if proxy: 926 if proxy: