From c4d894e1b37e4dceb62395fb4b1c30d273b7a2e7 Mon Sep 17 00:00:00 2001 From: Ansgar Burchardt Date: Tue, 18 Sep 2012 21:40:49 +0200 Subject: [PATCH] Improve error message for uploads that miss files. --- daklib/checks.py | 23 +++++++++++++++++------ daklib/upload.py | 7 +++++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/daklib/checks.py b/daklib/checks.py index 2e76e783..72980262 100644 --- a/daklib/checks.py +++ b/daklib/checks.py @@ -34,6 +34,7 @@ import daklib.utils as utils import apt_inst import apt_pkg from apt_pkg import version_compare +import errno import os import time import yaml @@ -165,13 +166,23 @@ class ChangesCheck(Check): class HashesCheck(Check): """Check hashes in .changes and .dsc are valid.""" def check(self, upload): - changes = upload.changes - for f in changes.files.itervalues(): - f.check(upload.directory) - source = changes.source - if source is not None: - for f in source.files.itervalues(): + what = None + try: + changes = upload.changes + what = changes.filename + for f in changes.files.itervalues(): f.check(upload.directory) + source = changes.source + what = source.filename + if source is not None: + for f in source.files.itervalues(): + f.check(upload.directory) + except IOError as e: + if e.errno == errno.ENOENT: + raise Reject('{0} refers to non-existing file: {1}\n' + 'Perhaps you need to include it in your upload?' + .format(what, os.path.basename(e.filename))) + raise class ExternalHashesCheck(Check): """Checks hashes in .changes and .dsc against an external database.""" diff --git a/daklib/upload.py b/daklib/upload.py index c55c4090..447fa34a 100644 --- a/daklib/upload.py +++ b/daklib/upload.py @@ -489,3 +489,10 @@ class Source(object): if len(fields) > 1: return fields[0] return "main" + + @property + def filename(self): + """filename of .dsc file + @type: str + """ + return self._dsc_file.filename -- 2.39.5