send.py (1376:190de61fed5a) | send.py (1381:6ede00091fa9) |
---|---|
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; --- 40 unchanged lines hidden (view full) --- 49 -v be verbose (list job parameters) 50 51 %(progname)s -h 52 -h display this help 53""" % locals() 54 55try: 56 import getopt | 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; --- 40 unchanged lines hidden (view full) --- 49 -v be verbose (list job parameters) 50 51 %(progname)s -h 52 -h display this help 53""" % locals() 54 55try: 56 import getopt |
57 opts, args = getopt.getopt(sys.argv[1:], '-cefhlq:v') | 57 opts, args = getopt.getopt(sys.argv[1:], '-cd:efhlq:v') |
58except getopt.GetoptError: 59 sys.exit(usage) 60 61clean = False 62onlyecho = False 63exprs = [] 64force = False 65listonly = False 66queue = '' 67verbose = False | 58except getopt.GetoptError: 59 sys.exit(usage) 60 61clean = False 62onlyecho = False 63exprs = [] 64force = False 65listonly = False 66queue = '' 67verbose = False |
68for o,a in opts: 69 if o == '-c': | 68rootdir = re.sub(r'^/\.automount/', r'/n/', os.getcwd()) 69for opt,arg in opts: 70 if opt == '-c': |
70 clean = True | 71 clean = True |
71 if o == '-e': | 72 if opt == '-d': 73 rootdir = arg 74 if opt == '-e': |
72 onlyecho = True | 75 onlyecho = True |
73 if o == '-f': | 76 if opt == '-f': |
74 force = True | 77 force = True |
75 if o == '-h': | 78 if opt == '-h': |
76 print usage 77 sys.exit(0) | 79 print usage 80 sys.exit(0) |
78 if o == '-l': | 81 if opt == '-l': |
79 listonly = True | 82 listonly = True |
80 if o == '-q': 81 queue = a 82 if o == '-v': | 83 if opt == '-q': 84 queue = arg 85 if opt == '-v': |
83 verbose = True 84 | 86 verbose = True 87 |
88basedir = joinpath(rootdir, 'Base') 89linkdir = joinpath(rootdir, 'Link') 90 |
|
85for arg in args: 86 exprs.append(re.compile(arg)) 87 | 91for arg in args: 92 exprs.append(re.compile(arg)) 93 |
88if not listonly and not onlyecho and isdir('Link'): | 94if not listonly and not onlyecho and isdir(linkdir): |
89 print 'Checking for outdated files in Link directory' | 95 print 'Checking for outdated files in Link directory' |
90 entries = listdir('Link') | 96 entries = listdir(linkdir) |
91 for entry in entries: | 97 for entry in entries: |
92 link = joinpath('Link', entry) 93 if not islink(link): | 98 link = joinpath(linkdir, entry) 99 if not islink(link) or not isfile(link): |
94 continue 95 | 100 continue 101 |
96 base = joinpath('Base', entry) | 102 base = joinpath(basedir, entry) |
97 if not isfile(base) or not filecmp(link, base): | 103 if not isfile(base) or not filecmp(link, base): |
98 print '%s is different than source %s...copying' % (base, link) | 104 print 'Base/%s is different than Link/%s: copying' % (entry, entry) |
99 copyfile(link, base) 100 101import job, jobfile, pbs 102 | 105 copyfile(link, base) 106 107import job, jobfile, pbs 108 |
103test = jobfile.JobFile(joinpath('Base', 'test.py')) | 109test = jobfile.JobFile(joinpath(basedir, 'test.py')) |
104 105joblist = [] 106for jobname in test.jobs: 107 if not exprs: 108 joblist.append(jobname) 109 continue 110 111 for expr in exprs: --- 26 unchanged lines hidden (view full) --- 138 sys.exit('job directory not clean!') 139 140 job.cleandir(jobname) 141 else: 142 os.mkdir(jobname) 143 jl.append(jobname) 144 joblist = jl 145 | 110 111joblist = [] 112for jobname in test.jobs: 113 if not exprs: 114 joblist.append(jobname) 115 continue 116 117 for expr in exprs: --- 26 unchanged lines hidden (view full) --- 144 sys.exit('job directory not clean!') 145 146 job.cleandir(jobname) 147 else: 148 os.mkdir(jobname) 149 jl.append(jobname) 150 joblist = jl 151 |
146rootdir = re.sub(r'^/\.automount/', r'/n/', os.getcwd()) | |
147for jobname in joblist: 148 jobdir = joinpath(rootdir, jobname) 149 150 if not onlyecho and not os.path.isdir(jobdir): 151 sys.exit('%s is not a directory. Cannot build job' % jobdir) 152 153 print >>sys.stderr, 'Job name: %s' % jobname 154 print >>sys.stderr, 'Job directory: %s' % jobdir --- 5 unchanged lines hidden (view full) --- 160 qsub.join = True 161 qsub.node_type = 'FAST' 162 qsub.onlyecho = onlyecho 163 qsub.env['ROOTDIR'] = rootdir 164 qsub.verbose = verbose 165 if len(queue): 166 qsub.queue = queue 167 | 152for jobname in joblist: 153 jobdir = joinpath(rootdir, jobname) 154 155 if not onlyecho and not os.path.isdir(jobdir): 156 sys.exit('%s is not a directory. Cannot build job' % jobdir) 157 158 print >>sys.stderr, 'Job name: %s' % jobname 159 print >>sys.stderr, 'Job directory: %s' % jobdir --- 5 unchanged lines hidden (view full) --- 165 qsub.join = True 166 qsub.node_type = 'FAST' 167 qsub.onlyecho = onlyecho 168 qsub.env['ROOTDIR'] = rootdir 169 qsub.verbose = verbose 170 if len(queue): 171 qsub.queue = queue 172 |
168 qsub.do(joinpath('Base', 'job.py')) | 173 qsub.do(joinpath(basedir, 'job.py')) |
169 print >>sys.stderr, '' | 174 print >>sys.stderr, '' |