Permalink
Browse files

Use sys.exit(1) instead of exit

  • Loading branch information...
1 parent 316c1df commit 505626a7f859613658a092952f083812bfa448ed @tom111 committed Oct 23, 2012
Showing with 22 additions and 19 deletions.
  1. +12 −12 scripts/tatt
  2. +7 −6 tatt/scriptwriter.py
  3. +1 −0 tatt/tattConfig.py
  4. +2 −1 tatt/tinderbox.py
View
@@ -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,18 +98,18 @@ 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:
print("Reporting success for bug number " + 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,25 +209,25 @@ 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:
calllist = calllist + ['--fixed']
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)
View
@@ -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]]
View
@@ -1,6 +1,7 @@
"""Abstraction of a tatt configuration"""
import os
+import sys
# from configobj
from configobj import ConfigObj
View
@@ -4,6 +4,7 @@
# 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

0 comments on commit 505626a

Please sign in to comment.