-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·27 lines (25 loc) · 1.01 KB
/
test.py
File metadata and controls
executable file
·27 lines (25 loc) · 1.01 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
import subprocess
import re
import logging as log
sp = subprocess.Popen(["/usr/bin/pbsnodes", "dynamictorque-worker"], shell=False,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(cmd_out, cmd_err) = sp.communicate(input=None)
returncode = sp.returncode
if returncode != 0:
log.error("checknode returns error, probably the node does not exist: cmd_out %s" % cmd_out)
log.error("cmd_err %s" % cmd_err)
m1=re.search("state = (.*)",cmd_out)
m2=re.search("rectime=([0-9]*)",cmd_out)
if m1 is not None and len(m1.groups())>0 and m2 is not None and len(m2.groups())>0:
state=m1.groups()[0].strip().lower()
length=m2.groups()[0].strip()
log.error("wn is in current state %s for %s"%(state, length))
# numbers=list(reversed(length.split(":")))
# total_seconds=int(numbers[0])
else:
log.error("can't find node's state from")
log.error("cmd_out %s" % cmd_out)
log.error("cmd_err %s" % cmd_err)
log.error("returncode %s" % returncode)
log.error("m1 %s" % m1)
log.error("m2 %s" % m2)