summaryrefslogtreecommitdiff
path: root/util/pbs/send.py
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2005-02-09 23:55:21 -0500
committerNathan Binkert <binkertn@umich.edu>2005-02-09 23:55:21 -0500
commit8efd7d90633520b93c4bfba93d248b9c9bd8fe5a (patch)
treed952ee7e4615b1f5cab93fdb9bf68a5fda87b670 /util/pbs/send.py
parent4a3e33fb6d2e13a0febd9696905da05e02f93834 (diff)
downloadgem5-8efd7d90633520b93c4bfba93d248b9c9bd8fe5a.tar.xz
More fixes to the pbs stuff to make it more robust.
sim/pyconfig/SConscript: Embed the jobfile.py script into the binary so that we don't need to copy it into the Base directory every time. test/genini.py: Add the util/pbs directory to the path so we can get to jobfile.py Add a -I argument to set to add to the path. util/pbs/pbs.py: Create a MyPOpen class. This is a lot like the popen2.Popen3 class in the python library except that my version allows redirection of standard in and standard out to a file instead of a pipe. Use this popen class to execute qsub or ssh qsub. This was important for the ssh version of qsub because we need to pipe the script into standard in of ssh so that the script can get to the qsub command. (Otherwise we have a problem discovering the path.) util/pbs/send.py: Tweak the script so it figures out paths in NFS correctly. Use the new system for running qsub. --HG-- extra : convert_revision : 1289915ba99cec6fd464b71215c32d2197ff2824
Diffstat (limited to 'util/pbs/send.py')
-rwxr-xr-xutil/pbs/send.py33
1 files changed, 24 insertions, 9 deletions
diff --git a/util/pbs/send.py b/util/pbs/send.py
index 3741b8696..4daf15b45 100755
--- a/util/pbs/send.py
+++ b/util/pbs/send.py
@@ -28,12 +28,20 @@
# Authors: Ali Saidi
# Nathan Binkert
-import os, os.path, re, sys
+import os, os.path, re, socket, sys
from os import environ as env, listdir
from os.path import basename, isdir, isfile, islink, join as joinpath
from filecmp import cmp as filecmp
from shutil import copyfile
+def nfspath(dir):
+ if dir.startswith('/.automount/'):
+ dir = '/n/%s' % dir[12:]
+ elif not dir.startswith('/n/'):
+ dir = '/n/%s%s' % (socket.gethostname().split('.')[0], dir)
+ return dir
+
+progpath = nfspath(sys.path[0])
progname = basename(sys.argv[0])
usage = """\
Usage:
@@ -65,7 +73,7 @@ force = False
listonly = False
queue = ''
verbose = False
-rootdir = re.sub(r'^/\.automount/', r'/n/', os.getcwd())
+rootdir = nfspath(os.getcwd())
for opt,arg in opts:
if opt == '-c':
clean = True
@@ -92,7 +100,8 @@ for arg in args:
exprs.append(re.compile(arg))
if not listonly and not onlyecho and isdir(linkdir):
- print 'Checking for outdated files in Link directory'
+ if verbose:
+ print 'Checking for outdated files in Link directory'
entries = listdir(linkdir)
for entry in entries:
link = joinpath(linkdir, entry)
@@ -156,8 +165,8 @@ for jobname in joblist:
if not onlyecho and not os.path.isdir(jobdir):
sys.exit('%s is not a directory. Cannot build job' % jobdir)
- print >>sys.stderr, 'Job name: %s' % jobname
- print >>sys.stderr, 'Job directory: %s' % jobdir
+ print 'Job name: %s' % jobname
+ print 'Job directory: %s' % jobdir
qsub = pbs.qsub()
qsub.pbshost = 'simpool.eecs.umich.edu'
@@ -165,11 +174,17 @@ for jobname in joblist:
qsub.name = jobname
qsub.join = True
qsub.node_type = 'FAST'
- qsub.onlyecho = onlyecho
qsub.env['ROOTDIR'] = rootdir
- qsub.verbose = verbose
if len(queue):
qsub.queue = queue
+ qsub.build(joinpath(progpath, 'job.py'))
- qsub.do(joinpath(basedir, 'job.py'))
- print >>sys.stderr, ''
+ if verbose:
+ print 'PBS Command: %s' % qsub.command
+
+ if not onlyecho:
+ ec = qsub.do()
+ if ec == 0:
+ print 'PBS Jobid: %s' % qsub.result
+ else:
+ print 'PBS Failed'