From: peusterm Date: Fri, 15 Jun 2018 12:46:23 +0000 (+0200) Subject: Fix1: Package upload using Python3 was still broken: X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F79%2F6279%2F1;p=osm%2Fosmclient.git Fix1: Package upload using Python3 was still broken: Loading file contents using 'r' does not work in Python 3 and results in an encoding error. Replaced with 'rb'. Fix2: Be more robust when MIME types are detected: Treat 'application/x-gzip' as 'application/gzip'. (This will also allow to use osmclient on OS X) Change-Id: I430b2fae2c275803120a6815d01bb26bff26ebdc Signed-off-by: peusterm --- diff --git a/osmclient/sol005/http.py b/osmclient/sol005/http.py index 7988d89..867db2d 100644 --- a/osmclient/sol005/http.py +++ b/osmclient/sol005/http.py @@ -74,7 +74,7 @@ class Http(http.Http): (pycurl.FORM_FILE, formfile[1])))]) elif filename is not None: - with open(filename, 'r') as stream: + with open(filename, 'rb') as stream: postdata=stream.read() curl_cmd.setopt(pycurl.POSTFIELDS, postdata) diff --git a/osmclient/sol005/nsd.py b/osmclient/sol005/nsd.py index 0dbec43..63308d6 100644 --- a/osmclient/sol005/nsd.py +++ b/osmclient/sol005/nsd.py @@ -128,7 +128,7 @@ class Nsd(object): headers= self._client._headers if mime_type in ['application/yaml', 'text/plain']: headers['Content-Type'] = 'application/yaml' - elif mime_type == 'application/gzip': + elif mime_type in ['application/gzip', 'application/x-gzip']: headers['Content-Type'] = 'application/gzip' #headers['Content-Type'] = 'application/binary' # Next three lines are to be removed in next version diff --git a/osmclient/sol005/vnfd.py b/osmclient/sol005/vnfd.py index c769d4c..b239d57 100644 --- a/osmclient/sol005/vnfd.py +++ b/osmclient/sol005/vnfd.py @@ -127,7 +127,7 @@ class Vnfd(object): headers= self._client._headers if mime_type in ['application/yaml', 'text/plain']: headers['Content-Type'] = 'application/yaml' - elif mime_type == 'application/gzip': + elif mime_type in ['application/gzip', 'application/x-gzip']: headers['Content-Type'] = 'application/gzip' #headers['Content-Type'] = 'application/binary' # Next three lines are to be removed in next version