Exemple #1
0
    def add(cls, **kwargs):
        # Clean up the version.
        version = parse_modversion(kwargs['version'])

        # Grab a session
        session = DBSession()

        # Grab device record, if it already exists.
        try:
            obj = session.query(cls).filter(cls.hash == kwargs['hash']).one()
        except:
            obj = cls()
            obj.date_added = func.now()

        # Flag this as a KANG if necessary.
        if version == None:
            version = kwargs['version']
            obj.kang = True
        else:
            obj.kang = False

        # Populate the rest of the records.
        obj.hash = kwargs['hash']
        obj.name = kwargs['name']
        obj.version = version
        obj.version_raw = kwargs['version']
        obj.country = kwargs['country']
        obj.carrier_id = kwargs['carrier_id']
        obj.date_updated = func.now()

        logging.info("Saving: %s" % obj)

        session.add(obj)
        session.commit()
    def add(cls, **kwargs):
        # Clean up the version.
        version = parse_modversion(kwargs['version'])

        # Grab a session
        session = DBSession()

        # Grab device record, if it already exists.
        try:
            obj = session.query(cls).filter(cls.hash == kwargs['hash']).one()
        except:
            obj = cls()
            obj.date_added = func.now()

        # Flag this as a KANG if necessary.
        if version == None:
            version = kwargs['version']
            obj.kang = True
        else:
            obj.kang = False

        # Populate the rest of the records.
        obj.hash = kwargs['hash']
        obj.name = kwargs['name']
        obj.version = version
        obj.version_raw = kwargs['version']
        obj.country = kwargs['country']
        obj.carrier_id = kwargs['carrier_id']
        obj.date_updated = func.now()

        logging.info("Saving: %s" % obj)

        session.add(obj)
        session.commit()
Exemple #3
0
def test_parse_modversion():
    rc = parse_modversion("CyanogenMod-7.0.0-RC2-N1")
    rc_four = parse_modversion("CyanogenMod-7.0.2.3-RC3-N1")
    stable = parse_modversion("CyanogenMod-7.0.0-N1")
    stable_four = parse_modversion("CyanogenMod-7.0.2.1-Supersonic")
    nightly = parse_modversion("CyanogenMod-7-01012011-NIGHTLY-N1")
    kang1 = parse_modversion("CyanogenMod-7.0.0-RC2-N1-KANG")
    kang2 = parse_modversion("CyanogenMod-7-Negro90-V.3.1-MAGLDR")

    assert rc == "7.0.0-RC2"
    assert rc_four == "7.0.2.3-RC3"
    assert stable == "7.0.0"
    assert stable_four == "7.0.2.1"
    assert nightly == "Nightly"
    assert kang1 == None
    assert kang2 == None