elementapi 0.4__tar.gz → 0.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: elementapi
3
- Version: 0.4
3
+ Version: 0.6
4
4
  Summary: element-iot api client lib
5
5
  Home-page: https://github.com/ZennerIoT/python-elementapi
6
6
  Download-URL: https://github.com/ZennerIoT/python-elementapi/archive/master.zip
@@ -1,7 +1,10 @@
1
1
  try:
2
- import ujson as json
3
- except:
4
- import json
2
+ import orjson as json
3
+ except ImportError:
4
+ try:
5
+ import ujson as json
6
+ except:
7
+ import json
5
8
 
6
9
  import logging
7
10
  import re
@@ -33,7 +36,7 @@ class ElementAPIException(Exception):
33
36
  )
34
37
 
35
38
  def __repr__(self):
36
- return self._str()
39
+ return self._str()
37
40
 
38
41
  def __str__(self):
39
42
  return self._str()
@@ -54,7 +57,6 @@ def get_body(resp):
54
57
  return r
55
58
 
56
59
 
57
-
58
60
  class ElementAPI:
59
61
  apitoken = None
60
62
  baseurl = "element-iot.com"
@@ -63,9 +65,22 @@ class ElementAPI:
63
65
  apiversion = "/"
64
66
  sync = False
65
67
  proxies = None
68
+ custom_ca = None
69
+ https_no_verify = False
66
70
  headers = {'Accept': 'application/json'}
67
71
 
68
- def __init__(self, apitoken, baseurl=None, https=True, port=None, apiversion=1, sync=False, proxies=None):
72
+ def __init__(
73
+ self,
74
+ apitoken,
75
+ baseurl=None,
76
+ https=True,
77
+ port=None,
78
+ apiversion=1,
79
+ sync=False,
80
+ proxies=None,
81
+ custom_ca=None,
82
+ https_no_verify=False
83
+ ):
69
84
  if baseurl:
70
85
  self.baseurl = baseurl
71
86
 
@@ -87,12 +102,20 @@ class ElementAPI:
87
102
  elif type(proxies) is str:
88
103
  # TODO: check if string ?
89
104
  self.proxies = {'http%s' % ('s' if https else ''): proxies}
90
-
105
+
106
+ self.custom_ca = custom_ca
107
+ self.https_no_verify = https_no_verify
108
+
91
109
  self.requestargs = {
92
110
  'headers': self.headers,
93
111
  'proxies': self.proxies
94
112
  }
95
113
 
114
+ if self.custom_ca:
115
+ self.requestargs['verify'] = self.custom_ca
116
+
117
+ if self.https_no_verify:
118
+ self.requestargs['verify'] = False
96
119
 
97
120
  # TODO: allow plain string paths !
98
121
  def genurl(self, _path=None, **opts):
@@ -167,7 +190,7 @@ class ElementAPI:
167
190
 
168
191
  if resp.status_code >= 400:
169
192
  if resp.status_code == 429 and not raise_rl:
170
- # hit reate-limit
193
+ # hit create-limit
171
194
 
172
195
  # sleep|block
173
196
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: elementapi
3
- Version: 0.4
3
+ Version: 0.6
4
4
  Summary: element-iot api client lib
5
5
  Home-page: https://github.com/ZennerIoT/python-elementapi
6
6
  Download-URL: https://github.com/ZennerIoT/python-elementapi/archive/master.zip
@@ -3,7 +3,7 @@ from distutils.core import setup
3
3
  setup(
4
4
  name='elementapi',
5
5
  packages=['elementapi'],
6
- version='0.4',
6
+ version='0.6',
7
7
  description='element-iot api client lib',
8
8
  author='Stefan Reiser',
9
9
  author_email='sr@zenner-iot.com',
File without changes