-
Notifications
You must be signed in to change notification settings - Fork 0
/
bulk_remote.py
executable file
·59 lines (52 loc) · 1.59 KB
/
bulk_remote.py
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
#!/usr/bin/python
import database
import os
import argparse
import subprocess
# Update database for energy shifts in EuO and substrate
def main():
parser = argparse.ArgumentParser(description='Update database for bulk results')
parser.add_argument('input', nargs='*', help='Folders containing results of bulk runs or folders containing subfolders with results')
parser.add_argument('--dry', action='store_true', help='Simulate updating of database')
parser.add_argument('--archive', action='store_true', help='Archive all results')
args = parser.parse_args()
# get host
host=database.get_host()
bdb=database.bulk_database()
bdb.download()
found=False
serverdir=''
clientdir=''
for worker in bdb.workers:
if host==worker.host:
serverdir=worker.serverdir
clientdir=worker.clientdir
found=True
if not found:
print "Error: Bulk database remote: Unknow host: %s" % host
print "Break."
exit(1)
# get path on steinschal-tradigist
inputs=[]
for ipath in args.input:
# get absolute path
apath=os.path.abspath(ipath)
if not apath.startswith(clientdir):
print "Error: Bulk database remote: %s is an unknown run path. Break." % apath
exit(1)
inputs.append(apath.replace(clientdir, serverdir, 1))
cmd='/users/stollenw/projects/euo/tools/euoscripts/bulk_update.py'
for inp in inputs:
cmd+=" %s" % inp
if args.dry:
cmd+=" --dry"
if args.archive:
cmd+=" --archive"
try:
rcmd=['ssh', 'steinschal-tradigist.th.physik.uni-bonn.de', '%s' % cmd]
subprocess.call(rcmd)
except:
print "Unable to update remote database. Break."
exit(1)
if __name__=="__main__":
main()