Exemplo n.º 1
0
def halt_kilnserver():
    if not current_user.is_admin:
        flash(
            "%s is not authorised to use this command.  This is a serious infraction and will be reported"
        ) % current_user.name
        return redirect(url_for(show_jobs))
    kc = kiln_command.KilnCommand()
    state = kc.halt()
    return state
Exemplo n.º 2
0
def start_job(job_id):
    job = model.Job.query.filter_by(id=job_id).first()
    if not job.user_id == current_user.id:
        flash("Accessing someone else's job is strictly not allowed.")
        flash("This infraction has been logged.")
        return redirect(url_for('show_jobs'))
    started = False
    if request.method == 'POST':
        kc = kiln_command.KilnCommand()
        kc.start(job_id)
        flash("Job %s started." % job.name)
        started = True
    return render_template('start_job.html', job=job, started=started)
Exemplo n.º 3
0
def remove_job_step(job_id):
    kc = kiln_command.KilnCommand()
    run_state, running_job_id = kc.status()
    job = model.Job.query.filter_by(id=job_id).first()
    if not job.user_id == current_user.id:
        flash("Accessing someone else's job is strictly not allowed.")
        flash("This infraction has been logged.")
        return redirect(url_for('show_jobs'))
    job_steps = model.JobStep.query.filter_by(job_id=job_id).all()
    return render_template('show_job_steps.html',
                           job=job,
                           job_steps=job_steps,
                           run_state=run_state)
Exemplo n.º 4
0
def show_jobs():
    form = NewJobForm()
    if not current_user.is_auth and not current_user.is_admin:
        flash('You must be authorized by an administrator to use the kiln')
        logout_user()
        return redirect(url_for('login'))
    if form.validate_on_submit():
        name = form.name.data
        comment = form.comment.data
        job = Job(name=name,
                  comment=comment,
                  user_id=current_user.id,
                  created=datetime.now(),
                  modified=datetime.now())
        app.db.session.add(job)
        app.db.session.commit()
        flash("added job %r" % (name))
    kc = kiln_command.KilnCommand()
    run_state, running_job_id = kc.status()
    running_job_info = None
    running_job_id = None
    running_job_user = None
    if running_job_id is not None:
        running_job_info = model.Job.query.filter_by(id=running_job_id).first()
        if running_job_info is not None:
            running_job_user_id = running_job_info.user_id
            running_job_user = model.User.query.filter_by(
                id=running_job_user_id).first()
    jobs = model.Job.query.filter_by(user_id=current_user.id)
    form.name.data = ""
    form.comment.data = ""
    return render_template('show_jobs.html',
                           jobs=jobs,
                           run_state=run_state,
                           running_job_id=running_job_id,
                           running_job=running_job_info,
                           running_job_user=running_job_user,
                           form=form)
Exemplo n.º 5
0
def stop_job():
    kc = kiln_command.KilnCommand()
    kc.stop()
    flash("Job stopped.")
    return redirect(url_for('show_jobs'))
Exemplo n.º 6
0
def resume_job():
    kc = kiln_command.KilnCommand()
    kc.resume()
    flash("Job resumed.")
    return redirect(url_for('show_jobs'))
Exemplo n.º 7
0
def pause_job():
    kc = kiln_command.KilnCommand()
    kc.pause()
    flash("Job paused.")
    return redirect(url_for('show_jobs'))