-
Notifications
You must be signed in to change notification settings - Fork 14
Python312 support #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -119,16 +119,17 @@ class OpenSRS(object): | |
|
|
||
| MSG_ALREADY_RENEWED_SANDBOX = 'Domain Already Renewed' | ||
|
|
||
| def __init__(self, host, port, username, private_key, default_timeout): | ||
| def __init__(self, host, port, username, private_key, default_timeout, proxy=None): | ||
| self.host = host | ||
| self.port = port | ||
| self.username = username | ||
| self.private_key = private_key | ||
| self.default_timeout = default_timeout | ||
| self.proxy = proxy | ||
|
|
||
| def _get_channel(self): | ||
| return XCPChannel(self.host, self.port, self.username, | ||
| self.private_key, self.default_timeout) | ||
| self.private_key, self.default_timeout, proxy=self.proxy) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. E128 continuation line under-indented for visual indent |
||
|
|
||
| def _req(self, action, object, attributes, **kw): | ||
| msg = XCPMessage(action, object, attributes, **kw) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| import hashlib | ||
| import logging | ||
| try: | ||
| from urllib.request import urlopen, Request | ||
| from urllib.request import urlopen, Request, ProxyHandler, build_opener, install_opener | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. E501 line too long (91 > 80 characters) |
||
| except ImportError: | ||
| from urllib2 import urlopen, Request | ||
| from urllib2 import urlopen, Request, ProxyHandler, build_opener, install_opener | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. E501 line too long (84 > 80 characters) |
||
| from xml.etree import ElementTree as ET | ||
|
|
||
| from opensrs.errors import XCPError | ||
|
|
@@ -87,17 +87,17 @@ def get_data(self, base_node=None): | |
| if not ET.iselement(base_node): | ||
| return base_node | ||
| if base_node.tag == 'item': | ||
| if base_node.getchildren() == []: | ||
| if list(base_node) == []: | ||
| return base_node.text | ||
| return self.get_data(base_node[0]) | ||
| if base_node.tag == 'dt_array': | ||
| indexed_children = [(e.get('key'), e) for e in | ||
| base_node.getchildren()] | ||
| list(base_node)] | ||
| indexed_children.sort() | ||
| return [self.get_data(e) for i, e in indexed_children] | ||
| if base_node.tag == 'dt_assoc': | ||
| data = {} | ||
| for e in base_node.getchildren(): | ||
| for e in list(base_node): | ||
| data[e.get('key')] = self.get_data(e) | ||
| return data | ||
| if base_node.tag == 'dt_scalar': | ||
|
|
@@ -128,23 +128,27 @@ def sign(self, private_key): | |
|
|
||
|
|
||
| class XCPChannel(object): | ||
| def __init__(self, host, port, username, private_key, default_timeout): | ||
| def __init__(self, host, port, username, private_key, default_timeout, proxy=None): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. E501 line too long (87 > 80 characters) |
||
| self.host = host | ||
| self.port = port | ||
| self.username = username | ||
| self.private_key = private_key.encode('UTF-8') | ||
| self.default_timeout = default_timeout | ||
| self.proxy = proxy | ||
|
|
||
| def _make_call(self, message): | ||
| """All network interaction is isolated here for stubbing out.""" | ||
| if self.proxy: | ||
| proxy = ProxyHandler(proxies={"https": self.proxy}) | ||
| opener = build_opener(proxy) | ||
| install_opener(opener) | ||
| request = Request('https://%s:%s/' % (self.host, self.port)) | ||
| headers = { | ||
| 'Content-Type': 'text/xml', | ||
| 'X-Username': self.username, | ||
| 'X-Signature': message.sign(self.private_key), | ||
| } | ||
| [request.add_header(k, v) for k, v in headers.items()] | ||
|
|
||
| timeout = message.timeout or self.default_timeout | ||
| log.debug('Making XCP call with timeout = %s', timeout) | ||
| xml = urlopen(request, message.get_content(), timeout).read() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| demands == 4.0.0 | ||
| flake8 == 2.4.1 | ||
| funcsigs < 0.5 | ||
| mock < 1.2.0 | ||
| nose < 2.0.0 | ||
| python-dateutil == 2.5.3 | ||
| demands == 5.1.0 | ||
| flake8 >= 6.0.0 | ||
| mock >= 5.0.0 | ||
| pytest >= 7.0.0 | ||
| python-dateutil >= 2.8.2 | ||
| requests >= 2.31.0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,13 @@ | ||
| [tox] | ||
| envlist = py27,py35 | ||
| envlist = py312 | ||
| isolated_build = true | ||
|
|
||
| [testenv] | ||
| deps = | ||
| -rrequirements.txt | ||
| pytest | ||
| setenv = | ||
| PYTHONPATH = {toxinidir} | ||
| commands = | ||
| /bin/cp test_settings.py.sample test_settings.py | ||
| nosetests | ||
| pytest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E501 line too long (87 > 80 characters)