ihcsdk 2.8.6__tar.gz → 2.8.7__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: ihcsdk
3
- Version: 2.8.6
3
+ Version: 2.8.7
4
4
  Summary: IHC Python SDK
5
5
  Home-page: https://github.com/dingusdk/PythonIhcSdk
6
6
  Author: Jens Nielsen
@@ -1,6 +1,7 @@
1
1
  """
2
2
  Implements the connection to the ihc controller
3
3
  """
4
+
4
5
  # pylint: disable=bare-except
5
6
  import base64
6
7
  import datetime
@@ -112,7 +113,7 @@ class IHCSoapClient:
112
113
  """Get the ihc project per segments.
113
114
  Param: info .. reuse existing project info. If not provided, the get_project_info() is called internally.
114
115
  """
115
- if info == None:
116
+ if info is None:
116
117
  info = self.get_project_info()
117
118
  if info:
118
119
  projectMajor = info.get("projectMajorRevision", 0)
@@ -355,8 +356,8 @@ class IHCSoapClient:
355
356
  "WSIntegerValue": lambda v: int(
356
357
  v.find("./ns2:integer", IHCSoapClient.ihcns).text
357
358
  ),
358
- "WSFloatingPointValue": lambda v: round(
359
- float( v.find("./ns2:floatingPointValue", IHCSoapClient.ihcns).text),2
359
+ "WSFloatingPointValue": lambda v: round(
360
+ float(v.find("./ns2:floatingPointValue", IHCSoapClient.ihcns).text), 2
360
361
  ),
361
362
  "WSEnumValue": lambda v: v.find("./ns2:enumName", IHCSoapClient.ihcns).text,
362
363
  "WSTimerValue": lambda v: int(
@@ -476,7 +477,7 @@ class IHCSoapClient:
476
477
  if change_list is False:
477
478
  return False
478
479
  last_changes = {}
479
- for (id, value) in change_list:
480
+ for id, value in change_list:
480
481
  last_changes[id] = value
481
482
  return last_changes
482
483
 
@@ -2,17 +2,18 @@
2
2
  Wraps the ihcclient in a more user friendly interface to handle lost connection
3
3
  Notify thread to handle change notifications
4
4
  """
5
+
5
6
  # pylint: disable=invalid-name, bare-except, too-many-instance-attributes
6
7
  from datetime import datetime, timedelta
7
8
  import logging
8
9
  import requests
9
- import sys
10
10
  import threading
11
11
  import time
12
12
  from ihcsdk.ihcclient import IHCSoapClient, IHCSTATE_READY
13
13
 
14
14
  _LOGGER = logging.getLogger(__name__)
15
15
 
16
+
16
17
  class IHCController:
17
18
  """
18
19
  Implements the notification thread and
@@ -49,17 +50,17 @@ class IHCController:
49
50
  return False
50
51
  return True
51
52
  except requests.exceptions.RequestException as exp:
52
- _LOGGER.warning( "is_ihc_controller %s",exp)
53
+ _LOGGER.warning("is_ihc_controller %s", exp)
53
54
  return False
54
55
 
55
56
  def authenticate(self) -> bool:
56
57
  """Authenticate and enable the registered notifications"""
57
58
  with IHCController._mutex:
58
- _LOGGER.debug( "Authenticating login on ihc controller")
59
+ _LOGGER.debug("Authenticating login on ihc controller")
59
60
  if not self.client.authenticate(self._username, self._password):
60
- _LOGGER.debug( "Authentication failed")
61
+ _LOGGER.debug("Authentication failed")
61
62
  return False
62
- _LOGGER.debug( "Authentication was successful")
63
+ _LOGGER.debug("Authentication was successful")
63
64
  if self._ihcevents:
64
65
  self.client.enable_runtime_notifications(self._ihcevents.keys())
65
66
  return True
@@ -131,7 +132,7 @@ class IHCController:
131
132
  self.re_authenticate()
132
133
  return self.client.set_runtime_value_time(ihcid, hours, minutes, seconds)
133
134
 
134
- def get_project(self) -> str:
135
+ def get_project(self, insegments: bool = True) -> str:
135
136
  """Get the ihc project and make sure controller is ready before"""
136
137
  with IHCController._mutex:
137
138
  if self._project is None:
@@ -139,7 +140,10 @@ class IHCController:
139
140
  ready = self.client.wait_for_state_change(IHCSTATE_READY, 10)
140
141
  if ready != IHCSTATE_READY:
141
142
  return None
142
- self._project = self.client.get_project_in_segments()
143
+ if insegments:
144
+ self._project = self.client.get_project_in_segments()
145
+ else:
146
+ self._project = self.client.get_project()
143
147
  return self._project
144
148
 
145
149
  def add_notify_event(self, resourceid: int, callback, delayed=False):
@@ -165,7 +169,7 @@ class IHCController:
165
169
 
166
170
  def _notify_fn(self):
167
171
  """The notify thread function."""
168
- _LOGGER.debug( "Starting notify thread")
172
+ _LOGGER.debug("Starting notify thread")
169
173
  while self._notifyrunning:
170
174
  try:
171
175
  with IHCController._mutex:
@@ -178,7 +182,7 @@ class IHCController:
178
182
  if changes is False:
179
183
  self.re_authenticate(True)
180
184
  continue
181
- for (ihcid, value) in changes:
185
+ for ihcid, value in changes:
182
186
  if ihcid in self._ihcevents:
183
187
  for callback in self._ihcevents[ihcid]:
184
188
  if (
@@ -188,7 +192,7 @@ class IHCController:
188
192
  callback(ihcid, value)
189
193
  self._ihcvalues[ihcid] = value
190
194
  except Exception as exp:
191
- _LOGGER.error( "Exception in notify thread %s",exp)
195
+ _LOGGER.error("Exception in notify thread %s", exp)
192
196
  self.re_authenticate(True)
193
197
 
194
198
  def re_authenticate(self, notify: bool = False) -> bool:
@@ -200,10 +204,12 @@ class IHCController:
200
204
  """
201
205
  timeout = datetime.now() + timedelta(seconds=self.reauthenticatetimeout)
202
206
  while True:
203
- _LOGGER.debug( "Reauthenticating login on ihc controller")
207
+ _LOGGER.debug("Reauthenticating login on ihc controller")
204
208
  if self.authenticate():
205
209
  return True
206
- _LOGGER.debug( "Authenticate failed - Reauthenticating login on ihc controller in 10 sec")
210
+ _LOGGER.debug(
211
+ "Authenticate failed - Reauthenticating login on ihc controller in 10 sec"
212
+ )
207
213
 
208
214
  # if called from the notify and notify a cancled we do not want to retry
209
215
  if notify:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ihcsdk
3
- Version: 2.8.6
3
+ Version: 2.8.7
4
4
  Summary: IHC Python SDK
5
5
  Home-page: https://github.com/dingusdk/PythonIhcSdk
6
6
  Author: Jens Nielsen
@@ -1,6 +1,9 @@
1
1
  [metadata]
2
2
  description-file = readme.md
3
3
 
4
+ [flake8]
5
+ max-line-length = 120
6
+
4
7
  [egg_info]
5
8
  tag_build =
6
9
  tag_date = 0
@@ -1,11 +1,12 @@
1
1
  """
2
2
  Setup of the ihcsdk module
3
3
  """
4
+
4
5
  from setuptools import setup
5
6
 
6
7
  setup(
7
8
  name="ihcsdk",
8
- version="2.8.6",
9
+ version="2.8.7",
9
10
  description="IHC Python SDK",
10
11
  long_description=(
11
12
  "SDK for connection to the LK IHC Controller. "
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes