Loading src/bin/archversion +6 −5 Original line number Diff line number Diff line Loading @@ -126,13 +126,14 @@ def main(): return args.func(args, vctrl) except KeyboardInterrupt: exit(ERR_ABORT) except MissingConfigFile: logging.error("Configuration file is missing. " "Please create it before!") exit(ERR_FATAL) except BaseError as exp: logging.error("Unknown error. Please report it.") logging.error(exp) exit(ERR_FATAL) except Exception as exp: logging.error("Unknown error. Please report it with --debug.") logging.error(exp) if logging.getLogger().getEffectiveLevel() == logging.DEBUG: raise exit(ERR_UNKNOWN) if __name__ == '__main__': Loading src/lib/archversion/config.py +1 −2 Original line number Diff line number Diff line Loading @@ -37,8 +37,7 @@ class BaseConfigFile(OrderedDict): if path is None: self.path = load_first_config(default_filename) if not isinstance(self.path, str) or not os.path.exists(self.path): logging.debug("No such config file: %s" % self.path) raise MissingConfigFile() raise MissingConfigFile(self.path) self.load() def load(self): Loading src/lib/archversion/error.py +19 −7 Original line number Diff line number Diff line Loading @@ -32,16 +32,28 @@ class VersionNotFound(BaseError): '''Version of a package is not found''' pass class ConfigFileError(BaseError): '''All errors related to config file ''' pass class NoSuchFile(BaseError): '''Config file is bad formatted''' def __init__(self, filename): BaseError.__init__(self) self.filename = filename class MissingConfigFile(ConfigFileError): def __str__(self): return "%s: No such file." % self.filename class MissingConfigFile(NoSuchFile): '''Config file is missing''' pass class InvalidConfigFile(ConfigFileError): def __str__(self): logging.debug("No such config file: %s" % self.filename) return "Missing configuration file. Please create it before!" class InvalidConfigFile(BaseError): '''Config file is bad formatted''' pass def __str__(self): return "Configuration file is bad formatted." # vim:set ts=4 sw=4 et ai: src/lib/archversion/version.py +2 −2 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ from archversion import USER_AGENT from archversion.error import ConfigFileError, InvalidConfigFile, VersionNotFound from archversion.error import InvalidConfigFile, VersionNotFound from urllib.request import urlopen, Request import json import logging Loading Loading @@ -256,7 +256,7 @@ class VersionController(object): yield (name, v_upstream, v_compare) except VersionNotFound as exp: logging.warning("%s: Version not found: %s" % (name, exp)) except ConfigFileError as exp: except InvalidConfigFile as exp: logging.warning("%s: Invalid configuration: %s" % (name, exp)) def print_names(self): Loading Loading
src/bin/archversion +6 −5 Original line number Diff line number Diff line Loading @@ -126,13 +126,14 @@ def main(): return args.func(args, vctrl) except KeyboardInterrupt: exit(ERR_ABORT) except MissingConfigFile: logging.error("Configuration file is missing. " "Please create it before!") exit(ERR_FATAL) except BaseError as exp: logging.error("Unknown error. Please report it.") logging.error(exp) exit(ERR_FATAL) except Exception as exp: logging.error("Unknown error. Please report it with --debug.") logging.error(exp) if logging.getLogger().getEffectiveLevel() == logging.DEBUG: raise exit(ERR_UNKNOWN) if __name__ == '__main__': Loading
src/lib/archversion/config.py +1 −2 Original line number Diff line number Diff line Loading @@ -37,8 +37,7 @@ class BaseConfigFile(OrderedDict): if path is None: self.path = load_first_config(default_filename) if not isinstance(self.path, str) or not os.path.exists(self.path): logging.debug("No such config file: %s" % self.path) raise MissingConfigFile() raise MissingConfigFile(self.path) self.load() def load(self): Loading
src/lib/archversion/error.py +19 −7 Original line number Diff line number Diff line Loading @@ -32,16 +32,28 @@ class VersionNotFound(BaseError): '''Version of a package is not found''' pass class ConfigFileError(BaseError): '''All errors related to config file ''' pass class NoSuchFile(BaseError): '''Config file is bad formatted''' def __init__(self, filename): BaseError.__init__(self) self.filename = filename class MissingConfigFile(ConfigFileError): def __str__(self): return "%s: No such file." % self.filename class MissingConfigFile(NoSuchFile): '''Config file is missing''' pass class InvalidConfigFile(ConfigFileError): def __str__(self): logging.debug("No such config file: %s" % self.filename) return "Missing configuration file. Please create it before!" class InvalidConfigFile(BaseError): '''Config file is bad formatted''' pass def __str__(self): return "Configuration file is bad formatted." # vim:set ts=4 sw=4 et ai:
src/lib/archversion/version.py +2 −2 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ from archversion import USER_AGENT from archversion.error import ConfigFileError, InvalidConfigFile, VersionNotFound from archversion.error import InvalidConfigFile, VersionNotFound from urllib.request import urlopen, Request import json import logging Loading Loading @@ -256,7 +256,7 @@ class VersionController(object): yield (name, v_upstream, v_compare) except VersionNotFound as exp: logging.warning("%s: Version not found: %s" % (name, exp)) except ConfigFileError as exp: except InvalidConfigFile as exp: logging.warning("%s: Invalid configuration: %s" % (name, exp)) def print_names(self): Loading