tagreader 5.3.0__tar.gz → 5.5.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: tagreader
3
- Version: 5.3.0
3
+ Version: 5.5.0
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
@@ -26,11 +26,11 @@ Classifier: Topic :: Scientific/Engineering :: Interface Engine/Protocol Transla
26
26
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
27
  Classifier: Topic :: Utilities
28
28
  Provides-Extra: notebooks
29
- Requires-Dist: certifi (>=2023.7.22,<2024.0.0)
29
+ Requires-Dist: certifi (>=2024.7.4,<2025.0.0)
30
30
  Requires-Dist: diskcache (>=5.6.1,<6.0.0)
31
- Requires-Dist: matplotlib (>=3,<4) ; extra == "notebooks"
32
- Requires-Dist: msal-bearer (>=0.2.1,<0.3.0)
33
- Requires-Dist: notebook (>=7.0.3,<8.0.0) ; extra == "notebooks"
31
+ Requires-Dist: matplotlib (>=3.7.0,<4.0.0) ; extra == "notebooks"
32
+ Requires-Dist: msal-bearer (>=0.2.1,<1.1.0)
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)
36
36
  Requires-Dist: requests (>=2,<3)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "tagreader"
3
- version = "5.3.0"
3
+ version = "5.5.0"
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"
@@ -30,12 +30,12 @@ classifiers=[
30
30
  [tool.poetry.dependencies]
31
31
  python = "^3.8"
32
32
  pandas = ">=1"
33
- certifi = "^2023.7.22"
33
+ certifi = "^2024.7.4"
34
34
  requests = "^2"
35
35
  requests-kerberos = "^0"
36
- msal-bearer = "^0.2.1"
37
- notebook = { version = "^7.0.3", optional = true }
38
- matplotlib = { version = "^3", optional = true }
36
+ msal-bearer = ">=0.2.1,<1.1.0"
37
+ notebook = { version = "^7.2.0", optional = true }
38
+ matplotlib = { version = "^3.7.0", optional = true }
39
39
  diskcache = "^5.6.1"
40
40
  pycryptodome = "^3.20.0"
41
41
  requests-ntlm = ">=1.1,<=2.0"
@@ -43,7 +43,7 @@ requests-ntlm = ">=1.1,<=2.0"
43
43
 
44
44
  [tool.poetry.group.dev.dependencies]
45
45
  pre-commit = "^3"
46
- pytest = "^7"
46
+ pytest = ">=7,<9"
47
47
 
48
48
  [tool.poetry.extras]
49
49
  notebooks = ["notebook", "matplotlib"]
@@ -2,13 +2,13 @@ from tagreader.clients import IMSClient, list_sources
2
2
  from tagreader.utils import (
3
3
  IMSType,
4
4
  ReaderType,
5
- add_statoil_root_certificate,
5
+ add_equinor_root_certificate,
6
6
  is_equinor,
7
7
  is_mac,
8
8
  is_windows,
9
9
  )
10
10
 
11
11
  if is_equinor():
12
- add_statoil_root_certificate()
12
+ add_equinor_root_certificate()
13
13
 
14
14
  from tagreader.__version__ import version as __version__
@@ -129,11 +129,7 @@ class ReaderType(enum.IntEnum):
129
129
  SNAPSHOT = FINAL = LAST = enum.auto() # Last sampled value
130
130
 
131
131
 
132
- def add_statoil_root_certificate() -> bool:
133
- return add_equinor_root_certificate(True) and add_equinor_root_certificate(False)
134
-
135
-
136
- def add_equinor_root_certificate(get_equinor: bool = True) -> bool:
132
+ def add_equinor_root_certificate() -> bool:
137
133
  """
138
134
  This is a utility function for Equinor employees on Equinor managed machines.
139
135
 
@@ -152,15 +148,8 @@ def add_equinor_root_certificate(get_equinor: bool = True) -> bool:
152
148
 
153
149
  import certifi
154
150
 
155
- STATOIL_ROOT_PEM_HASH = "ce7bb185ab908d2fea28c7d097841d9d5bbf2c76"
156
151
  EQUINOR_root_PEM_HASH = "5A206332CE73CED1D44C8A99C4C43B7CEE03DF5F"
157
-
158
- if get_equinor:
159
- used_hash = EQUINOR_root_PEM_HASH.upper()
160
- ca_search = "Equinor Root CA"
161
- else:
162
- used_hash = STATOIL_ROOT_PEM_HASH.upper()
163
- ca_search = "Statoil Root CA"
152
+ ca_search = "Equinor Root CA"
164
153
 
165
154
  found = False
166
155
  der = None
@@ -172,7 +161,7 @@ def add_equinor_root_certificate(get_equinor: bool = True) -> bool:
172
161
  for cert in ssl.enum_certificates("CA"):
173
162
  der = cert[0]
174
163
  # deepcode ignore InsecureHash: <Only hashes to compare with known hash>
175
- if hashlib.sha1(der).hexdigest().upper() == used_hash:
164
+ if hashlib.sha1(der).hexdigest().upper() == EQUINOR_root_PEM_HASH:
176
165
  found = True
177
166
  logger.debug("CA certificate found!")
178
167
  break
@@ -182,11 +171,11 @@ def add_equinor_root_certificate(get_equinor: bool = True) -> bool:
182
171
  stdout=subprocess.PIPE,
183
172
  ).stdout
184
173
 
185
- if used_hash in str(macos_ca_certs).upper():
174
+ if EQUINOR_root_PEM_HASH in str(macos_ca_certs).upper():
186
175
  c = get_macos_equinor_certificates()
187
176
  for cert in c:
188
177
  # deepcode ignore InsecureHash: <Only hashes to compare with known hash>
189
- if hashlib.sha1(cert).hexdigest().upper() == used_hash:
178
+ if hashlib.sha1(cert).hexdigest().upper() == EQUINOR_root_PEM_HASH:
190
179
  der = cert
191
180
  found = True
192
181
  break
@@ -209,14 +198,11 @@ def add_equinor_root_certificate(get_equinor: bool = True) -> bool:
209
198
  return found
210
199
 
211
200
 
212
- def get_macos_equinor_certificates(get_equinor: bool = True):
201
+ def get_macos_equinor_certificates():
213
202
  import ssl
214
203
  import tempfile
215
204
 
216
- if get_equinor:
217
- ca_search = "Equinor Root CA"
218
- else:
219
- ca_search = "Statoil Root CA"
205
+ ca_search = "Equinor Root CA"
220
206
 
221
207
  ctx = ssl.create_default_context()
222
208
  macos_ca_certs = subprocess.run(
@@ -242,12 +242,13 @@ class AspenHandlerWeb(BaseHandlerWeb):
242
242
  tag: Optional[str],
243
243
  desc: Optional[str],
244
244
  datasource: Optional[str],
245
+ max: Optional[int] = 100000,
245
246
  ) -> Dict[str, Any]:
246
247
  if not datasource:
247
248
  raise ValueError("Data source is required argument")
248
249
  # Aspen Web API expects single space instead of consecutive spaces.
249
250
  tag = " ".join(tag.split())
250
- params = {"datasource": datasource, "tag": tag, "max": 100, "getTrendable": 0}
251
+ params = {"datasource": datasource, "tag": tag, "max": max, "getTrendable": 0}
251
252
  return params
252
253
 
253
254
  def generate_read_query(
@@ -450,7 +451,7 @@ class AspenHandlerWeb(BaseHandlerWeb):
450
451
  desc = desc.replace("*", ".*") if isinstance(desc, str) else None
451
452
 
452
453
  params = self.generate_search_query(
453
- tag=tag, desc=desc, datasource=self.datasource
454
+ tag=tag, desc=desc, datasource=self.datasource, max=100000
454
455
  )
455
456
  # Ensure space is encoded as "%20" instead of default "+" and leave asterisks
456
457
  # unencoded. Otherwise, searches for tags containing spaces break, as do wildcard
@@ -523,11 +524,13 @@ class AspenHandlerWeb(BaseHandlerWeb):
523
524
  def _get_tag_description(self, tag: str):
524
525
  query = self.generate_get_description_query(tag)
525
526
  url = urljoin(self.base_url, "TagInfo")
526
- data = self.fetch(url, params=query)
527
527
  try:
528
+ data = self.fetch(url, params=query)
528
529
  desc = data["data"]["tags"][0]["attrData"][0]["samples"][0]["v"]
529
530
  except KeyError:
530
531
  desc = ""
532
+ except JSONDecodeError:
533
+ desc = ""
531
534
  return desc
532
535
 
533
536
  def read_tag(
@@ -742,6 +745,7 @@ class PIHandlerWeb(BaseHandlerWeb):
742
745
  tag: Optional[str],
743
746
  desc: Optional[str],
744
747
  datasource: Optional[str],
748
+ max: Optional[int] = 100,
745
749
  ) -> Dict[str, str]:
746
750
  q = []
747
751
  if tag is not None:
File without changes
File without changes
File without changes
File without changes