tagreader 5.5.0__tar.gz → 6.0.1__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: tagreader
3
- Version: 5.5.0
3
+ Version: 6.0.1
4
4
  Summary: Tagreader is a Python package for reading trend data from the OSIsoft PI and Aspen Infoplus.21 IMS systems.
5
5
  Home-page: https://github.com/equinor/tagreader-python
6
6
  License: MIT
@@ -29,7 +29,7 @@ Provides-Extra: notebooks
29
29
  Requires-Dist: certifi (>=2024.7.4,<2025.0.0)
30
30
  Requires-Dist: diskcache (>=5.6.1,<6.0.0)
31
31
  Requires-Dist: matplotlib (>=3.7.0,<4.0.0) ; extra == "notebooks"
32
- Requires-Dist: msal-bearer (>=0.2.1,<1.1.0)
32
+ Requires-Dist: msal-bearer (>=0.2.1,<1.2.0)
33
33
  Requires-Dist: notebook (>=7.2.0,<8.0.0) ; extra == "notebooks"
34
34
  Requires-Dist: pandas (>=1)
35
35
  Requires-Dist: pycryptodome (>=3.20.0,<4.0.0)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "tagreader"
3
- version = "5.5.0"
3
+ version = "6.0.1"
4
4
  description = "Tagreader is a Python package for reading trend data from the OSIsoft PI and Aspen Infoplus.21 IMS systems."
5
5
  authors = ["Einar S. Idsø <eiids@equinor.com>", "Morten Dæhli Aslesen <masl@equinor.com"]
6
6
  license = "MIT"
@@ -33,7 +33,7 @@ pandas = ">=1"
33
33
  certifi = "^2024.7.4"
34
34
  requests = "^2"
35
35
  requests-kerberos = "^0"
36
- msal-bearer = ">=0.2.1,<1.1.0"
36
+ msal-bearer = ">=0.2.1,<1.2.0"
37
37
  notebook = { version = "^7.2.0", optional = true }
38
38
  matplotlib = { version = "^3.7.0", optional = true }
39
39
  diskcache = "^5.6.1"
@@ -19,7 +19,7 @@ from urllib3.exceptions import InsecureRequestWarning
19
19
 
20
20
  from tagreader.cache import BucketCache, SmartCache
21
21
  from tagreader.logger import logger
22
- from tagreader.utils import ReaderType, is_mac, is_windows, urljoin
22
+ from tagreader.utils import IMSType, ReaderType, is_mac, is_windows, urljoin
23
23
 
24
24
 
25
25
  class MD4:
@@ -38,11 +38,16 @@ class MD4:
38
38
  return self._hash_obj.hexdigest()
39
39
 
40
40
 
41
- def patched_hashlib_new(name, data=b""):
41
+ def patched_hashlib_new(name, data=b"", usedforsecurity=True):
42
42
  if name.lower() == "md4":
43
43
  return MD4(data)
44
44
  else:
45
- return hashlib_new_method(name, data)
45
+ # Try / Catch easier than detecting python version
46
+ try:
47
+ return hashlib_new_method(name, data=data, usedforsecurity=usedforsecurity)
48
+ except TypeError:
49
+ # Required for python 3.8
50
+ return hashlib_new_method(name, data=data)
46
51
 
47
52
 
48
53
  # Monkey-patch md4 in hashlib.new due to missing support for md4 in later releases of Python:
