示例#1
0
    def __init__(self, distribution, packages):
        """The graph can be built from all packages or from selected.
		The decision is up to user of the class.

		:param distribution: OS distribution
		:type  distribution: string
		:param packages: list of packages in question
		:type  packages: [string]
		"""
        # TODO(jchaloup):
        # - inject the product together with buildsystem client
        self.product = "Fedora"
        self.distribution = distribution
        self.packages = packages
        # TODO(jchaloup):
        # - inject the client so the class can be used with Brew and CentOS as well
        self.client = FakeKojiClient()
        # TODO(jchaloup):
        # - inject the act and replace it with datasource instead
        #   so the artefact/data can be picked from more sources
        self.act = ActFactory().bake("scan-distribution-build")
示例#2
0
from gofed_lib.pkgdb.client import FakePkgDBClient
from gofed_lib.kojiclient import FakeKojiClient, KojiClient

if __name__ == "__main__":

	s1 = DistributionSnapshot().load("/home/jchaloup/Projects/gofed/infra/snapshot1.json")
	s2 = DistributionSnapshot().load("/home/jchaloup/Projects/gofed/infra/snapshot2.json")

	data = s2.compare(s1)
	print data["new_rpms"]

	exit(1)
	snapshot = DistributionSnapshot("rawhide", "1.5")

	client = FakePkgDBClient()
	kojiclient = FakeKojiClient()

	packages = client.getGolangPackages()
	for package in packages:
		try:
			data = kojiclient.getLatestRPMS("rawhide", package)
		except KeyError as e:
			print e
			continue
		snapshot.setRpms(package, data["rpms"])

	print json.dumps(snapshot.json())

	exit(1)

	file = "/home/jchaloup/Packages/etcd/fedora/etcd/etcd-5e6eb7e19d6385adfabb1f1caea03e732f9348ad/Godeps/Godeps.json"
示例#3
0
class DistributionLatestBuildGraphDataset:
    def __init__(self, distribution, packages):
        """The graph can be built from all packages or from selected.
		The decision is up to user of the class.

		:param distribution: OS distribution
		:type  distribution: string
		:param packages: list of packages in question
		:type  packages: [string]
		"""
        # TODO(jchaloup):
        # - inject the product together with buildsystem client
        self.product = "Fedora"
        self.distribution = distribution
        self.packages = packages
        # TODO(jchaloup):
        # - inject the client so the class can be used with Brew and CentOS as well
        self.client = FakeKojiClient()
        # TODO(jchaloup):
        # - inject the act and replace it with datasource instead
        #   so the artefact/data can be picked from more sources
        self.act = ActFactory().bake("scan-distribution-build")

    def build(self):
        """Build dataset for a given list of buildes
		"""
        # TODO(jchaloup): specify json schema for a dataset
        # get a list of latest rpms for selected packages
        counter = 0

        builder = DatasetBuilder()
        for pkg in self.packages:
            if pkg in [
                "golang-github-aws-aws-sdk-go",
                "golang-googlecode-google-api-go-client",
                "golang-googlecode-google-api-client",
            ]:
                continue

            try:
                data = self.client.getLatestRPMS("rawhide", pkg)
            except ValueError as e:
                logging.error("ValueError: %s" % e)
                continue
            except KeyError as e:
                logging.error("KeyError: %s" % e)
                continue

            rpms = []
            for rpm in data["rpms"]:
                rpm_name = Rpm(data["name"], rpm["name"]).name()
                # if not rpm_name.endswith("devel"): # and not rpm["name"].endswith("unit-test"):
                # 	continue

                rpms.append({"name": rpm["name"]})

                # get artefact
            data = {
                "product": self.product,
                "distribution": self.distribution,
                "build": {"name": data["name"], "rpms": rpms},
            }

            try:
                artefacts = self.act.call(data)
            except FunctionFailedError as e:
                logging.error(e)
                continue

            for rpm in artefacts["packages"]:
                builder.addArtefact(artefacts["packages"][rpm], rpm)

                # if counter == 40:
                # 	break

                # counter = counter + 1

        return builder.build().dataset()