labfreed 0.2.7__py3-none-any.whl → 0.2.8a0__py3-none-any.whl

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.

Potentially problematic release.


This version of labfreed might be problematic. Click here for more details.

labfreed/__init__.py CHANGED
@@ -2,7 +2,7 @@
2
2
  Python implementation of LabFREED building blocks
3
3
  '''
4
4
 
5
- __version__ = "0.2.7"
5
+ __version__ = "0.2.8a0"
6
6
 
7
7
  from labfreed.pac_id import * # noqa: F403
8
8
  from labfreed.pac_cat import * # noqa: F403
@@ -2,10 +2,11 @@
2
2
  from enum import auto, Enum
3
3
 
4
4
  from pydantic import Field
5
- from requests import RequestException, get, head
5
+ import requests
6
6
 
7
7
  from concurrent.futures import ThreadPoolExecutor, as_completed
8
8
 
9
+ import requests
9
10
  from rich import print
10
11
  from rich.table import Table
11
12
 
@@ -24,15 +25,17 @@ class Service(LabFREED_BaseModel):
24
25
  url:str
25
26
  status:ServiceStatus =ServiceStatus.UNKNOWN
26
27
 
27
- def check_service_status(self):
28
+ def check_service_status(self, session:requests.Session = None):
28
29
  '''Checks the availability of the service.'''
30
+ s = session or requests
31
+
29
32
  try:
30
- r = head(self.url, timeout=2)
33
+ r = s.head(self.url, timeout=2)
31
34
  if r.status_code < 400:
32
35
  self.status = ServiceStatus.ACTIVE
33
36
  else:
34
37
  self.status = ServiceStatus.INACTIVE
35
- except RequestException as e:
38
+ except requests.RequestException as e:
36
39
  print(f"Request failed: {e}")
37
40
  self.status = ServiceStatus.INACTIVE
38
41
 
@@ -42,12 +45,12 @@ class ServiceGroup(LabFREED_BaseModel):
42
45
  origin: str = ""
43
46
  services: list[Service] = Field(default_factory=list)
44
47
 
45
- def update_states(self):
48
+ def update_states(self, session:requests.Session = None):
46
49
  '''Triggers each service to check if the url can be reached'''
47
50
  if not _has_internet_connection():
48
51
  raise ConnectionError("No Internet Connection")
49
52
  with ThreadPoolExecutor(max_workers=10) as executor:
50
- futures = [executor.submit(s.check_service_status) for s in self.services]
53
+ futures = [executor.submit(s.check_service_status, session=session) for s in self.services]
51
54
  for _ in as_completed(futures):
52
55
  pass # just wait for all to finish
53
56
 
@@ -74,7 +77,7 @@ class ServiceGroup(LabFREED_BaseModel):
74
77
 
75
78
  def _has_internet_connection():
76
79
  try:
77
- get("https://1.1.1.1", timeout=3)
80
+ requests.get("https://1.1.1.1", timeout=3)
78
81
  return True
79
- except RequestException:
82
+ except requests.RequestException:
80
83
  return False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: labfreed
3
- Version: 0.2.7
3
+ Version: 0.2.8a0
4
4
  Summary: Python implementation of LabFREED building blocks
5
5
  Author-email: Reto Thürer <thuerer.r@buchi.com>
6
6
  Requires-Python: >=3.11
@@ -1,4 +1,4 @@
1
- labfreed/__init__.py,sha256=cdoNTE10KG03M6MTCkgCbySTOajvy8HehAEgYvLJKmY,336
1
+ labfreed/__init__.py,sha256=T85RGoqlJ09bUZIMDx5Nj1VFwW3rGCSQER_mX5m2gYU,338
2
2
  labfreed/labfreed_infrastructure.py,sha256=EPDSCaGxWakAoPpHyc6ltf-pOuKyS5829lj_EG6wa74,10072
3
3
  labfreed/pac_cat/__init__.py,sha256=KNPtQzBD1XVohvG_ucOs7RJj-oi6biUTGB1k-T2o6pk,568
4
4
  labfreed/pac_cat/category_base.py,sha256=lFQNiTUukyhWdaSCAI7CZxLtj6kNtnBCE4UsePwsGqE,1801
@@ -15,7 +15,7 @@ labfreed/pac_id_resolver/cit_common.py,sha256=xEkSSumj_IYgnXn3yKvoTBbgExnIfPY7E-
15
15
  labfreed/pac_id_resolver/cit_v1.py,sha256=W7UCO0Gm0w09FSo_USFB1-V2tl3iErDxoe2OHh4fkvc,9383
16
16
  labfreed/pac_id_resolver/cit_v2.py,sha256=wM1wf8UWbepatWNgkJ3l0l-HNJHqsqqPMql5k8fkVso,12127
17
17
  labfreed/pac_id_resolver/resolver.py,sha256=UfSxRwTTjSgL4VoHfsQiaGTj3tt8dTDDd2wVcbr2Xvc,2817
18
- labfreed/pac_id_resolver/services.py,sha256=TPoH6YlSwa0hmawHpOiMwIpBAinhoRhMSoexop0YscI,2462
18
+ labfreed/pac_id_resolver/services.py,sha256=fCt-CBUKoEm4-SZqlkt94Or-BnmJ91Q5kZO9ydPw55s,2609
19
19
  labfreed/qr/__init__.py,sha256=fdKwP6W2Js--yMbBUdn-g_2uq2VqPpfQJeDLHsMDO-Y,61
20
20
  labfreed/qr/generate_qr.py,sha256=mSt-U872O3ReHB_UdS-MzYu0wRgdlKcAOEfTxg5CLRk,16616
21
21
  labfreed/trex/__init__.py,sha256=r0MYrGk_XxsqSKo9c2i9jRXApTDeTZD8QRXcRpkOVXY,428
@@ -39,7 +39,7 @@ labfreed/well_known_keys/labfreed/well_known_keys.py,sha256=nqk66kHdSwJTJfMKlP-x
39
39
  labfreed/well_known_keys/unece/UneceUnits.json,sha256=kwfQSp_nTuWbADfBBgqTWrvPl6XtM5SedEVLbMJrM7M,898953
40
40
  labfreed/well_known_keys/unece/__init__.py,sha256=MSP9lmjg9_D9iqG9Yq2_ajYfQSNS9wIT7FXA1c--59M,122
41
41
  labfreed/well_known_keys/unece/unece_units.py,sha256=gNDQk6KGl-nGMf9Ycq_fQ8P2xxKITgLkcQWPd4H49gI,1630
42
- labfreed-0.2.7.dist-info/licenses/LICENSE,sha256=gHFOv9FRKHxO8cInP3YXyPoJnuNeqrvcHjaE_wPSsQ8,1100
43
- labfreed-0.2.7.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
44
- labfreed-0.2.7.dist-info/METADATA,sha256=LgChVG_EYO1fXu-FLEfydV_mZvDgmylj3-hxnREkE9g,18795
45
- labfreed-0.2.7.dist-info/RECORD,,
42
+ labfreed-0.2.8a0.dist-info/licenses/LICENSE,sha256=gHFOv9FRKHxO8cInP3YXyPoJnuNeqrvcHjaE_wPSsQ8,1100
43
+ labfreed-0.2.8a0.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
44
+ labfreed-0.2.8a0.dist-info/METADATA,sha256=KvCNBK689qFYtUn9K2Q3FGM_IHXYEJoSluP3futDVRU,18797
45
+ labfreed-0.2.8a0.dist-info/RECORD,,