pyemoncms 0.1.0__tar.gz → 0.1.2__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.1.0 → pyemoncms-0.1.2}/PKG-INFO +13 -2
- {pyemoncms-0.1.0 → pyemoncms-0.1.2}/pyemoncms/emoncms_client.py +34 -6
- {pyemoncms-0.1.0 → pyemoncms-0.1.2}/pyemoncms.egg-info/PKG-INFO +13 -2
- {pyemoncms-0.1.0 → pyemoncms-0.1.2}/setup.py +1 -1
- {pyemoncms-0.1.0 → pyemoncms-0.1.2}/LICENSE +0 -0
- {pyemoncms-0.1.0 → pyemoncms-0.1.2}/README.md +0 -0
- {pyemoncms-0.1.0 → pyemoncms-0.1.2}/pyemoncms/__init__.py +0 -0
- {pyemoncms-0.1.0 → pyemoncms-0.1.2}/pyemoncms.egg-info/SOURCES.txt +0 -0
- {pyemoncms-0.1.0 → pyemoncms-0.1.2}/pyemoncms.egg-info/dependency_links.txt +0 -0
- {pyemoncms-0.1.0 → pyemoncms-0.1.2}/pyemoncms.egg-info/requires.txt +0 -0
- {pyemoncms-0.1.0 → pyemoncms-0.1.2}/pyemoncms.egg-info/top_level.txt +0 -0
- {pyemoncms-0.1.0 → pyemoncms-0.1.2}/pyproject.toml +0 -0
- {pyemoncms-0.1.0 → pyemoncms-0.1.2}/setup.cfg +0 -0
- {pyemoncms-0.1.0 → pyemoncms-0.1.2}/tests/test_async_request.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: pyemoncms
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
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
|
|
@@ -13,6 +13,17 @@ Requires-Python: >=3.9
|
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
Requires-Dist: aiohttp
|
|
16
|
+
Dynamic: author
|
|
17
|
+
Dynamic: author-email
|
|
18
|
+
Dynamic: classifier
|
|
19
|
+
Dynamic: description
|
|
20
|
+
Dynamic: description-content-type
|
|
21
|
+
Dynamic: home-page
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
Dynamic: project-url
|
|
24
|
+
Dynamic: requires-dist
|
|
25
|
+
Dynamic: requires-python
|
|
26
|
+
Dynamic: summary
|
|
16
27
|
|
|
17
28
|
# pyemoncms
|
|
18
29
|
python library for emoncms API
|
|
@@ -14,8 +14,9 @@ so there is a type error if you search for a key in the response
|
|
|
14
14
|
|
|
15
15
|
import asyncio
|
|
16
16
|
from dataclasses import dataclass
|
|
17
|
+
import json
|
|
17
18
|
import logging
|
|
18
|
-
from typing import Any, TypeVar
|
|
19
|
+
from typing import Any, Dict, TypeVar, Optional
|
|
19
20
|
|
|
20
21
|
from aiohttp import ClientError, ClientSession
|
|
21
22
|
|
|
@@ -84,13 +85,40 @@ class EmoncmsClient:
|
|
|
84
85
|
self.logger.error(message)
|
|
85
86
|
return data
|
|
86
87
|
|
|
88
|
+
async def async_input_post(
|
|
89
|
+
self,
|
|
90
|
+
data: Dict[str, Any],
|
|
91
|
+
node: Optional[str] = None,
|
|
92
|
+
time: Optional[int] = None,
|
|
93
|
+
apikey: Optional[str] = None,
|
|
94
|
+
) -> bool:
|
|
95
|
+
"""Async post data to an emoncms input/node."""
|
|
96
|
+
if self.session is None:
|
|
97
|
+
self.session = ClientSession()
|
|
98
|
+
self._close_session = True
|
|
99
|
+
|
|
100
|
+
endpoint = f"{self.url.rstrip('/')}/input/post"
|
|
101
|
+
json_string = json.dumps(data)
|
|
102
|
+
|
|
103
|
+
effective_key = apikey if apikey is not None else self.api_key
|
|
104
|
+
if not effective_key:
|
|
105
|
+
raise ValueError("API key must be provided.")
|
|
106
|
+
|
|
107
|
+
params = {"apikey": effective_key, "json": json_string}
|
|
108
|
+
if node:
|
|
109
|
+
params["node"] = node
|
|
110
|
+
if time is not None:
|
|
111
|
+
params["time"] = str(time)
|
|
112
|
+
|
|
113
|
+
async with self.session.post(endpoint, params=params) as resp:
|
|
114
|
+
text = await resp.text()
|
|
115
|
+
if resp.status != 200:
|
|
116
|
+
raise RuntimeError(f"POST failed ({resp.status}): {text}")
|
|
117
|
+
return True
|
|
118
|
+
|
|
87
119
|
async def async_get_uuid(self) -> str | None:
|
|
88
120
|
"""Return the unique identifier or None.
|
|
89
121
|
|
|
90
|
-
drop a warning during migration process from a non uuid emoncms to a uuid one
|
|
91
|
-
|
|
92
|
-
this warns the user to do a database update
|
|
93
|
-
|
|
94
122
|
first uuid version of emoncms is 11.5.7
|
|
95
123
|
"""
|
|
96
124
|
result = await self.async_request('/user/getuuid.json')
|
|
@@ -102,7 +130,7 @@ class EmoncmsClient:
|
|
|
102
130
|
return json_response[MESSAGE_KEY]
|
|
103
131
|
message = json_response[MESSAGE_KEY]
|
|
104
132
|
message = f"{message} : {self.url}"
|
|
105
|
-
self.logger.
|
|
133
|
+
self.logger.debug(message)
|
|
106
134
|
return None
|
|
107
135
|
|
|
108
136
|
async def async_list_feeds(self) -> list[dict[str, Any]] | None:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: pyemoncms
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
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
|
|
@@ -13,6 +13,17 @@ Requires-Python: >=3.9
|
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
Requires-Dist: aiohttp
|
|
16
|
+
Dynamic: author
|
|
17
|
+
Dynamic: author-email
|
|
18
|
+
Dynamic: classifier
|
|
19
|
+
Dynamic: description
|
|
20
|
+
Dynamic: description-content-type
|
|
21
|
+
Dynamic: home-page
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
Dynamic: project-url
|
|
24
|
+
Dynamic: requires-dist
|
|
25
|
+
Dynamic: requires-python
|
|
26
|
+
Dynamic: summary
|
|
16
27
|
|
|
17
28
|
# pyemoncms
|
|
18
29
|
python library for emoncms API
|
|
@@ -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.1.
|
|
9
|
+
version="0.1.2",
|
|
10
10
|
author="Alexandre CUER",
|
|
11
11
|
author_email="alexandre.cuer@wanadoo.fr",
|
|
12
12
|
description="A python library to interrogate 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
|
|
File without changes
|
|
File without changes
|