예제 #1
0
def main(argv=sys.argv):

    session = DBSession()

    # Create temp table
    session.execute("""
    CREATE TABLE classifier__release_new (
            classifier_id integer REFERENCES classifier ON DELETE CASCADE,
            release_id integer REFERENCES release
    );
    """)

    # Copy data to new table
    session.execute("""
    INSERT INTO classifier__release_new (
            classifier_id, release_id)
    SELECT  classifier_id, release_id
    FROM classifier__release;
    """)

    # Swap the tables
    session.execute("""
    DROP TABLE classifier__release;
    """)
    session.execute("""
    ALTER TABLE classifier__release_new RENAME TO classifier__release;
    """)
    session.commit()
예제 #2
0
파일: install.py 프로젝트: disko/pyshop
def populate(engine, interactive=True):

    Base.metadata.create_all(engine)
    session = DBSession()
    user_perm = Permission(name=u'user_view')
    admin_perm = Permission(name=u'admin_view')
    download_perm = Permission(name=u'download_releasefile')
    upload_perm = Permission(name=u'upload_releasefile')
    session.add(user_perm)
    session.add(upload_perm)
    session.add(download_perm)
    session.add(admin_perm)

    admin_group = Group(name=u'admin')
    admin_group.permissions.append(user_perm)
    admin_group.permissions.append(download_perm)
    admin_group.permissions.append(upload_perm)
    admin_group.permissions.append(admin_perm)
    session.add(admin_group)

    user_group = Group(name=u'developer')
    user_group.permissions.append(user_perm)
    user_group.permissions.append(download_perm)
    user_group.permissions.append(upload_perm)
    session.add(user_group)

    pip_group = Group(name=u'installer')
    pip_group.permissions.append(download_perm)
    session.add(pip_group)

    if interactive:
        login = (raw_input('administrator login [admin]:')
                 or 'admin')
        password = (raw_input('administrator password [changeme]:')
                    or 'changeme')
        email = (raw_input('administrator email [[email protected]]')
                 or '*****@*****.**')
        piplogin = (raw_input('installer login [pip]:') or 'pip')
        pippassword = (raw_input('installer password [changeme]:') or
                       'changeme')
    else:
        login = '******'
        password = '******'
        email = '*****@*****.**'

        piplogin = '******'
        pippassword = '******'

    admin = User(login=unicode(login),
                 password=unicode(password),
                 email=unicode(email))
    admin.groups.append(admin_group)
    session.add(admin)
    pip = User(login=unicode(piplogin),
               password=unicode(pippassword),
               )
    pip.groups.append(pip_group)
    session.add(pip)

    session.commit()
예제 #3
0
def populate(engine, interactive=True):

    Base.metadata.create_all(engine)
    session = DBSession()
    user_perm = Permission(name=u'user_view')
    admin_perm = Permission(name=u'admin_view')
    download_perm = Permission(name=u'download_releasefile')
    upload_perm = Permission(name=u'upload_releasefile')
    session.add(user_perm)
    session.add(upload_perm)
    session.add(download_perm)
    session.add(admin_perm)

    admin_group = Group(name=u'admin')
    admin_group.permissions.append(user_perm)
    admin_group.permissions.append(download_perm)
    admin_group.permissions.append(upload_perm)
    admin_group.permissions.append(admin_perm)
    session.add(admin_group)

    user_group = Group(name=u'developer')
    user_group.permissions.append(user_perm)
    user_group.permissions.append(download_perm)
    user_group.permissions.append(upload_perm)
    session.add(user_group)

    pip_group = Group(name=u'installer')
    pip_group.permissions.append(download_perm)
    session.add(pip_group)

    if interactive:
        login = (input('administrator login [admin]:')
                 or 'admin')
        password = (input('administrator password [changeme]:')
                    or 'changeme')
        email = (input('administrator email [[email protected]]')
                 or '*****@*****.**')
        piplogin = (input('installer login [pip]:') or 'pip')
        pippassword = (input('installer password [changeme]:') or
                       'changeme')
    else:
        login = '******'
        password = '******'
        email = '*****@*****.**'

        piplogin = '******'
        pippassword = '******'

    admin = User(login=unicode(login),
                 password=unicode(password),
                 email=unicode(email))
    admin.groups.append(admin_group)
    session.add(admin)
    pip = User(login=unicode(piplogin),
               password=unicode(pippassword),
               )
    pip.groups.append(pip_group)
    session.add(pip)

    session.commit()
