polyswarmclient.utils
¶
Module Contents¶
-
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.
asyncio_join
()[source]¶ -
Gather all remaining tasks, assumes loop is not running
-
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