How to use pybit - 10 common examples

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 garethjns / PyBC / tests / tests_py3.py View on Github external
def test_hash_SHA256_twice_s1(self):
        """Test hashing with SHA256 twice."""
        inp = b'\xf3\x17\x9d\x8c\xd7\xbd\x03'

        exp = b"\xb8xn\xdc\x07\xa2\x19\x1e\xd8\xa5\x18\xa3"\
            b"\x8cc\xdf\xda\xf7\xde\xb3n\x91\x00\xfc)\x90P<\xbdzE\xff\xf6"

        self.assertEqual(hash_SHA256_twice(inp), exp)
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 / __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 / pybitweb / db.py View on Github external
def get_suitearch_id(self,suitearch_id):
        try:
            cur = self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
            cur.execute("SELECT id,suite_id,arch_id,master_weight FROM suitearches WHERE id=%s",(suitearch_id,))
            res = cur.fetchall()
            self.conn.commit()
            suitearch = SuiteArch(res[0]['id'],self.get_suite_id(res[0]['suite_id']),self.get_arch_id(res[0]['arch_id']),res[0]['master_weight'])
            cur.close()
            return suitearch
        except psycopg2.Error as e:
            self.conn.rollback()
            raise Exception("Error retrieving suite arch with id:" + str(suitearch_id) + ". Database error code: "  + str(e.pgcode) + " - Details: " + str(e.pgerror))
            return None
github nicholasdavidson / pybit / pybitweb / db.py View on Github external
def get_suitearches(self):
        try:
            cur = self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
            cur.execute("SELECT id,suite_id,arch_id,master_weight FROM suitearches ORDER BY master_weight DESC")
            res = cur.fetchall()
            self.conn.commit()

            suite_arches = []
            for i in res:
                suite_arches.append(SuiteArch(i['id'],self.get_suite_id(i['suite_id']),self.get_arch_id(i['arch_id']),i['master_weight']))
            cur.close()
            return suite_arches
        except psycopg2.Error as e:
            self.conn.rollback()
            raise Exception("Error retrieving suite arches list. Database error code: "  + str(e.pgcode) + " - Details: " + str(e.pgerror))
            return None
github nicholasdavidson / pybit / pybitweb / db.py View on Github external
def get_suitearch_by_suite_name(self,suite,arch):
        try:
            cur = self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
            cur.execute("SELECT id,suite_id,arch_id,master_weight FROM suitearches WHERE suite.id=%s, arch.id=%s",(suite.id,arch.id))
            res = cur.fetchall()
            self.conn.commit()
            suitearch = SuiteArch(res[0]['id'],self.get_suite_id(res[0]['suite_id']),self.get_arch_id(res[0]['arch_id']),res[0]['master_weight'])
            cur.close()
            return suitearch
        except psycopg2.Error as e:
            self.conn.rollback()
            raise Exception("Error retrieving suite arch with suite and arch:. Database error code: "  + str(e.pgcode) + " - Details: " + str(e.pgerror))
            return None
github nicholasdavidson / pybit / pybitweb / db.py View on Github external
def put_suitearch(self,suite_id,arch_id,master_weight = 0):
        try:
            cur = self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
            cur.execute("INSERT into suitearches(suite_id,arch_id,master_weight) VALUES (%s, %s, %s) RETURNING id",(remove_nasties(suite_id),remove_nasties(arch_id),remove_nasties(master_weight)))
            res = cur.fetchall()
            self.conn.commit()
            suitearch = SuiteArch(res[0]['id'],self.get_suite_id(suite_id),self.get_arch_id(arch_id),master_weight)
            cur.close()
            return suitearch
        except psycopg2.Error as e:
            self.conn.rollback()
            raise Exception("Error adding suite arch:" + suite_id + arch_id + ". Database error code: "  + str(e.pgcode) + " - Details: " + str(e.pgerror))
            return None
github nicholasdavidson / pybit / pybitweb / db.py View on Github external
def get_buildd_id(self,buildd_id):
        try:
            cur = self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
            cur.execute("SELECT id,name FROM buildclients WHERE id=%s",(buildd_id,))
            res = cur.fetchall()
            self.conn.commit()
            if (res):
                buildd = BuildD(res[0]['id'],res[0]['name'])
                cur.close()
                return buildd
            else:
                return None
        except psycopg2.Error as e:
            self.conn.rollback()
            raise Exception("Error retrieving buildd with id:" + str(buildd_id) + ". Database error code: "  + str(e.pgcode) + " - Details: " + str(e.pgerror))
            return None
github nicholasdavidson / pybit / pybitweb / db.py View on Github external
def put_buildclient(self,name):
        try:
            cur = self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
            cur.execute("INSERT into buildclients(name) VALUES (%s)  RETURNING id",(remove_nasties(name),))
            res = cur.fetchall()
            self.conn.commit()
            buildd = BuildD(res[0]['id'],name)
            cur.close()
            return buildd
        except psycopg2.Error as e:
            self.conn.rollback()
            raise Exception("Error adding buildd:" + name + ". Database error code: "  + str(e.pgcode) + " - Details: " + str(e.pgerror))
            return None
github nicholasdavidson / pybit / pybitweb / db.py View on Github external
def get_buildclients(self,page=None):
        try:
            cur = self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
            if page:
                # CONSTANT
                offset = (page -1) * self.limit_high;
                cur.execute("SELECT id,name FROM buildclients ORDER BY name LIMIT %s OFFSET %s", (self.limit_high,offset,))
            else:
                cur.execute("SELECT id,name FROM buildclients ORDER BY name")
            res = cur.fetchall()
            self.conn.commit()

            build_clients = []
            for i in res:
                build_clients.append(BuildD(i['id'],i['name']))
            cur.close()
            return build_clients
        except psycopg2.Error as e:
            self.conn.rollback()
            raise Exception("Error retrieving buildd list. Database error code: "  + str(e.pgcode) + " - Details: " + str(e.pgerror))
            return None