Ejemplo n.º 1
0
def insert_a_package():
    p = Package()
    p.id = input('Package id / name: ').strip().lower()

    p.summary = input('Package summary: ').strip()
    p.author_name = input('Author: ').strip()
    p.license = input('License: ').strip()

    print('Release 1:')
    r = Release()
    r.major_ver = int(input('Major Version: '))
    r.minor_ver = int(input('Minor Version: '))
    r.build_ver = int(input('Build Version: '))
    r.size = int(input('Size in bytes: '))
    p.releases.append(r)

    print('Release 2:')
    r = Release()
    r.major_ver = int(input('Major Version: '))
    r.minor_ver = int(input('Minor Version: '))
    r.build_ver = int(input('Build Version: '))
    r.size = int(input('Size in bytes: '))
    p.releases.append(r)

    session = db_session.create_session()
    session.add(p)
    session.commit()
Ejemplo n.º 2
0
def insert_a_package():

    p = Package()
    p.id = input('Package id / name: ').strip().lower()

    p.summary = input("Package summary: ").strip()
    p.author_name = input("Author: ").strip()
    p.license = input("License: ").strip()

    print("Release 1: ")
    r = Release()
    r.major_ver = int(input("Major version: "))
    r.minor_ver = int(input("Minor version: "))
    r.build_ver = int(input("Build version: "))
    r.size = int(input("Size in bytes: "))
    p.releases.append(r)

    print("Release 2: ")
    r = Release()
    r.major_ver = int(input("Major version: "))
    r.minor_ver = int(input("Minor version: "))
    r.build_ver = int(input("Build version: "))
    r.size = int(input("Size in bytes: "))
    p.releases.append(r)

    session = db_session.create_session()
    session.add(p)
    session.commit()
Ejemplo n.º 3
0
def insert_a_package():
    p = Package()
    p.id = input("package id").strip().lower()
    p.summary = input("sum").strip()
    p.author_name = input("name").strip()
    p.license = input("licence").strip()

    print("Release 1")
    r = Release()
    r.major_ver = int(input("int").strip())
    r.minor_ver = int(input("int").strip())
    r.build_ver = int(input("int").strip())
    r.size = int(input("int").strip())
    p.releases.append(r)

    print("Release 2")
    r = Release()
    r.major_ver = int(input("int").strip())
    r.minor_ver = int(input("int").strip())
    r.build_ver = int(input("int").strip())
    r.size = int(input("int").strip())
    p.releases.append(r)

    session = db_session.factory()
    session.add(p)
    session.commit()
Ejemplo n.º 4
0
def insert_a_package():
    p=Package()
    p.id=input("Package ID/Name:").strip().lower()
    p.summary=input("Summary: ").strip()
    p.license=input("Licence").strip()
    p.author_name=input("Author name").strip()
    print("Release 1")
    r=Release()
    r.major_ver=int(input("Major Version"))
    r.minor_ver=int(input("Minor Version"))
    r.build_ver=int(input("Build"))
    r.size=int(input("Size:"))
    p.releases.append(r)

    print("Release 2")
    r = Release()
    r.major_ver = int(input("Major Version"))
    r.minor_ver = int(input("Minor Version"))
    r.build_ver = int(input("Build"))
    r.size = int(input("Size:"))
    p.releases.append(r)

    session=db_session.create_session()

    session.add(p)

    session.commit()
Ejemplo n.º 5
0
def load_package(data: dict, user_lookup: Dict[str, User]):
    try:
        info = data.get('info', {})

        p = Package()
        p.id = data.get('package_name', '').strip()
        if not p.id:
            return

        p.author = info.get('author')
        p.author_email = info.get('author_email')

        releases = build_releases(p.id, data.get("releases", {}))

        if releases:
            p.created_date = releases[0].created_date

        maintainers_lookup = get_email_and_name_from_text(
            info.get('maintainer'), info.get('maintainer_email'))
        maintainers = []
        for email, name in maintainers_lookup.items():
            user = user_lookup.get(email)
            if not user:
                continue

            m = Maintainer()
            m.package_id = p.id
            m.user_id = user.id
            maintainers.append(m)

        p.summary = info.get('summary')
        p.description = info.get('description')

        p.home_page = info.get('home_page')
        p.docs_url = info.get('docs_url')
        p.package_url = info.get('package_url')

        p.author = info.get('author')
        p.author_email = info.get('author_email')
        p.license = detect_license(info.get('license'))

        session = db_session.create_session()
        session.add(p)
        session.add_all(releases)
        if maintainers:
            session.add_all(maintainers)
        session.commit()
        session.close()
    except OverflowError:
        # What the heck, people just putting fake data in here
        # Size is terabytes...
        pass
    except Exception:
        raise
Ejemplo n.º 6
0
def insert_a_package():
    p = Package()
    p.id = input("Package id / name: ").strip().lower()

    p.summary = input("Package summary: ").strip()
    p.author_name = input("Author: ").strip()
    p.license = input("License: ").strip()

    print("Release 1:")
    r = Release()
    r.major_ver = int(input("Major version: "))
    r.minor_ver = int(input("Minor version: "))
    r.build_ver = int(input("Build version: "))
    # this attaches the relationship with r to the Package p.  sa will traverse this object and see this relationship
    # and know it must add r even if we don't explicitly do a session.add(r) here.  Adding r here might be awkward since
    # we might have an auto generated p.primary_key, etc...
    p.releases.append(r)

    # if we want a second release object, we can do the same thing and again append to p.releases
    print("Release 2:")
    r = Release()
    r.major_ver = int(input("Major version: "))
    r.minor_ver = int(input("Minor version: "))
    r.build_ver = int(input("Build version: "))
    p.releases.append(r)

    session = db_session.create_session()

    # # Old way (before we had a db_session.create_session()).  Old way also had no type hinting
    # # If you want to see what the session object can do, you can use type casting
    # import sqlalchemy.orm as orm
    # session: orm.Session = db_session.__factory()
    # # Now type session <dot> <tab> and everything is available!

    # Add the changes we want to commit to the db (don't need to add r's because of the relations we already appended)
    session.add(p)

    # Once we have changes to commit (all at once), do a commit
    session.commit()