@@ -144,6 +149,33 @@ def list_piwebapi_sources(
144
149
  logger.error(f"Could not decode JSON response: {e}")
145
150
 
146
151
 
152
+ def get_piwebapi_source_to_webid_dict(
153
+ url: Optional[str] = None,
154
+ auth: Optional[Any] = None,
155
+ verify_ssl: Optional[bool] = True,
156
+ ) -> List[str]:
157
+ if url is None:
158
+ url = get_url_pi()
159
+
160
+ if auth is None:
161
+ auth = get_auth_pi()
162
+
163
+ if verify_ssl is None:
164
+ verify_ssl = get_verify_ssl()
165
+
166
+ if verify_ssl is False:
167
+ urllib3.disable_warnings(InsecureRequestWarning)
168
+
169
+ url_ = urljoin(url, "dataservers")
170
+ res = requests.get(url_, auth=auth, verify=verify_ssl)
171
+
172
+ res.raise_for_status()
173
+ try:
174
+ return {item["Name"]: item["WebId"] for item in res.json()["Items"]}
175
+ except JSONDecodeError as e:
176
+ logger.error(f"Could not decode JSON response: {e}")
177
+
178
+
147
179
  class BaseHandlerWeb(ABC):
148
180
  def __init__(
149
181
  self,
@@ -741,11 +773,10 @@ class PIHandlerWeb(BaseHandlerWeb):
741
773
  )
742
774
 
743
775
  @staticmethod
744
- def generate_search_query(
776
+ def generate_search_params(
745
777
  tag: Optional[str],
746
778
  desc: Optional[str],
747
779
  datasource: Optional[str],
748
- max: Optional[int] = 100,
749
780
  ) -> Dict[str, str]:
750
781
  q = []
751
782
  if tag is not None:
@@ -753,10 +784,12 @@ class PIHandlerWeb(BaseHandlerWeb):
753
784
  if desc is not None:
754
785
  q.extend([f"description:{PIHandlerWeb.escape(desc)}"])
755
786
  query = " AND ".join(q)
756
- params = {"q": f"{query}"}
787
+ params = {"query": f"{query}"}
757
788
 
758
789
  if datasource is not None:
759
- params["scope"] = f"pi:{datasource}"
790
+ params["dataserverwebid"] = (
791
+ f"{get_piwebapi_source_to_webid_dict()[datasource]}"
792
+ )
760
793
 
761
794
  return params
762
795
 
@@ -866,23 +899,23 @@ class PIHandlerWeb(BaseHandlerWeb):
866
899
  timeout: Optional[int] = None,
867
900
  return_desc: bool = True,
868
901
  ) -> Union[List[Tuple[str, str]], List[str]]:
869
- params = self.generate_search_query(
902
+ params = self.generate_search_params(
870
903
  tag=tag, desc=desc, datasource=self.datasource
871
904
  )
872
- url = urljoin(self.base_url, "search", "query")
905
+ url = urljoin(self.base_url, "points", "search")
873
906
  done = False
874
907
  ret = []
875
908
  while not done:
876
909
  data = self.fetch(url, params=params, timeout=timeout)
877
910
 
878
911
  for item in data["Items"]:
879
- description = item["Description"] if "Description" in item else ""
912
+ description = item["Descriptor"] if "Descriptor" in item else ""
880
913
  ret.append((item["Name"], description))
881
- next_start = int(data["Links"]["Next"].split("=")[-1])
882
- if int(data["Links"]["Last"].split("=")[-1]) >= next_start:
883
- params["start"] = next_start # noqa
884
- else:
885
- done = True
914
+ # next_start = int(data["Links"]["Next"].split("=")[-1])
915
+ # if int(data["Links"]["Last"].split("=")[-1]) >= next_start:
916
+ # params["start"] = next_start # noqa
917
+ # else:
918
+ done = True
886
919
 
887
920
  if not return_desc:
888
921
  ret = [x[0] for x in ret]
@@ -922,17 +955,12 @@ class PIHandlerWeb(BaseHandlerWeb):
922
955
  if self.web_id_cache and tag in self.web_id_cache:
923
956
  return self.web_id_cache[tag]
924
957
 
925
- params = self.generate_search_query(
958
+ params = self.generate_search_params(
926
959
  tag=tag, datasource=self.datasource, desc=None
927
960
  )
928
- params["fields"] = "name;webid"
929
- url = urljoin(self.base_url, "search", "query")
961
+ url = urljoin(self.base_url, "points", "search")
930
962
  data = self.fetch(url, params=params)
931
963
 
932
- if len(data["Errors"]) > 0:
933
- msg = f"Received error from server when searching for WebId for {tag}: {data['Errors']}"
934
- raise ValueError(msg)
935
-
936
964
  if len(data["Items"]) > 1:
937
965
  # Compare elements and if same, return the first
938
966
  first = data["Items"][0]
File without changes
File without changes
File without changes
File without changes
File without changes