multiSSH3 5.44__tar.gz → 5.46__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.44
3
+ Version: 5.46
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.44
3
+ Version: 5.46
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
@@ -33,6 +33,7 @@ import getpass
33
33
  import uuid
34
34
  import tempfile
35
35
  import math
36
+ from itertools import count
36
37
 
37
38
  try:
38
39
  # Check if functiools.cache is available
@@ -45,8 +46,9 @@ except AttributeError:
45
46
  # If neither is available, use a dummy decorator
46
47
  def cache_decorator(func):
47
48
  return func
48
- version = '5.44'
49
+ version = '5.46'
49
50
  VERSION = version
51
+ COMMIT_DATE = '2025-01-30'
50
52
 
51
53
  CONFIG_FILE_CHAIN = ['./multiSSH3.config.json',
52
54
  '~/multiSSH3.config.json',
@@ -157,8 +159,8 @@ def getIP(hostname: str,local=False):
157
159
  except:
158
160
  return None
159
161
 
160
- __host_i_lock = threading.Lock()
161
- __host_i_counter = -1
162
+
163
+ _i_counter = count()
162
164
  def _get_i():
163
165
  '''
164
166
  Get the global counter for the host objects
@@ -166,15 +168,11 @@ def _get_i():
166
168
  Returns:
167
169
  int: The global counter for the host objects
168
170
  '''
169
- global __host_i_counter
170
- global __host_i_lock
171
- with __host_i_lock:
172
- __host_i_counter += 1
173
- return __host_i_counter
171
+ return next(_i_counter)
174
172
 
175
173
  # ------------ Host Object ----------------
176
174
  class Host:
177
- def __init__(self, name, command, files = None,ipmi = False,interface_ip_prefix = None,scp=False,extraargs=None,gatherMode=False,identity_file=None,shell=False,i = _get_i(),uuid=uuid.uuid4(),ip = None):
175
+ def __init__(self, name, command, files = None,ipmi = False,interface_ip_prefix = None,scp=False,extraargs=None,gatherMode=False,identity_file=None,shell=False,i = -1,uuid=uuid.uuid4(),ip = None):
178
176
  self.name = name # the name of the host (hostname or IP address)
179
177
  self.command = command # the command to run on the host
180
178
  self.returncode = None # the return code of the command
@@ -193,7 +191,7 @@ class Host:
193
191
  self.extraargs = extraargs # extra arguments to be passed to ssh
194
192
  self.resolvedName = None # the resolved IP address of the host
195
193
  # also store a globally unique integer i from 0
196
- self.i = i
194
+ self.i = i if i != -1 else _get_i()
197
195
  self.uuid = uuid
198
196
  self.identity_file = identity_file
199
197
  self.ip = ip if ip else getIP(name)
@@ -1721,13 +1719,16 @@ def _curses_add_string_to_window(window, line = '', y = 0, x = 0, number_of_char
1721
1719
  charsWritten = 0
1722
1720
  boxAttr = __parse_ansi_escape_sequence_to_curses_attr(box_ansi_color)
1723
1721
  # first add the lead_str
1724
- window.addnstr(y, x, lead_str, numChar, boxAttr)
1725
- charsWritten = min(len(lead_str), numChar)
1722
+ if len(lead_str) > 0:
1723
+ window.addnstr(y, x, lead_str, numChar, boxAttr)
1724
+ charsWritten = min(len(lead_str), numChar)
1726
1725
  # process centering
1727
1726
  if centered:
1728
1727
  fill_length = numChar - len(lead_str) - len(trail_str) - sum([len(segment) for segment in segments if not segment.startswith("\x1b[")])
1729
- window.addnstr(y, x + charsWritten, fill_char * (fill_length // 2 // len(fill_char)), numChar - charsWritten, boxAttr)
1730
- charsWritten += min(len(fill_char * (fill_length // 2)), numChar - charsWritten)
1728
+ leading_fill_length = fill_length // 2
1729
+ if leading_fill_length > 0:
1730
+ window.addnstr(y, x + charsWritten, fill_char * (leading_fill_length // len(fill_char) + 1), leading_fill_length, boxAttr)
1731
+ charsWritten += leading_fill_length
1731
1732
  # add the segments
1732
1733
  for segment in segments:
1733
1734
  if not segment:
@@ -1737,17 +1738,17 @@ def _curses_add_string_to_window(window, line = '', y = 0, x = 0, number_of_char
1737
1738
  newAttr = __parse_ansi_escape_sequence_to_curses_attr(segment,color_pair_list)
1738
1739
  else:
1739
1740
  # Add text with current color
1740
- if charsWritten < numChar:
1741
+ if charsWritten < numChar and len(segment) > 0:
1741
1742
  window.addnstr(y, x + charsWritten, segment, numChar - charsWritten, color_pair_list[2])
1742
1743
  charsWritten += min(len(segment), numChar - charsWritten)
1743
1744
  # if we have finished printing segments but we still have space, we will fill it with fill_char
1744
- if charsWritten + len(trail_str) < numChar:
1745
- fillStr = fill_char * ((numChar - charsWritten - len(trail_str))//len(fill_char))
1746
- #fillStr = f'{color_pair_list}'
1747
- window.addnstr(y, x + charsWritten, fillStr + trail_str, numChar - charsWritten, boxAttr)
1748
- charsWritten += numChar - charsWritten
1749
- else:
1745
+ trail_fill_length = numChar - charsWritten - len(trail_str)
1746
+ if trail_fill_length > 0:
1747
+ window.addnstr(y, x + charsWritten,fill_char * (trail_fill_length // len(fill_char) + 1), trail_fill_length, boxAttr)
1748
+ charsWritten += trail_fill_length
1749
+ if len(trail_str) > 0 and charsWritten < numChar:
1750
1750
  window.addnstr(y, x + charsWritten, trail_str, numChar - charsWritten, boxAttr)
1751
+ charsWritten += min(len(trail_str), numChar - charsWritten)
1751
1752
 
1752
1753
  def _get_hosts_to_display (hosts, max_num_hosts, hosts_to_display = None):
1753
1754
  '''
@@ -2770,7 +2771,7 @@ def main():
2770
2771
  parser.add_argument('--store_config_file',type = str,nargs='?',help=f'Store the default config file from command line argument and current config. Same as --store_config_file --config_file=<path>',const='multiSSH3.config.json')
2771
2772
  parser.add_argument('--debug', action='store_true', help='Print debug information')
2772
2773
  parser.add_argument('-ci','--copy_id', action='store_true', help='Copy the ssh id to the hosts')
2773
- parser.add_argument("-V","--version", action='version', version=f'%(prog)s {version} with [ {", ".join(_binPaths.keys())} ] by {AUTHOR} ({AUTHOR_EMAIL})')
2774
+ parser.add_argument("-V","--version", action='version', version=f'%(prog)s {version} @ {COMMIT_DATE} with [ {", ".join(_binPaths.keys())} ] by {AUTHOR} ({AUTHOR_EMAIL})')
2774
2775
 
2775
2776
  # parser.add_argument('-u', '--user', metavar='user', type=str, nargs=1,
2776
2777
  # help='the user to use to connect to the hosts')
File without changes
File without changes
File without changes