-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsmith_kstat
executable file
·52 lines (39 loc) · 1.48 KB
/
smith_kstat
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
#!/usr/bin/env python3
# Author: Kurt Irvin Rojas
# https://github.com/kimrojas/smith_utils
import sys, os, subprocess
sys.dont_write_bytecode = True
from smith_user_parse import user
import smith_check
from smith_output import blue, green, warning, fail, bold
# print(f"{'-'*53}")
# print(f"{'RUNNING STATUS PROTOCOL':^53}")
# access = f"Access credentials: {user['smith_username']}"
# print(f"{access:^53}")
# print(f"{'-'*53}")
method = smith_check.check()
print(green(f"USER JOB STATUS ({user['smith_username']})" ))
print(green(f"{'-'*53}"))
# print(f"{'-'*53}")
if method == 'UseLocal': bashCommand = f"ssh -Y {user['smith_username']}@{user['smith_ip']}"
if method == 'UseGlobal': bashCommand = f"ssh -Y {user['smith_username']}@localhost -p {user['smith_univ_port']}"
lookCommand = f"qstat -u {user['smith_username']}"
fullCommand = f"{bashCommand} '{lookCommand}'"
process = subprocess.Popen(fullCommand, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = process.communicate()
output = (output.decode('ascii')).splitlines()
if len(output) != 0:
for line in output:
print(line)
else:
print(warning("No submitted jobs at this moment, try again later."))
print(green(f"{'-'*53}"))
# output = subprocess.run(fullCommand)
# if output.returncode != 0:
# print(f"{'-'*53}")
# print(f"{'!! CONNECTION FAILURE !!':^53}")
# print(f"{'-'*53}")
# sys.exit()
# print(f"{'-'*53}")
# print(f"{'!! CONNECTION TERMINATED !!':^53}")
# print(f"{'-'*53}")