extras-buildsys/common FileDownloader.py,1.14,1.15
Daniel Williams (dcbw)
fedora-extras-commits at redhat.com
Fri Sep 16 18:11:21 UTC 2005
Author: dcbw
Update of /cvs/fedora/extras-buildsys/common
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv8896/common
Modified Files:
FileDownloader.py
Log Message:
2005-09-16 Dan Williams <dcbw at redhat.com>
* builder/builder.py
common/FileDownloader.py
server/ArchJob.py
- Rename FileNameError -> FileNameException
* builder/builder.py
- Clean up exception handling on job creation so that we
don't end up calling start() before Thread.__init__() got
called.
Index: FileDownloader.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/common/FileDownloader.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- FileDownloader.py 26 Jul 2005 17:47:19 -0000 1.14
+++ FileDownloader.py 16 Sep 2005 18:11:19 -0000 1.15
@@ -25,13 +25,7 @@
import exceptions
-class FileNameError(exceptions.Exception):
- def __init__(self, args=None):
- exceptions.Exception.__init__(self)
- self.args = args
- def __str__(self):
- return self.args
-
+class FileNameException(exceptions.Exception): pass
def get_base_filename_from_url(url, legal_exts):
""" Safely unquotes a URL and gets the base file name from it.
@@ -51,12 +45,12 @@
# If after 5 iterations of unquoting, the strings still aren't the same,
# something is wrong.
if (count == 0) and (unquoted != last_unquoted):
- raise FileNameError("URL quoting level too deep.")
+ raise FileNameException("URL quoting level too deep.")
# Try to grab the filename off the end of the URL
index = url.rfind('/')
if index is -1:
- raise FileNameError("No separator in URL.")
+ raise FileNameException("No separator in URL.")
filename = url[index+1:]
# Only accept certain file extensions
@@ -67,7 +61,7 @@
break
if not ext_ok:
- raise FileNameError("Extension was not allowed.")
+ raise FileNameException("Extension was not allowed.")
# FIXME: what other validation can we do here?
safe_list = ['_', '-', '.', '+']
@@ -76,7 +70,7 @@
if c in safe_list or c.isalnum():
pass
else:
- raise FileNameError("Illegal character '%s' encountered." % c)
+ raise FileNameException("Illegal character '%s' encountered." % c)
return filename
@@ -88,10 +82,9 @@
self._cb_data = cb_data
self._url = url
self._target_dir = target_dir
- try:
- self._filename = get_base_filename_from_url(self._url, legal_exts)
- except FileNameError, e:
- print "Couldn't get base filename from url!! Error: '%s' URL: %s." % (e, url)
+
+ # May fail with FileNameException, trapped elsewhere
+ self._filename = get_base_filename_from_url(self._url, legal_exts)
if certs and len(certs) > 0:
self._opener = HTTPSURLopener.HTTPSURLopener(certs)
More information about the fedora-extras-commits
mailing list