Skip to content

Commit cd3c70f

Browse files
authored
Simplify the example for streamed artifacts
Going through an object adds a lot of complication. Adding example for unzipping on the fly
1 parent 1ca3080 commit cd3c70f

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

docs/gl_objects/builds.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,11 @@
7373
# end artifacts
7474

7575
# stream artifacts
76-
class Foo(object):
77-
def __init__(self):
78-
self._fd = open('artifacts.zip', 'wb')
79-
80-
def __call__(self, chunk):
81-
self._fd.write(chunk)
82-
83-
target = Foo()
84-
build_or_job.artifacts(streamed=True, action=target)
85-
del(target) # flushes data on disk
76+
zipfn = "___artifacts.zip"
77+
with open(zipfn, "wb") as f:
78+
build_or_job.artifacts(streamed=True, action=f.write)
79+
subprocess.run(["unzip", "-bo", zipfn])
80+
os.unlink(zipfn)
8681
# end stream artifacts
8782

8883
# keep artifacts

0 commit comments

Comments
 (0)