From 119f79ff8103018c12d9f3f5083a97e5a34aecba Mon Sep 17 00:00:00 2001 From: peusterm Date: Fri, 15 Jun 2018 14:46:23 +0200 Subject: [PATCH] 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 --- osmclient/sol005/http.py | 2 +- osmclient/sol005/nsd.py | 2 +- osmclient/sol005/vnfd.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 -- 2.17.1