multiSSH3 5.54__tar.gz → 5.55__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.54
3
+ Version: 5.55
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.54
3
+ Version: 5.55
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
@@ -54,7 +54,7 @@ except AttributeError:
54
54
  # If neither is available, use a dummy decorator
55
55
  def cache_decorator(func):
56
56
  return func
57
- version = '5.54'
57
+ version = '5.55'
58
58
  VERSION = version
59
59
  __version__ = version
60
60
  COMMIT_DATE = '2025-03-01'
@@ -144,7 +144,7 @@ def input_with_timeout_and_countdown(timeout, prompt='Please enter your selectio
144
144
  # Print the initial prompt
145
145
  eprint(f"{prompt} [{timeout}s]: ", end='', flush=True)
146
146
  # Countdown loop
147
- start_time = time.time()
147
+ start_time = time.monotonic()
148
148
  while True:
149
149
  # Check if the input thread has finished (i.e., user pressed Enter)
150
150
  if not input_queue.empty():
@@ -152,7 +152,7 @@ def input_with_timeout_and_countdown(timeout, prompt='Please enter your selectio
152
152
  user_input = input_queue.get().strip()
153
153
  eprint() # move to the next line
154
154
  return user_input
155
- elapsed = int(time.time() - start_time)
155
+ elapsed = int(time.monotonic() - start_time)
156
156
  remaining = timeout - elapsed
157
157
  if remaining <= 0:
158
158
  # Time is up, no input
@@ -227,7 +227,7 @@ class Host:
227
227
  self.stderr = [] # the stderr of the command
228
228
  self.printedLines = -1 # the number of lines printed on the screen
229
229
  self.lineNumToReprintSet = set() # whether to reprint the last line
230
- self.lastUpdateTime = time.time() # the last time the output was updated
230
+ self.lastUpdateTime = time.monotonic() # the last time the output was updated
231
231
  self.files = files # the files to be copied to the host
232
232
  self.ipmi = ipmi # whether to use ipmi to connect to the host
233
233
  self.shell = shell # whether to use shell to run the command
@@ -1134,7 +1134,7 @@ def __handle_reading_stream(stream,target, host):
1134
1134
  target.append(current_line_str)
1135
1135
  host.output.append(current_line_str)
1136
1136
  host.lineNumToReprintSet.add(len(host.output)-1)
1137
- host.lastUpdateTime = time.time()
1137
+ host.lastUpdateTime = time.monotonic()
1138
1138
  current_line = bytearray()
1139
1139
  lastLineCommited = True
1140
1140
  for char in iter(lambda:stream.read(1), b''):
@@ -1179,7 +1179,7 @@ def __handle_writing_stream(stream,stop_event,host):
1179
1179
  host.output.append(line)
1180
1180
  host.stdout.append(line)
1181
1181
  sentInput += 1
1182
- host.lastUpdateTime = time.time()
1182
+ host.lastUpdateTime = time.monotonic()
1183
1183
  else:
1184
1184
  time.sleep(0.01) # sleep for 10ms
1185
1185
  if sentInput < len(__keyPressesIn) - 1 :
@@ -1387,20 +1387,20 @@ def run_command(host, sem, timeout=60,passwds=None, retry_limit = 5):
1387
1387
  stdin_thread = threading.Thread(target=__handle_writing_stream, args=(proc.stdin,stdin_stop_event, host), daemon=True)
1388
1388
  stdin_thread.start()
1389
1389
  # Monitor the subprocess and terminate it after the timeout
1390
- host.lastUpdateTime = time.time()
1390
+ host.lastUpdateTime = time.monotonic()
1391
1391
  timeoutLineAppended = False
1392
1392
  sleep_interval = 1.0e-7 # 100 nanoseconds
1393
1393
  while proc.poll() is None: # while the process is still running
1394
1394
  if timeout > 0:
1395
- if time.time() - host.lastUpdateTime > timeout:
1395
+ if time.monotonic() - host.lastUpdateTime > timeout:
1396
1396
  host.stderr.append('Timeout!')
1397
1397
  host.output.append('Timeout!')
1398
1398
  proc.send_signal(signal.SIGINT)
1399
1399
  time.sleep(0.1)
1400
1400
  proc.terminate()
1401
1401
  break
1402
- elif time.time() - host.lastUpdateTime > max(1, timeout // 2):
1403
- timeoutLine = f'Timeout in [{timeout - int(time.time() - host.lastUpdateTime)}] seconds!'
1402
+ elif time.monotonic() - host.lastUpdateTime > max(1, timeout // 2):
1403
+ timeoutLine = f'Timeout in [{timeout - int(time.monotonic() - host.lastUpdateTime)}] seconds!'
1404
1404
  if host.output and not host.output[-1].strip().startswith(timeoutLine):
1405
1405
  # remove last line if it is a countdown
1406
1406
  if host.output and timeoutLineAppended and host.output[-1].strip().endswith('] seconds!') and host.output[-1].strip().startswith('Timeout in ['):
@@ -2333,7 +2333,7 @@ def processRunOnHosts(timeout, password, max_connections, hosts, returnUnfinishe
2333
2333
  # check for the old content, only update if the new content is different
2334
2334
  if not os.path.exists(os.path.join(tempfile.gettempdir(),'__multiSSH3_UNAVAILABLE_HOSTS.csv')):
2335
2335
  with open(os.path.join(tempfile.gettempdir(),'__multiSSH3_UNAVAILABLE_HOSTS.csv'),'w') as f:
2336
- f.write(f',{int(time.time())}\n'.join(unavailableHosts) + f',{int(time.time())}\n')
2336
+ f.write(f',{int(time.monotonic())}\n'.join(unavailableHosts) + f',{int(time.monotonic())}\n')
2337
2337
  else:
2338
2338
  oldDic = {}
2339
2339
  try:
@@ -2346,11 +2346,11 @@ def processRunOnHosts(timeout, password, max_connections, hosts, returnUnfinishe
2346
2346
  pass
2347
2347
  # remove entries that are either available now or older than min(timeout,3600) seconds
2348
2348
  for key in list(oldDic.keys()):
2349
- if key in reachableHosts or time.time() - oldDic[key] > min(timeout,3600):
2349
+ if key in reachableHosts or time.monotonic() < oldDic[key] or time.monotonic() - oldDic[key] > min(timeout,3600):
2350
2350
  del oldDic[key]
2351
2351
  # add new entries
2352
2352
  for host in unavailableHosts:
2353
- oldDic[host] = int(time.time())
2353
+ oldDic[host] = int(time.monotonic ())
2354
2354
  with open(os.path.join(tempfile.gettempdir(),'__multiSSH3_UNAVAILABLE_HOSTS.csv.new'),'w') as f:
2355
2355
  for key, value in oldDic.items():
2356
2356
  f.write(f'{key},{value}\n')
@@ -2517,7 +2517,7 @@ def run_command_on_hosts(hosts = DEFAULT_HOSTS,commands = None,oneonone = DEFAUL
2517
2517
  for line in f:
2518
2518
  line = line.strip()
2519
2519
  if line and ',' in line and len(line.split(',')) >= 2 and line.split(',')[0] and line.split(',')[1].isdigit():
2520
- if int(line.split(',')[1]) > time.time() - checkTime:
2520
+ if int(line.split(',')[1]) < time.monotonic() and int(line.split(',')[1]) + checkTime > time.monotonic():
2521
2521
  __globalUnavailableHosts.add(line.split(',')[0])
2522
2522
  readed = True
2523
2523
  if readed and not __global_suppress_printout:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes