Esempio n. 1
0
File: job.py Progetto: paultag/lucy
    def get_package(self):
        from lucy.models.source import Source
        from lucy.models.binary import Binary

        if self["package_type"] == "binary":
            return Binary.load(self["package"])

        if self["package_type"] == "source":
            return Source.load(self["package"])
Esempio n. 2
0
    def get_package(self):
        from lucy.models.source import Source
        from lucy.models.binary import Binary

        if self['package_type'] == 'binary':
            return Binary.load(self['package'])

        if self['package_type'] == 'source':
            return Source.load(self['package'])
Esempio n. 3
0
    def __init__(self,
                 report,
                 builder,
                 package,
                 package_type,
                 job,
                 failed,
                 source=None,
                 type=None,
                 **kwargs):

        if package_type not in ["source", "binary"]:
            raise ValueError("Bad package type")

        loaded_package = None
        if package_type == 'source':
            try:
                loaded_package = Source.load(package)
                if source is None:
                    source = loaded_package['_id']
            except KeyError:
                pass

        if package_type == 'binary':
            try:
                loaded_package = Binary.load(package)
                if source is None:
                    source = loaded_package['source']
            except KeyError:
                pass

        if loaded_package is None:
            raise KeyError("No such package")

        builder = Machine.load(builder)['_id']

        job = Job.load(job)

        if type is None:
            type = job['type']

        if source is None:
            raise ValueError("No source :(")

        super(Report, self).__init__(package_type=package_type,
                                     source=source,
                                     builder=builder,
                                     package=loaded_package['_id'],
                                     report=report,
                                     job=job['_id'],
                                     type=type,
                                     failed=failed,
                                     **kwargs)
Esempio n. 4
0
File: job.py Progetto: paultag/lucy
    def __init__(
        self,
        type,
        package,
        package_type,
        arch,
        suite,
        builder=None,
        finished_at=None,
        assigned_at=None,
        source=None,
        **kwargs
    ):

        from lucy.models.source import Source
        from lucy.models.binary import Binary

        if package_type not in ["source", "binary"]:
            raise ValueError("package_type needs to be binary or source")

        if package_type == "source":
            package = Source.load(package)
            if source is None:
                source = package["_id"]

        if package_type == "binary":
            package = Binary.load(package)
            if source is None:
                source = package["source"]

        if package is None:
            raise ValueError("Bad package")

        package = package["_id"]

        if builder:
            builder = Machine.load(builder)["_id"]

        if source is None:
            raise ValueError("Bad source :(")

        super(Job, self).__init__(
            type=type,
            arch=arch,
            suite=suite,
            source=source,
            package=package,
            builder=builder,
            finished_at=finished_at,
            assigned_at=assigned_at,
            package_type=package_type,
            **kwargs
        )
Esempio n. 5
0
def test_basic_source():
    """ Test that source routines works """
    User(_id='joe', name='', email='', gpg='').save()

    p = Source(source='fluxbox',
                version='1.0',
                owner="joe")
    p.save()

    p = Source(source='fluxbox',
                version='2.0',
                owner="joe")
    p.save()

    p = Source(source='frucksbox',
                version='2.0',
                owner="joe")
    x = p.save()

    obj = Source.load(x)
    assert obj['version'] == '2.0'
Esempio n. 6
0
    def __init__(self, report, builder, package,
                 package_type, job, failed,
                 source=None, type=None, **kwargs):

        if package_type not in ["source", "binary"]:
            raise ValueError("Bad package type")

        loaded_package = None
        if package_type == 'source':
            try:
                loaded_package = Source.load(package)
                if source is None:
                    source = loaded_package['_id']
            except KeyError:
                pass

        if package_type == 'binary':
            try:
                loaded_package = Binary.load(package)
                if source is None:
                    source = loaded_package['source']
            except KeyError:
                pass

        if loaded_package is None:
            raise KeyError("No such package")

        builder = Machine.load(builder)['_id']

        job = Job.load(job)

        if type is None:
            type = job['type']

        if source is None:
            raise ValueError("No source :(")

        super(Report, self).__init__(package_type=package_type,
                                     source=source,
                                     builder=builder,
                                     package=loaded_package['_id'],
                                     report=report,
                                     job=job['_id'],
                                     type=type,
                                     failed=failed,
                                     **kwargs)
Esempio n. 7
0
    def __init__(self, type, package, package_type, arch, suite,
                 builder=None, finished_at=None, assigned_at=None,
                 source=None, **kwargs):

        from lucy.models.source import Source
        from lucy.models.binary import Binary

        if package_type not in ["source", "binary"]:
            raise ValueError("package_type needs to be binary or source")

        if package_type == "source":
            package = Source.load(package)
            if source is None:
                source = package['_id']

        if package_type == "binary":
            package = Binary.load(package)
            if source is None:
                source = package['source']

        if package is None:
            raise ValueError("Bad package")

        package = package['_id']

        if builder:
            builder = Machine.load(builder)['_id']

        if source is None:
            raise ValueError("Bad source :(")

        super(Job, self).__init__(
            type=type,
            arch=arch,
            suite=suite,
            source=source,
            package=package,
            builder=builder,
            finished_at=finished_at,
            assigned_at=assigned_at,
            package_type=package_type,
            **kwargs)
Esempio n. 8
0
 def get_source(self):
     from lucy.models.source import Source
     return Source.load(self['source'])
Esempio n. 9
0
def test_basic_source():
    """ Test that source routines works """
    User(_id='joe', name='', email='', gpg='').save()

    p = Source(source='fluxbox', version='1.0', owner="joe")
    p.save()

    p = Source(source='fluxbox', version='2.0', owner="joe")
    p.save()

    p = Source(source='frucksbox', version='2.0', owner="joe")
    x = p.save()

    obj = Source.load(x)
    assert obj['version'] == '2.0'