Esempio n. 1
0
    def setUp(self):
        global ctx
        ctx = server.app.test_request_context()
        ctx.push()
        self.build = models.Build(name='My build')
        db.session.add(self.build)
        db.session.commit()

        self.release = models.Release(name='My release',
                                      number=1,
                                      status=models.Release.PROCESSING,
                                      build_id=self.build.id)
        db.session.add(self.release)
        db.session.commit()
Esempio n. 2
0
def _create_build(build_name):

    build = models.Build(name=build_name)
    build.public = True

    db.session.add(build)
    db.session.flush()

    auth.save_admin_log(build, created_build=True, message=build.name)

    db.session.commit()

    logging.info('Created build via UI: build_id=%r, name=%r',
                 build.id, build.name)

    return db.session.query(models.Build).filter(models.Build.name == build_name).first()
Esempio n. 3
0
def new_build():
    """Page for crediting or editing a build."""
    form = forms.BuildForm()
    if form.validate_on_submit():
        build = models.Build()
        form.populate_obj(build)
        build.owners.append(current_user)

        db.session.add(build)
        db.session.flush()

        auth.save_admin_log(build, created_build=True, message=build.name)

        db.session.commit()

        operations.UserOps(current_user.get_id()).evict()

        logging.info('Created build via UI: build_id=%r, name=%r', build.id,
                     build.name)
        return redirect(url_for('view_build', id=build.id))

    return render_template('new_build.html', build_form=form)
Esempio n. 4
0
os.environ['SQLITE_PRODUCTION'] = 'Yes'

from dpxdt.server import db
from dpxdt.server import models
from dpxdt.server import utils

parser = argparse.ArgumentParser(description="Configure startup behaviour")
parser.add_argument('-d','--dbexists', help='does db exist already',required=False)
args = parser.parse_args()
print "Argument --dbexists=%s" % args.dbexists

#See if we need to initialize the database
if args.dbexists == "false" or args.dbexists == None:
    db.create_all()

    build = models.Build(name='Primary build')
    db.session.add(build)
    db.session.commit()

    api_key = models.ApiKey(
        id=utils.human_uuid(),
        secret=utils.password_uuid(),
        purpose='Local workers',
        superuser=True,
        build_id=build.id)
    db.session.add(api_key)
    db.session.commit()

    db.session.flush()

    with open('flags.cfg', 'a') as f:
Esempio n. 5
0
def create_build():
    """Creates a new build and returns its ID."""
    build = models.Build(name='My build')
    db.session.add(build)
    db.session.commit()
    return build.id