polyswarmclient.utils

Module Contents

polyswarmclient.utils.logger[source]
polyswarmclient.utils.TASK_TIMEOUT = 1.0[source]
polyswarmclient.utils.MAX_WAIT[source]
polyswarmclient.utils.MAX_WORKERS = 4[source]
polyswarmclient.utils.DEPRECATION_MESSAGE = polyswarm-client 2.x.x is deprecated. However, polyswarm-client 2.x.x will still work with some PolySwarm communities in the near term.[source]

Action is required to continue using 2.x.x.

If your build is based off the polyswarm-client:latest docker image, you MUST change to another tag. Tag :2 will include all future fixes for polyswarm-client 2.x.x.

polyswarmclient.utils.to_bytes(value)[source]
polyswarmclient.utils.sha3(seed)[source]
polyswarmclient.utils.int_to_bytes(i)[source]
polyswarmclient.utils.int_from_bytes(b)[source]
polyswarmclient.utils.bool_list_to_int(bs)[source]
polyswarmclient.utils.int_to_bool_list(i, expected_size)[source]
polyswarmclient.utils.guid_as_string(guid)[source]
polyswarmclient.utils.calculate_commitment(account, verdicts, nonce=None)[source]
polyswarmclient.utils.configure_event_loop()[source]
polyswarmclient.utils.asyncio_join()[source]
Gather all remaining tasks, assumes loop is not running
polyswarmclient.utils.asyncio_stop()[source]
Stop the main event loop
polyswarmclient.utils.check_response(response)[source]
Check the status of responses from polyswarmd
Parameters

response – Response dict parsed from JSON from polyswarmd

Returns

True if successful else False

Return type

(bool)

polyswarmclient.utils.is_valid_sha256(uri)[source]
Ensure that a given uri is a valid sha256 hash by checking length, and converting to an int
Parameters

uri (str) – uri to validate

Returns

is this valid

Return type

bool

polyswarmclient.utils.is_valid_ipfs_uri(ipfs_uri)[source]
Ensure that a given ipfs_uri is valid by checking length and base58 encoding.
Parameters

ipfs_uri (str) – ipfs_uri to validate

Returns

is this valid?

Return type

bool

class polyswarmclient.utils.AsyncArtifactTempfile(blob: 'bytes' = None, filename: 'str' = None, mode: 'str' = 'w+b')[source]

asynchronous ctxmgr for temporary artifacts

Notes:

The following underlying file’s methods are awaited:

flush, peek, read, seek, write

You can use the object like an ordinary context manager or supply the binary blob to be written as the first argument

>>> blob = b'hello world'
>>> async with AsyncArtifactTempfile(blob) as f:
>>>     with open(f.name, 'rb') as of:
>>>         of.read()
b'hello world'
>>> async with AsyncArtifactTempfile() as f:
>>>     await f.write(blob)
>>>     await f.read()
b'hello world'

The underlying file is always deleted after ctxmgr exits

__del__(self)[source]
__getattr__(self, name)[source]
polyswarmclient.utils.return_on_exception(exceptions=(Exception, ), default=None)[source]
polyswarmclient.utils.finalize_polyswarmd_addr(polyswarmd_addr, api_key, allow_key_over_http, insecure_transport)[source]
polyswarmclient.utils.fill_scheme(polyswarmd_addr, insecure_transport)[source]