예제 #1
0
def main(args):
    aserver_api = get_server_api(args.token, args.site)
    username, notebook = parse(args.handle)
    username = username or aserver_api.user()['login']
    downloader = Downloader(aserver_api, username, notebook)
    packages_types = args.package_type or list(PACKAGE_TYPES.keys())

    # Check valid package type
    for ty in packages_types:
        if ty not in list(PACKAGE_TYPES.keys()):
            raise Exception("Invalid package type '{}'".format(ty))

    try:
        download_files = downloader.list_download_files(packages_types,
                                                        output=args.output,
                                                        force=args.force)
        for download_file, download_dist in download_files.items():
            downloader.download(download_dist)
            logger.info("{} has been downloaded as {}".format(
                args.handle, download_file))
            if has_environment(download_file):
                logger.info(
                    "{} has an environment embedded.".format(download_file))
                logger.info("Run:")
                logger.info("    conda env create {}".format(download_file))
                logger.info("To install the environment in your system")
    except (errors.DestionationPathExists, errors.NotFound,
            errors.BinstarError, OSError) as err:
        logger.info(err)
예제 #2
0
def main(args):
    aserver_api = get_server_api(args.token, args.site)
    username, notebook = parse(args.handle)
    username = username or aserver_api.user()['login']
    downloader = Downloader(aserver_api, username, notebook)
    packages_types = args.package_type or list(PACKAGE_TYPES.keys())

    # Check valid package type
    for ty in packages_types:
        if ty not in list(PACKAGE_TYPES.keys()):
            raise Exception("Invalid package type '{}'".format(ty))

    try:
        download_files = downloader.list_download_files(packages_types, output=args.output, force=args.force)
        for download_file, download_dist in download_files.items():
            downloader.download(download_dist)
            logger.info("{} has been downloaded as {}".format(args.handle, download_file))
            if has_environment(download_file):
                logger.info("{} has an environment embedded.".format(download_file))
                logger.info("Run:")
                logger.info("    conda env create {}".format(download_file))
                logger.info("To install the environment in your system")
    except (errors.DestionationPathExists, errors.NotFound, errors.BinstarError, OSError) as err:
        logger.info(err)