-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloth_backward_euler_nocona
executable file
·70 lines (65 loc) · 2.21 KB
/
cloth_backward_euler_nocona
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/python
import os
import sys
import re
import tempfile
library_directories="../../build/nocona/release/Public_Library"
binary_directory="../../build/nocona/release/Projects/strand_wrap_quasistatic"
binary="cloth_backward_euler"
base_directory=os.path.dirname(sys.argv[0])
dirs=":".join(map(lambda x:os.path.join(base_directory,x),library_directories.split(':')))
libpath='LD_LIBRARY_PATH'
if sys.platform=='darwin': libpath='DYLD_LIBRARY_PATH'
if os.environ.has_key(libpath):
os.environ[libpath]=dirs+":"+os.environ[libpath]
else:
os.environ[libpath]=dirs
# parse arguments
usage="Usage: %s [--debug <debugger>] [--copy] [arg1 arg2 ...]"%sys.argv[0]
args=sys.argv[1:]
args.reverse()
unconsumed=[]
debugger,copy,ldd="",False,False
usexterm=False
while len(args):
arg=args.pop()
if arg=="--debug":
debugger=args.pop()
elif arg=="--xterm":
usexterm=True
elif arg=="--ldd":
ldd=True
elif arg=="--copy":
copy=args.pop()
elif arg=="--wrapperhelp":
print usage
sys.exit(1)
else:
unconsumed.append(arg)
binary="%s/%s/%s"%(base_directory,binary_directory,binary)
if copy:
code=os.system("$PHYSBAM/Scripts/misc/copyexe \"%s\" %s"%(binary,copy))
sys.exit(code>>8)
elif ldd:
code=os.system("ldd \"%s\""%binary)
sys.exit(code>>8)
elif debugger:
if re.match('gdb|ddd',debugger):
handle,name=tempfile.mkstemp(prefix='gdb-command')
open(name,'w').write('run '+' '.join(unconsumed)+'\n')
if usexterm:
os.execvp('xterm',['xterm','-title',"rank-%s"%os.environ["LAMRANK"],'-e','%s %s %s'%(debugger,binary,'--command='+name)])
else:
os.execvp(debugger,[debugger,binary,'--command='+name])
elif re.match('valgrind|gldb',debugger):
code=0
if usexterm:
code=os.system("xterm -title %s -e \"%s %s %s\""%("rank-%s"%os.environ["LAMRANK"],debugger,binary,' '.join(unconsumed)))
else:
code=os.system("%s %s %s"%(debugger,binary,' '.join(unconsumed)))
sys.exit(code>>8)
else:
print 'Unrecognized debugger %s: discarding arguments'%debugger
os.execvp(debugger,[debugger,binary])
else:
os.execvp(binary,[sys.argv[0]]+unconsumed)