コード例 #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
ファイル: download.py プロジェクト: jakirkham/anaconda-client
def main(args):
    binstar = get_binstar(args)
    username, notebook = parse(args.handle)
    username = username or binstar.user()['login']
    downloader = Downloader(binstar, username, notebook)
    try:
        download_info = downloader(output=args.output, force=args.force)
        log.info("{} has been downloaded as {}.".format(args.handle, download_info[0]))
        if has_environment(download_info[0]):
            log.info("{} has an environment embedded.".format(download_info[0]))
            log.info("Run:")
            log.info("    conda env create {}".format(download_info[0]))
            log.info("To install the environment in your system")
    except (errors.DestionationPathExists, errors.NotFound, errors.BinstarError, OSError) as err:
        log.info(err.msg)
コード例 #3
0
ファイル: download.py プロジェクト: menghaozhu/hat
def main(args):
    aserver_api = get_binstar(args)
    username, notebook = parse(args.handle)
    username = username or aserver_api.user()['login']
    downloader = Downloader(aserver_api, username, notebook)
    try:
        download_info = downloader(output=args.output, force=args.force)
        log.info("{} has been downloaded as {}.".format(args.handle, download_info[0]))
        if has_environment(download_info[0]):
            log.info("{} has an environment embedded.".format(download_info[0]))
            log.info("Run:")
            log.info("    conda env create {}".format(download_info[0]))
            log.info("To install the environment in your system")
    except (errors.DestionationPathExists, errors.NotFound, errors.BinstarError, OSError) as err:
        log.info(err.msg)
コード例 #4
0
def download(args):
    aserver_api = get_server_api(args.token, args.site, args.log_level)

    username, notebook = parse(args.handle)
    username = username or aserver_api.user()['login']
    downloader = Downloader(aserver_api, username, notebook)
    try:
        download_info = downloader(output=args.output, force=args.force)
        log.info("{} has been downloaded as {}.".format(args.handle, download_info[0]))
        if has_environment(download_info[0]):
            log.info("{} has an environment embedded.".format(download_info[0]))
            log.info("Run:")
            log.info("    conda env create {}".format(download_info[0]))
            log.info("To install the environment in your system")
    except (errors.DestionationPathExists, errors.NotFound, OSError) as err:
        log.info(err.msg)
コード例 #5
0
ファイル: notebook.py プロジェクト: wodole/anaconda-client
def download(args):
    aserver_api = get_server_api(args.token, args.site, args.log_level)

    username, notebook = parse(args.handle)
    username = username or aserver_api.user()['login']
    downloader = Downloader(aserver_api, username, notebook)
    try:
        download_info = downloader(output=args.output, force=args.force)
        log.warn("`anaconda notebook` is going to be deprecated")
        log.warn("use `anaconda download` instead.")
        log.info("{} has been downloaded as {}.".format(
            args.handle, download_info[0]))
        if has_environment(download_info[0]):
            log.info("{} has an environment embedded.".format(
                download_info[0]))
            log.info("Run:")
            log.info("    conda env create {}".format(download_info[0]))
            log.info("To install the environment in your system")
    except (errors.DestionationPathExists, errors.NotFound, OSError) as err:
        log.info(err.msg)
コード例 #6
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)
コード例 #7
0
 def test_no_file(self):
     self.assertFalse(has_environment("no-file"))
コード例 #8
0
 def test_has_environment(self):
     assert has_environment(self.data_dir('notebook_with_env.ipynb'))
コード例 #9
0
 def test_has_no_environment(self):
     self.assertEqual(False, has_environment(self.data_dir('notebook.ipynb')))
コード例 #10
0
 def test_no_file(self):
     with self.assertRaises(BinstarError):
         has_environment("no-file")
コード例 #11
0
 def test_has_environment(self):
     self.assertTrue(has_environment(data_dir('notebook_with_env.ipynb')))
コード例 #12
0
 def test_has_no_environment(self):
     self.assertFalse(has_environment(data_dir('notebook.ipynb')))
コード例 #13
0
 def test_no_file(self):
     with self.assertRaises(BinstarError):
         has_environment("no-file")
コード例 #14
0
 def test_has_environment(self):
     assert has_environment(self.data_dir('notebook_with_env.ipynb'))
コード例 #15
0
 def test_has_no_environment(self):
     self.assertEqual(False, has_environment(self.data_dir('notebook.ipynb')))