summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Spooren <mail@aparcar.org>2020-05-06 12:39:07 -1000
committerPaul Spooren <mail@aparcar.org>2020-05-06 22:39:33 -1000
commit9a068e00eba364eb121a2d7d4c839e2f4c7371c8 (patch)
treef8b1ea7a788bda7cd4ab5ff90481b2999736c98d
parent74b3ddcd5d44c4fe6c7c0189f87852d861e807f0 (diff)
downloadgitlab-9a068e00eba364eb121a2d7d4c839e2f4c7371c8.tar.gz
docs(pipelines): simplify download
This uses a context instead of inventing your own stream handler which makes the code simpler and should be fine for most use cases. Signed-off-by: Paul Spooren <mail@aparcar.org>
-rw-r--r--docs/gl_objects/pipelines_and_jobs.rst12
1 files changed, 2 insertions, 10 deletions
diff --git a/docs/gl_objects/pipelines_and_jobs.rst b/docs/gl_objects/pipelines_and_jobs.rst
index c79d19f..7faf657 100644
--- a/docs/gl_objects/pipelines_and_jobs.rst
+++ b/docs/gl_objects/pipelines_and_jobs.rst
@@ -301,16 +301,8 @@ Get the artifacts of a job::
You can download artifacts as a stream. Provide a callable to handle the
stream::
- class Foo(object):
- def __init__(self):
- self._fd = open('artifacts.zip', 'wb')
-
- def __call__(self, chunk):
- self._fd.write(chunk)
-
- target = Foo()
- build_or_job.artifacts(streamed=True, action=target)
- del(target) # flushes data on disk
+ with open("archive.zip", "wb") as f:
+ build_or_job.artifacts(streamed=True, action=f.write)
You can also directly stream the output into a file, and unzip it afterwards::