Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 673444173f97245e2c260187e1a3a5a014812fa4
Author: Miroslav Suchý <miroslav(a)suchy.cz>
Date: Mon Dec 30 14:09:09 2013 +0100
[backend] do not traceback if jobfile is mangled
in my case was zero sized which raised ValueError exception
>---------------------------------------------------------------
backend/dispatcher.py | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/backend/dispatcher.py b/backend/dispatcher.py
index ee2dc86..16adfdb 100644
--- a/backend/dispatcher.py
+++ b/backend/dispatcher.py
@@ -215,7 +215,11 @@ class Worker(multiprocessing.Process):
def parse_job(self, jobfile):
# read the json of the job in
# break out what we need return a bunch of the info we need
- build = json.load(open(jobfile))
+ try:
+ build = json.load(open(jobfile))
+ except ValueError:
+ # empty file?
+ return None
jobdata = Bunch()
jobdata.pkgs = build['pkgs'].split(' ')
jobdata.repos = [r for r in build['repos'].split(' ') if r.strip() ]
@@ -298,6 +302,10 @@ class Worker(multiprocessing.Process):
# parse the job json into our info
job = self.parse_job(jobfile)
+ if job is None:
+ self.callback.log('jobfile %s is mangled, please investigate' % jobfile)
+ time.sleep(self.opts.sleeptime)
+ continue
# FIXME
# this is our best place to sanity check the job before starting
# up any longer process
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 4beb54b7f7be19c90302558838ead3ec5f22ae91
Author: Miroslav Suchý <miroslav(a)suchy.cz>
Date: Mon Dec 30 13:43:12 2013 +0100
[backend] print error messages to stderr
because stdout can be closed, if running as daemon
addressing:
close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr
>---------------------------------------------------------------
backend/dispatcher.py | 2 +-
backend/mockremote.py | 10 +++++-----
copr-be.py | 6 +++---
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/backend/dispatcher.py b/backend/dispatcher.py
index 915ac81..ee2dc86 100644
--- a/backend/dispatcher.py
+++ b/backend/dispatcher.py
@@ -51,7 +51,7 @@ class SilentPlaybookCallbacks(callbacks.PlaybookCallbacks):
def on_vars_prompt(self, varname, private=True, prompt=None, encrypt=None, confirm=False, salt_size=None, salt=None):
result = None
- print "***** VARS_PROMPT WILL NOT BE RUN IN THIS KIND OF PLAYBOOK *****"
+ sys.stderr.write("***** VARS_PROMPT WILL NOT BE RUN IN THIS KIND OF PLAYBOOK *****\n")
callbacks.call_callback_module('playbook_on_vars_prompt', varname, private=private, prompt=prompt, encrypt=encrypt, confirm=confirm, salt_size=salt_size, salt=None)
return result
diff --git a/backend/mockremote.py b/backend/mockremote.py
index 2e53416..a0c39e8 100755
--- a/backend/mockremote.py
+++ b/backend/mockremote.py
@@ -86,7 +86,7 @@ def log(lf, msg):
try:
open(lf, 'a').write(str(now) + ':' + msg + '\n')
except (IOError, OSError), e:
- print 'Could not write to logfile %s - %s' % (lf, str(e))
+ sys.stderr.write('Could not write to logfile %s - %s\n' % (lf, str(e)))
print msg
def get_ans_results(results, hostname):
@@ -604,7 +604,7 @@ def parse_args(args):
opts, args = parser.parse_args(args)
if not opts.builder:
- print "Must specify a system to build on"
+ sys.stderr.write("Must specify a system to build on")
sys.exit(1)
if opts.packages_file and os.path.exists(opts.packages_file):
@@ -614,16 +614,16 @@ def parse_args(args):
# :(
if not args:
- print "Must specify at least one pkg to build"
+ sys.stderr.write("Must specify at least one pkg to build")
sys.exit(1)
if not opts.chroot:
- print "Must specify a mock chroot"
+ sys.stderr.write("Must specify a mock chroot")
sys.exit(1)
for url in opts.repos:
if not (url.startswith('http://') or url.startswith('https://') or url.startswith('file://')):
- print "Only http[s] or file urls allowed for repos"
+ sys.stderr.write("Only http[s] or file urls allowed for repos")
sys.exit(1)
return opts, args
diff --git a/copr-be.py b/copr-be.py
index 24126c1..4c636ed 100755
--- a/copr-be.py
+++ b/copr-be.py
@@ -257,7 +257,7 @@ def parse_args(args):
opts, args = parser.parse_args(args)
if not os.path.exists(opts.config_file):
- print "No config file found at: %s" % opts.config_file
+ sys.stderr.write("No config file found at: %s\n" % opts.config_file)
sys.exit(1)
opts.config_file = os.path.abspath(opts.config_file)
@@ -289,7 +289,7 @@ def main(args):
cbe = CoprBackend(opts.config_file, ext_opts=opts)
cbe.run()
except Exception:
- print 'Killing/Dying'
+ sys.stderr.write("Killing/Dying\n")
if 'cbe' in locals():
cbe.terminate()
raise
@@ -298,5 +298,5 @@ if __name__ == '__main__':
try:
main(sys.argv[1:])
except KeyboardInterrupt:
- print "\nUser cancelled, may need cleanup\n"
+ sys.stderr.write("\nUser cancelled, may need cleanup\n")
sys.exit(0)