Skip to content
This repository has been archived by the owner on Jun 15, 2019. It is now read-only.

Commit

Permalink
Python 3: Use six.moves for moved imports
Browse files Browse the repository at this point in the history
  • Loading branch information
maiksprenger committed Aug 6, 2014
1 parent 248f6c6 commit 2bcce84
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 4 additions & 3 deletions datacash/gateway.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from xml.dom.minidom import Document, parseString
import httplib

from six.moves import http_client
import re
import logging
import datetime
Expand Down Expand Up @@ -99,13 +100,13 @@ def __init__(self, host, path, client, password, cv2avs=False, capturemethod='e

def _fetch_response_xml(self, request_xml):
# Need to fill in HTTP request here
conn = httplib.HTTPSConnection(self._host, 443, timeout=30)
conn = http_client.HTTPSConnection(self._host, 443, timeout=30)
headers = {"Content-type": "application/xml",
"Accept": ""}
conn.request("POST", self._path, request_xml.encode('utf8'), headers)
response = conn.getresponse()
response_xml = response.read()
if response.status != httplib.OK:
if response.status != http_client.OK:
raise GatewayError("Unable to communicate with payment gateway (code: %s, response: %s)" % (response.status, response_xml))
conn.close()
return response_xml
Expand Down
4 changes: 2 additions & 2 deletions datacash/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re
from xml.dom.minidom import parseString
import urlparse
from six.moves.urllib.parse import parse_qs

from django.db import models
from django.conf import settings
Expand Down Expand Up @@ -137,7 +137,7 @@ def create_from_querystring(cls, query):
def extract(data, key):
return data.get(key, [""])[0]

data = urlparse.parse_qs(query)
data = parse_qs(query)
return cls.create_from_payload(query, data, extract)

@classmethod
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
license='BSD',
packages=find_packages(exclude=['sandbox*', 'tests*']),
include_package_data=True,
install_requires=['django-oscar>=0.6'],
install_requires=[
'django-oscar>=0.6',
# Python 2 & 3 compatibility helper
'six>=1.5.2',
],
# See http://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=['Environment :: Web Environment',
'Framework :: Django',
Expand Down

0 comments on commit 2bcce84

Please sign in to comment.