Skip to content

Commit e9ed6e5

Browse files
authored
Merge pull request #91 from dataiku/perso/lpenet/download-plugin
Adding download_plugin_stream and download_plugin_to_file to dataikuapi.
2 parents 1b37147 + 235d60c commit e9ed6e5

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

dataikuapi/dssclient.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,31 @@ def list_plugins(self):
226226
"""
227227
return self._perform_json("GET", "/plugins/")
228228

229+
def download_plugin_stream(self, plugin_id):
230+
"""
231+
Download a development plugin, as a binary stream
232+
:param str plugin_id: identifier of the plugin to download
233+
234+
:param plugin_id:
235+
:return: the binary stream
236+
"""
237+
return self._perform_raw("GET", "/plugins/%s/download" % plugin_id)
238+
239+
def download_plugin_to_file(self, plugin_id, path):
240+
"""
241+
Download a development plugin to a file
242+
243+
:param str plugin_id: identifier of the plugin to download
244+
:param str path: the path where to download the plugin
245+
:return: None
246+
"""
247+
stream = self.download_plugin_stream(plugin_id)
248+
with open(path, 'wb') as f:
249+
for chunk in stream.iter_content(chunk_size=10000):
250+
if chunk:
251+
f.write(chunk)
252+
f.flush()
253+
229254
def install_plugin_from_archive(self, fp):
230255
"""
231256
Install a plugin from a plugin archive (as a file object)

0 commit comments

Comments
 (0)