diff options
-rwxr-xr-x | go | 4 | ||||
-rw-r--r-- | scripts/steuermann_report.cgi | 30 | ||||
-rw-r--r-- | steuermann/run.py | 16 | ||||
-rw-r--r-- | steuermann/run_all.py | 16 | ||||
-rw-r--r-- | steuermann/run_cron.py | 2 |
5 files changed, 37 insertions, 31 deletions
@@ -10,8 +10,8 @@ case "$p" in /usr/stsci/*) : ;; *) - echo why is python set to $p echo path = $PATH + echo why is python set to $p exit 1 ;; esac @@ -22,7 +22,7 @@ there=/ssbwebv1/data2/steuermann/s$n rm -rf $there -python setup.py -q install --home $there +python setup.py $quiet install --home $there rm -f /eng/ssb/websites/ssb/steuermann/s$n.cgi diff --git a/scripts/steuermann_report.cgi b/scripts/steuermann_report.cgi index 6953b0d..ba99a8d 100644 --- a/scripts/steuermann_report.cgi +++ b/scripts/steuermann_report.cgi @@ -8,11 +8,11 @@ import re import datetime import pandokia.text_table - STEUERMANN_DIR_HERE sys.path.insert(0, addpath) import steuermann.config +import steuermann.run_all cgitb.enable() @@ -216,7 +216,7 @@ elif action == 'cronlog' : print end_time print "status=",status print "----------" - f=open(steuermann.config.logdir + '/cron/' + logfile,"r") + f=open( steuermann.config.logdir + '/cron/' + logfile,"r") sys.stdout.write(f.read()) f.close() sys.exit(0) @@ -262,20 +262,30 @@ elif action == 'log' : for x in [ ' ' + x for x in notes.split('\n') ] : print x print "" - filename = '%s/run/%s/%s:%s.%s.log'%(steuermann.config.logdir,run,host,table,cmd) - try : - f=open(filename,'r') - except IOError: - print "No log file %s" %filename - f = None - print "--------------------" - + loglist = [ steuermann.run_all.make_log_file_name( run, host, table, cmd), + # compat mode until we delete the old files + '%s/%s/%s:%s.%s.log'%(steuermann.config.logdir,run,host,table,cmd), + # more compat mode + '%s/run/%s/%s:%s.%s.log'%(steuermann.config.logdir,run,host,table,cmd), + ] + + for filename in loglist : + try : + f=open(filename,'r') + break + except IOError: + f = None + if f : + print "--------------------" while 1 : x = f.read(65536) if x == '' : break sys.stdout.write(x) + else : + print "No log file found. tried " + print loglist sys.exit(0) diff --git a/steuermann/run.py b/steuermann/run.py index e83fca2..63900dd 100644 --- a/steuermann/run.py +++ b/steuermann/run.py @@ -53,9 +53,6 @@ class runner(object): # index of nodes node_index = None - # dir where we write our logs - logdir = '' - # host_info_cache = None @@ -65,18 +62,17 @@ class runner(object): ##### # - def __init__( self, nodes, logdir ) : + def __init__( self, nodes ) : self.all_procs = { } self.node_index = nodes self.load_host_info() - self.logdir = logdir self.host_info_cache = { } self.howmany = { } ##### # start a process - def run( self, node, run_name, no_run = False, logfile_name = None ): + def run( self, node, run_name, logfile_name, no_run = False ): try : try : @@ -144,13 +140,6 @@ class runner(object): if debug : print "RUN",run - if logfile_name is None : - # make sure the log directory is there - logdir= self.logdir + "/%s"%(run_name) - - # create a name for the log file, but do not use / in the name - logfile_name = "%s/%s.log"%( logdir, node.name.replace('/','.') ) - try : os.makedirs( os.path.dirname(logfile_name) ) except OSError, e : @@ -160,6 +149,7 @@ class runner(object): raise # open the log file, write initial notes + print "LOGFILE",logfile_name logfile=open(logfile_name,"w") logfile.write('%s %s\n'%(datetime.datetime.now(),run)) logfile.flush() diff --git a/steuermann/run_all.py b/steuermann/run_all.py index 1e179a2..71cabd1 100644 --- a/steuermann/run_all.py +++ b/steuermann/run_all.py @@ -177,7 +177,7 @@ def run_interactive( xnodes, run_name, db) : register_database(db, run_name, xnodes) - runner = run.runner( xnodes, steuermann.config.logdir ) + runner = run.runner( xnodes ) for x in xnodes : xnodes[x].finished = 0 @@ -440,10 +440,7 @@ def run_step( runner, xnodes, run_name, db ) : else : try : - if runner.run(x, run_name, no_run=no_run) : - # returns true/false whether it actually ran it - it may not because of resource limits - db.execute("UPDATE sm_status SET start_time = ?, status = 'R' WHERE ( run = ? AND host = ? AND tablename = ? AND cmd = ? )", - ( str(datetime.datetime.now()), run_name, host, table, cmd ) ) + tmp = runner.run(x, run_name, no_run=no_run, logfile = make_log_file_name(run_name, host, table, cmd) ) except run.run_exception, e : now = str(datetime.datetime.now()) db.execute("UPDATE sm_status SET start_time=?, end_time=?, status='E', notes=? WHERE ( run=? AND host=? AND tablename=? AND cmd=? )", @@ -451,6 +448,11 @@ def run_step( runner, xnodes, run_name, db ) : x.finished = 1 no_sleep = 1 keep_running = 1 + else : + if tmp : + # returns true/false whether it actually ran it - it may not because of resource limits + db.execute("UPDATE sm_status SET start_time = ?, status = 'R' WHERE ( run = ? AND host = ? AND tablename = ? AND cmd = ? )", + ( str(datetime.datetime.now()), run_name, host, table, cmd ) ) db.commit() @@ -510,6 +512,10 @@ def info_callback_depth( db, run, tablename, host, cmd ) : return n.depth ##### +def make_log_file_name( run_name, table, host, cmd ) : + return '%s/run/%s/%s/%s/%s.log'%(steuermann.config.logdir, run_name, table, host, cmd) + if __name__ == '__main__' : main() + diff --git a/steuermann/run_cron.py b/steuermann/run_cron.py index 39d5be7..5779e1e 100644 --- a/steuermann/run_cron.py +++ b/steuermann/run_cron.py @@ -57,7 +57,7 @@ def main() : else : node.script_type = 'r' # remote - runner = steuermann.run.runner( nodes = { node.name : node }, logdir=None ) + runner = steuermann.run.runner( nodes = { node.name : node } ) runner.run( node=node, run_name='', logfile_name = steuermann.config.logdir + '/cron/' + logfile ) n = 0.1 |