Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 81113d1

Browse files
committed
Added initial code to support Python3. A long was still to go
1 parent 4560bb8 commit 81113d1

4 files changed

Lines changed: 45 additions & 7 deletions

File tree

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,19 @@ $
338338
While it's easy to call anything within CloudFlare's API, it's not very useful to add items in here as they will simply return API URL errors.
339339
Technically, this is only useful for internal testing within CloudFlare.
340340

341+
## Issues
342+
343+
The following error can be caused by an out of date SSL/TLS library and/or out of date Python.
344+
345+
```
346+
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
347+
SNIMissingWarning
348+
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
349+
InsecurePlatformWarning
350+
```
351+
352+
The solution can be found [here](https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning) and/or [here](http://stackoverflow.com/questions/35144550/how-to-install-cryptography-on-ubuntu).
353+
341354
## Credit
342355
343356
This is based on work by [Felix Wong (gnowxilef)](https://github.com/gnowxilef) found [here](https://github.com/cloudflare-api/python-cloudflare-v4). It has been seriously expanded upon.

README.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,24 @@ While it's easy to call anything within CloudFlare's API, it's not very
444444
useful to add items in here as they will simply return API URL errors.
445445
Technically, this is only useful for internal testing within CloudFlare.
446446

447+
Issues
448+
------
449+
450+
The following error can be caused by an out of date SSL/TLS library
451+
and/or out of date Python.
452+
453+
::
454+
455+
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
456+
SNIMissingWarning
457+
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
458+
InsecurePlatformWarning
459+
460+
The solution can be found
461+
`here <https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning>`__
462+
and/or
463+
`here <http://stackoverflow.com/questions/35144550/how-to-install-cryptography-on-ubuntu>`__.
464+
447465
Credit
448466
------
449467

cli4/cli4.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
import CloudFlare
77

88
import re
9-
import json
10-
import yaml
119
import getopt
10+
import json
11+
try:
12+
import yaml
13+
except ImportError:
14+
yaml = None
1215

1316
def convert_zones_to_identifier(cf, zone_name):
1417
params = {'name':zone_name,'per_page':1}
@@ -137,9 +140,10 @@ def cli4(args):
137140
elif (value[0] is '{' and value[-1] is '}') or (value[0] is '[' and value[-1] is ']'):
138141
# a json structure - used in pagerules
139142
try:
140-
#value = json.loads(value) - changed to yaml code to remove unicode strings
143+
#value = json.loads(value) - changed to yaml code to remove unicode string issues
144+
if yaml is None:
145+
exit('cli4: install yaml support')
141146
value = yaml.safe_load(value)
142-
# success
143147
except ValueError:
144148
exit('cli4: %s="%s" - can\'t parse json value' % (tag, value))
145149
params[tag] = value
@@ -226,6 +230,6 @@ def cli4(args):
226230

227231
if output == 'json':
228232
print json.dumps(r, indent=4, sort_keys=True)
229-
if output == 'yaml':
233+
if output == 'yaml' and yaml is not None:
230234
print yaml.dump(r)
231235

setup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name='cloudflare',
11-
version='1.0.3',
11+
version='1.0.4',
1212
description='Python wrapper for the CloudFlare v4 API',
1313
long_description=long_description,
1414
author='Martin J. Levy',
@@ -18,7 +18,7 @@
1818
url='https://github.com/cloudflare/python-cloudflare',
1919
license='MIT',
2020
packages=['cli4']+find_packages(),
21-
install_requires=['requests'],
21+
install_requires=['requests', 'future', 'pyyaml'],
2222
keywords='cloudflare',
2323
entry_points={
2424
'console_scripts': [
@@ -33,6 +33,9 @@
3333
'Programming Language :: Python :: 2',
3434
'Programming Language :: Python :: 2.6',
3535
'Programming Language :: Python :: 2.7',
36+
# 'Programming Language :: Python :: 3',
37+
# 'Programming Language :: Python :: 3.4',
38+
# 'Programming Language :: Python :: 3.5',
3639
]
3740
)
3841

0 commit comments

Comments
 (0)