Added Python 2.7.x and 3.4.x compatibility to the code. Disabled HTTPS security warning in urllib3 package of 'requests' package.

This commit is contained in:
Michael Halls-Moore
2015-05-11 17:30:28 +01:00
parent 8e74edb4f7
commit a03bc7a1fb
9 changed files with 67 additions and 39 deletions
+14 -4
View File
@@ -1,6 +1,16 @@
from __future__ import print_function
from abc import ABCMeta, abstractmethod
import httplib
import urllib
try:
import httplib
except ImportError:
import http.client as httplib
try:
from urllib import urlencode
except ImportError:
from urllib.parse import urlencode
import urllib3
urllib3.disable_warnings()
class ExecutionHandler(object):
@@ -47,7 +57,7 @@ class OANDAExecutionHandler(ExecutionHandler):
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Bearer " + self.access_token
}
params = urllib.urlencode({
params = urlencode({
"instrument" : instrument,
"units" : event.units,
"type" : event.order_type,
@@ -59,5 +69,5 @@ class OANDAExecutionHandler(ExecutionHandler):
params, headers
)
response = self.conn.getresponse().read()
print response
print(response)