Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
ZKAPAuthorizer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Administrator
ZKAPAuthorizer
Commits
e12dc3c1
Commit
e12dc3c1
authored
3 years ago
by
Jean-Paul Calderone
Browse files
Options
Downloads
Patches
Plain Diff
more docstrings for the tahoe apis
parent
79661a6c
No related branches found
Branches containing commit
No related tags found
1 merge request
!298
Add Tahoe-LAFS `upload` and `download` helpers
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/_zkapauthorizer/tahoe.py
+32
-2
32 additions, 2 deletions
src/_zkapauthorizer/tahoe.py
with
32 additions
and
2 deletions
src/_zkapauthorizer/tahoe.py
+
32
−
2
View file @
e12dc3c1
...
...
@@ -15,6 +15,21 @@ async def upload(
)
->
Awaitable
:
# Awaitable[str] but this requires Python 3.9
"""
Upload data from the given path and return the resulting capability.
:param client: An HTTP client to use to make requests to the Tahoe-LAFS
HTTP API to perform the upload.
:param inpath: The path to the regular file to upload.
:param api_root: The location of the root of the Tahoe-LAFS HTTP API to
use to perform the upload. This should typically be the ``node.url``
value from a Tahoe-LAFS client node.
:return: If the upload is successful then the capability of the uploaded
data is returned.
:raise: If there is a problem uploading the data, some exception is
raised.
"""
with
inpath
.
open
()
as
f
:
resp
=
await
client
.
put
(
api_root
.
child
(
"
uri
"
),
f
)
...
...
@@ -29,6 +44,21 @@ async def download(
)
->
Awaitable
:
# Awaitable[None] but this requires Python 3.9
"""
Download the object identified by the given capability to the given path.
:param client: An HTTP client to use to make requests to the Tahoe-LAFS
HTTP API to perform the upload.
:param outpath: The path to the regular file to which the downloaded
content will be written. The content will be written to a temporary
file next to this one during download and then moved to this location
at the end.
:param api_root: The location of the root of the Tahoe-LAFS HTTP API to
use to perform the upload. This should typically be the ``node.url``
value from a Tahoe-LAFS client node.
:raise: If there is a problem downloading the data, some exception is
raised.
"""
outtemp
=
outpath
.
temporarySibling
()
...
...
@@ -38,5 +68,5 @@ async def download(
await
treq
.
collect
(
resp
,
f
.
write
)
outtemp
.
moveTo
(
outpath
)
else
:
content
=
await
treq
.
content
(
resp
)
raise
Exception
(
content
.
decode
(
"
utf-8
"
)
)
content
=
(
await
treq
.
content
(
resp
)
).
decode
(
"
utf-8
"
)
raise
Exception
(
content
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment