diff options
| author | Xavier Morel <xmo@odoo.com> | 2017-05-11 11:55:22 +0200 |
|---|---|---|
| committer | Xavier Morel <xmo@odoo.com> | 2017-05-15 12:26:30 +0200 |
| commit | 01e35141479b8dfc4a390518f89fc52e7cec5396 (patch) | |
| tree | 24ac6661613e8088140eb607e604d44b2ff5ce42 /addons/google_spreadsheet/models | |
| parent | 54df4b36d7c826de3d07f81297aa17f74d8271ea (diff) | |
[FIX] P3: urllib, urllib2 and urlparse
In Python 3, all of these were "consolidated" under urllib(.request,
.parse, .errors) which is inconvenient.
Since we already have hard dependencies on requests and
werkzeug(.urls, which is a backport of Python 3's unicode-aware
urllib.parse) migrate *everything* to that.
A sticking point is urllib2.URLError, those were (mostly) replaced by
the slightly more general IOError which URLError extends.
Diffstat (limited to 'addons/google_spreadsheet/models')
| -rw-r--r-- | addons/google_spreadsheet/models/google_drive.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/addons/google_spreadsheet/models/google_drive.py b/addons/google_spreadsheet/models/google_drive.py index 88b75a65ca3..dce4777a25e 100644 --- a/addons/google_spreadsheet/models/google_drive.py +++ b/addons/google_spreadsheet/models/google_drive.py @@ -3,10 +3,11 @@ import cgi import json import logging + +import requests from lxml import etree import re import werkzeug.urls -import urllib2 from odoo import api, models from odoo.addons.google_account import TIMEOUT @@ -72,12 +73,13 @@ class GoogleDrive(models.Model): </feed>''' .format(key=spreadsheet_key, formula=cgi.escape(formula, quote=True), config=cgi.escape(config_formula, quote=True)) try: - req = urllib2.Request( + req = requests.post( 'https://spreadsheets.google.com/feeds/cells/%s/od6/private/full/batch?%s' % (spreadsheet_key, werkzeug.url_encode({'v': 3, 'access_token': access_token})), data=request, - headers={'content-type': 'application/atom+xml', 'If-Match': '*'}) - urllib2.urlopen(req, timeout=TIMEOUT) - except (urllib2.HTTPError, urllib2.URLError): + headers={'content-type': 'application/atom+xml', 'If-Match': '*'}, + timeout=TIMEOUT, + ) + except IOError: _logger.warning("An error occured while writting the formula on the Google Spreadsheet.") description = ''' |
