This repository has been archived by the owner on Jan 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pythontools.py
executable file
·161 lines (145 loc) · 4.92 KB
/
pythontools.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/env python3
""" Command line interface for Python tools
Copyright Dutch Institute for Fundamental Energy Research (2016)
Contributors: Karel van de Plassche ([email protected])
License: CeCILL v2.1
"""
import sys
import os
import subprocess
import inspect
from qualikiz import (compare, legacy, qualikizrun, basicpoll,
sacct, craypat, fs_manipulation)
if len(sys.argv) < 2:
raise Exception('Please supply a command')
command = sys.argv[1]
if command == 'compare':
if len(sys.argv) < 4:
raise Exception('Please supply two paths to compare')
path1 = sys.argv[2]
path2 = sys.argv[3]
compare.compare_runs(path1, path2)
elif command == 'dump':
if len(sys.argv) < 4:
raise Exception('Please supply the style and path of the file')
style = sys.argv[2]
path = sys.argv[3]
if style == 'bin':
array = compare.bin_to_np(path)
elif style == 'ascii':
array = compare.ascii_to_np(path)
else:
raise Exception('Unknown file style \'' + style + '\'')
print(array)
elif command == 'poll':
if len(sys.argv) < 3:
raise Exception('Please supply poll path')
if len(sys.argv) == 4:
targetdir = sys.argv[3]
else:
targetdir = './polldb.sqlite3'
path = sys.argv[2]
basicpoll.create_database(path, targetdir)
sacct.create_database(path, targetdir, overwrite=False)
craypat.create_database(path, targetdir, overwrite=False)
elif command == 'basicpoll':
if len(sys.argv) < 3:
raise Exception('Please supply poll path')
if len(sys.argv) == 4:
targetdir = sys.argv[3]
else:
targetdir = './polldb.sqlite3'
path = sys.argv[2]
basicpoll.create_database(path, targetdir)
elif command == 'sacctpoll':
if len(sys.argv) < 3:
raise Exception('Please supply poll path')
if len(sys.argv) == 4:
targetdir = sys.argv[3]
else:
targetdir = './polldb.sqlite3'
path = sys.argv[2]
sacct.create_database(path, targetdir)
elif command == 'patpoll':
if len(sys.argv) < 3:
raise Exception('Please supply poll path')
if len(sys.argv) == 4:
targetdir = sys.argv[3]
else:
targetdir = './polldb.sqlite3'
path = sys.argv[2]
craypat.create_database(path, targetdir)
elif command == 'movecomplete':
if len(sys.argv) < 4:
raise Exception('please supply source and target')
else:
sourcedir = sys.argv[2]
targetdir = sys.argv[3]
fs_manipulation.move_completed(sourcedir, targetdir)
elif command == 'inputgo':
if len(sys.argv) < 3:
raise Exception('Please supply run path')
path = sys.argv[2]
batchlist = qualikizrun.QuaLiKizBatch.from_dir_recursive(path)
for batch in batchlist:
batch.prepare()
batch.generate_input()
batch.queue_batch()
elif command == 'convertto':
if len(sys.argv) < 3:
raise Exception('Please supply current style')
current = sys.argv[2]
if len(sys.argv) < 4:
raise Exception('Please supply conversion target')
target = sys.argv[3]
if len(sys.argv) < 5:
raise Exception('Please supply input path to convert')
path = sys.argv[4]
if current == 'current':
if target == '2.3.1' or target == '2.3.0':
legacy.convert_current_to_2_3_2(path)
legacy.convert_2_3_2_to_2_3_1(path)
elif target == '2.3.2':
legacy.convert_current_to_2_3_2(path)
else:
raise Exception('Unkown target')
elif current == '2.3.2':
if target == '2.3.1' or target == '2.3.0':
legacy.convert_2_3_2_to_2_3_1(path)
else:
raise Exception('Unkown target')
else:
raise Exception('Unkown current style')
else:
testsdir = os.path.abspath(
os.path.join(os.path.abspath(inspect.getfile(inspect.currentframe())),
'../tests'))
if command == 'create':
if len(sys.argv) < 3:
raise Exception('Please supply create target')
create_target = sys.argv[2]
if len(sys.argv) == 4:
target_dir = sys.argv[3]
else:
target_dir = ''
if create_target == 'mini':
cmd = ['python3',
os.path.join(testsdir, 'mini.py'),
target_dir]
elif create_target == 'performance':
cmd = ['python3',
os.path.join(testsdir, 'performance.py'),
target_dir]
else:
raise Exception('Unknown create target \'' + create_target + '\'')
subprocess.check_call(cmd)
elif command == 'analyse':
if len(sys.argv) < 3:
raise Exception('Please supply path to analyse')
path = sys.argv[2]
cmd = ['python3',
os.path.join(testsdir, 'performance_analyse.py'),
path]
subprocess.check_call(cmd)
else:
raise Exception('Unknown command \'' + command + '\'')