Example #1
0
def edit_repository_query(repo_id, json_repository):
    repository = Repository().get_by_id(repo_id)

    if repository_exist(json_repository['name']) and repository.name != json_repository['name']:
        return "-1"

    repository.name = json_repository["name"]
    repository.mirror_url = json_repository["mirror_url"]
    repository.mirror_zpool = json_repository["mirror_zpool"]
    repository.mirror_location = json_repository["mirror_location"]
    repository.mirror_type = json_repository["mirror_type"]
    repository.mirror_args = json_repository["mirror_args"]

    repository.schedule_status = json_repository["schedule_status"]
    repository.schedule_run = json_repository["schedule_run"]
    repository.schedule_number = json_repository["schedule_number"]

    repository.schedule_minute = json_repository["schedule_minute"]
    repository.schedule_hour = json_repository["schedule_hour"]
    repository.schedule_day = json_repository["schedule_day"]
    repository.schedule_month = json_repository["schedule_month"]
    repository.schedule_year = json_repository["schedule_year"]

    repository.updated_at = datetime.datetime.now()
    repository.save()

    task.write_task_status(repo=repository, msg=f"{repository.name} editing")
    return 0
Example #2
0
def set_next_update_date(repo: Repository):
    date = datetime.datetime.now()
    date += relativedelta(
        years=repo.schedule_year,
        months=repo.schedule_month,
        days=repo.schedule_day,
        hours=repo.schedule_hour,
        minutes=repo.schedule_minute
    )
    repo.schedule_next_update = date
    repo.save()
Example #3
0
def save_user_repos(username):
    try:
        user = User.objects.get(user_name=username)
    except User.DoesNotExist:
        user = User(user_name=username)
        user.save()

    repos = get_repos(username)

    for repo in repos:
        try:
            n_repo = Repository.objects.get(github_id=repo['id'])
        except Repository.DoesNotExist:
            n_repo = Repository(github_id=repo['id'], owner=user)
            n_repo.save()
Example #4
0
def deinit_mirror(repo: Repository):
    repo.mirror_init = False
    repo.save()
Example #5
0
def init_mirror(repo: Repository):
    repo.mirror_init = True
    repo.save()