addftool 0.1.3__py3-none-any.whl → 0.1.4__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.
@@ -7,8 +7,7 @@ from .utils import get_processes, get_process_using_rocm, get_process_using_cuda
7
7
  def add_killer_args(subparsers):
8
8
  process_killer_parser = subparsers.add_parser('kill', help='process kill')
9
9
 
10
- process_killer_parser.add_argument("--prefix", help="prefix of command", default=None)
11
- process_killer_parser.add_argument("--contains", help="contains of command", default=None)
10
+ process_killer_parser.add_argument("-c", "--contains", help="contains of command", action='store_true', default=False)
12
11
  process_killer_parser.add_argument("--timeout", help="timeout of command", default=5, type=int)
13
12
  process_killer_parser.add_argument("--try_count", help="try count of command", default=3, type=int)
14
13
 
@@ -17,6 +16,8 @@ def add_killer_args(subparsers):
17
16
 
18
17
  process_killer_parser.add_argument("-v", "--view", help="view process", action='store_true', default=False)
19
18
 
19
+ process_killer_parser.add_argument("name", nargs='?', help="name of process", type=str, default="")
20
+
20
21
 
21
22
  def kill_process(processes, timeout=5, try_count=3):
22
23
  for process in processes:
@@ -57,8 +58,8 @@ def kill_process(processes, timeout=5, try_count=3):
57
58
  exit(1)
58
59
 
59
60
 
60
- def find_and_kill_process(prefix=None, contains=None, use_rocm=False, use_cuda=False, timeout=5, try_count=3, only_view=False):
61
- do_not_do_anything = prefix is None and contains is None
61
+ def find_and_kill_process(command="", contains=False, use_rocm=False, use_cuda=False, timeout=5, try_count=3, only_view=False):
62
+ do_not_do_anything = command is None or len(command) == 0
62
63
  if use_rocm:
63
64
  processes = get_process_using_rocm()
64
65
  elif use_cuda:
@@ -67,7 +68,7 @@ def find_and_kill_process(prefix=None, contains=None, use_rocm=False, use_cuda=F
67
68
  print("Use top or htop to find the process you want to kill")
68
69
  return
69
70
  else:
70
- processes = get_processes(command_prefix=prefix, prefix_contains=contains)
71
+ processes = get_processes(command=command, contains=contains)
71
72
 
72
73
  if only_view:
73
74
  print(f"Found {len(processes)} processes")
@@ -82,6 +83,6 @@ def find_and_kill_process(prefix=None, contains=None, use_rocm=False, use_cuda=F
82
83
 
83
84
  def killer_main(args):
84
85
  find_and_kill_process(
85
- args.prefix, args.contains, use_rocm=args.rocm, use_cuda=args.cuda,
86
+ args.name, args.contains, use_rocm=args.rocm, use_cuda=args.cuda,
86
87
  timeout=args.timeout, try_count=args.try_count, only_view=args.view,
87
88
  )
addftool/process/utils.py CHANGED
@@ -2,7 +2,7 @@ import psutil
2
2
  import subprocess
3
3
 
4
4
 
5
- def get_processes(command_prefix=None, prefix_contains=None, pids=None):
5
+ def get_processes(command="", contains=False, pids=None):
6
6
  """获取进程的PID和命令"""
7
7
 
8
8
  processes = []
@@ -14,10 +14,11 @@ def get_processes(command_prefix=None, prefix_contains=None, pids=None):
14
14
  continue
15
15
  if pids is not None and pid not in pids:
16
16
  continue
17
- if command_prefix and not cmdline[0] == command_prefix:
18
- continue
19
- if prefix_contains and prefix_contains not in cmdline[0]:
20
- continue
17
+ if len(command) > 0:
18
+ if contains and command not in cmdline[0]:
19
+ continue
20
+ if not contains and command != cmdline[0]:
21
+ continue
21
22
  if len(cmdline) > 1 and cmdline[1].endswith('addf'):
22
23
  continue
23
24
  processes.append({'pid': pid, 'command': cmdline})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: addftool
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Requires-Dist: cryptography
5
5
  Requires-Dist: requests
6
6
  Requires-Dist: PyYAML
@@ -0,0 +1,12 @@
1
+ addftool/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ addftool/addf_portal.py,sha256=U52TdNcwWOEvv_C5r-guWYxn3ntzwYI2eBzJIE7IdcY,493
3
+ addftool/blob.py,sha256=NZOItDyFUIdV1tfhJZJJBEzGy296CE5NCictTzP4OPc,8282
4
+ addftool/tool.py,sha256=EuKQ2t2InN7yB-_oYLcdsA7vRqzRGTunwIxplUSqEG0,2054
5
+ addftool/util.py,sha256=Q3A68vJDxgfeNiEFmk54HuMuworVndocXpSbVpvGMfc,362
6
+ addftool/process/__init__.py,sha256=OB-cZXP1jK7l8uN8nKfhg_bCX6Slz6DeeBpEodt-IK4,3515
7
+ addftool/process/utils.py,sha256=me4HqMz5OgRcQMUJmVhKdTJh4SW5BB-pd_lq7g8-UwE,2252
8
+ addftool-0.1.4.dist-info/METADATA,sha256=ohQCdQdVevHRzMRu7ByPhBGxqPlxmEKnDxNmfcy_WII,148
9
+ addftool-0.1.4.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
10
+ addftool-0.1.4.dist-info/entry_points.txt,sha256=9lkmuWMInwUAtev8w8poNkNd7iML9Bjd5CBCFVxg2b8,111
11
+ addftool-0.1.4.dist-info/top_level.txt,sha256=jqj56-plrBbyzY0tIxB6wPzjAA8kte4hUlajyyQygN4,9
12
+ addftool-0.1.4.dist-info/RECORD,,
@@ -1,12 +0,0 @@
1
- addftool/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- addftool/addf_portal.py,sha256=U52TdNcwWOEvv_C5r-guWYxn3ntzwYI2eBzJIE7IdcY,493
3
- addftool/blob.py,sha256=NZOItDyFUIdV1tfhJZJJBEzGy296CE5NCictTzP4OPc,8282
4
- addftool/tool.py,sha256=EuKQ2t2InN7yB-_oYLcdsA7vRqzRGTunwIxplUSqEG0,2054
5
- addftool/util.py,sha256=Q3A68vJDxgfeNiEFmk54HuMuworVndocXpSbVpvGMfc,362
6
- addftool/process/__init__.py,sha256=EFJ90RcF04M4imGm5NLgb9rmpwxBslZUL_4LKA52uv8,3487
7
- addftool/process/utils.py,sha256=kS1bYYiWymB1_SObqQLfGiVbZdCJqd57SO6DrwN5H1s,2246
8
- addftool-0.1.3.dist-info/METADATA,sha256=YwSmBYP8v9T_PnVr-3WM-V2KkCcPg17IwMKllfp-pc0,148
9
- addftool-0.1.3.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
10
- addftool-0.1.3.dist-info/entry_points.txt,sha256=9lkmuWMInwUAtev8w8poNkNd7iML9Bjd5CBCFVxg2b8,111
11
- addftool-0.1.3.dist-info/top_level.txt,sha256=jqj56-plrBbyzY0tIxB6wPzjAA8kte4hUlajyyQygN4,9
12
- addftool-0.1.3.dist-info/RECORD,,