[Checkins] SVN: zc.buildout/branches/tlotze-download-api/src/zc/buildout/download. raise UserError instead of ValueError on checksum mismatch

Thomas Lotze tl at gocept.com
Mon May 25 03:19:10 EDT 2009


Log message for revision 100354:
  raise UserError instead of ValueError on checksum mismatch

Changed:
  U   zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.py
  U   zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.txt

-=-
Modified: zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.py
===================================================================
--- zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.py	2009-05-25 07:18:34 UTC (rev 100353)
+++ zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.py	2009-05-25 07:19:10 UTC (rev 100354)
@@ -99,8 +99,9 @@
         cached_path = os.path.join(self.cache, self.filename(url))
         if os.path.isfile(cached_path):
             if not check_md5sum(cached_path, md5sum):
-                raise ValueError('MD5 checksum mismatch for cached download '
-                                 'from %r at %r' % (url, cached_path))
+                raise zc.buildout.UserError(
+                    'MD5 checksum mismatch for cached download '
+                    'from %r at %r' % (url, cached_path))
         else:
             if not os.path.exists(self.cache):
                 os.makedirs(self.cache)
@@ -123,7 +124,8 @@
         urllib._urlopener = url_opener
         path, headers = urllib.urlretrieve(url, path)
         if not check_md5sum(path, md5sum):
-            raise ValueError('MD5 checksum mismatch downloading %r' % url)
+            raise zc.buildout.UserError(
+                'MD5 checksum mismatch downloading %r' % url)
         return path
 
     def filename(self, url):

Modified: zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.txt
===================================================================
--- zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.txt	2009-05-25 07:18:34 UTC (rev 100353)
+++ zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.txt	2009-05-25 07:19:10 UTC (rev 100354)
@@ -54,7 +54,7 @@
 >>> path = download(server+'foo.txt', md5('This is a foo text.').hexdigest())
 >>> path = download(server+'foo.txt', md5('The wrong text.').hexdigest())
 Traceback (most recent call last):
-ValueError: MD5 checksum mismatch downloading 'http://localhost/foo.txt'
+UserError: MD5 checksum mismatch downloading 'http://localhost/foo.txt'
 
 Finally, we can download the file to a specified place in the file system:
 
@@ -138,8 +138,8 @@
 
 >>> path = download(server+'foo.txt', md5('The wrong text.').hexdigest())
 Traceback (most recent call last):
-ValueError: MD5 checksum mismatch for cached download
-            from 'http://localhost/foo.txt' at '/download-cache/foo.txt'
+UserError: MD5 checksum mismatch for cached download
+           from 'http://localhost/foo.txt' at '/download-cache/foo.txt'
 
 Trying to access another file at a different URL which has the same base name
 will result in the cached copy being used:



More information about the Checkins mailing list