Change pyNMA use of urllib to requests.

This commit is contained in:
JackDandy 2015-07-05 20:22:46 +01:00
parent 36b6335c7f
commit 9197566231
3 changed files with 5 additions and 14 deletions

View file

@ -94,6 +94,7 @@
* Fix saving root dirs
* Change pushbullet from urllib2 to requests
* Change to make pushbullet error messages clearer
* Change pyNMA use of urllib to requests (ref:hacks.txt)
[develop changelog]
* Update Requests library 2.7.0 (ab1f493) to 2.7.0 (8b5e457)

View file

@ -4,3 +4,4 @@ Libs with customisations...
/lib/requests/packages/urllib3/connectionpool.py
/lib/requests/packages/urllib3/util/ssl_.py
/lib/cachecontrol/caches/file_cache.py
/lib/pynma/pynma.py

View file

@ -3,15 +3,7 @@
from . import __version__
from xml.dom.minidom import parseString
try:
from http.client import HTTPSConnection
except ImportError:
from httplib import HTTPSConnection
try:
from urllib.parse import urlencode
except ImportError:
from urllib import urlencode
import requests
class PyNMA(object):
@ -126,12 +118,9 @@ class PyNMA(object):
if 'POST' == method:
headers['Content-type'] = 'application/x-www-form-urlencoded'
http_handler = HTTPSConnection(self.api_server)
http_handler.request(method, path, urlencode(args), headers)
resp = http_handler.getresponse()
try:
res = self._parse_response(resp.read())
resp = requests.post('%s:443%s' % (self.api_server, path), data=args, headers=headers).text
res = self._parse_response(resp)
except Exception as e:
res = {'type': 'pynmaerror',
'code': 600,