How to use the pybit.models.CommandRequest function in pybit

To help you get started, we’ve selected a few pybit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nicholasdavidson / pybit / pybit / models.py View on Github external
return  dict( host=self.host, userid=self.userid, password=self.password,
            virtual_host=self.vhost, insist= False )
    def __repr__(self):
        return "host: %s user id:%s password:%s vhost:%s insist: %s" % (
            self.host, self.userid, self.password, self.vhost, self.insist)



class CommandRequest(Model):
    def __init__(self,job,web_host):
        self.job = job
        self.web_host = web_host
    def get_job_id(self):
        return self.job.id

class CancelRequest(CommandRequest):
    def  __init__(self,job,web_host):
        CommandRequest.__init__(self, job, web_host)

class StatusRequest(CommandRequest):
    def  __init__(self,job,web_host):
        CommandRequest.__init__(self, job, web_host)

class TaskComplete(Model):
    def __init__(self, message, success = True):
        self.success = success
        self.message = message

def checkValue(value,container):
    if value in container and container[value] is not None and container[value] is not "":
        return True
    else:
github nicholasdavidson / pybit / pybitclient / __init__.py View on Github external
def command_handler(self, msg):
		cmd_req = jsonpickle.decode(msg.body)
		if (not isinstance(cmd_req, TaskComplete) and
			not isinstance(cmd_req, CommandRequest)):
			logging.debug ("Can't handle message type.")
			self.command_chan.basic_ack(msg.delivery_tag)
		elif isinstance(cmd_req, CommandRequest) :
			if isinstance(cmd_req, CancelRequest) :
				logging.debug ("Received CANCEL request for jobid:", cmd_req.get_job_id())
				self.set_status(ClientMessage.cancelled, cmd_req)
				if (self.current_request and
					self.current_request.get_job_id() == cmd_req.get_job_id() and
					self.process is not None) :
					self.process.terminate()
					self.process.join()
					self.process = None
					self.move_state("IDLE")
				else:
					logging.debug("Ignoring cancel request as no current request or id doesn't match.")
			else :
github nicholasdavidson / pybit / pybitclient / __init__.py View on Github external
def command_handler(self, msg):
        cmd_req = jsonpickle.decode(msg.body)
        if (not isinstance(cmd_req, TaskComplete) and
                not isinstance(cmd_req, CommandRequest)):
            logging.debug("Can't handle message type.")
            self.command_chan.basic_ack(msg.delivery_tag)
        elif isinstance(cmd_req, CommandRequest):
            if isinstance(cmd_req, CancelRequest):
                logging.debug("Received CANCEL request for jobid: %s" % cmd_req.get_job_id())
                self.set_status(ClientMessage.cancelled, cmd_req)
                if (self.current_request and
                    self.current_request.get_job_id() == cmd_req.get_job_id() and
                        self.process is not None):
                    #We have to sigint because it's completely unsafe to sigkill an sbuild process.
                    os.kill(self.process.pid, signal.SIGINT)
                    self.process.join()
                    self.process = None
                    self.move_state("IDLE")
                else:
                    logging.debug("Ignoring cancel request as no current request or id doesn't match.")
            else:
                logging.debug("Received COMMAND request for jobid:", cmd_req.get_job_id())
        else:
github nicholasdavidson / pybit / pybitclient / __init__.py View on Github external
def command_handler(self, msg):
		cmd_req = jsonpickle.decode(msg.body)
		if (not isinstance(cmd_req, TaskComplete) and
			not isinstance(cmd_req, CommandRequest)):
			logging.debug ("Can't handle message type.")
			self.command_chan.basic_ack(msg.delivery_tag)
		elif isinstance(cmd_req, CommandRequest) :
			if isinstance(cmd_req, CancelRequest) :
				logging.debug ("Received CANCEL request for jobid:", cmd_req.get_job_id())
				self.set_status(ClientMessage.cancelled, cmd_req)
				if (self.current_request and
					self.current_request.get_job_id() == cmd_req.get_job_id() and
					self.process is not None) :
					self.process.terminate()
					self.process.join()
					self.process = None
					self.move_state("IDLE")
				else:
					logging.debug("Ignoring cancel request as no current request or id doesn't match.")
			else :
				logging.debug ("Received COMMAND request for jobid:", cmd_req.get_job_id())
		else:
			self.state_table[self.state](msg, cmd_req)
github nicholasdavidson / pybit / pybitclient / __init__.py View on Github external
def command_handler(self, msg):
        cmd_req = jsonpickle.decode(msg.body)
        if (not isinstance(cmd_req, TaskComplete) and
                not isinstance(cmd_req, CommandRequest)):
            logging.debug("Can't handle message type.")
            self.command_chan.basic_ack(msg.delivery_tag)
        elif isinstance(cmd_req, CommandRequest):
            if isinstance(cmd_req, CancelRequest):
                logging.debug("Received CANCEL request for jobid: %s" % cmd_req.get_job_id())
                self.set_status(ClientMessage.cancelled, cmd_req)
                if (self.current_request and
                    self.current_request.get_job_id() == cmd_req.get_job_id() and
                        self.process is not None):
                    #We have to sigint because it's completely unsafe to sigkill an sbuild process.
                    os.kill(self.process.pid, signal.SIGINT)
                    self.process.join()
                    self.process = None
                    self.move_state("IDLE")
                else:
                    logging.debug("Ignoring cancel request as no current request or id doesn't match.")
github nicholasdavidson / pybit / pybit / models.py View on Github external
def  __init__(self,job,web_host):
        CommandRequest.__init__(self, job, web_host)
github nicholasdavidson / pybit / pybit / models.py View on Github external
self.host, self.userid, self.password, self.vhost, self.insist)



class CommandRequest(Model):
    def __init__(self,job,web_host):
        self.job = job
        self.web_host = web_host
    def get_job_id(self):
        return self.job.id

class CancelRequest(CommandRequest):
    def  __init__(self,job,web_host):
        CommandRequest.__init__(self, job, web_host)

class StatusRequest(CommandRequest):
    def  __init__(self,job,web_host):
        CommandRequest.__init__(self, job, web_host)

class TaskComplete(Model):
    def __init__(self, message, success = True):
        self.success = success
        self.message = message

def checkValue(value,container):
    if value in container and container[value] is not None and container[value] is not "":
        return True
    else:
        return False

class Blacklist(Model):
    def __init__(self,blacklist_id,field,regex):