-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Applied upstream.
On Mon, 29 Sep 2014 16:54:55 +0200
Mathieu Bridon <bochecha(a)fedoraproject.org> wrote:
If a failure occured when trying to create the cache folder, mash
would just silently ignore the error and happily continue cranking
along. It might of course fail later on, but the problem is
impossible to debug if errors are silently suppressed.
However, if the error is merely that the directory already exists (as
opposed to a permission issue, for example), then that is fine to
ignore.
Likewise, if a failure occurs when trying to download, merely saying
"can't download" is not helpful. Adding the actual error message makes
it easier to figure out what went wrong.
---
mash/__init__.py | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/mash/__init__.py b/mash/__init__.py
index 566b8c1..27cdc47 100644
--- a/mash/__init__.py
+++ b/mash/__init__.py
@@ -12,6 +12,7 @@
# with this program; if not, write to the Free Software Foundation,
Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+import errno
import glob
import os
import logging
@@ -269,8 +270,11 @@ class Mash:
path =
os.path.join(koji.pathinfo.build(builds_hash[pkg['build_id']]),
koji.pathinfo.rpm(pkg)) try: os.mkdir(os.path.dirname(cachepath))
- except:
- pass
+ except Exception as e:
+ if e.errno != errno.EEXIST:
+ # If the directory already exists, that's
fine
+ self.logger.error(e)
+
try:
result = urlgrabber.grabber.urlgrab(path,
cachepath) except:
@@ -279,8 +283,9 @@ class Mash:
path =
os.path.join(koji.pathinfo.build(builds_hash[pkg['build_id']]),
koji.pathinfo.rpm(pkg)) try: result =
urlgrabber.grabber.urlgrab(path, cachepath)
- except:
- self.logger.error("ERROR: can't download %s
from %s" % (nevra(pkg), path))
+ except Exception as e:
+ self.logger.error("ERROR: can't download %s
from %s: %s"
+ % (nevra(pkg), path, e))
return None
fd = open(result)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQIcBAEBAgAGBQJUVBh7AAoJEH7ltONmPFDRE10P/Rr+Fk6gVtgtDEtfh7MnbtoO
y2PFgNH9Q5sH5FaecAhxiFXmbvklePaL9T4rqTLGDExQWe2bHQ2HHRv3USvrz8Wd
t+8BQJCS+Gfv5dpMjz6CkoUlpJCgMAw0VGZiCcpt+Sf7o3N8sbBo/ez1jDDobhbv
9Q5oMFxhVfPEJSmiQWrO4hzHnyP3QyeEzigXtUKqD5fxWzU01JQ9vfUfyFUGTnAa
nA1qcRZnggZCJDTylwU+pT9+h/o1x14zU6KGlUtAA5CdAasqhWWVxSkWbEO19baO
PzSgIFlk/m5BLctw4MEdvI6JCakG8Roksu7x/6QQ5Az8V/HOxV3oNR+8/nih3s/w
LinGLesj3bDS5pTEow+CYOMaGqixgVvc/TgJO2Q+EBEYcPiffHCrTjFlXJg5wpXk
R04mEFcM+znZ9BB6zb8OFGgQE/ESipvUfKC9kh0i1XeCEblKsrow77AVhPPViQCX
G+aZTmSGbyZU2HuMxM8gVNTPoiGY5a4SyD/E42zHhz4YETfFo3IDpIDQ1h2/HQTe
B1Aq42CNxb//v3kaHkviD4R6RmERBSgSJAsMAidtCdvpuJBabAZOxhIcU1dRT9ud
jDdRT5q8I0eddBGX0FI6VFsblXF4ig6bUxj+Me/r2H4J8SdrAZnbUxoPvxpCjv9c
wxqyxI6ELH+JXLwzgEv4
=NohB
-----END PGP SIGNATURE-----