Exemplo n.º 1
0
def files_build(name, id, path = ""):
    project = models.Project.get(name = name)
    build = models.Build.get(project = name, id = id)

    file_path = build.get_file_path(path)
    is_directory = os.path.isdir(file_path)
    if not is_directory: return flask.send_file(file_path)

    if path and not path.endswith("/"):
        return flask.redirect(
            flask.url_for(
                "files_build", name = name, id = id, path = path + "/"
            )
        )

    files = build.get_files(path)
    return flask.render_template(
        "build_files.html.tpl",
        link = "projects",
        sub_link = "files",
        project = project,
        build = build,
        path = path,
        files = files
    )
Exemplo n.º 2
0
def run_project(name):
    # retrieves the "custom" run function to be used
    # as the work "callable", note that the schedule flag
    # is not set meaning that no schedule will be done
    # after the execution
    project = models.Project.get(name=name)
    _run = project.get_run(schedule=False)

    # inserts a new work task into the execution thread
    # for the current time, this way this task is going
    # to be executed immediately
    current_time = time.time()
    quorum.insert_work(current_time, _run)

    return flask.redirect(flask.url_for("show_project", name=name))
Exemplo n.º 3
0
def run_project(name):
    # retrieves the "custom" run function to be used
    # as the work "callable", note that the schedule flag
    # is not set meaning that no schedule will be done
    # after the execution
    project = models.Project.get(name = name)
    _run = project.get_run(schedule = False)

    # inserts a new work task into the execution thread
    # for the current time, this way this task is going
    # to be executed immediately
    current_time = time.time()
    quorum.insert_work(current_time, _run)

    return flask.redirect(
        flask.url_for("show_project", name = name)
    )
Exemplo n.º 4
0
def files_build(name, id, path=""):
    project = models.Project.get(name=name)
    build = models.Build.get(project=name, id=id)

    file_path = build.get_file_path(path)
    is_directory = os.path.isdir(file_path)
    if not is_directory: return flask.send_file(file_path)

    if path and not path.endswith("/"):
        return flask.redirect(
            flask.url_for("files_build", name=name, id=id, path=path + "/"))

    files = build.get_files(path)
    return flask.render_template("build_files.html.tpl",
                                 link="projects",
                                 sub_link="files",
                                 project=project,
                                 build=build,
                                 path=path,
                                 files=files)
Exemplo n.º 5
0
def delete_project(name):
    project = models.Project.get(name = name)
    project.delete()
    return flask.redirect(
        flask.url_for("list_projects")
    )
Exemplo n.º 6
0
def create_project():
    # creates the new project, using the provided arguments and
    # then saves it into the data source, all the validations
    # should be ran upon the save operation
    project = models.Project
    try: project.save()
    except quorum.ValidationError, error:
        return flask.render_template(
            "project_new.html.tpl",
            link = "new project",
            project = error.model,
            errors = error.errors
        )

    return flask.redirect(
        flask.url_for("show_project", name = project.name)
    )

@app.route("/projects/<name>", methods = ("GET",))
def show_project(name):
    project = models.Project.get(name = name)
    return flask.render_template(
        "project_show.html.tpl",
        link = "projects",
        sub_link = "info",
        project = project
    )

@app.route("/projects/<name>/edit", methods = ("GET",))
def edit_project(name):
    project = models.Project.get(name = name)
Exemplo n.º 7
0
def delete_build(name, id):
    build = models.Build.get(project=name, id=id)
    build.delete()
    return flask.redirect(flask.url_for("list_builds", name=name))
Exemplo n.º 8
0
def delete_project(name):
    project = models.Project.get(name=name)
    project.delete()
    return flask.redirect(flask.url_for("list_projects"))
Exemplo n.º 9
0
@app.route("/projects", methods=("POST", ))
def create_project():
    # creates the new project, using the provided arguments and
    # then saves it into the data source, all the validations
    # should be ran upon the save operation
    project = models.Project.new()
    try:
        project.save()
    except quorum.ValidationError, error:
        return flask.render_template("project_new.html.tpl",
                                     link="new project",
                                     project=error.model,
                                     errors=error.errors)

    return flask.redirect(flask.url_for("show_project", name=project.name))


@app.route("/projects/<name>", methods=("GET", ))
def show_project(name):
    project = models.Project.get(name=name)
    return flask.render_template("project_show.html.tpl",
                                 link="projects",
                                 sub_link="info",
                                 project=project)


@app.route("/projects/<name>/edit", methods=("GET", ))
def edit_project(name):
    project = models.Project.get(name=name)
    return flask.render_template("project_edit.html.tpl",
Exemplo n.º 10
0
def delete_build(name, id):
    build = models.Build.get(project = name, id = id)
    build.delete()
    return flask.redirect(
        flask.url_for("list_builds", name = name)
    )