diff --git a/bin/linspector b/bin/linspector index 334e09a..0f08cfc 100755 --- a/bin/linspector +++ b/bin/linspector @@ -62,13 +62,14 @@ def parseArgs(): return parser.parse_args() -def setupLogging(logfile="./log/linspector.log", logLevel=logging.DEBUG, logfileLevel=logging.DEBUG): +def setupLogging(logfile="./log/linspector.log", logLevel=logging.ERROR, logfileLevel=logging.DEBUG): logfile = path.expanduser(logfile) if not path.exists(path.dirname(logfile)): os.makedirs(path.dirname(logfile)) + logging.basicConfig(level=logging.CRITICAL) log = logging.getLogger(__name__) - log.setLevel(logging.DEBUG) + #log.setLevel(logging.) consoleHandler = logging.StreamHandler() consoleHandler.setLevel(logLevel) @@ -76,6 +77,7 @@ def setupLogging(logfile="./log/linspector.log", logLevel=logging.DEBUG, logfile fileHandler = logging.handlers.RotatingFileHandler(logfile, maxBytes=1024000, backupCount=4) fileHandler.setLevel(logfileLevel) + consoleFormatter = logging.Formatter('[%(levelname)s]: %(message)s') #TODO: if debug with file and function else without that fileFormatter = logging.Formatter('%(asctime)s %(pathname)s %(module)s %(funcName)s %(lineno)d [%(levelname)s]: %(message)s') diff --git a/linspector/config/parser.py b/linspector/config/parser.py index bf5f675..4e193b8 100644 --- a/linspector/config/parser.py +++ b/linspector/config/parser.py @@ -47,7 +47,7 @@ KEY_CORE = "core" class ConfigurationException(Exception): def __init__(self, msg, log): - log.e(msg) + log.error(msg) self.msg = msg def __str__(self): diff --git a/linspector/core/job.py b/linspector/core/job.py index 3743556..616d84c 100644 --- a/linspector/core/job.py +++ b/linspector/core/job.py @@ -21,6 +21,7 @@ along with this program. If not, see . """ from datetime import datetime +from binascii import crc32 def generateId(): @@ -43,9 +44,22 @@ class Job: def __str__(self): return str(self.__dict__) + + def __hex__(self): + return hex(crc32(str(self.service) + str(self.host) + str(self.members))) + def set_logger(self, log): self.log = log + + + def pretty_string(self): + ret = self.__hex__() + if ret[0] == "-": + ret = ret[1:] + ret += ": (" + str(self.host) + str(self.service) + str(self.job) + ")" + return ret[2:] + def set_job(self, job): self.job = job diff --git a/linspector/frontends/lish.py b/linspector/frontends/lish.py index 4861cf0..ffc89af 100644 --- a/linspector/frontends/lish.py +++ b/linspector/frontends/lish.py @@ -164,7 +164,7 @@ class LishCommander(Exit, ShellCommander, LogCommander): try: hgCommander = HostgroupCommander(hg) hgCommander.cmdloop("Entering Hostmode of " + hgName + ":\n") - except KeyboardInterrupt, ke: + except KeyboardInterrupt, key: pass def do_python(self, text): @@ -172,8 +172,8 @@ class LishCommander(Exit, ShellCommander, LogCommander): def do_jobs(self, text): if text == "list": - for job in self._scheduler.get_jobs(): - print job + for job in self._jobs: + print job.pretty_string() def help_jobs(self): print "Job helper functions"