+2008-05-05 Mark Hymers <mhy@debian.org>
+
+ * daklib/dak_exceptions.py: Add a default message and tidy up our string
+ representation
+
+2008-05-05 Joerg Jaspert <joerg@debian.org>
+
+ * 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>
+ * daklib/queue.py: Various pychecker cleanups
+
* dak/import_keyring.py: Remove unused daklib.logging and Logger
and add the actually used daklib/utils
* dak/clean_suites.py: likewise
* dak/compare_suites.py: likewise
* dak/cruft_report.py: likewise
+ (get_suite_binaries): Seperated in own function, out of main. More
+ of main should be splitted. (Or well, cruft_report redesigned a
+ little, so its easier to run on multiple suites with differing tests)
+
* dak/examine_package.py: likewise
* dak/find_null_maintainers.py: likewise
* dak/generate_index_diffs.py: likewise
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
print " dak rm -S -p -m \"[auto-cruft] obsolete source package\" %s" % (" ".join(to_remove))
print
+def get_suite_binaries():
+ # Initalize a large hash table of all binary packages
+ binaries = {}
+ before = time.time()
+
+ sys.stderr.write("[Getting a list of binary packages in %s..." % (suite))
+ q = projectB.query("SELECT distinct b.package FROM binaries b, bin_associations ba WHERE ba.suite = %s AND ba.bin = b.id" % (suite_id))
+ ql = q.getresult()
+ sys.stderr.write("done. (%d seconds)]\n" % (int(time.time()-before)))
+ for i in ql:
+ binaries[i[0]] = ""
+
+ return binaries
+
################################################################################
def main ():
bin_not_built = {}
if "bnb" in checks:
- # Initalize a large hash table of all binary packages
- before = time.time()
- sys.stderr.write("[Getting a list of binary packages in %s..." % (suite))
- q = projectB.query("SELECT distinct b.package FROM binaries b, bin_associations ba WHERE ba.suite = %s AND ba.bin = b.id" % (suite_id))
- ql = q.getresult()
- sys.stderr.write("done. (%d seconds)]\n" % (int(time.time()-before)))
- for i in ql:
- bins_in_suite[i[0]] = ""
+ bins_in_suite = get_suite_binaries()
# Checks based on the Sources files
components = Cnf.ValueList("Suite::%s::Components" % (suite))
import sys, os, popen2, tempfile, stat, time, pg
import apt_pkg
import daklib.utils as utils
+from daklib.dak_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.dak_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)
import daklib.logging as logging
import daklib.queue as queue
import daklib.utils as utils
+from daklib.dak_exceptions import *
from types import *
# 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
(changes["maintainer822"], changes["maintainer2047"],
changes["maintainername"], changes["maintaineremail"]) = \
utils.fix_maintainer (changes["maintainer"])
- except utils.ParseMaintError, msg:
+ except ParseMaintError, msg:
reject("%s: Maintainer field ('%s') failed to parse: %s" \
% (filename, changes["maintainer"], msg))
(changes["changedby822"], changes["changedby2047"],
changes["changedbyname"], changes["changedbyemail"]) = \
utils.fix_maintainer (changes.get("changed-by", ""))
- except utils.ParseMaintError, msg:
+ except ParseMaintError, msg:
(changes["changedby822"], changes["changedby2047"],
changes["changedbyname"], changes["changedbyemail"]) = \
("", "", "", "")
# 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
# Validate the Maintainer field
try:
utils.fix_maintainer (dsc["maintainer"])
- except utils.ParseMaintError, msg:
+ except ParseMaintError, msg:
reject("%s: Maintainer field ('%s') failed to parse: %s" \
% (dsc_filename, dsc["maintainer"], msg))
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
import daklib.queue as queue
import daklib.utils as utils
+from daklib.dak_exceptions import *
Cnf = None
Upload = None
(maintainer["maintainer822"], maintainer["maintainer2047"],
maintainer["maintainername"], maintainer["maintaineremail"]) = \
utils.fix_maintainer (j["maintainer"])
- except utils.ParseMaintError, msg:
+ except ParseMaintError, msg:
print "Problems while parsing maintainer address\n"
maintainer["maintainername"] = "Unknown"
maintainer["maintaineremail"] = "Unknown"
import apt_pkg, apt_inst
import daklib.database as database
import daklib.utils as utils
+from daklib.dak_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(','):
--- /dev/null
+# Exception classes used in dak
+
+# Copyright (C) 2008 Mark Hymers <mhy@debian.org>
+
+################################################################################
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+################################################################################
+
+class DakError(Exception):
+ """Base class for all simple errors in this module.
+
+ Attributes:
+
+ message -- explanation of the error
+ """
+
+ def __init__(self, message=""):
+ self.args = str(message)
+ self.message = str(message)
+
+ def __str__(self):
+ return self.message
+
+__all__ = ['DakError']
+
+dakerrors = {
+ "ParseMaintError": """Exception raised for errors in parsing a maintainer field.""",
+ "ParseChangesError": """Exception raised for errors in parsing a changes file.""",
+ "InvalidDscError": """Exception raised for invalid dsc files.""",
+ "UnknownFormatError": """Exception raised for unknown Format: lines in changes files.""",
+ "NoFilesFieldError": """Exception raised for missing files field in dsc/changes.""",
+ "CantOpenError": """Exception raised when files can't be opened.""",
+ "CantOverwriteError": """Exception raised when files cant be overwritten.""",
+ "FileExistsError": """Exception raised when destination file exists.""",
+ "SendmailFailedError": """Exception raised when Sendmail invocation failed.""",
+ "NoFreeFilenameError": """Exception raised when no alternate filename was found."""
+}
+
+
+def construct_dak_exception(name, description):
+ class Er(DakError):
+ __doc__ = description
+ setattr(Er, "__name__", name)
+ return Er
+
+for e in dakerrors.keys():
+ globals()[e] = construct_dak_exception(e, dakerrors[e])
+ __all__ += [e]
+
+
+
+################################################################################
import cPickle, errno, os, pg, re, stat, sys, time
import apt_inst, apt_pkg
import utils, database
+from dak_exceptions import *
from types import *
new = {}
# Build up a list of potentially new things
- for file in files.keys():
- f = files[file]
+ for file_entry in files.keys():
+ f = files[file_entry]
# Skip byhand elements
if f["type"] == "byhand":
continue
pkg = f["package"]
priority = f["priority"]
section = f["section"]
- type = get_type(f)
+ file_type = get_type(f)
component = f["component"]
- if type == "dsc":
+ if file_type == "dsc":
priority = "source"
if not new.has_key(pkg):
new[pkg] = {}
new[pkg]["priority"] = priority
new[pkg]["section"] = section
- new[pkg]["type"] = type
+ new[pkg]["type"] = file_type
new[pkg]["component"] = component
new[pkg]["files"] = []
else:
old_type = new[pkg]["type"]
- if old_type != type:
+ if old_type != file_type:
# source gets trumped by deb or udeb
if old_type == "dsc":
new[pkg]["priority"] = priority
new[pkg]["section"] = section
- new[pkg]["type"] = type
+ new[pkg]["type"] = file_type
new[pkg]["component"] = component
- new[pkg]["files"].append(file)
+ new[pkg]["files"].append(file_entry)
if f.has_key("othercomponents"):
new[pkg]["othercomponents"] = f["othercomponents"]
q = projectB.query("SELECT package FROM override WHERE package = '%s' AND suite = %s AND component = %s AND type = %s" % (pkg, suite_id, component_id, type_id))
ql = q.getresult()
if ql:
- for file in new[pkg]["files"]:
- if files[file].has_key("new"):
- del files[file]["new"]
+ for file_entry in new[pkg]["files"]:
+ if files[file_entry].has_key("new"):
+ del files[file_entry]["new"]
del new[pkg]
if warn:
def get_type(f):
# Determine the type
if f.has_key("dbtype"):
- type = f["dbtype"]
+ file_type = f["dbtype"]
elif f["type"] in [ "orig.tar.gz", "orig.tar.bz2", "tar.gz", "tar.bz2", "diff.gz", "diff.bz2", "dsc" ]:
- type = "dsc"
+ file_type = "dsc"
else:
- utils.fubar("invalid type (%s) for new. Dazed, confused and sure as heck not continuing." % (type))
+ utils.fubar("invalid type (%s) for new. Dazed, confused and sure as heck not continuing." % (file_type))
# Validate the override type
- type_id = database.get_override_type_id(type)
+ type_id = database.get_override_type_id(file_type)
if type_id == -1:
- utils.fubar("invalid type (%s) for new. Say wha?" % (type))
+ utils.fubar("invalid type (%s) for new. Say wha?" % (file_type))
- return type
+ return file_type
################################################################################
for pkg in new.keys():
section = new[pkg]["section"]
priority = new[pkg]["priority"]
- type = new[pkg]["type"]
+ file_type = new[pkg]["type"]
new[pkg]["section id"] = database.get_section_id(section)
new[pkg]["priority id"] = database.get_priority_id(new[pkg]["priority"])
# Sanity checks
di = section.find("debian-installer") != -1
- if (di and type != "udeb") or (not di and type == "udeb"):
+ if (di and file_type != "udeb") or (not di and file_type == "udeb"):
new[pkg]["section id"] = -1
- if (priority == "source" and type != "dsc") or \
- (priority != "source" and type == "dsc"):
+ if (priority == "source" and file_type != "dsc") or \
+ (priority != "source" and file_type == "dsc"):
new[pkg]["priority id"] = -1
for i in [ "d_changes", "d_dsc", "d_files", "d_dsc_files" ]:
exec "%s = {}" % i
## files
- for file in files.keys():
- d_files[file] = {}
+ for file_entry in files.keys():
+ d_files[file_entry] = {}
for i in [ "package", "version", "architecture", "type", "size",
"md5sum", "component", "location id", "source package",
"source version", "maintainer", "dbtype", "files id",
"new", "section", "priority", "othercomponents",
"pool name", "original component" ]:
- if files[file].has_key(i):
- d_files[file][i] = files[file][i]
+ if files[file_entry].has_key(i):
+ d_files[file_entry][i] = files[file_entry][i]
## changes
# Mandatory changes fields
for i in [ "distribution", "source", "architecture", "version",
if dsc.has_key(i):
d_dsc[i] = dsc[i]
## dsc_files
- for file in dsc_files.keys():
- d_dsc_files[file] = {}
+ for file_entry in dsc_files.keys():
+ d_dsc_files[file_entry] = {}
# Mandatory dsc_files fields
for i in [ "size", "md5sum" ]:
- d_dsc_files[file][i] = dsc_files[file][i]
+ d_dsc_files[file_entry][i] = dsc_files[file_entry][i]
# Optional dsc_files fields
for i in [ "files id" ]:
- if dsc_files[file].has_key(i):
- d_dsc_files[file][i] = dsc_files[file][i]
+ if dsc_files[file_entry].has_key(i):
+ d_dsc_files[file_entry][i] = dsc_files[file_entry][i]
for i in [ d_changes, d_dsc, d_files, d_dsc_files,
legacy_source_untouchable, orig_tar_id, orig_tar_location ]:
override_summary ="";
file_keys = files.keys()
file_keys.sort()
- for file in file_keys:
- if files[file].has_key("byhand"):
+ for file_entry in file_keys:
+ if files[file_entry].has_key("byhand"):
byhand = 1
- summary += file + " byhand\n"
- elif files[file].has_key("new"):
+ summary += file_entry + " byhand\n"
+ elif files[file_entry].has_key("new"):
new = 1
- summary += "(new) %s %s %s\n" % (file, files[file]["priority"], files[file]["section"])
- if files[file].has_key("othercomponents"):
- summary += "WARNING: Already present in %s distribution.\n" % (files[file]["othercomponents"])
- if files[file]["type"] == "deb":
- deb_fh = utils.open_file(file)
+ summary += "(new) %s %s %s\n" % (file_entry, files[file_entry]["priority"], files[file_entry]["section"])
+ if files[file_entry].has_key("othercomponents"):
+ summary += "WARNING: Already present in %s distribution.\n" % (files[file_entry]["othercomponents"])
+ if files[file_entry]["type"] == "deb":
+ deb_fh = utils.open_file(file_entry)
summary += apt_pkg.ParseSection(apt_inst.debExtractControl(deb_fh))["Description"] + '\n'
deb_fh.close()
else:
- files[file]["pool name"] = utils.poolify (changes.get("source",""), files[file]["component"])
- destination = self.Cnf["Dir::PoolRoot"] + files[file]["pool name"] + file
- summary += file + "\n to " + destination + "\n"
- if not files[file].has_key("type"):
- files[file]["type"] = "unknown"
- if files[file]["type"] in ["deb", "udeb", "dsc"]:
+ files[file_entry]["pool name"] = utils.poolify (changes.get("source",""), files[file_entry]["component"])
+ destination = self.Cnf["Dir::PoolRoot"] + files[file_entry]["pool name"] + file_entry
+ summary += file_entry + "\n to " + destination + "\n"
+ if not files[file_entry].has_key("type"):
+ files[file_entry]["type"] = "unknown"
+ if files[file_entry]["type"] in ["deb", "udeb", "dsc"]:
# (queue/unchecked), there we have override entries already, use them
# (process-new), there we dont have override entries, use the newly generated ones.
- override_prio = files[file].get("override priority", files[file]["priority"])
- override_sect = files[file].get("override section", files[file]["section"])
- override_summary += "%s - %s %s\n" % (file, override_prio, override_sect)
+ override_prio = files[file_entry].get("override priority", files[file_entry]["priority"])
+ override_sect = files[file_entry].get("override section", files[file_entry]["section"])
+ override_summary += "%s - %s %s\n" % (file_entry, override_prio, override_sect)
short_summary = summary
Subst["__SHORT_SUMMARY__"] = short_summary
for dist in changes["distribution"].keys():
- list = Cnf.Find("Suite::%s::Announce" % (dist))
- if list == "" or lists_done.has_key(list):
+ announce_list = Cnf.Find("Suite::%s::Announce" % (dist))
+ if announce_list == "" or lists_done.has_key(announce_list):
continue
- lists_done[list] = 1
- summary += "Announcing to %s\n" % (list)
+ lists_done[announce_list] = 1
+ summary += "Announcing to %s\n" % (announce_list)
if action:
- Subst["__ANNOUNCE_LIST_ADDRESS__"] = list
+ Subst["__ANNOUNCE_LIST_ADDRESS__"] = announce_list
if Cnf.get("Dinstall::TrackingServer") and changes["architecture"].has_key("source"):
Subst["__ANNOUNCE_LIST_ADDRESS__"] = Subst["__ANNOUNCE_LIST_ADDRESS__"] + "\nBcc: %s@%s" % (changes["source"], Cnf["Dinstall::TrackingServer"])
mail_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/process-unchecked.announce")
# Move all the files into the accepted directory
utils.move(changes_file, Cnf["Dir::Queue::Accepted"])
file_keys = files.keys()
- for file in file_keys:
- utils.move(file, Cnf["Dir::Queue::Accepted"])
- self.accept_bytes += float(files[file]["size"])
+ for file_entry in file_keys:
+ utils.move(file_entry, Cnf["Dir::Queue::Accepted"])
+ self.accept_bytes += float(files[file_entry]["size"])
self.accept_count += 1
# Send accept mail, announce to lists, close bugs and check for
temp_filename = utils.temp_filename(Cnf["Dir::Queue::BTSVersionTrack"],
dotprefix=1, perms=0644)
debinfo = utils.open_file(temp_filename, 'w')
- for file in file_keys:
- f = files[file]
+ for file_entry in file_keys:
+ f = files[file_entry]
if f["type"] == "deb":
line = " ".join([f["package"], f["version"],
f["architecture"], f["source package"],
dest_dir = Cnf["Dir::QueueBuild"]
if Cnf.FindB("Dinstall::SecurityQueueBuild"):
dest_dir = os.path.join(dest_dir, suite)
- for file in file_keys:
- src = os.path.join(path, file)
- dest = os.path.join(dest_dir, file)
+ for file_entry in file_keys:
+ src = os.path.join(path, file_entry)
+ dest = os.path.join(dest_dir, file_entry)
if Cnf.FindB("Dinstall::SecurityQueueBuild"):
# Copy it since the original won't be readable by www-data
utils.copy(src, dest)
summary = ""
file_keys = files.keys()
file_keys.sort()
- for file in file_keys:
- if not files[file].has_key("new") and files[file]["type"] == "deb":
- section = files[file]["section"]
- override_section = files[file]["override section"]
+ for file_entry in file_keys:
+ if not files[file_entry].has_key("new") and files[file_entry]["type"] == "deb":
+ section = files[file_entry]["section"]
+ override_section = files[file_entry]["override section"]
if section.lower() != override_section.lower() and section != "-":
- summary += "%s: package says section is %s, override says %s.\n" % (file, section, override_section)
- priority = files[file]["priority"]
- override_priority = files[file]["override priority"]
+ summary += "%s: package says section is %s, override says %s.\n" % (file_entry, section, override_section)
+ priority = files[file_entry]["priority"]
+ override_priority = files[file_entry]["override priority"]
if priority != override_priority and priority != "-":
- summary += "%s: package says priority is %s, override says %s.\n" % (file, priority, override_priority)
+ summary += "%s: package says priority is %s, override says %s.\n" % (file_entry, priority, override_priority)
if summary == "":
return
Cnf = self.Cnf
- for file in files:
+ for file_entry in files:
# Skip any files which don't exist or which we don't have permission to copy.
- if os.access(file,os.R_OK) == 0:
+ if os.access(file_entry,os.R_OK) == 0:
continue
- dest_file = os.path.join(Cnf["Dir::Queue::Reject"], file)
+ dest_file = os.path.join(Cnf["Dir::Queue::Reject"], file_entry)
try:
dest_fd = os.open(dest_file, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0644)
except OSError, e:
# File exists? Let's try and move it to the morgue
if errno.errorcode[e.errno] == 'EEXIST':
- morgue_file = os.path.join(Cnf["Dir::Morgue"],Cnf["Dir::MorgueReject"],file)
+ 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))
+ utils.warn("**WARNING** failed to move %s from the reject directory to the morgue." % (file_entry))
return
utils.move(dest_file, morgue_file, perms=0660)
try:
dest_fd = os.open(dest_file, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0644)
except OSError, e:
# Likewise
- utils.warn("**WARNING** failed to claim %s in the reject directory." % (file))
+ utils.warn("**WARNING** failed to claim %s in the reject directory." % (file_entry))
return
else:
raise
# If we got here, we own the destination file, so we can
# safely overwrite it.
- utils.move(file, dest_file, 1, perms=0660)
+ utils.move(file_entry, dest_file, 1, perms=0660)
os.close(dest_fd)
###########################################################################
files = self.pkg.files
if binary_type == "": # must be source
- type = "dsc"
+ file_type = "dsc"
else:
- type = binary_type
+ file_type = binary_type
# Override suite name; used for example with proposed-updates
if self.Cnf.Find("Suite::%s::OverrideSuite" % (suite)) != "":
if suite_id == -1:
return None
component_id = database.get_component_id(component)
- type_id = database.get_override_type_id(type)
+ type_id = database.get_override_type_id(file_type)
q = self.projectB.query("SELECT s.section, p.priority FROM override o, section s, priority p WHERE package = '%s' AND suite = %s AND component = %s AND type = %s AND o.section = s.id AND o.priority = p.id"
% (package, suite_id, component_id, type_id))
result = q.getresult()
# If checking for a source package fall back on the binary override type
- if type == "dsc" and not result:
+ if file_type == "dsc" and not result:
deb_type_id = database.get_override_type_id("deb")
udeb_type_id = database.get_override_type_id("udeb")
q = self.projectB.query("SELECT s.section, p.priority FROM override o, section s, priority p WHERE package = '%s' AND suite = %s AND component = %s AND (type = %s OR type = %s) AND o.section = s.id AND o.priority = p.id"
if os.path.exists(in_unchecked) and False:
return (self.reject_message, in_unchecked)
else:
- for dir in [ "Accepted", "New", "Byhand", "ProposedUpdates", "OldProposedUpdates" ]:
- in_otherdir = os.path.join(self.Cnf["Dir::Queue::%s" % (dir)],dsc_file)
+ for directory in [ "Accepted", "New", "Byhand", "ProposedUpdates", "OldProposedUpdates" ]:
+ in_otherdir = os.path.join(self.Cnf["Dir::Queue::%s" % (directory)],dsc_file)
if os.path.exists(in_otherdir):
in_otherdir_fh = utils.open_file(in_otherdir)
actual_md5 = apt_pkg.md5sum(in_otherdir_fh)
sys, tempfile, traceback
import apt_pkg
import database
+from dak_exceptions import *
################################################################################
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"
################################################################################
-class Error(Exception):
- """Base class for exceptions in this module."""
- pass
-
-class ParseMaintError(Error):
- """Exception raised for errors in parsing a maintainer field.
-
- Attributes:
- message -- explanation of the error
- """
-
- def __init__(self, message):
- self.args = message,
- self.message = message
-
-################################################################################
-
def open_file(filename, mode='r'):
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
################################################################################