1#!/usr/bin/env python 2# Copyright (c) 2005 The Regents of The University of Michigan 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are 7# met: redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer; --- 14 unchanged lines hidden (view full) --- 23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27# 28# Authors: Ali Saidi 29# Nathan Binkert 30 |
31import os, os.path, re, socket, sys |
32from os import environ as env, listdir 33from os.path import basename, isdir, isfile, islink, join as joinpath 34from filecmp import cmp as filecmp 35from shutil import copyfile 36 |
37def nfspath(dir): 38 if dir.startswith('/.automount/'): 39 dir = '/n/%s' % dir[12:] 40 elif not dir.startswith('/n/'): 41 dir = '/n/%s%s' % (socket.gethostname().split('.')[0], dir) 42 return dir 43 44progpath = nfspath(sys.path[0]) |
45progname = basename(sys.argv[0]) 46usage = """\ 47Usage: 48 %(progname)s [-c] [-e] [-f] [-q queue] [-v] <regexp> 49 -c clean directory if job can be run 50 -e only echo pbs command info, don't actually send the job 51 -f force the job to run regardless of state 52 -q <queue> submit job to the named queue --- 15 unchanged lines hidden (view full) --- 68 69clean = False 70onlyecho = False 71exprs = [] 72force = False 73listonly = False 74queue = '' 75verbose = False |
76rootdir = nfspath(os.getcwd()) |
77for opt,arg in opts: 78 if opt == '-c': 79 clean = True 80 if opt == '-d': 81 rootdir = arg 82 if opt == '-e': 83 onlyecho = True 84 if opt == '-f': --- 10 unchanged lines hidden (view full) --- 95 96basedir = joinpath(rootdir, 'Base') 97linkdir = joinpath(rootdir, 'Link') 98 99for arg in args: 100 exprs.append(re.compile(arg)) 101 102if not listonly and not onlyecho and isdir(linkdir): |
103 if verbose: 104 print 'Checking for outdated files in Link directory' |
105 entries = listdir(linkdir) 106 for entry in entries: 107 link = joinpath(linkdir, entry) 108 if not islink(link) or not isfile(link): 109 continue 110 111 base = joinpath(basedir, entry) 112 if not isfile(base) or not filecmp(link, base): --- 47 unchanged lines hidden (view full) --- 160 joblist = jl 161 162for jobname in joblist: 163 jobdir = joinpath(rootdir, jobname) 164 165 if not onlyecho and not os.path.isdir(jobdir): 166 sys.exit('%s is not a directory. Cannot build job' % jobdir) 167 |
168 print 'Job name: %s' % jobname 169 print 'Job directory: %s' % jobdir |
170 171 qsub = pbs.qsub() 172 qsub.pbshost = 'simpool.eecs.umich.edu' 173 qsub.stdout = joinpath(jobdir, 'jobout') 174 qsub.name = jobname 175 qsub.join = True 176 qsub.node_type = 'FAST' |
177 qsub.env['ROOTDIR'] = rootdir |
178 if len(queue): 179 qsub.queue = queue |
180 qsub.build(joinpath(progpath, 'job.py')) |
181 |
182 if verbose: 183 print 'PBS Command: %s' % qsub.command 184 185 if not onlyecho: 186 ec = qsub.do() 187 if ec == 0: 188 print 'PBS Jobid: %s' % qsub.result 189 else: 190 print 'PBS Failed' |