portune 0.1.20__py3-none-any.whl → 1.0.1__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 portune might be problematic. Click here for more details.

portune/portune.py CHANGED
@@ -32,6 +32,9 @@ from email.mime.application import MIMEApplication
32
32
  from typing import List, Dict, Tuple, Any, Optional, Union
33
33
 
34
34
  # Constants and global variables
35
+
36
+ # Use system ping command based on the OS
37
+ # as raw socket ICMP ping requires privileges
35
38
  OS = platform.system().lower()
36
39
  if OS == "windows":
37
40
  PING = "ping -n 1 -w {timeoutms} {ip}"
@@ -40,9 +43,9 @@ elif OS == "darwin": # macOS
40
43
  elif OS == "sunos": # SunOS
41
44
  PING = "ping {ip} {timeout}"
42
45
  elif OS == "aix": # IBM AIX
43
- PING = "ping -c 1 -w {timeout} {ip}"
44
- elif OS.startswith("hp-ux"): # HP-UX
45
- PING = "ping -n 1 -w {timeout} {ip}"
46
+ PING = "ping -c 1 -w {timeout} {ip}"
47
+ elif OS.startswith("hp-ux"): # HP-UX 11.11+
48
+ PING = "ping -n 1 -m {timeout} {ip}"
46
49
  else:
47
50
  PING = "ping -c 1 -W {timeout} {ip}"
48
51
 
@@ -818,21 +821,13 @@ def ping_hosts(hosts: List[Tuple[str, List[int], str]],
818
821
 
819
822
  # Use a lock for thread-safe progress updates
820
823
  lock = threading.Lock()
821
-
822
- def _update_progress(_):
823
- with lock:
824
- progress_bar.update(1)
825
-
824
+
826
825
  with ThreadPoolExecutor(max_workers=parallelism) as executor:
827
826
  future_to_host = {
828
827
  executor.submit(resolve_and_ping_host, hostname, timeout, noping): hostname
829
828
  for hostname, _, _ in hosts
830
829
  }
831
830
 
832
- # Add callback to update progress bar when each future completes
833
- for future in future_to_host:
834
- future.add_done_callback(_update_progress)
835
-
836
831
  for future in as_completed(future_to_host):
837
832
  orig_hostname = future_to_host[future]
838
833
  resolved_hostname, info = future.result()
@@ -841,6 +836,9 @@ def ping_hosts(hosts: List[Tuple[str, List[int], str]],
841
836
  if resolved_hostname != orig_hostname:
842
837
  # Keep resolved hostname in the info dict
843
838
  results[orig_hostname]['hostname'] = resolved_hostname
839
+ with lock:
840
+ # Update progress bar in a thread-safe manner
841
+ progress_bar.update(1)
844
842
 
845
843
  print(file=sys.stderr) # New line after progress bar
846
844
  return results
portune/version.py CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.1.20'
21
- __version_tuple__ = version_tuple = (0, 1, 20)
20
+ __version__ = version = '1.0.1'
21
+ __version_tuple__ = version_tuple = (1, 0, 1)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: portune
3
- Version: 0.1.20
3
+ Version: 1.0.1
4
4
  Summary: Simple Python HTTP Exec Server
5
5
  Author: Franck Jouvanceau
6
6
  Maintainer: Franck Jouvanceau
@@ -0,0 +1,9 @@
1
+ portune/__init__.py,sha256=RfXuNfHBqfRt_z4IukwN1a0oeCXahuMOO8_eBt4T8NM,58
2
+ portune/portune.py,sha256=JLpRM5ag8FgM0xxflob95lLbsBi7lW-Hxem5UAuGyA8,67736
3
+ portune/version.py,sha256=2Cl9kcQGg7NiH_eHRcv8wDYSW0X4uS5J0mGdZFO9-h0,511
4
+ portune-1.0.1.dist-info/licenses/LICENSE,sha256=gRJf0JPT_wsZJsUGlWPTS8Vypfl9vQ1qjp6sNbKykuA,1064
5
+ portune-1.0.1.dist-info/METADATA,sha256=tIxYl0yT_Fooci1JTLhz_eGu-UIVoTcpqFbWpSK2Qso,2377
6
+ portune-1.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
+ portune-1.0.1.dist-info/entry_points.txt,sha256=6j7jAf5fOZrLPbVIs3z92R1tT891WyY9YxQ6OVnPKG0,80
8
+ portune-1.0.1.dist-info/top_level.txt,sha256=CITDikHhRKAsSOGmNJzD-xSp6D5iBhSr9ZS1qy8-SL0,8
9
+ portune-1.0.1.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- portune/__init__.py,sha256=RfXuNfHBqfRt_z4IukwN1a0oeCXahuMOO8_eBt4T8NM,58
2
- portune/portune.py,sha256=GwTb4SmxdVvLvMqAHdBmbZUDiWcWT9k0rxsXG-n0VsU,67776
3
- portune/version.py,sha256=HrX7HW5_qgG2kKtggMCOAOnIAM_IUpfjsr4EaS77COI,513
4
- portune-0.1.20.dist-info/licenses/LICENSE,sha256=gRJf0JPT_wsZJsUGlWPTS8Vypfl9vQ1qjp6sNbKykuA,1064
5
- portune-0.1.20.dist-info/METADATA,sha256=Yij34H8N8a-HCt08tzcaoofm5wcXe3HVQyaFh7XneDA,2378
6
- portune-0.1.20.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- portune-0.1.20.dist-info/entry_points.txt,sha256=6j7jAf5fOZrLPbVIs3z92R1tT891WyY9YxQ6OVnPKG0,80
8
- portune-0.1.20.dist-info/top_level.txt,sha256=CITDikHhRKAsSOGmNJzD-xSp6D5iBhSr9ZS1qy8-SL0,8
9
- portune-0.1.20.dist-info/RECORD,,