-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjob_query.py
47 lines (30 loc) · 1.15 KB
/
job_query.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
from __future__ import print_function
import paramiko,os, subprocess,time
def getRemoteDetails(userName, ip, location, passwd=None):
client = paramiko.SSHClient()
client._policy = paramiko.WarningPolicy()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(
ip,
port='22',
username=userName,
password=passwd
)
for loc in location:
print('='*90)
print("\033[1mHost : {}\nLocation : {}\n\033[0m".format(userName, loc))
_,b,_ = client.exec_command('cd {}; python PESMan.py status'.format(loc))
for i in b.readlines(): print(i,end='')
_,b,_ = client.exec_command("""
python -c "import os;import time ;print(time.ctime(os.path.getmtime(os.path.expanduser('{}/h3.db'))))"
""".format(loc))
bb = b.readline()
print("Database last modified on : ",bb)
print('-'*90,'\n')
client.close()
def getLocalDetails(location):
currentDir = os.getcwd()
os.chdir(location)
subprocess.call('python PESMan.py status', shell=True)
print(time.ctime(os.path.getmtime('h3.db')))
os.chdir(currentDir)