Пример #1
0
def remove_index(config, index_name, async_rpc=False):
    from infi.app_repo.indexers import get_indexers
    from infi.app_repo.utils import log_execute_assert_success
    from infi.app_repo.service import get_client
    assert index_name in config.indexes
    config.indexes = [name for name in config.indexes if name != index_name]
    config.to_disk()
    for indexer in get_indexers(config, index_name):
        log_execute_assert_success(["rm", "-rf", indexer.base_directory])
    get_client(config).reload_configuration_from_disk(async_rpc=async_rpc)
Пример #2
0
def add_index(config, index_name, async_rpc=False):
    from infi.app_repo.indexers import get_indexers
    from infi.app_repo.install import ensure_directory_exists, path
    from infi.app_repo.service import get_client
    assert index_name not in config.indexes
    for indexer in get_indexers(config, index_name):
        indexer.initialise()
    ensure_directory_exists(path.join(config.incoming_directory, index_name))
    ensure_directory_exists(path.join(config.rejected_directory, index_name))
    config.indexes.append(index_name)
    config.to_disk()
    get_client(config).reload_configuration_from_disk(async_rpc=async_rpc)
Пример #3
0
def delete_packages(config, should_delete, index, index_type, dry_run, quiet):
    from infi.logging.wrappers import script_logging_context
    from infi.gevent_utils.os import path
    from infi.app_repo.service import get_client
    client = get_client(config)
    show_warning = False
    with script_logging_context(syslog=False, logfile=False, stderr=True):
        artifacts = client.get_artifacts(index, index_type)
    files_to_remove = [
        filepath for filepath in artifacts
        if should_delete(path.basename(filepath))
    ]
    for filepath in files_to_remove:
        filepath_relative = path.relpath(filepath, config.base_directory)
        if dry_run:
            logger.info("[dry-run] deleting {}".format(filepath_relative))
            continue
        if not quiet:
            if not raw_input(
                    'delete {} [y/N]? '.format(filepath_relative)).lower() in (
                        'y', 'yes'):
                continue
        logger.info("deleting {} ".format(filepath_relative))
        show_warning = True
        client.delete_artifact(filepath)
    if show_warning:
        logger.warn(
            "do not forget to rebuild the index(es) after deleting all the packages that you wanted to delete"
        )
Пример #4
0
 def test_reload_configuration_from_disk(self):
     with self.temporary_base_directory_context():
         config = Configuration.from_disk(None)
         config.to_disk()
         with self.rpc_server_context(config):
             client = service.get_client(config)
             client.reload_configuration_from_disk()
             client.reload_configuration_from_disk()
Пример #5
0
def process_rejected_file(config,
                          index,
                          filepath,
                          platform,
                          arch,
                          async_rpc=False):
    from infi.app_repo.service import get_client
    return get_client(config).process_filepath(index,
                                               filepath,
                                               platform,
                                               arch,
                                               async_rpc=async_rpc)
Пример #6
0
def rpc_client(config, method, arguments, style, async_rpc=False):
    from IPython import embed
    from infi.rpc import patched_ipython_getargspec_context
    from infi.app_repo.service import get_client
    from infi.app_repo.utils import pretty_print, jsonify_arguments

    client = get_client(config)
    from os import environ
    if method:
        pretty_print(getattr(client, method)(*jsonify_arguments(*arguments), async_rpc=async_rpc), style)
    else:
        with patched_ipython_getargspec_context(client):
            embed()
Пример #7
0
def rpc_client(config, method, arguments, style, async_rpc=False):
    from IPython import embed
    from infi.rpc import patched_ipython_getargspec_context
    from infi.app_repo.service import get_client
    from infi.app_repo.utils import pretty_print, jsonify_arguments

    client = get_client(config)
    from os import environ
    if method:
        pretty_print(getattr(client, method)(*jsonify_arguments(*arguments), async_rpc=async_rpc), style)
    else:
        with patched_ipython_getargspec_context(client):
            embed()
Пример #8
0
def delete_packages(config, should_delete, index, index_type, dry_run, quiet):
    from infi.logging.wrappers import script_logging_context
    from infi.gevent_utils.os import path
    from infi.app_repo.service import get_client
    client = get_client(config)
    show_warning = False
    with script_logging_context(syslog=False, logfile=False, stderr=True):
        artifacts = client.get_artifacts(index, index_type)
    files_to_remove = [filepath for filepath in artifacts if should_delete(path.basename(filepath))]
    for filepath in files_to_remove:
        filepath_relative = path.relpath(filepath, config.base_directory)
        if dry_run:
            logger.info("[dry-run] deleting {}".format(filepath_relative))
            continue
        if not quiet:
            if not raw_input('delete {} [y/N]? '.format(filepath_relative)).lower() in ('y', 'yes'):
                continue
        logger.info("deleting {} ".format(filepath_relative))
        show_warning = True
        client.delete_artifact(filepath)
    if show_warning:
        logger.warn("do not forget to rebuild the index(es) after deleting all the packages that you wanted to delete")
Пример #9
0
def delete_packages(config, should_delete, index, index_type, dry_run, quiet, no_rebuild, async_rpc=False):
    from infi.gevent_utils.os import path
    from infi.app_repo.service import get_client
    client = get_client(config)
    files_were_deleted = False
    artifacts = client.get_artifacts(index, index_type)
    files_to_remove = [filepath for filepath in artifacts if should_delete(filepath)]
    for filepath in files_to_remove:
        filepath_relative = path.relpath(filepath, config.base_directory)
        if dry_run:
            logger.info("[dry-run] deleting {}".format(filepath_relative))
            continue
        if not quiet:
            if not raw_input('delete {} [y/N]? '.format(filepath_relative)).lower() in ('y', 'yes'):
                continue
        logger.info("deleting {} ".format(filepath_relative))
        files_were_deleted = True
        client.delete_artifact(filepath)
    # not rebuilding index if nothing was deleted
    if files_were_deleted:
        if no_rebuild:
            logger.warn("do not forget to rebuild the index(es) after deleting all the packages that you wanted to delete")
        else:
            rebuild_index(config, index, index_type, async_rpc)
Пример #10
0
def resign_packages(config, async_rpc=False):
    from infi.app_repo.service import get_client
    return get_client(config).resign_packages(async_rpc=async_rpc)
Пример #11
0
def rebuild_index(config, index, index_type, async_rpc=False):
    from infi.app_repo.service import get_client
    return get_client(config).rebuild_index(index, index_type, async_rpc=async_rpc)
Пример #12
0
def process_incoming(config, index, async_rpc=False):
    from infi.app_repo.service import get_client
    return get_client(config).process_incoming(index, async_rpc=async_rpc)
Пример #13
0
def process_rejected_file(config, index, filepath, platform, arch, async_rpc=False):
    from infi.app_repo.service import get_client
    return get_client(config).process_filepath(index, filepath, platform, arch, async_rpc=async_rpc)
Пример #14
0
def rebuild_index(config, index, index_type, async_rpc=False):
    from infi.app_repo.service import get_client
    return get_client(config).rebuild_index(index, index_type, async_rpc=async_rpc)
Пример #15
0
def process_incoming(config, index, async_rpc=False):
    from infi.app_repo.service import get_client
    return get_client(config).process_incoming(index, async_rpc=async_rpc)