class Job(object): def __init__(self, host, command): self.log = Config().getLogger("distributor." + host.getHostName(), host) self.startTime = time.ctime() self.endTime = None self.__status = None self.__command = command self.__host = host self.HC = HashCat(self.__host, self.__command) self.__status = self.HC.get_result() if self.__host.addProcess(): self.HC.start() else: self.log.debug("could not add process") self.__status.set_command_xcode(-1000) def __str__(self): ret = "[Job on host %s: %-15s started %s]" % ( self.__host.getHostName(), self.__command.getCommand()[:15], self.startTime, ) return ret def terminate(self): self.HC.abort(True) self.poll() def poll(self): self.log.debug("Job status is: %s" % self.HC.isAlive()) if not self.HC.isAlive() or self.HC.isAborted(): self.log.debug("Waiting for thread to finish...") self.HC.join(300.0) self.endTime = time.ctime() self.__host.delProcess() if self.__status.get_command_xcode() != 0: if self.__status.get_command_xcode() != -500: self.log.debug("exit code is not 0 and -500") self.__host.addError() else: self.__host.resetErrors() return False elif self.__status.get_command_xcode() == -1000: self.log.debug("return status -1000") self.endTime = time.ctime() self.__host.addError() return False else: return True def getStatus(self): return self.__status
def __init__(self, host, command): self.log = Config().getLogger("distributor." + host.getHostName(), host) self.startTime = time.ctime() self.endTime = None self.__status = None self.__command = command self.__host = host self.HC = HashCat(self.__host, self.__command) self.__status = self.HC.get_result() if self.__host.addProcess(): self.HC.start() else: self.log.debug("could not add process") self.__status.set_command_xcode(-1000)