From 2b227a1a9cfcfdc9ec67e4e5e3779414a5d2009a Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 12 Oct 2012 02:37:04 +0200 Subject: improved worker sanity check --- src/flufigut.py | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src/flufigut.py b/src/flufigut.py index f715e03..0a718b3 100755 --- a/src/flufigut.py +++ b/src/flufigut.py @@ -67,14 +67,15 @@ for machine in globals['machines']: if w in worker: raise SystemExit("ERROR: worker '%s' is assigned to more than one machine!!" % w) else: - worker[w] = False + worker[w] = 0 ### generate input components ################################### flow['input'] = {} if 'input' not in worker: - raise SystemExit("ERROR: worker 'input' is not assigned to any machine!!") -worker['input'] = True + worker['input'] = -1 +else: + worker['input'] = 1 flow['input']['raw-input'] = { 'type': input['source'], 'desc': "capture raw AV from %s" % input['source'], @@ -150,8 +151,9 @@ for format in transcode.keys(): if video_encoder not in flow['encoder_video'].keys(): worker_name = 'encoder-%s-%s' % (encoder, resolution) if worker_name not in worker: - raise SystemExit("ERROR: worker '%s' is not assigned to any machine!!" % worker_name) - worker[worker_name] = True + worker[worker_name] = -1 + else: + worker[worker_name] = 1 flow['encoder_video'][video_encoder] = { 'type': '%s-encode' % encoder, 'desc': "%s encoder for %sx%s" % (encoder, globals['resolutions'][resolution]['width'], globals['resolutions'][resolution]['height']), @@ -176,8 +178,9 @@ for format in transcode.keys(): if audio_encoder not in flow['encoder_audio']: worker_name = 'encoder-%s-%s' % (encoder, bitrate) if worker_name not in worker: - raise SystemExit("ERROR: worker '%s' is not assigned to any machine!!" % worker_name) - worker[worker_name] = True + worker[worker_name] = -1 + else: + worker[worker_name] = 1 flow['encoder_audio'][audio_encoder] = { 'type': '%s-encode' % encoder, 'desc': "%s encoder for %i kbit/s @ %i Hz" % (encoder, bitrate, samplerate), @@ -191,8 +194,9 @@ for format in transcode.keys(): muxer = globals['formats'][format]['muxer'] worker_name = 'muxer-%s-%s' % (format, profile) if worker_name not in worker: - raise SystemExit("ERROR: worker '%s' is not assigned to any machine!!" % worker_name) - worker[worker_name] = True + worker[worker_name] = -1 + else: + worker[worker_name] = 1 flow['muxer']['muxer-%s-%s' % (format, profile)] = { 'type': '%s-mux' % muxer, 'desc': "%s muxer profile %s" % (format, profile), @@ -229,8 +233,9 @@ for cluster in stream.keys(): } if stream_worker not in worker: - raise SystemExit("ERROR: worker '%s' is not assigned to any machine!!" % stream_worker) - worker[stream_worker] = True + worker[stream_worker] = -1 + else: + worker[stream_worker] = 1 atmosphere['porter-%s-%i'%(machine, port)] = { 'type': "porter", 'desc': "Porter for %s on port %i"%(machine, port), @@ -289,9 +294,16 @@ for cluster in stream.keys(): ### sanity checks, cont'd ####################################### +error = 0 for w in worker: - if not worker[w]: - print("WARNING: worker '%s' is not used" % w) + if worker[w] == 0: + print "WARNING: worker '%s' is not used" % w + elif worker[w] < 0: + error = error +1 + print "ERROR: worker '%s' is not assigned to any machine" % w + +if error != 0: + raise SystemExit("%i Errors found - not generating any configuration" % error) ### initialize and render templates ############################# # -- cgit v1.2.3