forked from dguest/pandamonium
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpanda-kill-taskid
More file actions
executable file
·62 lines (44 loc) · 1.21 KB
/
panda-kill-taskid
File metadata and controls
executable file
·62 lines (44 loc) · 1.21 KB
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
#!/usr/bin/env python
"""
Kill jobs with pbook
Runs on pure python beauty.
"""
_h_jobid = 'panda taskid, you can also pipe them'
epi = 'Thanks ATLAS. Thatlas.'
import sys, os
import argparse
from pandatools import PBookCore
def get_args():
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=epi,
)
parser.add_argument('taskids', type=int, nargs='*', help=_h_jobid)
args = parser.parse_args()
if not args.taskids and sys.stdin.isatty():
parser.print_usage()
sys.exit('ERROR: need to pipe in a taskid')
return args
def kill(jobs, args):
# enforceEnter, verbose, restoreDB
pbook = PBookCore.PBookCore()
for job in jobs:
pbook.kill(job)
def stdin_iter():
for line in sys.stdin:
for job in line.split():
yield int(job)
if __name__ == '__main__':
args = get_args()
try:
from pandatools import PBookCore
except ImportError:
print("Failed to load PandaClient, please set up locally")
sys.exit(1)
jobs = []
if not args.taskids:
jobs = stdin_iter()
else:
jobs = args.taskids
kill(jobs, args)