aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--steuermann/run.py63
1 files changed, 35 insertions, 28 deletions
diff --git a/steuermann/run.py b/steuermann/run.py
index c90a40a..2cde419 100644
--- a/steuermann/run.py
+++ b/steuermann/run.py
@@ -20,7 +20,7 @@ on process exit.
#
# When the process finishes, release the resource reservation.
#
-
+from __future__ import print_function
import subprocess
import time
import datetime
@@ -47,6 +47,13 @@ def config_yes_no(d,which) :
debug=0
+if 'STEUERMANN_DEBUG' in os.environ:
+ try:
+ debug = int(os.environ['STEUERMANN_DEBUG'])
+ except ValueError:
+ print('STEUERMANN_DEBUG expects an integer value', file=sys.stderr)
+ exit(1)
+
#####
class struct :
@@ -206,35 +213,35 @@ class runner(object):
raise
# open the log file, write initial notes
- with open(logfile_name,"w") as logfile:
- logfile.write('%s %s\n'%(datetime.datetime.now(),run))
- logfile.flush()
-
- # debug - just say the name of the node we would run
-
- if ( no_run ) :
- run = [ 'echo', 'disable run - node=', node.name ]
-
- # start running the process
- if debug :
- print("RUN",run)
- p = subprocess.Popen(
- args=run,
- stdout=logfile,
- stderr=subprocess.STDOUT,
- shell=False, close_fds=True
- )
+ logfile = open(logfile_name, "w")
+ logfile.write('%s %s\n'%(datetime.datetime.now(),run))
+ logfile.flush()
+
+ # debug - just say the name of the node we would run
+
+ if ( no_run ) :
+ run = [ 'echo', 'disable run - node=', node.name ]
+
+ # start running the process
+ if debug :
+ print("RUN",run)
+ p = subprocess.Popen(
+ args=run,
+ stdout=logfile,
+ stderr=subprocess.STDOUT,
+ shell=False, close_fds=True
+ )
- # remember the popen object for the process; remember the open log file
- n = struct()
- n.proc = p
- n.logfile = logfile
- n.logfile_name = logfile_name
+ # remember the popen object for the process; remember the open log file
+ n = struct()
+ n.proc = p
+ n.logfile = logfile
+ n.logfile_name = logfile_name
- # remember the process is running
- self.all_procs[node.name] = n
+ # remember the process is running
+ self.all_procs[node.name] = n
- return 'R'
+ return 'R'
except Exception as e :
log_traceback()
@@ -258,7 +265,7 @@ class runner(object):
if debug :
hostname = args['hostname']
- print("finish %s %s %d"%(hostname,node_name,n))
+ print("finish %s %s"%(hostname,node_name))
# note the termination of the process at the end of the log file
logfile = self.all_procs[node_name].logfile