예제 #4
0
def main(argv=sys.argv):

    session = DBSession()
    session.execute("""
    CREATE TABLE release_file_new (
            id INTEGER NOT NULL,
            created_at DATETIME,
            release_id INTEGER NOT NULL,
            filename VARCHAR(200) NOT NULL,
            md5_digest VARCHAR(50),
            size INTEGER,
            package_type VARCHAR(13) NOT NULL,
            python_version VARCHAR(25),
            url VARCHAR(1024),
            downloads INTEGER,
            has_sig BOOLEAN,
            comment_text TEXT,
            PRIMARY KEY (id),
            FOREIGN KEY(release_id) REFERENCES release (id),
            UNIQUE (filename),
            CHECK (package_type IN ('sdist', 'bdist_egg', 'bdist_msi',
                                    'bdist_dmg', 'bdist_rpm', 'bdist_dumb',
                                    'bdist_wininst', 'bdist_wheel'))
            CHECK (has_sig IN (0, 1))
    );
    """)
    session.execute("""
    INSERT INTO release_file_new (
            id, created_at, release_id, filename,
            md5_digest, size, package_type, python_version,
            url, downloads, has_sig, comment_text)
    SELECT  id, created_at, release_id, filename,
            md5_digest, size, package_type, python_version,
            url, downloads, has_sig, comment_text
    FROM release_file;
    """)
    session.execute("""
    DROP TABLE release_file;
    """)
    session.execute("""
    ALTER TABLE release_file_new RENAME TO release_file;
    """)
    session.commit()
예제 #5
0
def setUpModule():

    engine = create_engine(settings)
    populate(engine, interactive=False)


    session = DBSession()
    admin_user = User.by_login(session, u'admin')
    local_user = User(login=u'local_user', password=u'secret', local=True,
                      firstname=u'Local', lastname=u'User')
    local_user.groups.append(Group.by_name(session, u'developer'))
    jdo = User(login=u'johndo', local=False)
    jdoe = User(login=u'janedoe', local=False)

    session.add(jdo)
    session.add(jdoe)
    session.add(local_user)

    classifiers_names = [u'Programming Language :: Python',
                         u'Programming Language :: Python :: 2.6',
                         u'Programming Language :: Python :: 2.7',
                         u'Topic :: Software Development',
                         u'Topic :: System :: Archiving :: Mirroring',
                         u'Topic :: System :: Archiving :: Packaging',
                         u'Intended Audience :: Developers',
                         u'Intended Audience :: System Administrators'
                         ]
    classifiers = [Classifier.by_name(session, name=c,
                                      create_if_not_exists=True)
                   for c in classifiers_names]

    pack1 = Package(name=u'mirrored_package1')
    pack1.owners.append(jdo)
    pack1.owners.append(jdoe)
    pack1.downloads = 7
    session.add(pack1)

    release1 = Release(package=pack1, version=u'0.1',
                       summary=u'Common Usage Library',
                       author=jdoe)
    for c in classifiers[:3]:
        release1.classifiers.append(c)
    session.add(release1)
    release1.files.append(ReleaseFile(filename=u'mirrored_package1-0.1.tar.gz',
                                      package_type=u'sdist'))
    session.add(release1)

    release2 = Release(package=pack1, version=u'0.2',
                       summary=u'Common Usage Library')
    for c in classifiers[:5]:
        release2.classifiers.append(c)
    release2.files.append(ReleaseFile(filename=u'mirrored_package1-0.2.tar.gz',
                                      package_type=u'sdist'))
    release2.files.append(ReleaseFile(filename=u'mirrored_package1-0.2.egg',
                                      package_type=u'bdist_egg'))
    session.add(release2)

    pack2 = Package(name=u'mirrored_package2')
    pack2.owners.append(jdo)
    pack2.maintainers.append(jdoe)
    pack2.downloads = 1
    session.add(pack2)

    release3 = Release(package=pack2, version=u'1.0',
                       summary=u'Web Framework For Everybody')
    for c in classifiers[:3] + classifiers[-2:-2]:
        release3.classifiers.append(c)
    session.add(release3)
    release3.files.append(ReleaseFile(filename=u'mirrored_package2-1.0.tar.gz',
                                      package_type=u'sdist'))
    session.add(release3)

    pack3 = Package(name=u'local_package1', local=True)
    pack3.owners.append(local_user)
    pack3.owners.append(admin_user)
    session.add(pack3)

    release4 = Release(package=pack3, version=u'0.1',
                       summary=u'Pet Shop Application')
    for c in classifiers:
        release4.classifiers.append(c)
    release4.files.append(ReleaseFile(filename=u'local_package1-0.1.tar.gz',
                                      package_type=u'sdist'))
    session.add(release4)

    session.commit()
