multiSSH3 5.47__tar.gz → 5.48__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 multiSSH3 might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: multiSSH3
3
- Version: 5.47
3
+ Version: 5.48
4
4
  Summary: Run commands on multiple hosts via SSH
5
5
  Home-page: https://github.com/yufei-pan/multiSSH3
6
6
  Author: Yufei Pan
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: multiSSH3
3
- Version: 5.47
3
+ Version: 5.48
4
4
  Summary: Run commands on multiple hosts via SSH
5
5
  Home-page: https://github.com/yufei-pan/multiSSH3
6
6
  Author: Yufei Pan
@@ -34,6 +34,7 @@ import uuid
34
34
  import tempfile
35
35
  import math
36
36
  from itertools import count
37
+ import queue
37
38
 
38
39
  try:
39
40
  # Check if functiools.cache is available
@@ -46,7 +47,7 @@ except AttributeError:
46
47
  # If neither is available, use a dummy decorator
47
48
  def cache_decorator(func):
48
49
  return func
49
- version = '5.47'
50
+ version = '5.48'
50
51
  VERSION = version
51
52
  COMMIT_DATE = '2025-01-30'
52
53
 
@@ -90,31 +91,68 @@ def signal_handler(sig, frame):
90
91
  os.system(f'pkill -ef {os.path.basename(__file__)}')
91
92
  sys.exit(0)
92
93
 
94
+ # def input_with_timeout_and_countdown(timeout, prompt='Please enter your selection'):
95
+ # """
96
+ # Read an input from the user with a timeout and a countdown.
97
+
98
+ # Parameters:
99
+ # timeout (int): The timeout value in seconds.
100
+ # prompt (str): The prompt message to display to the user. Default is 'Please enter your selection'.
101
+
102
+ # Returns:
103
+ # str or None: The user input if received within the timeout, or None if no input is received.
104
+ # """
105
+ # import select
106
+ # # Print the initial prompt with the countdown
107
+ # eprint(f"{prompt} [{timeout}s]: ", end='', flush=True)
108
+ # # Loop until the timeout
109
+ # for remaining in range(timeout, 0, -1):
110
+ # # If there is an input, return it
111
+ # # this only works on linux
112
+ # if sys.stdin in select.select([sys.stdin], [], [], 0)[0]:
113
+ # return input().strip()
114
+ # # Print the remaining time
115
+ # eprint(f"\r{prompt} [{remaining}s]: ", end='', flush=True)
116
+ # # Wait a second
117
+ # time.sleep(1)
118
+ # # If there is no input, return None
119
+ # return None
120
+
93
121
  def input_with_timeout_and_countdown(timeout, prompt='Please enter your selection'):
94
122
  """
95
- Read an input from the user with a timeout and a countdown.
96
-
97
- Parameters:
98
- timeout (int): The timeout value in seconds.
99
- prompt (str): The prompt message to display to the user. Default is 'Please enter your selection'.
100
-
101
- Returns:
102
- str or None: The user input if received within the timeout, or None if no input is received.
123
+ Read input from the user with a timeout (cross-platform).
124
+ If the user does not enter any input within `timeout` seconds, return None.
125
+ Otherwise, return the input string.
103
126
  """
104
- import select
105
- # Print the initial prompt with the countdown
127
+ # Queue to receive user input from the background thread
128
+ input_queue = queue.Queue()
129
+ def read_input():
130
+ # Read line from stdin and put it in the queue
131
+ user_input = sys.stdin.readline()
132
+ input_queue.put(user_input)
133
+ # Start a thread that will block on input()
134
+ input_thread = threading.Thread(target=read_input, daemon=True)
135
+ input_thread.start()
136
+ # Print the initial prompt
106
137
  eprint(f"{prompt} [{timeout}s]: ", end='', flush=True)
107
- # Loop until the timeout
108
- for remaining in range(timeout, 0, -1):
109
- # If there is an input, return it
110
- if sys.stdin in select.select([sys.stdin], [], [], 0)[0]:
111
- return input().strip()
112
- # Print the remaining time
138
+ # Countdown loop
139
+ start_time = time.time()
140
+ while True:
141
+ # Check if the input thread has finished (i.e., user pressed Enter)
142
+ if not input_queue.empty():
143
+ # We got user input
144
+ user_input = input_queue.get().strip()
145
+ eprint() # move to the next line
146
+ return user_input
147
+ elapsed = int(time.time() - start_time)
148
+ remaining = timeout - elapsed
149
+ if remaining <= 0:
150
+ # Time is up, no input
151
+ eprint() # move to the next line
152
+ return None
153
+ # Update prompt countdown
113
154
  eprint(f"\r{prompt} [{remaining}s]: ", end='', flush=True)
114
- # Wait a second
115
155
  time.sleep(1)
116
- # If there is no input, return None
117
- return None
118
156
 
119
157
  @cache_decorator
120
158
  def getIP(hostname: str,local=False):
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes