示例#1
0
 def test_fetchrepodate_connectionerror(self):
     with env_var('CONDA_REMOTE_CONNECT_TIMEOUT_SECS', 1, conda_tests_ctxt_mgmt_def_pol):
         with env_var('CONDA_REMOTE_READ_TIMEOUT_SECS', 1, conda_tests_ctxt_mgmt_def_pol):
             with env_var('CONDA_REMOTE_MAX_RETRIES', 1, conda_tests_ctxt_mgmt_def_pol):
                 with pytest.raises(CondaHTTPError) as execinfo:
                     url = "http://240.0.0.0/channel/osx-64"
                     msg = "Connection error:"
                     fetch_repodata_remote_request(url, None, None)
                     assert msg in str(execinfo)
示例#2
0
 def test_fetchrepodate_connectionerror(self):
     with env_var('CONDA_REMOTE_CONNECT_TIMEOUT_SECS', 1, reset_context):
         with env_var('CONDA_REMOTE_READ_TIMEOUT_SECS', 1, reset_context):
             with env_var('CONDA_REMOTE_MAX_RETRIES', 1, reset_context):
                 with pytest.raises(CondaHTTPError) as execinfo:
                     url = "http://240.0.0.0/channel/osx-64"
                     msg = "Connection error:"
                     fetch_repodata_remote_request(url, None, None)
                     assert msg in str(execinfo)
示例#3
0
 def test_fetch_repodata_remote_request_invalid_arch(self):
     # see https://github.com/conda/conda/issues/8150
     url = 'file:///fake/fake/fake/linux-64'
     etag = None
     mod_stamp = 'Mon, 28 Jan 2019 01:01:01 GMT'
     result = fetch_repodata_remote_request(url, etag, mod_stamp)
     assert result is None
示例#4
0
 def get_repodata(url):
     if CONDA_MAJOR_MINOR >= (4, 5):
         from conda.core.subdir_data import fetch_repodata_remote_request
         raw_repodata_str = fetch_repodata_remote_request(url, None, None)
     elif CONDA_MAJOR_MINOR >= (4, 4):
         from conda.core.repodata import fetch_repodata_remote_request
         raw_repodata_str = fetch_repodata_remote_request(url, None, None)
     elif CONDA_MAJOR_MINOR >= (4, 3):
         from conda.core.repodata import fetch_repodata_remote_request
         repodata_obj = fetch_repodata_remote_request(None, url, None, None)
         raw_repodata_str = json.dumps(repodata_obj)
     else:
         raise NotImplementedError("unsupported version of conda: %s" %
                                   CONDA_INTERFACE_VERSION)
     full_repodata = json.loads(raw_repodata_str)
     return full_repodata
示例#5
0
 def test_fetch_repodata_remote_request_invalid_arch(self):
     # see https://github.com/conda/conda/issues/8150
     url = 'file:///fake/fake/fake/linux-64'
     etag = None
     mod_stamp = 'Mon, 28 Jan 2019 01:01:01 GMT'
     result = fetch_repodata_remote_request(url, etag, mod_stamp)
     assert result is None
示例#6
0
def save_data_source(url, name):
    raw_repodata_str = fetch_repodata_remote_request(url, None, None)
    json.loads(raw_repodata_str)
    with open(join(DATA_DIR, name + ".json"), 'w') as fh:
        json.dump(json.loads(raw_repodata_str),
                  fh,
                  indent=2,
                  sort_keys=True,
                  separators=(',', ': '))
示例#7
0
    def get_repodata(url):
        if CONDA_MAJOR_MINOR >= (4, 5):
            from conda.core.subdir_data import fetch_repodata_remote_request
            raw_repodata_str = fetch_repodata_remote_request(url, None, None)
        elif CONDA_MAJOR_MINOR >= (4, 4):
            from conda.core.repodata import fetch_repodata_remote_request
            raw_repodata_str = fetch_repodata_remote_request(url, None, None)
        elif CONDA_MAJOR_MINOR >= (4, 3):
            from conda.core.repodata import fetch_repodata_remote_request
            repodata_obj = fetch_repodata_remote_request(None, url, None, None)
            raw_repodata_str = json.dumps(repodata_obj)
        else:
            raise NotImplementedError("unsupported version of conda: %s" % CONDA_INTERFACE_VERSION)

        # noarch-only repos are valid. In this case, the architecture specific channel will return None
        if raw_repodata_str is None:
            full_repodata = None
        else:
            full_repodata = json.loads(raw_repodata_str)

        return full_repodata
示例#8
0
 def write_repodata(cache_dir, url):
     if CONDA_MAJOR_MINOR >= (4, 5):
         from conda.core.subdir_data import fetch_repodata_remote_request
         raw_repodata_str = fetch_repodata_remote_request(url, None, None)
         repodata_filename = _cache_fn_url(url)
         with open(join(cache_dir, repodata_filename), 'w') as fh:
             fh.write(raw_repodata_str)
     elif CONDA_MAJOR_MINOR >= (4, 4):
         from conda.core.repodata import fetch_repodata_remote_request
         raw_repodata_str = fetch_repodata_remote_request(url, None, None)
         repodata_filename = _cache_fn_url(url)
         with open(join(cache_dir, repodata_filename), 'w') as fh:
             fh.write(raw_repodata_str)
     elif CONDA_MAJOR_MINOR >= (4, 3):
         from conda.core.repodata import fetch_repodata_remote_request
         repodata_obj = fetch_repodata_remote_request(None, url, None, None)
         raw_repodata_str = json.dumps(repodata_obj)
         repodata_filename = _cache_fn_url(url)
         with open(join(cache_dir, repodata_filename), 'w') as fh:
             fh.write(raw_repodata_str)
     else:
         raise NotImplementedError("unsupported version of conda: %s" % CONDA_INTERFACE_VERSION)
示例#9
0
 def test_fetch_repodata_remote_request_invalid_noarch(self):
     url = 'file:///fake/fake/fake/noarch'
     etag = None
     mod_stamp = 'Mon, 28 Jan 2019 01:01:01 GMT'
     with pytest.raises(UnavailableInvalidChannel):
         result = fetch_repodata_remote_request(url, etag, mod_stamp)
示例#10
0
 def test_fetch_repodata_remote_request_invalid_noarch(self):
     url = 'file:///fake/fake/fake/noarch'
     etag = None
     mod_stamp = 'Mon, 28 Jan 2019 01:01:01 GMT'
     with pytest.raises(UnavailableInvalidChannel):
         result = fetch_repodata_remote_request(url, etag, mod_stamp)
示例#11
0
def save_data_source(url, name):
    raw_repodata_str = fetch_repodata_remote_request(url, None, None)
    json.loads(raw_repodata_str)
    with open(join(DATA_DIR, name + ".json"), 'w') as fh:
        json.dump(json.loads(raw_repodata_str), fh, indent=2, sort_keys=True, separators=(',', ': '))