Exemple #1
0
def create_project():
    """
    Setup a new project directory and add it to the projects overview config file.
    The given project name will be used for constructing the directory in the given path.
    """
    data = request.form
    project_name = data['projectName']
    path = data['path']

    path = os.path.join(path, project_utils.get_folder_name_for_project(project_name))
    os.mkdir(path)

    # Setup new project
    project_utils.setup_new_project(project_name, path)

    return redirect(url_for('project_details', project=project_name))
Exemple #2
0
def update_project():
    """
    Update an existing project entry with a new path. If a config file exists in there, it will be
    used, otherwise a new one will be created.
    The project will keep the given project name.
    """
    data = request.form
    project_name = data['projectName']
    path = data['path']

    # Check for existing config file (might be None)
    config = project_utils.load_project_config(path)

    # Make sure the directory is correctly set up
    project_utils.setup_new_project(project_name, path, config)

    return redirect(url_for('project_details', project=project_name))
Exemple #3
0
def import_project():
    """
    Import an existing project from the given path. If a config file exists in there, it will be
    used while also making sure that the project name is still unique. Otherwise, a new config
    will be created and a unique project name will be constructed from the directory name.
    """
    data = request.form
    path = data['path']

    # Check for existing config file and make sure project name is unique
    config = project_utils.load_project_config(path)
    if config:
        project_name = project_utils.get_unique_project_name(config['name'])
    else:
        # Use folder name as project name and make sure it is unique
        project_name = project_utils.get_unique_project_name(os.path.basename(path))

    # Make sure the directory is correctly set up
    project_utils.setup_new_project(project_name, path, config)

    return redirect(url_for('project_details', project=project_name))