Browse Source

add a basic error management for OVH case

pull/128/head
Sébastien BEAU 9 years ago
committed by MonsieurB
parent
commit
166238e924
  1. 13
      smsclient_ovh/smsclient.py

13
smsclient_ovh/smsclient.py

@ -21,7 +21,6 @@
############################################################################### ###############################################################################
from openerp import api, models, _ from openerp import api, models, _
from openerp.exceptions import Warning
import urllib import urllib
import logging import logging
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
@ -79,3 +78,15 @@ class SmsSms(models.Model):
if self.coding: if self.coding:
params['smsCoding'] = self.coding params['smsCoding'] = self.coding
return params 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)
Loading…
Cancel
Save