mirror of https://github.com/dcarrillo/digaws.git
Add limited support for python 3.6
This commit is contained in:
parent
e6756888e7
commit
35f99df4ac
|
@ -14,7 +14,7 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
python-version: [3.7, 3.8, 3.9]
|
||||
python-version: [3.6, 3.7, 3.8, 3.9]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
__version__ = '1.0.2'
|
||||
__description__ = 'Look up canonical information for AWS IP addresses and networks'
|
||||
__python_required__ = '3.6'
|
||||
|
|
|
@ -14,8 +14,7 @@ from dateutil import tz
|
|||
import requests
|
||||
from requests.exceptions import RequestException
|
||||
|
||||
from . import __description__
|
||||
from . import __version__
|
||||
from . import __description__, __version__
|
||||
|
||||
AWS_IP_RANGES_URL = 'https://ip-ranges.amazonaws.com/ip-ranges.json'
|
||||
CACHE_DIR = Path(Path.home() / '.digaws')
|
||||
|
@ -172,6 +171,10 @@ class DigAWS():
|
|||
data = [prefix for prefix in self.ipv6_prefixes
|
||||
if addr in prefix['ipv6_prefix']]
|
||||
except ipaddress.AddressValueError:
|
||||
if sys.version_info.major == 3 and sys.version_info.minor == 6:
|
||||
raise ValueError('python 3.6 does not support subnet_of checking, '
|
||||
'please upgrade your python version or do not query '
|
||||
f'CIDRs: {address}')
|
||||
try:
|
||||
addr = ipaddress.IPv4Network(address)
|
||||
data = [prefix for prefix in self.ip_prefixes
|
||||
|
|
4
setup.py
4
setup.py
|
@ -1,4 +1,4 @@
|
|||
from digaws import __description__, __version__
|
||||
from digaws import __description__, __python_required__, __version__
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
|
@ -25,7 +25,7 @@ setup(
|
|||
'License :: OSI Approved :: Apache Software License',
|
||||
'Operating System :: OS Independent',
|
||||
],
|
||||
python_requires='>=3.7',
|
||||
python_requires=f'>={__python_required__}',
|
||||
entry_points={
|
||||
'console_scripts': ['digaws=digaws.digaws:main']
|
||||
},
|
||||
|
|
|
@ -81,8 +81,15 @@ def test_lookup(test_dig):
|
|||
assert str(test_dig._lookup_data('2600:1f14::/36')[0]['ipv6_prefix']) == '2600:1f14::/35'
|
||||
|
||||
with pytest.raises(ValueError) as e:
|
||||
test_dig.lookup('what are you talking about')
|
||||
assert e.startswith('Wrong IP or CIDR format')
|
||||
test_dig._lookup_data('what are you talking about')
|
||||
assert e.match('Wrong IP or CIDR format')
|
||||
|
||||
|
||||
def test_python36_cidr_lookup(test_dig):
|
||||
if sys.version_info.major == 3 and sys.version_info.minor == 6:
|
||||
with pytest.raises(ValueError) as e:
|
||||
test_dig._lookup_data('52.94.76.0/22')
|
||||
assert e.match('python 3.6 does not support subnet_of checking')
|
||||
|
||||
|
||||
def test_response_plain_print(test_dig, capsys):
|
||||
|
|
Loading…
Reference in New Issue