addftool 0.1.8__py3-none-any.whl → 0.1.9__py3-none-any.whl

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.
@@ -11,6 +11,8 @@ def add_killer_args(subparsers):
11
11
  process_killer_parser.add_argument("--timeout", help="timeout of command", default=5, type=int)
12
12
  process_killer_parser.add_argument("--try_count", help="try count of command", default=3, type=int)
13
13
 
14
+ process_killer_parser.add_argument("--contain_arg", help="args of command", default="", type=str)
15
+
14
16
  process_killer_parser.add_argument("--rocm", help="kill process using rocm", action='store_true', default=False)
15
17
  process_killer_parser.add_argument("--cuda", help="kill process using cuda", action='store_true', default=False)
16
18
 
@@ -59,7 +61,7 @@ def kill_process(processes, timeout=5, try_count=3):
59
61
  exit(1)
60
62
 
61
63
 
62
- def find_and_kill_process(command="", contains=False, use_rocm=False, use_cuda=False, timeout=5, try_count=3, only_view=False):
64
+ def find_and_kill_process(command="", contains=False, contain_arg="", use_rocm=False, use_cuda=False, timeout=5, try_count=3, only_view=False):
63
65
  do_not_do_anything = command is None or len(command) == 0
64
66
  if use_rocm:
65
67
  processes = get_process_using_rocm()
@@ -69,7 +71,7 @@ def find_and_kill_process(command="", contains=False, use_rocm=False, use_cuda=F
69
71
  print("Use top or htop to find the process you want to kill")
70
72
  return
71
73
  else:
72
- processes = get_processes(command=command, contains=contains)
74
+ processes = get_processes(command=command, contains=contains, contain_arg=contain_arg)
73
75
 
74
76
  if only_view:
75
77
  print(f"Found {len(processes)} processes")
@@ -83,7 +85,8 @@ def find_and_kill_process(command="", contains=False, use_rocm=False, use_cuda=F
83
85
 
84
86
 
85
87
  def killer_main(args):
88
+ print(args)
86
89
  find_and_kill_process(
87
- args.name, args.contains, use_rocm=args.rocm, use_cuda=args.cuda,
90
+ args.name, args.contains, args.contain_arg, use_rocm=args.rocm, use_cuda=args.cuda,
88
91
  timeout=args.timeout, try_count=args.try_count, only_view=args.view,
89
92
  )
addftool/process/utils.py CHANGED
@@ -2,7 +2,7 @@ import psutil
2
2
  import subprocess
3
3
 
4
4
 
5
- def get_processes(command="", contains=False, pids=None):
5
+ def get_processes(command="", contains=False, pids=None, contain_arg=""):
6
6
  """获取进程的PID和命令"""
7
7
 
8
8
  processes = []
@@ -21,6 +21,17 @@ def get_processes(command="", contains=False, pids=None):
21
21
  continue
22
22
  if len(cmdline) > 1 and cmdline[1].endswith('addf'):
23
23
  continue
24
+ if len(contain_arg) > 0:
25
+ if len(cmdline) <= 1:
26
+ continue
27
+ flag = False
28
+ for arg in cmdline[1:]:
29
+ if contain_arg in arg:
30
+ flag = True
31
+ break
32
+ if not flag:
33
+ continue
34
+
24
35
  processes.append({'pid': pid, 'command': cmdline})
25
36
  except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
26
37
  pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: addftool
3
- Version: 0.1.8
3
+ Version: 0.1.9
4
4
  Requires-Dist: cryptography
5
5
  Requires-Dist: requests
6
6
  Requires-Dist: PyYAML
@@ -7,11 +7,11 @@ addftool/util.py,sha256=zlNLu8Be8cGIpNRqBw8_0q7nFxWlsJ9cToN62ohjdXE,2335
7
7
  addftool/deploy/__init__.py,sha256=tpyoTh3SqAQojPizsJDvQohu1Pcb3-w-DP5sO4-5lBM,1220
8
8
  addftool/deploy/azure.py,sha256=_o_9Eh8cVwLDAqvfyRYBtQRHs_Gul-nCs2ZXttwO1bk,1301
9
9
  addftool/deploy/ssh_server.py,sha256=f2T8fgwACVljPfdcimMywUjsFnLCWRde7iWPAILpRz8,5463
10
- addftool/process/__init__.py,sha256=gPdGsjMEET6crzOz4Iw5cmf6RR1toXGovydRXv8Uagk,3543
11
- addftool/process/utils.py,sha256=me4HqMz5OgRcQMUJmVhKdTJh4SW5BB-pd_lq7g8-UwE,2252
10
+ addftool/process/__init__.py,sha256=Dze8OrcyjQlAbPrjE_h8bMi8W4b3OJyZOjTucPrkJvM,3721
11
+ addftool/process/utils.py,sha256=JldxnwanLJOgxaPgmCJh7SeBRaaj5rFxWWxh1hpsvbA,2609
12
12
  addftool/ssh/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- addftool-0.1.8.dist-info/METADATA,sha256=f50lOq51j55hNh2hnk6SdAni0E7MXHec81sBCOHZ_ro,170
14
- addftool-0.1.8.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
15
- addftool-0.1.8.dist-info/entry_points.txt,sha256=9lkmuWMInwUAtev8w8poNkNd7iML9Bjd5CBCFVxg2b8,111
16
- addftool-0.1.8.dist-info/top_level.txt,sha256=jqj56-plrBbyzY0tIxB6wPzjAA8kte4hUlajyyQygN4,9
17
- addftool-0.1.8.dist-info/RECORD,,
13
+ addftool-0.1.9.dist-info/METADATA,sha256=VEfXNesNw0S0lZl2_hYrJhrUyRN9SpP1iT1aIhtgKbU,170
14
+ addftool-0.1.9.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
15
+ addftool-0.1.9.dist-info/entry_points.txt,sha256=9lkmuWMInwUAtev8w8poNkNd7iML9Bjd5CBCFVxg2b8,111
16
+ addftool-0.1.9.dist-info/top_level.txt,sha256=jqj56-plrBbyzY0tIxB6wPzjAA8kte4hUlajyyQygN4,9
17
+ addftool-0.1.9.dist-info/RECORD,,