fix: ok_python global variable definition
This commit is contained in:
parent
e03ba93186
commit
cac41658f8
30
nodes.py
30
nodes.py
@ -83,7 +83,7 @@ class Node(object):
|
|||||||
if bname[0] == '.':
|
if bname[0] == '.':
|
||||||
if self.os_platform in bname:
|
if self.os_platform in bname:
|
||||||
logging.debug('os %s in filename %s' %
|
logging.debug('os %s in filename %s' %
|
||||||
(self.os_platform, filename))
|
(self.os_platform, filename))
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
@ -118,7 +118,7 @@ class Node(object):
|
|||||||
sshopts=sshopts,
|
sshopts=sshopts,
|
||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
command=''
|
command=''
|
||||||
)
|
)
|
||||||
if code != 0:
|
if code != 0:
|
||||||
logging.error("node: %s, ip: %s, cmdfile: %s,"
|
logging.error("node: %s, ip: %s, cmdfile: %s,"
|
||||||
" code: %s, error message: %s" %
|
" code: %s, error message: %s" %
|
||||||
@ -146,8 +146,8 @@ class Node(object):
|
|||||||
inputfile=infile)
|
inputfile=infile)
|
||||||
if code != 0:
|
if code != 0:
|
||||||
logging.warning("node: %s, ip: %s, cmdfile: %s,"
|
logging.warning("node: %s, ip: %s, cmdfile: %s,"
|
||||||
" code: %s, error message: %s" %
|
" code: %s, error message: %s" %
|
||||||
(self.node_id, self.ip, cmd, code, errs))
|
(self.node_id, self.ip, cmd, code, errs))
|
||||||
|
|
||||||
def du_logs(self, label, sshopts, odir='info', timeout=15):
|
def du_logs(self, label, sshopts, odir='info', timeout=15):
|
||||||
logging.info('node:%s(%s), filelist: %s' %
|
logging.info('node:%s(%s), filelist: %s' %
|
||||||
@ -209,25 +209,24 @@ class Node(object):
|
|||||||
|
|
||||||
def logs_filter(self, lfilter):
|
def logs_filter(self, lfilter):
|
||||||
flogs = {}
|
flogs = {}
|
||||||
logging.info('logs_filter: node: %s, filter: %s' %(self.node_id, lfilter))
|
logging.info('logs_filter: node: %s, filter: %s' % (self.node_id, lfilter))
|
||||||
for f in self.dulogs.splitlines():
|
for f in self.dulogs.splitlines():
|
||||||
try:
|
try:
|
||||||
if (('include' in lfilter and re.search(lfilter['include'], f)) and
|
if (('include' in lfilter and re.search(lfilter['include'], f)) and
|
||||||
('exclude' in lfilter and not re.search(lfilter['exclude'], f))
|
('exclude' in lfilter and not re.search(lfilter['exclude'], f))):
|
||||||
):
|
flogs[f.split("\t")[1:]] = int(f.split("\t")[0])
|
||||||
flogs[f.split("\t")[1]] = int(f.split("\t")[0])
|
|
||||||
else:
|
else:
|
||||||
logging.debug("filter %s by %s" %(f, lfilter))
|
logging.debug("filter %s by %s" % (f, lfilter))
|
||||||
except re.error as e:
|
except re.error as e:
|
||||||
logging.error('logs_include_filter: filter: %s, str: %s, re.error: %s' %
|
logging.error('logs_include_filter: filter: %s, str: %s, re.error: %s' %
|
||||||
(lfilter, f, str(e)))
|
(lfilter, f, str(e)))
|
||||||
sys.exit(5)
|
sys.exit(5)
|
||||||
|
|
||||||
#logging.debug('logs_include_filter: %s, filter: %s' %(flogs, lfilter))
|
# logging.debug('logs_include_filter: %s, filter: %s' %(flogs, lfilter))
|
||||||
self.flogs.update(flogs)
|
self.flogs.update(flogs)
|
||||||
|
|
||||||
def log_size_from_find(self, path, sshopts, timeout=5):
|
def log_size_from_find(self, path, sshopts, timeout=5):
|
||||||
cmd = ("find '%s' -type f -exec du -b {} +" %(path))
|
cmd = ("find '%s' -type f -exec du -b {} +" % (path))
|
||||||
logging.info('log_size_from_find: node: %s, logs du-cmd: %s' % (self.node_id, cmd))
|
logging.info('log_size_from_find: node: %s, logs du-cmd: %s' % (self.node_id, cmd))
|
||||||
outs, errs, code = ssh_node(ip=self.ip,
|
outs, errs, code = ssh_node(ip=self.ip,
|
||||||
command=cmd,
|
command=cmd,
|
||||||
@ -240,7 +239,7 @@ class Node(object):
|
|||||||
(self.node_id, self.ip, cmd, code, errs))
|
(self.node_id, self.ip, cmd, code, errs))
|
||||||
return False
|
return False
|
||||||
self.dulogs = outs
|
self.dulogs = outs
|
||||||
logging.info('log_size_from_find: dulogs: %s' %(self.dulogs))
|
logging.info('log_size_from_find: dulogs: %s' % (self.dulogs))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def print_files(self):
|
def print_files(self):
|
||||||
@ -309,7 +308,8 @@ class Nodes(object):
|
|||||||
if self.conf.hard_filter.status and (node.status not in self.conf.hard_filter.status):
|
if self.conf.hard_filter.status and (node.status not in self.conf.hard_filter.status):
|
||||||
logging.info("hard filter by status: excluding node-%s" % node.node_id)
|
logging.info("hard filter by status: excluding node-%s" % node.node_id)
|
||||||
return False
|
return False
|
||||||
if isinstance(self.conf.hard_filter.online, bool) and (bool(node.online) != bool(self.conf.hard_filter.online)):
|
if (isinstance(self.conf.hard_filter.online, bool) and
|
||||||
|
(bool(node.online) != bool(self.conf.hard_filter.online))):
|
||||||
logging.info("hard filter by online: excluding node-%s" % node.node_id)
|
logging.info("hard filter by online: excluding node-%s" % node.node_id)
|
||||||
return False
|
return False
|
||||||
if self.conf.hard_filter.node_ids and ((int(node.node_id) not in self.conf.hard_filter.node_ids) and (str(node.node_id) not in self.conf.hard_filter.node_ids)):
|
if self.conf.hard_filter.node_ids and ((int(node.node_id) not in self.conf.hard_filter.node_ids) and (str(node.node_id) not in self.conf.hard_filter.node_ids)):
|
||||||
|
4
tools.py
4
tools.py
@ -26,15 +26,15 @@ import sys
|
|||||||
def import_subprocess():
|
def import_subprocess():
|
||||||
if 'subprocess' not in globals():
|
if 'subprocess' not in globals():
|
||||||
global subprocess
|
global subprocess
|
||||||
|
global ok_python
|
||||||
try:
|
try:
|
||||||
import subprocess32 as subprocess
|
import subprocess32 as subprocess
|
||||||
logging.info("using improved subprocess32 module\n")
|
logging.info("using improved subprocess32 module\n")
|
||||||
|
ok_python = True
|
||||||
except:
|
except:
|
||||||
import subprocess
|
import subprocess
|
||||||
logging.warning(("Please upgrade the module 'subprocess' to the latest version: "
|
logging.warning(("Please upgrade the module 'subprocess' to the latest version: "
|
||||||
"https://pypi.python.org/pypi/subprocess32/"))
|
"https://pypi.python.org/pypi/subprocess32/"))
|
||||||
### set not_ok python
|
|
||||||
global ok_python
|
|
||||||
ok_python = True
|
ok_python = True
|
||||||
if sys.version > (2,7,0):
|
if sys.version > (2,7,0):
|
||||||
ok_python = False
|
ok_python = False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user