diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2009-02-08 00:57:54 -0500 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2009-02-08 00:57:54 -0500 |
| commit | 69ac57d85b275115c0bfbb73af37dccec8a515be (patch) | |
| tree | 1cb1be2ec152e3190c6d84c491d4d498e176edc5 | |
| parent | 5a5b8a85aa5d073023e71e28bdc5b0b224eae359 (diff) | |
| download | rpmbuild-remote-69ac57d85b275115c0bfbb73af37dccec8a515be.tar.gz rpmbuild-remote-69ac57d85b275115c0bfbb73af37dccec8a515be.tar.xz rpmbuild-remote-69ac57d85b275115c0bfbb73af37dccec8a515be.zip | |
Added argument parsing
| -rw-r--r-- | rpmbuild-remote.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/rpmbuild-remote.py b/rpmbuild-remote.py index 1b7b762..901cb08 100644 --- a/rpmbuild-remote.py +++ b/rpmbuild-remote.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- from iniparse import INIConfig +import logging import paramiko import getopt import sys @@ -39,6 +40,7 @@ def main(argv): print str(err) usage() sys.exit(1) + log = logging.getLogger('rpmbuild-remote') home = os.path.expanduser('~') config = os.path.join(home, '.rpmbuild-remote') system = '' @@ -47,6 +49,39 @@ def main(argv): port = 21 dest = os.path.join(home, 'rpmbuild-remote') mock = '' + jobs = [] + for opt, val in opts: + if opt in ['c', 'config']: + config = val + elif opt in ['s', 'system']: + system = val + elif opt in ['u', 'user']: + user = val + elif opt in ['h', 'host']: + host = val + elif opt in ['p', 'port']: + port = val + elif opt in ['d', 'dest']: + dest = val + elif opt in ['m', 'mock']: + mock = val + elif opt in ['help']: + usage() + sys.exit(0) + for arg in args: + ext = arg.split('.')[-1] + if ext == 'srpm': + jobs.append([arg]) + continue + if ext == 'spec': + jobs.append([arg]) + continue + if ext not in ['gz', 'tgz', 'bz2', 'patch']: + log.warning("Uncommon source extension. Please double check files.") + if not jobs: + log.error("Source file given without spec file.") + sys.exit(1) + jobs[-1].append(arg) if __name__ == '__main__': main(sys.argv[1:]) |
