pyemoncms 0.0.2__tar.gz → 0.0.4__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.
- pyemoncms-0.0.4/PKG-INFO +52 -0
- pyemoncms-0.0.4/README.md +36 -0
- {pyemoncms-0.0.2 → pyemoncms-0.0.4}/pyemoncms/emoncms_client.py +33 -13
- pyemoncms-0.0.4/pyemoncms.egg-info/PKG-INFO +52 -0
- {pyemoncms-0.0.2 → pyemoncms-0.0.4}/setup.py +1 -1
- pyemoncms-0.0.2/PKG-INFO +0 -18
- pyemoncms-0.0.2/README.md +0 -2
- pyemoncms-0.0.2/pyemoncms.egg-info/PKG-INFO +0 -18
- {pyemoncms-0.0.2 → pyemoncms-0.0.4}/LICENSE +0 -0
- {pyemoncms-0.0.2 → pyemoncms-0.0.4}/pyemoncms/__init__.py +0 -0
- {pyemoncms-0.0.2 → pyemoncms-0.0.4}/pyemoncms.egg-info/SOURCES.txt +0 -0
- {pyemoncms-0.0.2 → pyemoncms-0.0.4}/pyemoncms.egg-info/dependency_links.txt +0 -0
- {pyemoncms-0.0.2 → pyemoncms-0.0.4}/pyemoncms.egg-info/requires.txt +0 -0
- {pyemoncms-0.0.2 → pyemoncms-0.0.4}/pyemoncms.egg-info/top_level.txt +0 -0
- {pyemoncms-0.0.2 → pyemoncms-0.0.4}/pyproject.toml +0 -0
- {pyemoncms-0.0.2 → pyemoncms-0.0.4}/setup.cfg +0 -0
pyemoncms-0.0.4/PKG-INFO
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pyemoncms
|
|
3
|
+
Version: 0.0.4
|
|
4
|
+
Summary: A python library to interrogate emoncms API
|
|
5
|
+
Home-page: https://github.com/Open-Building-Management/pyemoncms
|
|
6
|
+
Author: Alexandre CUER
|
|
7
|
+
Author-email: alexandre.cuer@wanadoo.fr
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/Open-Building-Management/pyemoncms/issues
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: aiohttp
|
|
16
|
+
|
|
17
|
+
# pyemoncms
|
|
18
|
+
python library for emoncms API
|
|
19
|
+
|
|
20
|
+
rely on [aiohttp](https://github.com/aio-libs/aiohttp)
|
|
21
|
+
|
|
22
|
+
to install : `pip3 install pyemoncms`
|
|
23
|
+
|
|
24
|
+
how to use :
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
import logging
|
|
28
|
+
import asyncio
|
|
29
|
+
from pyemoncms import EmoncmsClient
|
|
30
|
+
|
|
31
|
+
key = "your32bitsAPIkey"
|
|
32
|
+
url = "http://url:8081"
|
|
33
|
+
client = EmoncmsClient(url, key, request_timeout=1)
|
|
34
|
+
client.logger.setLevel("DEBUG")
|
|
35
|
+
|
|
36
|
+
async def get_path(path):
|
|
37
|
+
print(await client.async_request(path))
|
|
38
|
+
|
|
39
|
+
async def list_feeds():
|
|
40
|
+
print(await client.async_list_feeds())
|
|
41
|
+
|
|
42
|
+
async def get_feed_fields(feed_id):
|
|
43
|
+
print(await client.async_get_feed_fields(feed_id))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
loop = asyncio.get_event_loop()
|
|
47
|
+
loop.create_task(get_path("/feed/list.json"))
|
|
48
|
+
loop.create_task(get_path("/user/getuuid.json"))
|
|
49
|
+
loop.create_task(list_feeds())
|
|
50
|
+
loop.create_task(get_feed_fields(1))
|
|
51
|
+
loop.run_forever()
|
|
52
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# pyemoncms
|
|
2
|
+
python library for emoncms API
|
|
3
|
+
|
|
4
|
+
rely on [aiohttp](https://github.com/aio-libs/aiohttp)
|
|
5
|
+
|
|
6
|
+
to install : `pip3 install pyemoncms`
|
|
7
|
+
|
|
8
|
+
how to use :
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
import logging
|
|
12
|
+
import asyncio
|
|
13
|
+
from pyemoncms import EmoncmsClient
|
|
14
|
+
|
|
15
|
+
key = "your32bitsAPIkey"
|
|
16
|
+
url = "http://url:8081"
|
|
17
|
+
client = EmoncmsClient(url, key, request_timeout=1)
|
|
18
|
+
client.logger.setLevel("DEBUG")
|
|
19
|
+
|
|
20
|
+
async def get_path(path):
|
|
21
|
+
print(await client.async_request(path))
|
|
22
|
+
|
|
23
|
+
async def list_feeds():
|
|
24
|
+
print(await client.async_list_feeds())
|
|
25
|
+
|
|
26
|
+
async def get_feed_fields(feed_id):
|
|
27
|
+
print(await client.async_get_feed_fields(feed_id))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
loop = asyncio.get_event_loop()
|
|
31
|
+
loop.create_task(get_path("/feed/list.json"))
|
|
32
|
+
loop.create_task(get_path("/user/getuuid.json"))
|
|
33
|
+
loop.create_task(list_feeds())
|
|
34
|
+
loop.create_task(get_feed_fields(1))
|
|
35
|
+
loop.run_forever()
|
|
36
|
+
```
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
"""Emoncms client.
|
|
1
|
+
"""Emoncms client.
|
|
2
|
+
|
|
3
|
+
emoncms feed module :
|
|
4
|
+
an inexisting json route responds by {success: false, message : "Feed does not exist"}
|
|
5
|
+
examples of inexisting json routes :
|
|
6
|
+
- feed/aget.json?id=200 if there is no feed number 200
|
|
7
|
+
- feed/basket.json
|
|
8
|
+
the feed/list.json always returns an array of json objects, which can be empty if there is no feed
|
|
9
|
+
|
|
10
|
+
emoncms user module
|
|
11
|
+
an inexisting json route responds by false which is not a json object
|
|
12
|
+
so there is a type error if you search for a key in the response
|
|
13
|
+
"""
|
|
2
14
|
|
|
3
15
|
import asyncio
|
|
4
16
|
import logging
|
|
@@ -6,11 +18,6 @@ from typing import Any
|
|
|
6
18
|
|
|
7
19
|
import aiohttp
|
|
8
20
|
|
|
9
|
-
client_exceptions = (
|
|
10
|
-
aiohttp.ClientError,
|
|
11
|
-
asyncio.TimeoutError,
|
|
12
|
-
)
|
|
13
|
-
|
|
14
21
|
HTTP_STATUS = {
|
|
15
22
|
400: "invalid request",
|
|
16
23
|
401: "unauthorized access",
|
|
@@ -50,8 +57,13 @@ class EmoncmsClient:
|
|
|
50
57
|
response = await session.get(
|
|
51
58
|
path, timeout=self.request_timeout, params=params
|
|
52
59
|
)
|
|
53
|
-
except
|
|
54
|
-
message = f"
|
|
60
|
+
except aiohttp.ClientError as er:
|
|
61
|
+
message = f"client error : {er}"
|
|
62
|
+
data[MESSAGE_KEY] = message
|
|
63
|
+
self.logger.error(message)
|
|
64
|
+
return data
|
|
65
|
+
except asyncio.TimeoutError:
|
|
66
|
+
message = "time out error"
|
|
55
67
|
data[MESSAGE_KEY] = message
|
|
56
68
|
self.logger.error(message)
|
|
57
69
|
return data
|
|
@@ -59,8 +71,13 @@ class EmoncmsClient:
|
|
|
59
71
|
data[SUCCESS_KEY] = True
|
|
60
72
|
json_response = await response.json()
|
|
61
73
|
data[MESSAGE_KEY] = json_response
|
|
62
|
-
|
|
63
|
-
|
|
74
|
+
try:
|
|
75
|
+
if MESSAGE_KEY in json_response:
|
|
76
|
+
data[MESSAGE_KEY] = json_response[MESSAGE_KEY]
|
|
77
|
+
except TypeError as er:
|
|
78
|
+
message = f"type error : {er}"
|
|
79
|
+
self.logger.error(message)
|
|
80
|
+
data[SUCCESS_KEY] = False
|
|
64
81
|
else:
|
|
65
82
|
message = f"error {response.status}"
|
|
66
83
|
if response.status in HTTP_STATUS:
|
|
@@ -83,7 +100,10 @@ class EmoncmsClient:
|
|
|
83
100
|
return feed_data[MESSAGE_KEY]
|
|
84
101
|
return None
|
|
85
102
|
|
|
86
|
-
async def async_get_feed_fields(self, feed_id: int) -> list[str, Any]:
|
|
87
|
-
"""Get all feed
|
|
103
|
+
async def async_get_feed_fields(self, feed_id: int) -> list[str, Any] | None:
|
|
104
|
+
"""Get all fields for a single feed."""
|
|
88
105
|
params = {"apikey": self.api_key, "id": feed_id}
|
|
89
|
-
|
|
106
|
+
feed_data = await self.async_request("/feed/aget.json", params=params)
|
|
107
|
+
if feed_data[SUCCESS_KEY]:
|
|
108
|
+
return feed_data[MESSAGE_KEY]
|
|
109
|
+
return None
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pyemoncms
|
|
3
|
+
Version: 0.0.4
|
|
4
|
+
Summary: A python library to interrogate emoncms API
|
|
5
|
+
Home-page: https://github.com/Open-Building-Management/pyemoncms
|
|
6
|
+
Author: Alexandre CUER
|
|
7
|
+
Author-email: alexandre.cuer@wanadoo.fr
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/Open-Building-Management/pyemoncms/issues
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: aiohttp
|
|
16
|
+
|
|
17
|
+
# pyemoncms
|
|
18
|
+
python library for emoncms API
|
|
19
|
+
|
|
20
|
+
rely on [aiohttp](https://github.com/aio-libs/aiohttp)
|
|
21
|
+
|
|
22
|
+
to install : `pip3 install pyemoncms`
|
|
23
|
+
|
|
24
|
+
how to use :
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
import logging
|
|
28
|
+
import asyncio
|
|
29
|
+
from pyemoncms import EmoncmsClient
|
|
30
|
+
|
|
31
|
+
key = "your32bitsAPIkey"
|
|
32
|
+
url = "http://url:8081"
|
|
33
|
+
client = EmoncmsClient(url, key, request_timeout=1)
|
|
34
|
+
client.logger.setLevel("DEBUG")
|
|
35
|
+
|
|
36
|
+
async def get_path(path):
|
|
37
|
+
print(await client.async_request(path))
|
|
38
|
+
|
|
39
|
+
async def list_feeds():
|
|
40
|
+
print(await client.async_list_feeds())
|
|
41
|
+
|
|
42
|
+
async def get_feed_fields(feed_id):
|
|
43
|
+
print(await client.async_get_feed_fields(feed_id))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
loop = asyncio.get_event_loop()
|
|
47
|
+
loop.create_task(get_path("/feed/list.json"))
|
|
48
|
+
loop.create_task(get_path("/user/getuuid.json"))
|
|
49
|
+
loop.create_task(list_feeds())
|
|
50
|
+
loop.create_task(get_feed_fields(1))
|
|
51
|
+
loop.run_forever()
|
|
52
|
+
```
|
|
@@ -6,7 +6,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
|
|
|
6
6
|
|
|
7
7
|
setuptools.setup(
|
|
8
8
|
name="pyemoncms",
|
|
9
|
-
version="0.0.
|
|
9
|
+
version="0.0.4",
|
|
10
10
|
author="Alexandre CUER",
|
|
11
11
|
author_email="alexandre.cuer@wanadoo.fr",
|
|
12
12
|
description="A python library to interrogate emoncms API",
|
pyemoncms-0.0.2/PKG-INFO
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: pyemoncms
|
|
3
|
-
Version: 0.0.2
|
|
4
|
-
Summary: A python library to interrogate emoncms API
|
|
5
|
-
Home-page: https://github.com/Open-Building-Management/pyemoncms
|
|
6
|
-
Author: Alexandre CUER
|
|
7
|
-
Author-email: alexandre.cuer@wanadoo.fr
|
|
8
|
-
Project-URL: Bug Tracker, https://github.com/Open-Building-Management/pyemoncms/issues
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
-
Classifier: Operating System :: OS Independent
|
|
12
|
-
Requires-Python: >=3.10
|
|
13
|
-
Description-Content-Type: text/markdown
|
|
14
|
-
License-File: LICENSE
|
|
15
|
-
Requires-Dist: aiohttp
|
|
16
|
-
|
|
17
|
-
# pyemoncms
|
|
18
|
-
python library for emoncms API
|
pyemoncms-0.0.2/README.md
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: pyemoncms
|
|
3
|
-
Version: 0.0.2
|
|
4
|
-
Summary: A python library to interrogate emoncms API
|
|
5
|
-
Home-page: https://github.com/Open-Building-Management/pyemoncms
|
|
6
|
-
Author: Alexandre CUER
|
|
7
|
-
Author-email: alexandre.cuer@wanadoo.fr
|
|
8
|
-
Project-URL: Bug Tracker, https://github.com/Open-Building-Management/pyemoncms/issues
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
-
Classifier: Operating System :: OS Independent
|
|
12
|
-
Requires-Python: >=3.10
|
|
13
|
-
Description-Content-Type: text/markdown
|
|
14
|
-
License-File: LICENSE
|
|
15
|
-
Requires-Dist: aiohttp
|
|
16
|
-
|
|
17
|
-
# pyemoncms
|
|
18
|
-
python library for emoncms API
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|