Skip to content

Commit

Permalink
Added initial code to support Python3. A long was still to go
Browse files Browse the repository at this point in the history
  • Loading branch information
mahtin committed May 17, 2016
1 parent 4560bb8 commit 81113d1
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 7 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,19 @@ $
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.
Technically, this is only useful for internal testing within CloudFlare.

## Issues

The following error can be caused by an out of date SSL/TLS library and/or out of date Python.

```
/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.
SNIMissingWarning
/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.
InsecurePlatformWarning
```
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).
## Credit
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.
Expand Down
18 changes: 18 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,24 @@ 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.
Technically, this is only useful for internal testing within CloudFlare.

Issues
------

The following error can be caused by an out of date SSL/TLS library
and/or out of date Python.

::

/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.
SNIMissingWarning
/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.
InsecurePlatformWarning

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>`__.

Credit
------

Expand Down
14 changes: 9 additions & 5 deletions cli4/cli4.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
import CloudFlare

import re
import json
import yaml
import getopt
import json
try:
import yaml
except ImportError:
yaml = None

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

if output == 'json':
print json.dumps(r, indent=4, sort_keys=True)
if output == 'yaml':
if output == 'yaml' and yaml is not None:
print yaml.dump(r)

7 changes: 5 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='cloudflare',
version='1.0.3',
version='1.0.4',
description='Python wrapper for the CloudFlare v4 API',
long_description=long_description,
author='Martin J. Levy',
Expand All @@ -18,7 +18,7 @@
url='https://github.com/cloudflare/python-cloudflare',
license='MIT',
packages=['cli4']+find_packages(),
install_requires=['requests'],
install_requires=['requests', 'future', 'pyyaml'],
keywords='cloudflare',
entry_points={
'console_scripts': [
Expand All @@ -33,6 +33,9 @@
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
# 'Programming Language :: Python :: 3',
# 'Programming Language :: Python :: 3.4',
# 'Programming Language :: Python :: 3.5',
]
)

Expand Down

0 comments on commit 81113d1

Please sign in to comment.