Esempio n. 1
0
def health_check(args):
    to_remove = []
    data = get_user_config_repo_data()
    if not data:
        return
    for uuid, path in data.get('repos', {}).items():
        if not os.path.isdir(path):
            print('Removing repository {uuid} => {path}'.format(uuid=uuid,
                                                                path=path))
            to_remove.append(uuid)
    for uuid in to_remove:
        data.get('repos', {}).pop(uuid, None)
    with open(get_user_config_repos(), 'w') as f:
        json.dump(data, f)
Esempio n. 2
0
def register_path(path):
    """
    Calling this function will register a path to be a well
    :param path: Path to the repository repository
    :return:
    """
    path = os.path.abspath(os.path.realpath(path))
    data = {}
    repos = get_user_config_repos()
    if os.path.isfile(repos):
        with open(repos) as f:
            data = json.load(f)
    data.setdefault('repos', {}).update({get_repository_id(path): path})
    with open(repos, 'w') as f:
        json.dump(data, f)