portune 0.1.20__tar.gz → 1.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.
Potentially problematic release.
This version of portune might be problematic. Click here for more details.
- {portune-0.1.20/portune.egg-info → portune-1.0.1}/PKG-INFO +1 -1
- {portune-0.1.20 → portune-1.0.1}/portune/portune.py +10 -12
- {portune-0.1.20 → portune-1.0.1}/portune/version.py +2 -2
- {portune-0.1.20 → portune-1.0.1/portune.egg-info}/PKG-INFO +1 -1
- {portune-0.1.20 → portune-1.0.1}/.github/workflows/python-publish.yml +0 -0
- {portune-0.1.20 → portune-1.0.1}/.gitignore +0 -0
- {portune-0.1.20 → portune-1.0.1}/LICENSE +0 -0
- {portune-0.1.20 → portune-1.0.1}/README.md +0 -0
- {portune-0.1.20 → portune-1.0.1}/portune/__init__.py +0 -0
- {portune-0.1.20 → portune-1.0.1}/portune.egg-info/SOURCES.txt +0 -0
- {portune-0.1.20 → portune-1.0.1}/portune.egg-info/dependency_links.txt +0 -0
- {portune-0.1.20 → portune-1.0.1}/portune.egg-info/entry_points.txt +0 -0
- {portune-0.1.20 → portune-1.0.1}/portune.egg-info/top_level.txt +0 -0
- {portune-0.1.20 → portune-1.0.1}/pyproject.toml +0 -0
- {portune-0.1.20 → portune-1.0.1}/setup.cfg +0 -0
|
@@ -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
|
|
44
|
-
elif OS.startswith("hp-ux"): # HP-UX
|
|
45
|
-
PING = "ping -n 1 -
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|