diff options
author | Nicolas Vigier <boklm@mageia.org> | 2012-12-04 13:18:57 +0000 |
---|---|---|
committer | Nicolas Vigier <boklm@mageia.org> | 2012-12-04 13:18:57 +0000 |
commit | 7b66b55903f09fef8bd1a9a3a3b0941890e2ac4f (patch) | |
tree | 3272eccc4276d9577ab336c01e9299602437dea4 /create-srpm | |
parent | fa6e28fa34acb6167d5a70c138c5041d1b19d03d (diff) | |
download | mgarepo-7b66b55903f09fef8bd1a9a3a3b0941890e2ac4f.tar mgarepo-7b66b55903f09fef8bd1a9a3a3b0941890e2ac4f.tar.gz mgarepo-7b66b55903f09fef8bd1a9a3a3b0941890e2ac4f.tar.bz2 mgarepo-7b66b55903f09fef8bd1a9a3a3b0941890e2ac4f.tar.xz mgarepo-7b66b55903f09fef8bd1a9a3a3b0941890e2ac4f.zip |
create-srpm: don't use youridb if no db defined
Diffstat (limited to 'create-srpm')
-rwxr-xr-x | create-srpm | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/create-srpm b/create-srpm index 837c776..9b654a3 100755 --- a/create-srpm +++ b/create-srpm @@ -13,7 +13,6 @@ import optparse import subprocess import urlparse import urllib -import psycopg2 import rpm def get_rpm_hdr(filename): @@ -26,6 +25,11 @@ def get_rpm_hdr(filename): class youridb: def __init__(self): dbname = config.get("youridb", "dbname") + if not dbname: + self.usedb = False + return + import psycopg2 + self.usedb = True dbuser = config.get("youridb", "dbuser") dbpasswd = config.get("youridb", "dbpasswd") dbhost = config.get("youridb", "dbhost") @@ -34,6 +38,8 @@ class youridb: password=dbpasswd, host=dbhost) def add(self, srpm, url, revision, packager): + if not self.usedb: + return rpmhdr = get_rpm_hdr(srpm) rpmname = rpmhdr[rpm.RPMTAG_NAME] rpmEVR = rpmhdr[rpm.RPMTAG_EVR] @@ -45,6 +51,8 @@ class youridb: self.db.commit() def close(self): + if not self.usedb: + return self.db.close() class CmdError(Error): pass |