예제 #6
0
def setUpModule():

    engine = create_engine(settings)
    populate(engine, interactive=False)

    session = DBSession()
    admin_user = User.by_login(session, u'admin')
    local_user = User(login=u'local_user',
                      password=u'secret',
                      local=True,
                      firstname=u'Local',
                      lastname=u'User')
    local_user.groups.append(Group.by_name(session, u'developer'))
    jdo = User(login=u'johndo', local=False)
    jdoe = User(login=u'janedoe', local=False)

    session.add(jdo)
    session.add(jdoe)
    session.add(local_user)

    classifiers_names = [
        u'Programming Language :: Python',
        u'Programming Language :: Python :: 2.6',
        u'Programming Language :: Python :: 2.7',
        u'Topic :: Software Development',
        u'Topic :: System :: Archiving :: Mirroring',
        u'Topic :: System :: Archiving :: Packaging',
        u'Intended Audience :: Developers',
        u'Intended Audience :: System Administrators'
    ]
    classifiers = [
        Classifier.by_name(session, name=c, create_if_not_exists=True)
        for c in classifiers_names
    ]

    pack1 = Package(name=u'mirrored_package1')
    pack1.owners.append(jdo)
    pack1.owners.append(jdoe)
    pack1.downloads = 7
    session.add(pack1)

    release1 = Release(package=pack1,
                       version=u'0.1',
                       summary=u'Common Usage Library',
                       author=jdoe)
    for c in classifiers[:3]:
        release1.classifiers.append(c)
    session.add(release1)
    release1.files.append(
        ReleaseFile(filename=u'mirrored_package1-0.1.tar.gz',
                    package_type=u'sdist'))
    session.add(release1)

    release2 = Release(package=pack1,
                       version=u'0.2',
                       summary=u'Common Usage Library')
    for c in classifiers[:5]:
        release2.classifiers.append(c)
    release2.files.append(
        ReleaseFile(filename=u'mirrored_package1-0.2.tar.gz',
                    package_type=u'sdist'))
    release2.files.append(
        ReleaseFile(filename=u'mirrored_package1-0.2.egg',
                    package_type=u'bdist_egg'))
    session.add(release2)

    pack2 = Package(name=u'mirrored_package2')
    pack2.owners.append(jdo)
    pack2.maintainers.append(jdoe)
    pack2.downloads = 1
    session.add(pack2)

    release3 = Release(package=pack2,
                       version=u'1.0',
                       summary=u'Web Framework For Everybody')
    for c in classifiers[:3] + classifiers[-2:-2]:
        release3.classifiers.append(c)
    session.add(release3)
    release3.files.append(
        ReleaseFile(filename=u'mirrored_package2-1.0.tar.gz',
                    package_type=u'sdist'))
    session.add(release3)

    pack3 = Package(name=u'local_package1', local=True)
    pack3.owners.append(local_user)
    pack3.owners.append(admin_user)
    session.add(pack3)

    release4 = Release(package=pack3,
                       version=u'0.1',
                       summary=u'Pet Shop Application')
    for c in classifiers:
        release4.classifiers.append(c)
    release4.files.append(
        ReleaseFile(filename=u'local_package1-0.1.tar.gz',
                    package_type=u'sdist'))
    session.add(release4)

    session.commit()
