mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
* common.py:
- If loading a cookie file raises an exception exit. - Improve cookie file writing.
This commit is contained in:
parent
70fc6fa3c7
commit
49c0e14da3
38
common.py
38
common.py
@ -164,20 +164,20 @@ def _check_for_launchpad_cookie(cookie_file):
|
|||||||
newLPCookieLocation = os.path.expanduser("~/.lpcookie.txt")
|
newLPCookieLocation = os.path.expanduser("~/.lpcookie.txt")
|
||||||
|
|
||||||
# Open file for writing.
|
# Open file for writing.
|
||||||
newLPCookie = open(newLPCookieLocation, 'w')
|
try:
|
||||||
# For security reasons, change file mode to write and read
|
newLPCookie = open(newLPCookieLocation, 'w')
|
||||||
# only by owner.
|
# For security reasons, change file mode to write and read
|
||||||
os.chmod(newLPCookieLocation, 0600)
|
# only by owner.
|
||||||
newLPCookie.write("# HTTP Cookie File.\n") # Header.
|
os.chmod(newLPCookieLocation, 0600)
|
||||||
|
newLPCookie.write("# HTTP Cookie File for Launchpad.\n") # Header.
|
||||||
|
|
||||||
for item in items:
|
for item in items:
|
||||||
# Write entries.
|
# Write entries.
|
||||||
newLPCookie.write("%s\t%s\t%s\t%s\t%s\t%s\t%s\n" % (
|
newLPCookie.write("%s\t%s\t%s\t%s\t%s\t%s\t%s\n" % (
|
||||||
item[0], ftstr[item[0].startswith('.')], item[1],
|
item[0], ftstr[item[0].startswith('.')], item[1],
|
||||||
ftstr[item[2]], item[3], item[4], item[5]))
|
ftstr[item[2]], item[3], item[4], item[5]))
|
||||||
|
finally:
|
||||||
newLPCookie.write("\n") # New line.
|
newLPCookie.close() # And close file.
|
||||||
newLPCookie.close() # And close file.
|
|
||||||
|
|
||||||
return newLPCookieLocation
|
return newLPCookieLocation
|
||||||
else:
|
else:
|
||||||
@ -188,8 +188,16 @@ def _check_for_launchpad_cookie(cookie_file):
|
|||||||
|
|
||||||
def setupLaunchpadUrlOpener(cookie):
|
def setupLaunchpadUrlOpener(cookie):
|
||||||
""" Build HTML opener with cookie file. """
|
""" Build HTML opener with cookie file. """
|
||||||
cj = cookielib.MozillaCookieJar()
|
|
||||||
cj.load(cookie)
|
# Attempt to load our cookie file.
|
||||||
|
try:
|
||||||
|
cj = cookielib.MozillaCookieJar()
|
||||||
|
cj.load(cookie)
|
||||||
|
except cookielib.LoadError, error:
|
||||||
|
print "Unable to load cookie file: %s (%s)" % (cookie, error)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# Add cookie to our URL opener.
|
||||||
urlopener = urllib2.build_opener()
|
urlopener = urllib2.build_opener()
|
||||||
urlopener.add_handler(urllib2.HTTPCookieProcessor(cj))
|
urlopener.add_handler(urllib2.HTTPCookieProcessor(cj))
|
||||||
|
|
||||||
|
8
debian/changelog
vendored
8
debian/changelog
vendored
@ -1,3 +1,11 @@
|
|||||||
|
ubuntu-dev-tools (0.43ubuntu1) intrepid; urgency=low
|
||||||
|
|
||||||
|
* common.py:
|
||||||
|
- If loading a cookie file raises an exception exit.
|
||||||
|
- Improve cookie file writing.
|
||||||
|
|
||||||
|
-- Jonathan Patrick Davies <jpds@ubuntu.com> Wed, 27 Aug 2008 15:32:14 +0100
|
||||||
|
|
||||||
ubuntu-dev-tools (0.42ubuntu1) intrepid; urgency=low
|
ubuntu-dev-tools (0.42ubuntu1) intrepid; urgency=low
|
||||||
|
|
||||||
[Jonathan Patrick Davies]
|
[Jonathan Patrick Davies]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user