+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.
+
2008-05-04 Joerg Jaspert <joerg@debian.org>
* daklib/queue.py: Various pychecker cleanups
import daklib.logging as logging
import daklib.queue as queue
import daklib.utils as utils
+from daklib.dak_exceptions import *
from types import *
(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"]) = \
("", "", "", "")
# 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))
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"
--- /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 = message
+ self.message = 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]
+
+
+
+################################################################################
sys, tempfile, traceback
import apt_pkg
import database
+from dak_exceptions import *
################################################################################
################################################################################
-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)