Skip to content

Commit 9a068e0

Browse files
committed
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>
1 parent 74b3ddc commit 9a068e0

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

docs/gl_objects/pipelines_and_jobs.rst

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -301,16 +301,8 @@ Get the artifacts of a job::
301301
You can download artifacts as a stream. Provide a callable to handle the
302302
stream::
303303

304-
class Foo(object):
305-
def __init__(self):
306-
self._fd = open('artifacts.zip', 'wb')
307-
308-
def __call__(self, chunk):
309-
self._fd.write(chunk)
310-
311-
target = Foo()
312-
build_or_job.artifacts(streamed=True, action=target)
313-
del(target) # flushes data on disk
304+
with open("archive.zip", "wb") as f:
305+
build_or_job.artifacts(streamed=True, action=f.write)
314306

315307
You can also directly stream the output into a file, and unzip it afterwards::
316308

0 commit comments

Comments
 (0)