Skip to content

Commit

Permalink
docs(pipelines): simplify download
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
aparcar committed May 7, 2020
1 parent 74b3ddc commit 9a068e0
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions docs/gl_objects/pipelines_and_jobs.rst
Expand Up @@ -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::

Expand Down

0 comments on commit 9a068e0

Please sign in to comment.