Example #1
0
    def clean(self):
        # Clean dockerfile
        delete_path(self.dockerfile_path)

        # Clean tmp dir if created
        if self.in_tmp_repo and self.copy_code:
            delete_tmp_dir(self.image_tag)
Example #2
0
def external_repo_deleted(sender, **kwargs):
    if kwargs.get('raw'):
        # Ignore signal handling for fixture loading
        return

    instance = kwargs['instance']

    # Clean repo
    delete_path(instance.path)
Example #3
0
def fetch(git_url, repo_path, overwrite=False):
    if os.path.isdir(repo_path):
        logger.info('Current checkout path has content.')
        if overwrite:
            logger.info('Overwriting current checkout path.')
            delete_path(repo_path)
        else:
            run_command(cmd='git fetch origin master', data=None, location=repo_path, chw=True)
            run_command(cmd='git reset --hard FETCH_HEAD', data=None, location=repo_path, chw=True)
            run_command(cmd='git clean -df', data=None, location=repo_path, chw=True)
            return
    return clone_git_repo(repo_path=repo_path, git_url=git_url)
Example #4
0
def handle_new_files(user_id, repo_id, tar_file_name):
    if not tarfile.is_tarfile(tar_file_name):
        raise ValueError('Received wrong file format.')

    User = get_user_model()
    try:
        user = User.objects.get(id=user_id)
    except User.DoesNotExist:
        logger.warning(
            'User with id `{}` does not exist anymore.'.format(user_id))
        return

    try:
        repo = Repo.objects.get(id=repo_id)
        # Checkout to master
        git.checkout_commit(repo.path)
    except User.DoesNotExist:
        logger.warning(
            'Repo with id `{}` does not exist anymore.'.format(repo_id))
        return

    # Destination files
    new_repo_path = repo.get_tmp_tar_path()

    # clean the current path from all files
    path_files = os.listdir(repo.path)
    for member in path_files:
        if member == '.git':
            continue
        member = os.path.join(repo.path, member)
        if os.path.isfile(member):
            os.remove(member)
        else:
            delete_path(member)

    # Move the tar inside the repo path
    shutil.move(tar_file_name, new_repo_path)

    # Untar the file
    with tarfile.open(new_repo_path) as tar:
        tar.extractall(repo.path)

    # Delete the current tar
    os.remove(new_repo_path)

    # Get the git repo
    if not git.get_status(repo.path):
        return

    # commit changes
    git.commit(repo.path, user.email, user.username)
Example #5
0
def delete_experiment_outputs(experiment_group_name):
    path = get_experiment_outputs_path(experiment_group_name)
    delete_path(path)
Example #6
0
def delete_experiment_logs(experiment_group_name):
    path = get_experiment_logs_path(experiment_group_name)
    delete_path(path)
Example #7
0
def delete_project_repos(project_name):
    path = get_project_repos_path(project_name)
    delete_path(path)
Example #8
0
def delete_project_logs(project_name):
    path = get_project_logs_path(project_name)
    delete_path(path)
Example #9
0
def delete_project_outputs(project_name):
    path = get_project_outputs_path(project_name)
    delete_path(path)