From 45502332d7563bd38a27b5825654fb9236d48546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20BEAU?= Date: Tue, 22 Sep 2015 08:24:23 +0200 Subject: [PATCH] fix encoding issue by using the beautiful request --- smsclient_ovh/sms_gateway.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/smsclient_ovh/sms_gateway.py b/smsclient_ovh/sms_gateway.py index 1a47c15..e1b93b5 100644 --- a/smsclient_ovh/sms_gateway.py +++ b/smsclient_ovh/sms_gateway.py @@ -21,7 +21,7 @@ ############################################################################### from openerp import api, models, _ -import urllib +import requests import logging _logger = logging.getLogger(__name__) @@ -82,11 +82,10 @@ class SmsSms(models.Model): @api.multi def _send_http_ovh(self): self.ensure_one() - params = self._prepare_http_ovh() - params_encoded = urllib.urlencode(params) - url = "%s?%s" % (self.gateway_id.url, params_encoded) - _logger.debug("Call OVH API : %s", url) - answer = urllib.urlopen(url) - response = answer.read() + params = self._prepare_http_ovh().items() + r = requests.get(self.gateway_id.url, params=params) + _logger.debug("Call OVH API : %s params %s", + self.gateway_id.url, params) + response = r.text if response[0:2] != 'OK': raise ValueError(response)