예제 #1
0
def home_page():
    form = UsernameForm()

    if directory.has_error_changing_dir:
        flash(f'You are only allowed to change into folders', 'danger')
        directory.has_error_changing_dir = False

    if github_handler.has_executed_command == 'git-pull':
        if github_handler.folder_size['difference'] > 0:
            flash(
                f'Pull Succesful! Elements of {format_size(github_handler.folder_size["difference"])}'
                +
                'was added to the local repository which is now a total of ' +
                '{format_size(github_handler.folder_size["end_size"])}',
                'success')

        elif github_handler.folder_size['difference'] < 0:
            flash(
                f'Pull Succesful! Elements of {format_size(github_handler.folder_size["difference"]*-1)} was removed from the local repository which is now a total of {format_size(github_handler.folder_size["end_size"])}',
                'success')

        else:
            flash(f'Already up to date', 'info')

    elif github_handler.has_executed_command == 'git-add-commit':
        if github_handler.response_message_from_command:
            flash(f'{github_handler.response_message_from_command}', 'success')
        else:
            flash(f'Nothing to commit', 'warning')

    elif github_handler.has_executed_command == 'git-push':
        if 'Everything up-to-date' in github_handler.response_message_from_command:
            flash(
                f'{github_handler.response_message_from_command}. Try adding and commiting first',
                'info')

        elif '.git' in github_handler.response_message_from_command.split(
                '\n')[0][-4:]:
            flash(
                f'Pushed \'{os.getcwd().split("/")[-1]}\' To GitHub In {github_handler.time_spend} seconds',
                'success')

        else:

            print(f'----\n {github_handler.response_message_from_command}')
            github_handler.response_message_from_command.split('\n')[0][-4:]
            flash(f'Maybe a merge confilt', 'danger')

    elif github_handler.has_executed_command == 'git-fetch':
        flash(f'Fetch Succesful', 'success')

    github_handler.has_executed_command = False

    table = DirectoryTable(directory.content)

    return render_template('home.html',
                           title='Home',
                           form=form,
                           table=table,
                           directory=directory)
예제 #2
0
def repository_page(id):
    form = UsernameForm()

    if directory.has_error_changing_dir:
        flash(f'You are only allowed to change into folders', 'danger')
        directory.has_error_changing_dir = False

    if github_handler.has_executed_command:
        flash(
            f'Succesfully cloned {repository.name} of {(format_size(github_handler.folder_size))} in {github_handler.time_spend} seconds',
            'success')
        github_handler.has_executed_command = False

    # sets the repository to be the one we want to clone
    repository.id, repository.name, repository.created_at, repository.updated_at, repository.language, repository.clone_url = github_account.find_repo_with_gen(
        id)

    table = DirectoryTableForClone(directory.content)

    return render_template('repository.html',
                           title=f'Clone \'{repository.name}\' to Folder...',
                           form=form,
                           repo=repository,
                           table=table,
                           directory=directory)
예제 #3
0
def change_logo_page(changed=None):
    form = UsernameForm()

    logo_urls = download_github_logos(directory.base_dir_path)

    if changed:
        flash('Succesfully changed the logo. Hit refresh to see it', 'success')

    # generator
    url_for_path_to_downloaded_logos = (url_for('static',
                                                filename=f'logo_{i}.png')
                                        for i in range(len(logo_urls)))

    # list comp
    url_for_button_to_change_logo = [
        url_for('change_logo_command_page', filename=f'logo_{i}.png')
        for i in range(len(logo_urls))
    ]

    return render_template(
        'change_logo.html',
        title='Change Logo',
        form=form,
        enumerate=enumerate,
        url_for_path_to_downloaded_logos=url_for_path_to_downloaded_logos,
        url_for_button_to_change_logo=url_for_button_to_change_logo)
예제 #4
0
def result_page():
    form = UsernameForm()

    # sets the account name to the name of the user
    github_account.username = request.args.get('username')

    github_account.fetch_repositories()
    table = ResultTable(github_account.repositories)

    if len(github_account) > 0:
        flash(
            f'Found {len(github_account)} of {github_account.username}\'s repositories',
            'success')

    return render_template('result.html',
                           title='Results',
                           form=form,
                           table=table)