diff options
author | Jesse Keating <jkeating@redhat.com> | 2010-01-04 14:17:45 -0800 |
---|---|---|
committer | Jesse Keating <jkeating@redhat.com> | 2010-01-04 14:17:45 -0800 |
commit | 76cb0035e4928cf7f6c32e239cd35515c0a92161 (patch) | |
tree | 085507e2724a4ceae92ae3ac281eacb0107a0791 /src/fedpkg | |
parent | 536ca47f4b5ba5ad9f968cb10c30cc191549e486 (diff) | |
download | fedora-packager-76cb0035e4928cf7f6c32e239cd35515c0a92161.tar.gz fedora-packager-76cb0035e4928cf7f6c32e239cd35515c0a92161.tar.xz fedora-packager-76cb0035e4928cf7f6c32e239cd35515c0a92161.zip |
Add a custom error class
This makes it easier to catch errors in the calling tools.
They won't have to know about the internals of the library,
just catch the custom error and deal with it.
Diffstat (limited to 'src/fedpkg')
-rw-r--r-- | src/fedpkg/__init__.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/fedpkg/__init__.py b/src/fedpkg/__init__.py index ceffbbc..17ea192 100644 --- a/src/fedpkg/__init__.py +++ b/src/fedpkg/__init__.py @@ -19,6 +19,10 @@ LOOKASIDE = 'http://cvs.fedoraproject.org/repo/pkgs' LOOKASIDEHASH = 'md5' GITBASEURL = 'ssh://%(user)s@pkgs.stg.fedoraproject.org/%(module)s' +# Define our own error class +class FedpkgError(Exception): + pass + # Define some helper functions, they start with _ def _hash_file(file, hashtype): """Return the hash of a file given a hash type""" @@ -187,7 +191,7 @@ class PackageModule: os.uname()[4]) if not os.path.exists(os.path.join(self.path, srpm)) and not \ os.path.exists(os.path.join(self.path, rpm)): - return "Need to build srpm and rpm first" + raise FedpkgError("Need to build srpm and rpm first") cmd = ['rpmlint', os.path.join(self.path, srpm), os.path.join(self.path, rpm)] output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate() |