2008-05-05 Joerg Jaspert <joerg@debian.org>
- * dak/queue_report.py: Use the exception class
- * dak/process_unchecked.py: dito
-
* daklib/dak_exceptions.py: New file, central place for all those
own exceptions dak may raise.
* daklib/utils.py: Use dak_exceptions and delete all those string
exception raising stuff, which is depcreated.
+ During that delete the unknown_hostname_exc, as it wasnt used.
+
+ * dak/import_archive.py: use the new Exception class
+ * dak/rm.py: dito
+ * dak/generate_releases.py: dito
+ * dak/queue_report.py: dito
+ * daklib/queue.py: dito
2008-05-04 Joerg Jaspert <joerg@debian.org>
f = line[:-1]
try:
utils.parse_changes(f, signing_rules=1)
- except utils.invalid_dsc_format_exc, line:
+ except InvalidDscError, line:
utils.warn("syntax error in .dsc file '%s', line %s." % (f, line))
count += 1
import sys, os, popen2, tempfile, stat, time, pg
import apt_pkg
import daklib.utils as utils
+from daklib.exceptions import *
################################################################################
else:
size = os.stat(path + name)[stat.ST_SIZE]
file_handle = utils.open_file(path + name)
- except utils.cant_open_exc:
+ except CantOpenError:
print "ALERT: Couldn't open " + path + name
else:
hash = hashop(file_handle)
import apt_pkg
import daklib.database as database
import daklib.utils as utils
+from daklib.exceptions import *
###############################################################################
suite_id = database.get_suite_id(suite)
try:
file = utils.open_file (filename)
- except utils.cant_open_exc:
+ except CantOpenError:
utils.warn("can't open '%s'" % (filename))
return
Scanner = apt_pkg.ParseTagFile(file)
suite_id = database.get_suite_id(suite)
try:
file = utils.open_file (filename)
- except utils.cant_open_exc:
+ except CantOpenError:
utils.warn("can't open '%s'" % (filename))
return
Scanner = apt_pkg.ParseTagFile(file)
# Parse the .changes field into a dictionary
try:
changes.update(utils.parse_changes(filename))
- except utils.cant_open_exc:
+ except CantOpenError:
reject("%s: can't read file." % (filename))
return 0
- except utils.changes_parse_error_exc, line:
+ except ParseChangesError, line:
reject("%s: parse error, can't grok: %s." % (filename, line))
return 0
# Parse the Files field from the .changes into another dictionary
try:
files.update(utils.build_file_list(changes))
- except utils.changes_parse_error_exc, line:
+ except ParseChangesError, line:
reject("%s: parse error, can't grok: %s." % (filename, line))
- except utils.nk_format_exc, format:
+ except UnknownFormatError, format:
reject("%s: unknown format '%s'." % (filename, format))
return 0
# Parse the .dsc file
try:
dsc.update(utils.parse_changes(dsc_filename, signing_rules=1))
- except utils.cant_open_exc:
+ except CantOpenError:
# if not -n copy_to_holding() will have done this for us...
if Options["No-Action"]:
reject("%s: can't read file." % (dsc_filename))
- except utils.changes_parse_error_exc, line:
+ except ParseChangesError, line:
reject("%s: parse error, can't grok: %s." % (dsc_filename, line))
- except utils.invalid_dsc_format_exc, line:
+ except InvalidDscError, line:
reject("%s: syntax error on line %s." % (dsc_filename, line))
# Build up the file list of files mentioned by the .dsc
try:
dsc_files.update(utils.build_file_list(dsc, is_a_dsc=1))
- except utils.no_files_exc:
+ except NoFilesFieldError:
reject("%s: no Files: field." % (dsc_filename))
return 0
- except utils.changes_parse_error_exc, line:
+ except ParseChangesError, line:
reject("%s: parse error, can't grok: %s." % (dsc_filename, line))
return 0
try:
fs = utils.build_file_list(changes, 0, "checksums-%s" % h, h)
check_hash(".changes %s" % (h), fs, h, f, files)
- except utils.no_files_exc:
+ except NoFilesFieldError:
reject("No Checksums-%s: field in .changes" % (h))
- except utils.changes_parse_error_exc, line:
+ except ParseChangesError, line:
reject("parse error for Checksums-%s in .changes, can't grok: %s." % (h, line))
if "source" not in changes["architecture"]: continue
try:
fs = utils.build_file_list(dsc, 1, "checksums-%s" % h, h)
check_hash(".dsc %s" % (h), fs, h, f, dsc_files)
- except utils.no_files_exc:
+ except NoFilesFieldError:
reject("No Checksums-%s: field in .dsc" % (h))
- except utils.changes_parse_error_exc, line:
+ except ParseChangesError, line:
reject("parse error for Checksums-%s in .dsc, can't grok: %s." % (h, line))
################################################################################
try:
file_handle = utils.open_file(f)
- except utils.cant_open_exc:
+ except CantOpenError:
continue
# Check hash
import apt_pkg, apt_inst
import daklib.database as database
import daklib.utils as utils
+from daklib.exceptions import *
################################################################################
filename = "/".join(source_packages[i])
try:
dsc = utils.parse_changes(filename)
- except utils.cant_open_exc:
+ except CantOpenError:
utils.warn("couldn't open '%s'." % (filename))
continue
for package in dsc.get("binary").split(','):
import cPickle, errno, os, pg, re, stat, sys, time
import apt_inst, apt_pkg
import utils, database
+from dak_exceptions import *
from types import *
morgue_file = os.path.join(Cnf["Dir::Morgue"],Cnf["Dir::MorgueReject"],file_entry)
try:
morgue_file = utils.find_next_free(morgue_file)
- except utils.tried_too_hard_exc:
+ except NoFreeFilenameError:
# Something's either gone badly Pete Tong, or
# someone is trying to exploit us.
utils.warn("**WARNING** failed to move %s from the reject directory to the morgue." % (file_entry))
re_srchasver = re.compile(r"^(\S+)\s+\((\S+)\)$")
-changes_parse_error_exc = "Can't parse line in .changes file"
-invalid_dsc_format_exc = "Invalid .dsc file"
-nk_format_exc = "Unknown Format: in .changes file"
-no_files_exc = "No Files: field in .dsc or .changes file."
-cant_open_exc = "Can't open file"
-unknown_hostname_exc = "Unknown hostname"
-cant_overwrite_exc = "Permission denied; can't overwrite existent file."
-file_exists_exc = "Destination file exists"
-sendmail_failed_exc = "Sendmail invocation failed"
-tried_too_hard_exc = "Tried too hard to find a free filename."
-
default_config = "/etc/dak/dak.conf"
default_apt_config = "/etc/dak/apt.conf"
try:
f = open(filename, mode)
except IOError:
- raise cant_open_exc, filename
+ raise CantOpenError, filename
return f
################################################################################
lines = changes_in.readlines()
if not lines:
- raise changes_parse_error_exc, "[Empty changes file]"
+ raise ParseChangesError, "[Empty changes file]"
# Reindex by line number so we can easily verify the format of
# .dsc files...
if signing_rules == 1:
index += 1
if index > num_of_lines:
- raise invalid_dsc_format_exc, index
+ raise InvalidDscError, index
line = indexed_lines[index]
if not line.startswith("-----BEGIN PGP SIGNATURE"):
- raise invalid_dsc_format_exc, index
+ raise InvalidDscError, index
inside_signature = 0
break
else:
mlf = re_multi_line_field.match(line)
if mlf:
if first == -1:
- raise changes_parse_error_exc, "'%s'\n [Multi-line field continuing on from nothing?]" % (line)
+ raise ParseChangesError, "'%s'\n [Multi-line field continuing on from nothing?]" % (line)
if first == 1 and changes[field] != "":
changes[field] += '\n'
first = 0
error += line
if signing_rules == 1 and inside_signature:
- raise invalid_dsc_format_exc, index
+ raise InvalidDscError, index
changes_in.close()
changes["filecontents"] = "".join(lines)
changes["source-version"] = srcver.group(2)
if error:
- raise changes_parse_error_exc, error
+ raise ParseChangesError, error
return changes
# Make sure we have a Files: field to parse...
if not changes.has_key(field):
- raise no_files_exc
+ raise NoFilesFieldError
# Make sure we recognise the format of the Files: field
format = re_verwithext.search(changes.get("format", "0.0"))
if not format:
- raise nk_format_exc, "%s" % (changes.get("format","0.0"))
+ raise UnknownFormatError, "%s" % (changes.get("format","0.0"))
format = format.groups()
if format[1] == None:
if is_a_dsc:
if format != (1,0):
- raise nk_format_exc, "%s" % (changes.get("format","0.0"))
+ raise UnknownFormatError, "%s" % (changes.get("format","0.0"))
else:
if (format < (1,5) or format > (1,8)):
- raise nk_format_exc, "%s" % (changes.get("format","0.0"))
+ raise UnknownFormatError, "%s" % (changes.get("format","0.0"))
if field != "files" and format < (1,8):
- raise nk_format_exc, "%s" % (changes.get("format","0.0"))
+ raise UnknownFormatError, "%s" % (changes.get("format","0.0"))
includes_section = (not is_a_dsc) and field == "files"
else:
(md5, size, name) = s
except ValueError:
- raise changes_parse_error_exc, i
+ raise ParseChangesError, i
if section == "":
section = "-"
# Invoke sendmail
(result, output) = commands.getstatusoutput("%s < %s" % (Cnf["Dinstall::SendmailCommand"], filename))
if (result != 0):
- raise sendmail_failed_exc, output
+ raise SendmailFailedError, output
# Clean up any temporary files
if message:
# Don't overwrite unless forced to
if os.path.exists(dest):
if not overwrite:
- raise file_exists_exc
+ raise FileExistsError
else:
if not os.access(dest, os.W_OK):
- raise cant_overwrite_exc
+ raise CantOverwriteError
shutil.copy2(src, dest)
os.chmod(dest, perms)
dest = orig_dest + '.' + repr(extra)
extra += 1
if extra >= too_many:
- raise tried_too_hard_exc
+ raise NoFreeFilenameError
return dest
################################################################################