How to use the pybit.models.BuildRequest 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 republish_job(self, buildreq):
		if (isinstance(buildreq, BuildRequest)) :
			routing_key = pybit.get_build_route_name(buildreq.get_dist(),
				buildreq.get_arch(),
				buildreq.get_suite(),
				buildreq.get_format())
			try:
				msg = jsonpickle.encode(buildreq)
				self.message_chan.basic_publish(amqp.Message(msg),
					exchange=pybit.exchange_name,
					routing_key=routing_key,
					mandatory=True)
			except amqp.AMQPConnectionException as e:
				logging.debug("Couldn't connect to channel. traceback: %s" % e)
	def wait(self):
github nicholasdavidson / pybit / pybitclient / crossdebian.py View on Github external
def build_master(self, buildreq, conn_data):
        retval = None
        logfile = self.get_buildlog(self.settings["buildroot"], buildreq)
        if not isinstance(buildreq, BuildRequest):
            logging.debug("E: not able to identify package name.")
            retval = "misconfigured"
            pybitclient.send_message(conn_data, retval)
            return
        srcdir = os.path.join(self.settings["buildroot"],
                              buildreq.get_suite(), buildreq.transport.method)
        package_dir = "%s/%s" % (srcdir, buildreq.get_package())
        command = "(cd %s ; dpkg-buildpackage -S -d -uc -us)" % package_dir
        if pybitclient.run_cmd(command, self.settings["dry_run"], logfile):
            retval = "build-dep-wait"
        if not retval:
            command = "sbuild -n --debbuildopt=\"-a%s\" --setup-hook=\"/usr/bin/sbuild-cross.sh\" --arch=%s -A -s -d %s %s/%s_%s.dsc" % (
                buildreq.get_arch(), buildreq.get_arch(), buildreq.get_suite(), srcdir,
                buildreq.get_package(), buildreq.get_version())
            if pybitclient.run_cmd(command, self.settings["dry_run"], logfile):
                retval = "build_binary"
github nicholasdavidson / pybit / pybitclient / __init__.py View on Github external
def idle_handler(self, msg, decoded):
        if isinstance(decoded, BuildRequest):
            self.current_msg = msg
            self.current_request = decoded
            try:
                status = self.get_status()
                if (status == ClientMessage.waiting or
                        status == ClientMessage.blocked):
                    self.vcs_handler = self.handlers[self.current_request.transport.method]
                    if self.vcs_handler is None:
                        self.overall_success = False
                        self.move_state("IDLE")
                        return
                    self.move_state("CHECKOUT")
                elif status is None:
                    self.move_state("IDLE")
                elif status == ClientMessage.cancelled:
                    logging.debug("jobid: %s has been cancelled. Acking." % self.current_request.get_job_id())
github nicholasdavidson / pybit / pybitclient / __init__.py View on Github external
def message_handler(self, msg):
		build_req = jsonpickle.decode(msg.body)
		if not isinstance(build_req, BuildRequest) :
			self.message_chan.basic_ack(msg.delivery_tag)
			return
		if self.process:
			logging.debug ("Detected a running process")
		self.state_table[self.state](msg, build_req)
github nicholasdavidson / pybit / pybitclient / debianclient.py View on Github external
def build_master (self, buildreq, conn_data):
        retval = None
        logfile = self.get_buildlog (self.settings["buildroot"], buildreq)
        if (not isinstance(buildreq, BuildRequest)):
            logging.warn ("E: not able to identify package name.")
            retval = "misconfigured"
            return self._overall_success(retval, conn_data)
        srcdir = os.path.join (self.settings["buildroot"],
                buildreq.get_suite(), buildreq.transport.method)
        package_dir = "%s/%s" % (srcdir, buildreq.get_package())
        # To check the build-dependencies in advance, we need to ensure the
        # chroot has an update apt-cache, so can't use apt-update option of
        # sbuild. The alternative is to update the apt-cache twice per build,
        # once for the dep check and once before the build. The choice depends
        # on whether two network trips are more efficient than rewriting the
        # lvm snapshot before even trying to do any build.
        chroot_name = buildreq.get_suite()
        if (buildreq.get_buildenv() is not None):
            chroot_name = "%s-%s" % (buildreq.get_buildenv(), buildreq.get_suite())
        if self.settings["use_lvm"] :
github nicholasdavidson / pybit / pybitweb / controller.py View on Github external
chan = self.get_amqp_channel()
            for build_env_suite_arch in build_env_suite_arch :
                current_arch = build_env_suite_arch.suitearch.arch
                if current_build_env and current_build_env.name != build_env_suite_arch.get_buildenv_name() : #FIXME
                    #first packageinstance for each build environment should have master flag set
                    master_flag = True
                current_build_env = build_env_suite_arch.buildenv
                current_packageinstance = self.process_packageinstance(current_build_env, current_arch, current_package, current_dist, current_format, current_suite, master_flag)
                if current_packageinstance.id :
                    new_job = self.db.put_job(current_packageinstance,None)
                    if (new_job and new_job.id):
#                       self.log.debug("\nCREATED NEW JOB: %s\n", jsonpickle.encode(new_job))
                        self.cancel_superceded_jobs(new_job)
                        # NEW STUFF FOR RESUBMITTING JOBS
                        build_request_obj = BuildRequest(new_job,transport,
                            "%s:%s" % (self.settings['web']['hostname'], self.settings['web']['port']));
                        build_req = jsonpickle.encode(build_request_obj)
                        self.db.log_buildRequest(build_request_obj)
                        #print "SENDING REQUEST WITH DATA", str(build_req)
                        msg = amqp.Message(build_req)
                        msg.properties["delivery_mode"] = 2
                        routing_key = pybit.get_build_route_name(new_job.packageinstance.get_distribution_name(),
                                                new_job.packageinstance.get_arch_name(),
                                                new_job.packageinstance.get_suite_name(),
                                                new_job.packageinstance.get_format_name())
                        build_queue = pybit.get_build_queue_name(new_job.packageinstance.get_distribution_name(),
                                                new_job.packageinstance.get_arch_name(),
                                                new_job.packageinstance.get_suite_name(),
                                                new_job.packageinstance.get_format_name())
                        self.add_message_queue(build_queue, routing_key, chan)
github nicholasdavidson / pybit / pybitclient / __init__.py View on Github external
def republish_job(self, buildreq):
        if isinstance(buildreq, BuildRequest):
            routing_key = pybit.get_build_route_name(buildreq.get_dist(), buildreq.get_arch(),
                                                     buildreq.get_suite(), buildreq.get_format())
            try:
                msg = jsonpickle.encode(buildreq)
                self.message_chan.basic_publish(amqp.Message(msg), exchange=pybit.exchange_name,
                                                routing_key=routing_key, mandatory=True)
            except amqp.AMQPConnectionException as e:
                logging.debug("Couldn't connect to channel. traceback: %s" % e)