extras-buildsys/common FileDownloader.py,1.11,1.12
Daniel Williams (dcbw)
fedora-extras-commits at redhat.com
Mon Jul 18 17:24:41 UTC 2005
Author: dcbw
Update of /cvs/fedora/extras-buildsys/common
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv13131/common
Modified Files:
FileDownloader.py
Log Message:
2005-07-18 Dan Williams <dcbw at redhat.com>
* builder/builder.py
common/FileDownloader.py
server/ArchJob.py
- Allow '+' character in RPM names
- Clean up file name handling in URLs
Index: FileDownloader.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/common/FileDownloader.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- FileDownloader.py 6 Jul 2005 21:20:55 -0000 1.11
+++ FileDownloader.py 18 Jul 2005 17:24:38 -0000 1.12
@@ -22,6 +22,15 @@
import HTTPSURLopener
import OpenSSL
import CommonErrors
+import exceptions
+
+
+class FileNameError(exceptions.Exception):
+ def __init__(self, args=None):
+ exceptions.Exception.__init__(self)
+ self.args = args
+ def __str__(self):
+ return self.args
def get_base_filename_from_url(url, legal_exts):
@@ -42,12 +51,12 @@
# If after 5 iterations of unquoting, the strings still aren't the same,
# something is wrong.
if (count == 0) and (unquoted != last_unquoted):
- return None
+ raise FileNameError("URL quoting level too deep.")
# Try to grab the filename off the end of the URL
index = url.rfind('/')
if index is -1:
- return None
+ raise FileNameError("No separator in URL.")
filename = url[index+1:]
# Only accept certain file extensions
@@ -58,15 +67,15 @@
break
if not ext_ok:
- return None
+ raise FileNameError("Extension was not allowed.")
# FIXME: what other validation can we do here?
for c in filename:
# For now, legal characters are '_-.' plus alphanumeric
- if (c == '_') or (c == '-') or (c == '.') or c.isalnum():
+ if (c == '_') or (c == '-') or (c == '.') or (c == '+') or c.isalnum():
pass
else:
- return None
+ raise FileNameError("Illegal character '%s' encountered." % c)
return filename
@@ -78,9 +87,11 @@
self._cb_data = cb_data
self._url = url
self._target_dir = target_dir
- self._filename = get_base_filename_from_url(self._url, legal_exts)
- if not self._filename:
- print "Couldn't get base filename from url!! target_dir=%s, url=%s" % (target_dir, url)
+ 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)
+
if certs and len(certs) > 0:
self._opener = HTTPSURLopener.HTTPSURLopener(certs)
else:
More information about the scm-commits
mailing list