multiSSH3 5.39__tar.gz → 5.40__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.39
3
+ Version: 5.40
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.39
3
+ Version: 5.40
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,13 +1,21 @@
1
1
  #!/usr/bin/env python3
2
2
  __curses_available = False
3
+ __resource_lib_available = False
3
4
  try:
4
5
  import curses
5
6
  __curses_available = True
6
7
  except ImportError:
7
8
  pass
9
+ try:
10
+ import resource
11
+ __resource_lib_available = True
12
+ except ImportError:
13
+ pass
14
+
8
15
  import subprocess
9
16
  import threading
10
- import time,os
17
+ import time
18
+ import os
11
19
  import argparse
12
20
  from itertools import product
13
21
  import re
@@ -37,7 +45,7 @@ except AttributeError:
37
45
  # If neither is available, use a dummy decorator
38
46
  def cache_decorator(func):
39
47
  return func
40
- version = '5.39'
48
+ version = '5.40'
41
49
  VERSION = version
42
50
 
43
51
  CONFIG_FILE = '/etc/multiSSH3.config.json'
@@ -352,26 +360,34 @@ if True:
352
360
  __curses_current_color_pair_index = 2 # Start from 1, as 0 is the default color pair
353
361
  __curses_color_table = {}
354
362
  __curses_current_color_index = 10
363
+ __max_connections_nofile_limit_supported = 0
364
+ if __resource_lib_available:
365
+ # Get the current limits
366
+ _, __system_nofile_limit = resource.getrlimit(resource.RLIMIT_NOFILE)
367
+ # Set the soft limit to the hard limit
368
+ resource.setrlimit(resource.RLIMIT_NOFILE, (__system_nofile_limit, __system_nofile_limit))
369
+ __max_connections_nofile_limit_supported = int((__system_nofile_limit - 5) / 4.6)
355
370
 
356
371
  # Mapping of ANSI 4-bit colors to curses colors
357
- ANSI_TO_CURSES_COLOR = {
358
- 30: curses.COLOR_BLACK,
359
- 31: curses.COLOR_RED,
360
- 32: curses.COLOR_GREEN,
361
- 33: curses.COLOR_YELLOW,
362
- 34: curses.COLOR_BLUE,
363
- 35: curses.COLOR_MAGENTA,
364
- 36: curses.COLOR_CYAN,
365
- 37: curses.COLOR_WHITE,
366
- 90: curses.COLOR_BLACK, # Bright Black (usually gray)
367
- 91: curses.COLOR_RED, # Bright Red
368
- 92: curses.COLOR_GREEN, # Bright Green
369
- 93: curses.COLOR_YELLOW, # Bright Yellow
370
- 94: curses.COLOR_BLUE, # Bright Blue
371
- 95: curses.COLOR_MAGENTA, # Bright Magenta
372
- 96: curses.COLOR_CYAN, # Bright Cyan
373
- 97: curses.COLOR_WHITE # Bright White
374
- }
372
+ if __curses_available:
373
+ ANSI_TO_CURSES_COLOR = {
374
+ 30: curses.COLOR_BLACK,
375
+ 31: curses.COLOR_RED,
376
+ 32: curses.COLOR_GREEN,
377
+ 33: curses.COLOR_YELLOW,
378
+ 34: curses.COLOR_BLUE,
379
+ 35: curses.COLOR_MAGENTA,
380
+ 36: curses.COLOR_CYAN,
381
+ 37: curses.COLOR_WHITE,
382
+ 90: curses.COLOR_BLACK, # Bright Black (usually gray)
383
+ 91: curses.COLOR_RED, # Bright Red
384
+ 92: curses.COLOR_GREEN, # Bright Green
385
+ 93: curses.COLOR_YELLOW, # Bright Yellow
386
+ 94: curses.COLOR_BLUE, # Bright Blue
387
+ 95: curses.COLOR_MAGENTA, # Bright Magenta
388
+ 96: curses.COLOR_CYAN, # Bright Cyan
389
+ 97: curses.COLOR_WHITE # Bright White
390
+ }
375
391
  # ------------ Exportable Help Functions ----------------
376
392
  # check if command sshpass is available
377
393
  _binPaths = {}
@@ -2437,9 +2453,12 @@ def run_command_on_hosts(hosts = DEFAULT_HOSTS,commands = None,oneonone = DEFAUL
2437
2453
  if not max_connections:
2438
2454
  max_connections = 4 * os.cpu_count()
2439
2455
  elif max_connections == 0:
2440
- max_connections = 1048576
2456
+ max_connections = __max_connections_nofile_limit_supported
2441
2457
  elif max_connections < 0:
2442
2458
  max_connections = (-max_connections) * os.cpu_count()
2459
+ if __max_connections_nofile_limit_supported > 0 and max_connections > __max_connections_nofile_limit_supported:
2460
+ eprint(f"Warning: The number of maximum connections {max_connections} is larger than estimated limit {__max_connections_nofile_limit_supported} from ulimit nofile limit {__system_nofile_limit}, setting the maximum connections to {__max_connections_nofile_limit_supported}.")
2461
+ max_connections = __max_connections_nofile_limit_supported
2443
2462
  if not commands:
2444
2463
  commands = []
2445
2464
  else:
@@ -1,8 +1,9 @@
1
1
  from setuptools import setup
2
+ from multiSSH3 import version
2
3
 
3
4
  setup(
4
5
  name='multiSSH3',
5
- version='5.39',
6
+ version=version,
6
7
  description='Run commands on multiple hosts via SSH',
7
8
  long_description=open('README.md').read(),
8
9
  long_description_content_type='text/markdown',
File without changes
File without changes
File without changes