Merge zizzer:/z/m5/Bitkeeper/m5
into zizzer.eecs.umich.edu:/.automount/zazzer/z/rdreslin/m5bk/timing_L1 --HG-- extra : convert_revision : c12f7ad9143bc69d25c39132d30889f22c73edf1
This commit is contained in:
commit
118b374b84
4 changed files with 73 additions and 23 deletions
30
base/str.cc
30
base/str.cc
|
@ -39,6 +39,36 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
bool
|
||||||
|
split_first(const string &s, string &lhs, string &rhs, char c)
|
||||||
|
{
|
||||||
|
string::size_type offset = s.find(c);
|
||||||
|
if (offset == string::npos) {
|
||||||
|
lhs = s;
|
||||||
|
rhs = "";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
lhs = s.substr(0, offset);
|
||||||
|
rhs = s.substr(offset + 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
split_last(const string &s, string &lhs, string &rhs, char c)
|
||||||
|
{
|
||||||
|
string::size_type offset = s.rfind(c);
|
||||||
|
if (offset == string::npos) {
|
||||||
|
lhs = s;
|
||||||
|
rhs = "";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
lhs = s.substr(0, offset);
|
||||||
|
rhs = s.substr(offset + 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tokenize(vector<string>& v, const string &s, char token, bool ignore)
|
tokenize(vector<string>& v, const string &s, char token, bool ignore)
|
||||||
{
|
{
|
||||||
|
|
14
base/str.hh
14
base/str.hh
|
@ -90,6 +90,20 @@ to_lower(const std::string &s)
|
||||||
return lower;
|
return lower;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Split the string s into lhs and rhs on the first occurence of the
|
||||||
|
// character c.
|
||||||
|
bool
|
||||||
|
split_first(const std::string &s, std::string &lhs, std::string &rhs, char c);
|
||||||
|
|
||||||
|
// Split the string s into lhs and rhs on the last occurence of the
|
||||||
|
// character c.
|
||||||
|
bool
|
||||||
|
split_last(const std::string &s, std::string &lhs, std::string &rhs, char c);
|
||||||
|
|
||||||
|
// Tokenize the string <s> splitting on the character <token>, and
|
||||||
|
// place the result in the string vector <vector>. If <ign> is true,
|
||||||
|
// then empty result strings (due to trailing tokens, or consecutive
|
||||||
|
// tokens) are skipped.
|
||||||
void
|
void
|
||||||
tokenize(std::vector<std::string> &vector, const std::string &s,
|
tokenize(std::vector<std::string> &vector, const std::string &s,
|
||||||
char token, bool ign = true);
|
char token, bool ign = true);
|
||||||
|
|
|
@ -36,11 +36,12 @@ env = {}
|
||||||
env.update(os.environ)
|
env.update(os.environ)
|
||||||
|
|
||||||
def panic(*args, **kwargs):
|
def panic(*args, **kwargs):
|
||||||
sys.exit(*args, **kwargs)
|
print >>sys.stderr, 'panic:', string
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
def AddToPath(path):
|
def AddToPath(path):
|
||||||
path = os.path.realpath(path)
|
path = os.path.realpath(path)
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path) and path not in sys.path:
|
||||||
sys.path.append(path)
|
sys.path.append(path)
|
||||||
|
|
||||||
def Import(path):
|
def Import(path):
|
||||||
|
|
|
@ -54,7 +54,7 @@ Usage:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import getopt
|
import getopt
|
||||||
opts, args = getopt.getopt(sys.argv[1:], '-cefhlq:v')
|
opts, args = getopt.getopt(sys.argv[1:], '-cd:efhlq:v')
|
||||||
except getopt.GetoptError:
|
except getopt.GetoptError:
|
||||||
sys.exit(usage)
|
sys.exit(usage)
|
||||||
|
|
||||||
|
@ -65,42 +65,48 @@ force = False
|
||||||
listonly = False
|
listonly = False
|
||||||
queue = ''
|
queue = ''
|
||||||
verbose = False
|
verbose = False
|
||||||
for o,a in opts:
|
rootdir = re.sub(r'^/\.automount/', r'/n/', os.getcwd())
|
||||||
if o == '-c':
|
for opt,arg in opts:
|
||||||
|
if opt == '-c':
|
||||||
clean = True
|
clean = True
|
||||||
if o == '-e':
|
if opt == '-d':
|
||||||
|
rootdir = arg
|
||||||
|
if opt == '-e':
|
||||||
onlyecho = True
|
onlyecho = True
|
||||||
if o == '-f':
|
if opt == '-f':
|
||||||
force = True
|
force = True
|
||||||
if o == '-h':
|
if opt == '-h':
|
||||||
print usage
|
print usage
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
if o == '-l':
|
if opt == '-l':
|
||||||
listonly = True
|
listonly = True
|
||||||
if o == '-q':
|
if opt == '-q':
|
||||||
queue = a
|
queue = arg
|
||||||
if o == '-v':
|
if opt == '-v':
|
||||||
verbose = True
|
verbose = True
|
||||||
|
|
||||||
|
basedir = joinpath(rootdir, 'Base')
|
||||||
|
linkdir = joinpath(rootdir, 'Link')
|
||||||
|
|
||||||
for arg in args:
|
for arg in args:
|
||||||
exprs.append(re.compile(arg))
|
exprs.append(re.compile(arg))
|
||||||
|
|
||||||
if not listonly and not onlyecho and isdir('Link'):
|
if not listonly and not onlyecho and isdir(linkdir):
|
||||||
print 'Checking for outdated files in Link directory'
|
print 'Checking for outdated files in Link directory'
|
||||||
entries = listdir('Link')
|
entries = listdir(linkdir)
|
||||||
for entry in entries:
|
for entry in entries:
|
||||||
link = joinpath('Link', entry)
|
link = joinpath(linkdir, entry)
|
||||||
if not islink(link):
|
if not islink(link) or not isfile(link):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
base = joinpath('Base', entry)
|
base = joinpath(basedir, entry)
|
||||||
if not isfile(base) or not filecmp(link, base):
|
if not isfile(base) or not filecmp(link, base):
|
||||||
print '%s is different than source %s...copying' % (base, link)
|
print 'Base/%s is different than Link/%s: copying' % (entry, entry)
|
||||||
copyfile(link, base)
|
copyfile(link, base)
|
||||||
|
|
||||||
import job, jobfile, pbs
|
import job, jobfile, pbs
|
||||||
|
|
||||||
test = jobfile.JobFile(joinpath('Base', 'test.py'))
|
test = jobfile.JobFile(joinpath(basedir, 'test.py'))
|
||||||
|
|
||||||
joblist = []
|
joblist = []
|
||||||
for jobname in test.jobs:
|
for jobname in test.jobs:
|
||||||
|
@ -143,7 +149,6 @@ if not onlyecho:
|
||||||
jl.append(jobname)
|
jl.append(jobname)
|
||||||
joblist = jl
|
joblist = jl
|
||||||
|
|
||||||
rootdir = re.sub(r'^/\.automount/', r'/n/', os.getcwd())
|
|
||||||
for jobname in joblist:
|
for jobname in joblist:
|
||||||
jobdir = joinpath(rootdir, jobname)
|
jobdir = joinpath(rootdir, jobname)
|
||||||
|
|
||||||
|
@ -165,5 +170,5 @@ for jobname in joblist:
|
||||||
if len(queue):
|
if len(queue):
|
||||||
qsub.queue = queue
|
qsub.queue = queue
|
||||||
|
|
||||||
qsub.do(joinpath('Base', 'job.py'))
|
qsub.do(joinpath(basedir, 'job.py'))
|
||||||
print >>sys.stderr, ''
|
print >>sys.stderr, ''
|
||||||
|
|
Loading…
Reference in a new issue