How to use the ipfshttpclient.exceptions.VersionMismatch function in ipfshttpclient

To help you get started, we’ve selected a few ipfshttpclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ipfs / py-ipfs-http-client / test / unit / test_client.py View on Github external
def test_assert_version():
	# Minimum required version
	ipfshttpclient.assert_version("0.1.0", "0.1.0", "0.2.0", ["0.1.2"])
	
	# Too high version
	with pytest.raises(ipfshttpclient.exceptions.VersionMismatch):
		ipfshttpclient.assert_version("0.2.0", "0.1.0", "0.2.0", ["0.1.2"])
	
	# Too low version
	with pytest.raises(ipfshttpclient.exceptions.VersionMismatch):
		ipfshttpclient.assert_version("0.0.5", "0.1.0", "0.2.0", ["0.1.2"])
	
	# Blacklisted version
	with pytest.raises(ipfshttpclient.exceptions.VersionMismatch):
		ipfshttpclient.assert_version("0.1.2-1", "0.1.0", "0.2.0", ["0.1.2"])
github ipfs / py-ipfs-http-client / test / unit / test_client.py View on Github external
def test_assert_version():
	# Minimum required version
	ipfshttpclient.assert_version("0.1.0", "0.1.0", "0.2.0", ["0.1.2"])
	
	# Too high version
	with pytest.raises(ipfshttpclient.exceptions.VersionMismatch):
		ipfshttpclient.assert_version("0.2.0", "0.1.0", "0.2.0", ["0.1.2"])
	
	# Too low version
	with pytest.raises(ipfshttpclient.exceptions.VersionMismatch):
		ipfshttpclient.assert_version("0.0.5", "0.1.0", "0.2.0", ["0.1.2"])
	
	# Blacklisted version
	with pytest.raises(ipfshttpclient.exceptions.VersionMismatch):
		ipfshttpclient.assert_version("0.1.2-1", "0.1.0", "0.2.0", ["0.1.2"])
github ipfs / py-ipfs-http-client / test / functional / tests.py View on Github external
def is_available():
    """
    Return whether the IPFS daemon is reachable or not
    """
    global __is_available

    if not isinstance(__is_available, bool):
        try:
            ipfshttpclient.connect()
        except ipfshttpclient.exceptions.Error as error:
            __is_available = False

            # Make sure version incompatiblity is displayed to the user
            if isinstance(error, ipfshttpclient.exceptions.VersionMismatch):
                raise
        else:
            __is_available = True

    return __is_available
github ipfs / py-ipfs-http-client / test / functional / tests.py View on Github external
def test_assert_version(self):
        # Minimum required version
        ipfshttpclient.assert_version("0.1.0", "0.1.0", "0.2.0")

        # Too high version
        with self.assertRaises(ipfshttpclient.exceptions.VersionMismatch):
            ipfshttpclient.assert_version("0.2.0", "0.1.0", "0.2.0")

        # Too low version
        with self.assertRaises(ipfshttpclient.exceptions.VersionMismatch):
            ipfshttpclient.assert_version("0.0.5", "0.1.0", "0.2.0")
github ipfs / py-ipfs-http-client / ipfshttpclient / client / __init__.py View on Github external
Parameters
	----------
	version : str
		The actual version of an IPFS daemon
	minimum : str
		The minimal IPFS daemon version to allowed
	maximum : str
		The maximum IPFS daemon version to allowed
	"""
	# Convert version strings to integer tuples
	version = list(map(int, version.split('-', 1)[0].split('.')))
	minimum = list(map(int, minimum.split('-', 1)[0].split('.')))
	maximum = list(map(int, maximum.split('-', 1)[0].split('.')))

	if minimum > version or version >= maximum:
		raise exceptions.VersionMismatch(version, minimum, maximum)
	
	for blacklisted in blacklist:
		blacklisted = list(map(int, blacklisted.split('-', 1)[0].split('.')))
		if version == blacklisted:
			raise exceptions.VersionMismatch(version, minimum, maximum)
github ipfs / py-ipfs-http-client / ipfshttpclient / client.py View on Github external
Parameters
    ----------
    version : str
        The version of an IPFS daemon.
    minimum : str
        The minimal IPFS version to allow.
    maximum : str
        The maximum IPFS version to allow.
    """
    # Convert version strings to integer tuples
    version = list(map(int, version.split('-', 1)[0].split('.')))
    minimum = list(map(int, minimum.split('-', 1)[0].split('.')))
    maximum = list(map(int, maximum.split('-', 1)[0].split('.')))

    if minimum > version or version >= maximum:
        raise exceptions.VersionMismatch(version, minimum, maximum)
github ipfs / py-ipfs-http-client / ipfshttpclient / client / __init__.py View on Github external
The minimal IPFS daemon version to allowed
	maximum : str
		The maximum IPFS daemon version to allowed
	"""
	# Convert version strings to integer tuples
	version = list(map(int, version.split('-', 1)[0].split('.')))
	minimum = list(map(int, minimum.split('-', 1)[0].split('.')))
	maximum = list(map(int, maximum.split('-', 1)[0].split('.')))

	if minimum > version or version >= maximum:
		raise exceptions.VersionMismatch(version, minimum, maximum)
	
	for blacklisted in blacklist:
		blacklisted = list(map(int, blacklisted.split('-', 1)[0].split('.')))
		if version == blacklisted:
			raise exceptions.VersionMismatch(version, minimum, maximum)