How to use the pybit.models.TaskComplete 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 / pybitclient / __init__.py View on Github external
def send_message(conn_data, msg):
    conn = None
    chan = None
    if conn_data is not None:
        conn = amqp.Connection(host=conn_data.host, userid=conn_data.userid,
                               password=conn_data.password, virtual_host=conn_data.vhost, insist=True)
        chan = conn.channel()
    task = None
    if msg == "success":
        task = TaskComplete(msg, True)
    else:
        task = TaskComplete(msg, False)
    if conn and chan:
        chan.basic_publish(amqp.Message(task.toJson()), exchange=pybit.exchange_name,
                           routing_key=conn_data.client_name)
        chan.close()
        conn.close()
    else:
        logging.debug("I: Simulating sending message: %s " % msg)
github nicholasdavidson / pybit / pybitclient / __init__.py View on Github external
def send_message (conn_data, msg) :
	conn = None
	chan = None
	if conn_data is not None:
		conn = amqp.Connection(host=conn_data.host, userid=conn_data.userid,
			password=conn_data.password, virtual_host=conn_data.vhost, insist=True)
		chan = conn.channel()
	task = None
	if msg == "success":
		task = TaskComplete(msg, True)
	else:
		task = TaskComplete(msg, False)
	if conn and chan:
		chan.basic_publish(amqp.Message(task.toJson()),exchange=pybit.exchange_name,
			routing_key=conn_data.client_name)
		chan.close()
		conn.close()
	else :
		logging.debug("I: Simulating sending message: %s " % (msg))
github nicholasdavidson / pybit / pybitclient / __init__.py View on Github external
def checkout_handler(self, msg, decoded):
        if isinstance(decoded, TaskComplete):
            self.process.join()
            if decoded.success is True:
                self.move_state("BUILD")
            else:
                self.overall_success = False
                self.move_state("CLEAN")
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:
github nicholasdavidson / pybit / pybitclient / __init__.py View on Github external
def clean_handler(self, msg, decoded):
		if isinstance(decoded, TaskComplete) :
			self.process.join()
			if decoded.success == True:
				self.move_state("IDLE")
			else:
				self.overall_success = False
				self.move_state("FATAL_ERROR")
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.")
github nicholasdavidson / pybit / pybitclient / __init__.py View on Github external
def send_message(conn_data, msg):
    conn = None
    chan = None
    if conn_data is not None:
        conn = amqp.Connection(host=conn_data.host, userid=conn_data.userid,
                               password=conn_data.password, virtual_host=conn_data.vhost, insist=True)
        chan = conn.channel()
    task = None
    if msg == "success":
        task = TaskComplete(msg, True)
    else:
        task = TaskComplete(msg, False)
    if conn and chan:
        chan.basic_publish(amqp.Message(task.toJson()), exchange=pybit.exchange_name,
                           routing_key=conn_data.client_name)
        chan.close()
        conn.close()
    else:
        logging.debug("I: Simulating sending message: %s " % msg)
github nicholasdavidson / pybit / pybitclient / __init__.py View on Github external
def send_message (conn_data, msg) :
	conn = None
	chan = None
	if conn_data is not None:
		conn = amqp.Connection(host=conn_data.host, userid=conn_data.userid,
			password=conn_data.password, virtual_host=conn_data.vhost, insist=True)
		chan = conn.channel()
	task = None
	if msg == "success":
		task = TaskComplete(msg, True)
	else:
		task = TaskComplete(msg, False)
	if conn and chan:
		chan.basic_publish(amqp.Message(task.toJson()),exchange=pybit.exchange_name,
			routing_key=conn_data.client_name)
		chan.close()
		conn.close()
	else :
		logging.debug("I: Simulating sending message: %s " % (msg))