diff options
author | Thomas Kahle <tomka@gentoo.org> | 2012-10-23 09:48:58 -0700 |
---|---|---|
committer | Thomas Kahle <tomka@gentoo.org> | 2012-10-23 09:48:58 -0700 |
commit | 505626a7f859613658a092952f083812bfa448ed (patch) | |
tree | 0ba74e892261356c55d902539a0c2f141c584885 | |
parent | Set default repodir to cvs module name (diff) | |
download | tatt-505626a7f859613658a092952f083812bfa448ed.tar.gz tatt-505626a7f859613658a092952f083812bfa448ed.tar.bz2 tatt-505626a7f859613658a092952f083812bfa448ed.zip |
Use sys.exit(1) instead of exit
-rwxr-xr-x | scripts/tatt | 24 | ||||
-rw-r--r-- | tatt/scriptwriter.py | 13 | ||||
-rw-r--r-- | tatt/tattConfig.py | 1 | ||||
-rw-r--r-- | tatt/tinderbox.py | 3 |
4 files changed, 22 insertions, 19 deletions
diff --git a/scripts/tatt b/scripts/tatt index 5280367..31676af 100755 --- a/scripts/tatt +++ b/scripts/tatt @@ -86,7 +86,7 @@ try: int(options.bugnum) except ValueError: print ("The bugnumber you gave with -b should be an integer.") - exit(1) + sys.exit(1) except TypeError: # This occurs if bugnum is None, that is, -b was not given pass @@ -98,7 +98,7 @@ if config['safedir'] != "": print ("Your safedir variable is set to '" + config['safedir'] + "',") print ("but you are in " + os.getcwd()) print ("Exiting.") - exit (1) + sys.exit (1) ## -s and a bugnumber was given ? if options.succbugnum: @@ -106,10 +106,10 @@ if options.succbugnum: retcode = call(['bugz', 'modify', options.succbugnum, '-c', config['successmessage']]) if retcode == 0: print("Success!"); - exit (0) + sys.exit (0) else: print("Failure commenting on Bugzilla") - exit(1) + sys.exit(1) # get a job object to save things to myJob = job() @@ -120,7 +120,7 @@ if options.infile: packfile=open(options.infile, 'r') except IOError: print("Given filename not found !") - exit(1) + sys.exit(1) packraw = packfile.read() packfile.close() myJob.packageList = packageFinder.findPackages(packraw, re.compile(config['atom-regexp'])) @@ -143,7 +143,7 @@ if options.bugnum: myJob.type="stable" else: print ("Could not detect bug's type, is the 'Keywords' field set?") - exit(1) + sys.exit(1) # If myJob.packageList is still empty we search in the bug-title if myJob.packageList==None: myJob.packageList = packageFinder.findPackages(bugtitle, re.compile(config['atom-regexp'])) @@ -182,7 +182,7 @@ if not myJob.packageList==None: print " ".join(["Is",os.path.split(config['unmaskfile'])[0],"a writeable directory?"]) print "Probably you want to configure a different unmaskfile" print "in your ~/.tatt. Exiting" - exit(1) + sys.exit(1) unmaskfile=open(config['unmaskfile'], 'r+') unmaskfileContent = unmaskfile.read() @@ -209,14 +209,14 @@ if not myJob.packageList==None: if myJob.bugnumber: writeSuccess(myJob, config) writeCommit(myJob, config) - exit (0) + sys.exit (0) # Code for resolving bugs (-r and -m) ##################################### if options.resolvenum: if not options.resolvemessage: print("Please call with a message per -m") - exit (1) + sys.exit (1) print("Resolving bug number " + options.resolvenum) calllist = ['bugz', 'modify', options.resolvenum, '-c', options.resolvemessage, '--remove-cc', config['arch']+"@gentoo.org"] if options.close: @@ -224,10 +224,10 @@ if options.resolvenum: retcode = call(calllist) if retcode == 0: print("Success!"); - exit (0) + sys.exit (0) else: print("Failure accessing bugzilla.") - exit(1) + sys.exit(1) ## If we arrive here then a package atom should be given @@ -236,7 +236,7 @@ try: myJob.name=myJob.packageList[0].packageName() except IndexError: print("Please call with package atom as argument") - exit (1) + sys.exit (1) if options.depend: writeRdeps(myJob, config) diff --git a/tatt/scriptwriter.py b/tatt/scriptwriter.py index c65c90b..33c922d 100644 --- a/tatt/scriptwriter.py +++ b/tatt/scriptwriter.py @@ -2,6 +2,7 @@ import random import os +import sys from .usecombis import findUseFlagCombis from .tinderbox import stablerdeps @@ -15,7 +16,7 @@ def useCombiTestString(pack, config): usesnippetfile=open(config['template-dir'] + "use-snippet", 'r') except IOError: print("use-snippet not found in " + config['template-dir']) - exit(1) + sys.exit(1) s = "" # This will contain the resulting string usesnippet = usesnippetfile.read() usesnippet = usesnippet.replace("@@CPV@@", pack.packageString() ) @@ -38,7 +39,7 @@ def writeusecombiscript(job, config): useheaderfile=open(config['template-dir'] + "use-header", 'r') except IOError: print("use-header not found in " + config['template-dir']) - exit(1) + sys.exit(1) useheader=useheaderfile.read().replace("@@JOB@@", job.name) outfilename = (job.name + "-useflags.sh") reportname = (job.name + ".report") @@ -63,7 +64,7 @@ def rdepTestString(rdep, config): rdepsnippetfile=open(config['template-dir'] + "revdep-snippet", 'r') except IOError: print("revdep-snippet not found in " + config['template-dir']) - exit(1) + sys.exit(1) rdepsnippet=rdepsnippetfile.read() snip = rdepsnippet.replace("@@FEATURES@@", "FEATURES=\"${FEATURES} test\"") ustring = "USE=\'" + " ".join([st for st in rdep[1] if not st[0] == "!"]) + " " @@ -87,7 +88,7 @@ def writerdepscript(job, config): rdepheaderfile=open(config['template-dir'] + "revdep-header", 'r') except IOError: print("revdep-header not found in " + config['template-dir']) - exit(1) + sys.exit(1) rdepheader=rdepheaderfile.read().replace("@@JOB@@", job.name) outfilename = (job.name + "-rdeps.sh") reportname = (job.name + ".report") @@ -130,7 +131,7 @@ def writecommitscript (job, config): commitfooterfile=open(config['template-dir'] + "commit-footer", 'r') except IOError: print("Some commit template not found in " + config['template-dir']) - exit(1) + sys.exit(1) csnippet = commitsnippetfile.read().replace("@@JOB@@", job.name) csnippet2 = commitsnippetfile2.read().replace("@@JOB@@", job.name) outfilename = (job.name + "-commit.sh") @@ -161,7 +162,7 @@ def writecommitscript (job, config): newkeyword="~"+config['arch'] else: print "No job type? Can't continue. This is a bug" - exit(1) + sys.exit(1) s = s.replace("@@NEWKEYWORD@@", newkeyword) # Prepare a list of ebuild names strings ebuilds = [p.packageName()+"-"+p.packageVersion()+".ebuild" for p in packageHash[pack]] diff --git a/tatt/tattConfig.py b/tatt/tattConfig.py index 36c22ab..68f2eac 100644 --- a/tatt/tattConfig.py +++ b/tatt/tattConfig.py @@ -1,6 +1,7 @@ """Abstraction of a tatt configuration""" import os +import sys # from configobj from configobj import ConfigObj diff --git a/tatt/tinderbox.py b/tatt/tinderbox.py index 1fb30d3..be9ac4b 100644 --- a/tatt/tinderbox.py +++ b/tatt/tinderbox.py @@ -4,6 +4,7 @@ import socket # For setting a global timeout # This will not work with python-2.6 # import urllib.request, urllib.error, urllib.parse import urllib2 +import sys from subprocess import * import random @@ -41,7 +42,7 @@ def stablerdeps (package, config): else: # Some other error should not occur: print("Non 404 Error on accessing the tinderbox") - exit (1) + sys.exit (1) # If we are here everything is fine, cleanup the timeout: socket.setdefaulttimeout(None) # The result is a "\n" separated list of packages : useflags |