-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.py
executable file
·36 lines (25 loc) · 929 Bytes
/
check.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
#!/usr/bin/python3
import sys
import argparse
from glob import glob
assert sys.version_info.major == 3
assert sys.version_info.minor >= 6
def get_args():
parser = argparse.ArgumentParser("Check status of a sweep of jobs")
# arguments that need to be set for each sweep
parser.add_argument("-s", "--substr", type=str, default="")
parser.add_argument("-f", "--file", type=str, default="log.txt")
parser.add_argument("-l", "--line", type=int, default=-1)
parser.add_argument("-n", "--name", action="store_true", default=False)
return parser.parse_args()
def main():
args = get_args()
for log_file in glob(f"*{args.substr}*/{args.file}"):
with open(log_file, "r") as f:
line = f.readlines()[args.line].rstrip()
if args.name:
print(f"{line}\t{log_file}")
else:
print(line)
if __name__ == "__main__":
main()