From 84de1851f6982ca73a2f82eb382ff3f13742e31f Mon Sep 17 00:00:00 2001 From: Scott Bahling Date: Wed, 18 Jul 2018 17:23:15 +0200 Subject: Handle retrieving binary files properly --- obsapi/buildapi.py | 8 ++++++-- obsapi/httpapi.py | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/obsapi/buildapi.py b/obsapi/buildapi.py index eceea4d..698e5e7 100644 --- a/obsapi/buildapi.py +++ b/obsapi/buildapi.py @@ -13,8 +13,12 @@ class ObsBuildApi(ObsHttpApi): def __put(self, *args, **kwargs): return super(ObsBuildApi, self).put(*args, **kwargs) - def get(self, prj='', repo='', arch='', pkg='', binaryname='', view=None): - return self.__get(prj, repo, arch, pkg, binaryname, view=view) + def get(self, prj='', repo='', arch='', pkg='', binaryname='', + view=None, binary_get=False): + if binaryname: + binary_get = True + return self.__get(prj, repo, arch, pkg, binaryname, + view=view, binary_get=binary_get) def get_builddepinfo(self, prj, pkg, repo, arch): return self.__get(prj, repo, arch, '_builddepinfo', package=pkg) diff --git a/obsapi/httpapi.py b/obsapi/httpapi.py index 4b0ab65..8ef893e 100644 --- a/obsapi/httpapi.py +++ b/obsapi/httpapi.py @@ -110,11 +110,15 @@ class ObsHttpApi(object): return '/'.join(['{}'] * len(args)).format(*args) def get(self, *args, **params): + binary_get = params.pop('binary_get', False) api = self.__api(*args) r = self.__api_get(api, params=params) if not self.success: return self.default_xml + if binary_get: + return r.content + return r.text def put(self, *args, **kwargs): -- cgit v1.2.3