Bug 413742 Improve handling for URLs with spaces in minotaur r=alice

This commit is contained in:
ctalbert@mozilla.com 2008-02-20 14:47:31 -08:00
parent 55f86eb18c
commit 05224af62e
2 changed files with 20 additions and 2 deletions

View File

@ -39,6 +39,7 @@ import urllib
import urlparse
import shutil
import subprocess
import traceback
from optparse import OptionParser
import os
@ -76,6 +77,11 @@ class mozURLopener(urllib.FancyURLopener):
raise IOError, 401
return None
def http_error_404(self, url, fp, errcode, errmsg, headers, data=None):
debug("mozURLOpener: Got a 404!")
raise IOError, 404
return None
class MozDownloader:
def __init__(self, **kwargs):
assert (kwargs['url'] != "" and kwargs['url'] != None)
@ -96,8 +102,17 @@ class MozDownloader:
destfile = open(self.dest, "wb")
destfile.write(data.read())
destfile.close()
except IOError, errcode:
if str(errcode) == "401":
print "Download Fails - Invalid username and password"
elif str(errcode) == "404":
print "Download Fails - URL does not exist: URL = " + self.url
else:
print "Download Fails, IOError"
traceback.print_exc()
except:
print "Download did not work - is your username and password correct?"
print "Download Fails, unrecognized error."
traceback.print_exc()
def ensureDest(self):
try:

View File

@ -37,10 +37,13 @@
from optparse import OptionParser
import partner
import urllib
def main(branch, version, url, loc, name, vFiles, minDir, creds, aus):
partner.doDownload(name, loc, url, minDir, creds)
# Ensure the URL is properly encoded, but don't encode : or /
quotedurl = urllib.quote(urllib.unquote(url), ":/")
partner.doDownload(name, loc, quotedurl, minDir, creds)
partner.doInstall(branch, name, loc)
partner.doMinotaur(name, loc, minDir, vFiles, aus, version)
partner.doUninstall(branch, name, loc)