pyemoncms 0.0.8__tar.gz → 0.1.0__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: pyemoncms
3
- Version: 0.0.8
3
+ Version: 0.1.0
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
@@ -64,8 +64,7 @@ async def main():
64
64
  """fetches somes datas in emoncms"""
65
65
  async with EmoncmsClient(url, key, request_timeout=1) as client:
66
66
  client.logger.setLevel("DEBUG")
67
- print(await client.async_request("/feed/list.json"))
68
- print(await client.async_request("/user/getuuid.json"))
67
+ print(await client.async_get_uuid())
69
68
  print(await client.async_list_feeds())
70
69
  print(await client.async_get_feed_fields(1))
71
70
 
@@ -48,8 +48,7 @@ async def main():
48
48
  """fetches somes datas in emoncms"""
49
49
  async with EmoncmsClient(url, key, request_timeout=1) as client:
50
50
  client.logger.setLevel("DEBUG")
51
- print(await client.async_request("/feed/list.json"))
52
- print(await client.async_request("/user/getuuid.json"))
51
+ print(await client.async_get_uuid())
53
52
  print(await client.async_list_feeds())
54
53
  print(await client.async_get_feed_fields(1))
55
54
 
@@ -76,13 +76,6 @@ class EmoncmsClient:
76
76
  data[SUCCESS_KEY] = True
77
77
  json_response = await response.json()
78
78
  data[MESSAGE_KEY] = json_response
79
- if json_response is False:
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)
86
79
  else:
87
80
  message = f"error {response.status}"
88
81
  if response.status in HTTP_STATUS:
@@ -91,11 +84,29 @@ class EmoncmsClient:
91
84
  self.logger.error(message)
92
85
  return data
93
86
 
94
- async def async_list_feeds(self) -> list[dict[str, Any]] | None:
95
- """Request emoncms feeds list.
96
-
97
- return a uuid per feed if available
87
+ async def async_get_uuid(self) -> str | None:
88
+ """Return the unique identifier or None.
89
+
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
+ first uuid version of emoncms is 11.5.7
98
95
  """
96
+ result = await self.async_request('/user/getuuid.json')
97
+ if result[SUCCESS_KEY]:
98
+ json_response = result[MESSAGE_KEY]
99
+ if json_response is False:
100
+ return None
101
+ if json_response[SUCCESS_KEY]:
102
+ return json_response[MESSAGE_KEY]
103
+ message = json_response[MESSAGE_KEY]
104
+ message = f"{message} : {self.url}"
105
+ self.logger.warning(message)
106
+ return None
107
+
108
+ async def async_list_feeds(self) -> list[dict[str, Any]] | None:
109
+ """Request emoncms feeds list."""
99
110
  feed_data = await self.async_request("/feed/list.json")
100
111
  if feed_data[SUCCESS_KEY]:
101
112
  return feed_data[MESSAGE_KEY]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyemoncms
3
- Version: 0.0.8
3
+ Version: 0.1.0
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
@@ -64,8 +64,7 @@ async def main():
64
64
  """fetches somes datas in emoncms"""
65
65
  async with EmoncmsClient(url, key, request_timeout=1) as client:
66
66
  client.logger.setLevel("DEBUG")
67
- print(await client.async_request("/feed/list.json"))
68
- print(await client.async_request("/user/getuuid.json"))
67
+ print(await client.async_get_uuid())
69
68
  print(await client.async_list_feeds())
70
69
  print(await client.async_get_feed_fields(1))
71
70
 
@@ -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.8",
9
+ version="0.1.0",
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