From 166238e9245ec1507676c595c8a643e7670debc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20BEAU?= Date: Tue, 22 Sep 2015 00:06:47 +0200 Subject: [PATCH] add a basic error management for OVH case --- smsclient_ovh/smsclient.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/smsclient_ovh/smsclient.py b/smsclient_ovh/smsclient.py index 4643845..86f8762 100644 --- a/smsclient_ovh/smsclient.py +++ b/smsclient_ovh/smsclient.py @@ -21,7 +21,6 @@ ############################################################################### from openerp import api, models, _ -from openerp.exceptions import Warning import urllib import logging _logger = logging.getLogger(__name__) @@ -79,3 +78,15 @@ class SmsSms(models.Model): if self.coding: params['smsCoding'] = self.coding return params + + @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() + if response[0:2] != 'OK': + raise ValueError(response)