Skip to content

Commit

Permalink
Update ipfshttpclient dependency to ipfshttpclient4ipwb
Browse files Browse the repository at this point in the history
  • Loading branch information
machawk1 committed Jun 18, 2020
1 parent 3222d14 commit d9c08e7
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions ipwb/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Optional
from urllib.parse import urlparse

import ipfshttpclient
import ipfshttpclient4ipwb
import requests

from ipwb import util
Expand Down Expand Up @@ -35,10 +35,10 @@ def fetch_ipfs_index(path: str) -> Optional[str]:
return None

try:
with ipfshttpclient.connect(util.IPFSAPI_MUTLIADDRESS) as client:
with ipfshttpclient4ipwb.connect(util.IPFSAPI_MUTLIADDRESS) as client:
return client.cat(path).decode('utf-8')

except ipfshttpclient.exceptions.StatusError as err:
except ipfshttpclient4ipwb.exceptions.StatusError as err:
raise BackendError(backend_name='ipfs') from err


Expand Down
4 changes: 2 additions & 2 deletions ipwb/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import sys
import os
import json
import ipfshttpclient as ipfsapi
import ipfshttpclient4ipwb as ipfsapi
import argparse
import zlib
import surt
Expand All @@ -27,7 +27,7 @@
from warcio.recordloader import ArchiveLoadFailed

from requests.packages.urllib3.exceptions import NewConnectionError
from ipfshttpclient.exceptions import ConnectionError
from ipfshttpclient4ipwb.exceptions import ConnectionError
# from requests.exceptions import ConnectionError

from six.moves import input
Expand Down
2 changes: 1 addition & 1 deletion ipwb/replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from __future__ import print_function
import sys
import os
import ipfshttpclient as ipfsapi
import ipfshttpclient4ipwb as ipfsapi
import json
import subprocess
import pkg_resources
Expand Down
6 changes: 3 additions & 3 deletions ipwb/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
import sys
import requests
import ipfshttpclient as ipfsapi
import ipfshttpclient4ipwb as ipfsapi

import re
# Datetime conversion to rfc1123
Expand All @@ -22,8 +22,8 @@
from pkg_resources import parse_version

# from requests.exceptions import ConnectionError
from ipfshttpclient.exceptions import ConnectionError
from ipfshttpclient.exceptions import AddressError
from ipfshttpclient4ipwb.exceptions import ConnectionError
from ipfshttpclient4ipwb.exceptions import AddressError
from multiaddr.exceptions import StringParseError

IPFSAPI_MUTLIADDRESS = '/dns/localhost/tcp/5001/http'
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warcio>=1.5.3
git+git://github.com/ipfs-shipyard/py-ipfs-http-client@master#egg=ipfshttpclient
ipfshttpclient4ipwb
Flask==1.1.1
pycryptodome>=3.4.11
requests>=2.19.1
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
],
install_requires=[
'warcio>=1.5.3',
'ipfshttpclient @ git+https://github.com/ipfs-shipyard/py-ipfs-http-client@master', # noqa: E501
'ipfshttpclient4ipwb',
'Flask==1.1.1',
'pycryptodome>=3.4.11',
'requests>=2.19.1',
Expand Down
8 changes: 4 additions & 4 deletions tests/test_backends.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from unittest import mock

import pytest
from ipfshttpclient.exceptions import StatusError
from ipfshttpclient4ipwb.exceptions import StatusError

from ipwb.backends import get_web_archive_index, BackendError
from pathlib import Path
Expand Down Expand Up @@ -32,7 +32,7 @@ def test_ipfs_success():
connect_to_ipfs = mock.MagicMock()
connect_to_ipfs.return_value.cat.return_value = expected_content

with mock.patch('ipfshttpclient.connect', connect_to_ipfs):
with mock.patch('ipfshttpclient4ipwb.connect', connect_to_ipfs):
assert get_web_archive_index(
'QmReQCtRpmEhdWZVLhoE3e8bqreD8G3avGpVfcLD7r4K6W'
).startswith('!context ["http://tools.ietf.org/html/rfc7089"]')
Expand All @@ -41,7 +41,7 @@ def test_ipfs_success():
def test_ipfs_failure():
with pytest.raises(BackendError) as err_info:
with mock.patch(
'ipfshttpclient.client.Client.cat',
'ipfshttpclient4ipwb.client.Client.cat',
side_effect=StatusError(original='')
):
get_web_archive_index(
Expand All @@ -60,7 +60,7 @@ def test_ipfs_url_success():
connect_to_ipfs = mock.MagicMock()
connect_to_ipfs.return_value.cat.return_value = expected_content

with mock.patch('ipfshttpclient.connect', connect_to_ipfs):
with mock.patch('ipfshttpclient4ipwb.connect', connect_to_ipfs):
assert get_web_archive_index(
'ipfs://QmReQCtRpmEhdWZVLhoE3e8bqreD8G3avGpVfcLD7r4K6W'
).startswith('!context ["http://tools.ietf.org/html/rfc7089"]')

0 comments on commit d9c08e7

Please sign in to comment.