pyemoncms 0.0.7__tar.gz → 0.0.8__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.7 → pyemoncms-0.0.8}/PKG-INFO +3 -4
- {pyemoncms-0.0.7 → pyemoncms-0.0.8}/README.md +2 -3
- {pyemoncms-0.0.7 → pyemoncms-0.0.8}/pyemoncms/emoncms_client.py +7 -14
- {pyemoncms-0.0.7 → pyemoncms-0.0.8}/pyemoncms.egg-info/PKG-INFO +3 -4
- {pyemoncms-0.0.7 → pyemoncms-0.0.8}/setup.py +1 -1
- {pyemoncms-0.0.7 → pyemoncms-0.0.8}/tests/test_async_request.py +1 -1
- {pyemoncms-0.0.7 → pyemoncms-0.0.8}/LICENSE +0 -0
- {pyemoncms-0.0.7 → pyemoncms-0.0.8}/pyemoncms/__init__.py +0 -0
- {pyemoncms-0.0.7 → pyemoncms-0.0.8}/pyemoncms.egg-info/SOURCES.txt +0 -0
- {pyemoncms-0.0.7 → pyemoncms-0.0.8}/pyemoncms.egg-info/dependency_links.txt +0 -0
- {pyemoncms-0.0.7 → pyemoncms-0.0.8}/pyemoncms.egg-info/requires.txt +0 -0
- {pyemoncms-0.0.7 → pyemoncms-0.0.8}/pyemoncms.egg-info/top_level.txt +0 -0
- {pyemoncms-0.0.7 → pyemoncms-0.0.8}/pyproject.toml +0 -0
- {pyemoncms-0.0.7 → pyemoncms-0.0.8}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pyemoncms
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.8
|
|
4
4
|
Summary: A python library to interrogate emoncms API
|
|
5
5
|
Home-page: https://github.com/Open-Building-Management/pyemoncms
|
|
6
6
|
Author: Alexandre CUER
|
|
@@ -36,8 +36,8 @@ client.logger.setLevel("DEBUG")
|
|
|
36
36
|
async def get_path(path):
|
|
37
37
|
print(await client.async_request(path))
|
|
38
38
|
|
|
39
|
-
async def list_feeds(
|
|
40
|
-
print(await client.async_list_feeds(
|
|
39
|
+
async def list_feeds():
|
|
40
|
+
print(await client.async_list_feeds())
|
|
41
41
|
|
|
42
42
|
async def get_feed_fields(feed_id):
|
|
43
43
|
print(await client.async_get_feed_fields(feed_id))
|
|
@@ -47,7 +47,6 @@ loop = asyncio.get_event_loop()
|
|
|
47
47
|
loop.create_task(get_path("feed/list.json"))
|
|
48
48
|
loop.create_task(get_path("/user/getuuid.json"))
|
|
49
49
|
loop.create_task(list_feeds())
|
|
50
|
-
loop.create_task(list_feeds(uuid=True))
|
|
51
50
|
loop.create_task(get_feed_fields(1))
|
|
52
51
|
try:
|
|
53
52
|
loop.run_forever()
|
|
@@ -20,8 +20,8 @@ client.logger.setLevel("DEBUG")
|
|
|
20
20
|
async def get_path(path):
|
|
21
21
|
print(await client.async_request(path))
|
|
22
22
|
|
|
23
|
-
async def list_feeds(
|
|
24
|
-
print(await client.async_list_feeds(
|
|
23
|
+
async def list_feeds():
|
|
24
|
+
print(await client.async_list_feeds())
|
|
25
25
|
|
|
26
26
|
async def get_feed_fields(feed_id):
|
|
27
27
|
print(await client.async_get_feed_fields(feed_id))
|
|
@@ -31,7 +31,6 @@ loop = asyncio.get_event_loop()
|
|
|
31
31
|
loop.create_task(get_path("feed/list.json"))
|
|
32
32
|
loop.create_task(get_path("/user/getuuid.json"))
|
|
33
33
|
loop.create_task(list_feeds())
|
|
34
|
-
loop.create_task(list_feeds(uuid=True))
|
|
35
34
|
loop.create_task(get_feed_fields(1))
|
|
36
35
|
try:
|
|
37
36
|
loop.run_forever()
|
|
@@ -76,11 +76,13 @@ class EmoncmsClient:
|
|
|
76
76
|
data[SUCCESS_KEY] = True
|
|
77
77
|
json_response = await response.json()
|
|
78
78
|
data[MESSAGE_KEY] = json_response
|
|
79
|
-
|
|
80
|
-
if MESSAGE_KEY in json_response:
|
|
81
|
-
data[MESSAGE_KEY] = json_response[MESSAGE_KEY]
|
|
82
|
-
except TypeError:
|
|
79
|
+
if json_response is False:
|
|
83
80
|
data[SUCCESS_KEY] = False
|
|
81
|
+
elif SUCCESS_KEY in json_response:
|
|
82
|
+
data = json_response
|
|
83
|
+
if not data[SUCCESS_KEY]:
|
|
84
|
+
message = data[MESSAGE_KEY].replace("ADMIN", "EMONCMS ADMIN")
|
|
85
|
+
self.logger.warning(message)
|
|
84
86
|
else:
|
|
85
87
|
message = f"error {response.status}"
|
|
86
88
|
if response.status in HTTP_STATUS:
|
|
@@ -89,21 +91,12 @@ class EmoncmsClient:
|
|
|
89
91
|
self.logger.error(message)
|
|
90
92
|
return data
|
|
91
93
|
|
|
92
|
-
async def async_list_feeds(self
|
|
94
|
+
async def async_list_feeds(self) -> list[dict[str, Any]] | None:
|
|
93
95
|
"""Request emoncms feeds list.
|
|
94
96
|
|
|
95
97
|
return a uuid per feed if available
|
|
96
98
|
"""
|
|
97
99
|
feed_data = await self.async_request("/feed/list.json")
|
|
98
|
-
if uuid:
|
|
99
|
-
uuid_data = await self.async_request("/user/getuuid.json")
|
|
100
|
-
if not uuid_data[SUCCESS_KEY]:
|
|
101
|
-
message = "no uuid available"
|
|
102
|
-
message = f"{message} - migrate your emoncms sensor to a newer version"
|
|
103
|
-
self.logger.warning(message)
|
|
104
|
-
if feed_data[SUCCESS_KEY] and uuid_data[SUCCESS_KEY]:
|
|
105
|
-
for feed in feed_data[MESSAGE_KEY]:
|
|
106
|
-
feed["uuid"] = f"{uuid_data[MESSAGE_KEY]}_{feed['id']}"
|
|
107
100
|
if feed_data[SUCCESS_KEY]:
|
|
108
101
|
return feed_data[MESSAGE_KEY]
|
|
109
102
|
return None
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pyemoncms
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.8
|
|
4
4
|
Summary: A python library to interrogate emoncms API
|
|
5
5
|
Home-page: https://github.com/Open-Building-Management/pyemoncms
|
|
6
6
|
Author: Alexandre CUER
|
|
@@ -36,8 +36,8 @@ client.logger.setLevel("DEBUG")
|
|
|
36
36
|
async def get_path(path):
|
|
37
37
|
print(await client.async_request(path))
|
|
38
38
|
|
|
39
|
-
async def list_feeds(
|
|
40
|
-
print(await client.async_list_feeds(
|
|
39
|
+
async def list_feeds():
|
|
40
|
+
print(await client.async_list_feeds())
|
|
41
41
|
|
|
42
42
|
async def get_feed_fields(feed_id):
|
|
43
43
|
print(await client.async_get_feed_fields(feed_id))
|
|
@@ -47,7 +47,6 @@ loop = asyncio.get_event_loop()
|
|
|
47
47
|
loop.create_task(get_path("feed/list.json"))
|
|
48
48
|
loop.create_task(get_path("/user/getuuid.json"))
|
|
49
49
|
loop.create_task(list_feeds())
|
|
50
|
-
loop.create_task(list_feeds(uuid=True))
|
|
51
50
|
loop.create_task(get_feed_fields(1))
|
|
52
51
|
try:
|
|
53
52
|
loop.run_forever()
|
|
@@ -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.8",
|
|
10
10
|
author="Alexandre CUER",
|
|
11
11
|
author_email="alexandre.cuer@wanadoo.fr",
|
|
12
12
|
description="A python library to interrogate emoncms API",
|
|
@@ -67,7 +67,7 @@ async def test_timeout():
|
|
|
67
67
|
|
|
68
68
|
async def test_client_error():
|
|
69
69
|
"""Test when IP exists but client not running."""
|
|
70
|
-
client = EmoncmsClient("http://127.0.0.1:
|
|
70
|
+
client = EmoncmsClient("http://127.0.0.1:8087", API_KEY)
|
|
71
71
|
datas = await client.async_request("/feed/list.json")
|
|
72
72
|
assert not datas["success"]
|
|
73
73
|
assert "client error" in datas["message"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|