예제 #7
0
파일: __init__.py 프로젝트: rtveitch/pyshop
def setUpModule():

    engine = create_engine(settings)
    populate(engine, interactive=False)

    session = DBSession()
    admin_user = User.by_login(session, u"admin")
    local_user = User(login=u"local_user", password=u"secret", local=True, firstname=u"Local", lastname=u"User")
    local_user.groups.append(Group.by_name(session, u"developer"))
    jdo = User(login=u"johndo", local=False)
    jdoe = User(login=u"janedoe", local=False)

    session.add(jdo)
    session.add(jdoe)
    session.add(local_user)

    classifiers_names = [
        u"Programming Language :: Python",
        u"Programming Language :: Python :: 2.6",
        u"Programming Language :: Python :: 2.7",
        u"Topic :: Software Development",
        u"Topic :: System :: Archiving :: Mirroring",
        u"Topic :: System :: Archiving :: Packaging",
        u"Intended Audience :: Developers",
        u"Intended Audience :: System Administrators",
    ]
    classifiers = [Classifier.by_name(session, name=c) for c in classifiers_names]

    pack1 = Package(name=u"mirrored_package1")
    pack1.owners.append(jdo)
    pack1.owners.append(jdoe)
    pack1.downloads = 7
    session.add(pack1)

    release1 = Release(package=pack1, version=u"0.1", summary=u"Common Usage Library", author=jdoe)
    for c in classifiers[:3]:
        release1.classifiers.append(c)
    session.add(release1)
    release1.files.append(ReleaseFile(filename=u"mirrored_package1-0.1.tar.gz", package_type=u"sdist"))
    session.add(release1)

    release2 = Release(package=pack1, version=u"0.2", summary=u"Common Usage Library")
    for c in classifiers[:5]:
        release2.classifiers.append(c)
    release2.files.append(ReleaseFile(filename=u"mirrored_package1-0.2.tar.gz", package_type=u"sdist"))
    release2.files.append(ReleaseFile(filename=u"mirrored_package1-0.2.egg", package_type=u"bdist_egg"))
    session.add(release2)

    pack2 = Package(name=u"mirrored_package2")
    pack2.owners.append(jdo)
    pack2.maintainers.append(jdoe)
    pack2.downloads = 1
    session.add(pack2)

    release3 = Release(package=pack2, version=u"1.0", summary=u"Web Framework For Everybody")
    for c in classifiers[:3] + classifiers[-2:-2]:
        release3.classifiers.append(c)
    session.add(release3)
    release3.files.append(ReleaseFile(filename=u"mirrored_package2-1.0.tar.gz", package_type=u"sdist"))
    session.add(release3)

    pack3 = Package(name=u"local_package1", local=True)
    pack3.owners.append(local_user)
    pack3.owners.append(admin_user)
    session.add(pack3)

    release4 = Release(package=pack3, version=u"0.1", summary=u"Pet Shop Application")
    for c in classifiers:
        release4.classifiers.append(c)
    release4.files.append(ReleaseFile(filename=u"local_package1-0.1.tar.gz", package_type=u"sdist"))
    session.add(release4)

    session.commit()