kport 2.0.0__py3-none-any.whl → 2.1.1__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.
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kport
3
- Version: 2.0.0
3
+ Version: 2.1.1
4
4
  Summary: A cross-platform command-line tool to inspect and kill processes using specific ports
5
5
  Home-page: https://github.com/farman20ali/port-killer
6
- Author: Farman Ali (Alien)
7
- Author-email: farman20ali@example.com
6
+ Author: Farman Ali
7
+ Author-email: farman20ali@gmail.com
8
8
  Project-URL: Bug Reports, https://github.com/farman20ali/port-killer/issues
9
9
  Project-URL: Source, https://github.com/farman20ali/port-killer
10
10
  Keywords: port,kill,process,network,cross-platform,cli
@@ -42,16 +42,24 @@ Dynamic: summary
42
42
 
43
43
  # 🔪 kport - Cross-Platform Port Inspector and Killer
44
44
 
45
+ [![Version](https://img.shields.io/badge/version-1.0.0-blue.svg)](https://github.com/farman20ali/port-killer)
46
+ [![Python](https://img.shields.io/badge/python-3.6+-blue.svg)](https://www.python.org/downloads/)
47
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
48
+ [![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS-lightgrey.svg)](https://github.com/farman20ali/port-killer)
49
+
45
50
  A simple, powerful command-line tool to inspect and kill processes using specific ports on Windows, Linux, and macOS.
46
51
 
47
52
  ## ✨ Features
48
53
 
49
54
  - 🔍 **Inspect ports** - Find which process is using a specific port
55
+ - 🔎 **Inspect multiple ports** - Check multiple ports at once
56
+ - 🔍 **Inspect port range** - Scan a range of ports (e.g., 3000-3010)
50
57
  - 🔎 **Inspect by process name** - Find all processes matching a name and their ports
51
58
  - 🔪 **Kill processes** - Terminate processes using specific ports
52
- - 📋 **List all ports** - View all listening ports and their processes
59
+ - 💥 **Kill port range** - Terminate processes on a range of ports
60
+ - 🔫 **Kill multiple ports** - Kill processes on multiple ports at once
53
61
  - 🎯 **Kill by process name** - Kill all processes matching a name (e.g., "node", "python")
54
- - 🔥 **Kill multiple ports** - Kill processes on multiple ports at once
62
+ - 📋 **List all ports** - View all listening ports and their processes
55
63
  - 🎨 **Colorized output** - Easy-to-read colored terminal output
56
64
  - ✅ **Confirmation prompts** - Safety confirmation before killing processes
57
65
  - 🌍 **Cross-platform** - Works on Windows, Linux, and macOS
@@ -62,13 +70,17 @@ A simple, powerful command-line tool to inspect and kill processes using specifi
62
70
  ### Quick Install (Once Published to PyPI)
63
71
 
64
72
  ```bash
73
+ # Recommended: Install to user directory
74
+ pip install --user kport
75
+
76
+ # Or install system-wide (requires admin/sudo)
65
77
  pip install kport
66
78
  ```
67
79
 
68
80
  ### Install from GitHub
69
81
 
70
82
  ```bash
71
- pip install git+https://github.com/farman20ali/port-killer.git
83
+ pip install --user git+https://github.com/farman20ali/port-killer.git
72
84
  ```
73
85
 
74
86
  ### Install from Source
@@ -78,7 +90,10 @@ pip install git+https://github.com/farman20ali/port-killer.git
78
90
  git clone https://github.com/farman20ali/port-killer.git
79
91
  cd port-killer
80
92
 
81
- # Install
93
+ # Install to user directory (recommended)
94
+ pip install --user .
95
+
96
+ # Or install system-wide (requires admin/sudo)
82
97
  pip install .
83
98
  ```
84
99
 
@@ -86,7 +101,7 @@ pip install .
86
101
 
87
102
  ```bash
88
103
  # Install in editable mode
89
- pip install -e .
104
+ pip install --user -e .
90
105
  ```
91
106
 
92
107
  After installation, `kport` will be available globally in your terminal.
@@ -98,6 +113,8 @@ After installation, `kport` will be available globally in your terminal.
98
113
  python kport.py -h
99
114
  ```
100
115
 
116
+ > 💡 **Tip:** If `kport` command doesn't work after installation, see [TROUBLESHOOTING.md](TROUBLESHOOTING.md)
117
+ >
101
118
  > 📖 For detailed installation instructions, see [INSTALL.md](INSTALL.md)
102
119
  >
103
120
  > 🚀 For publishing instructions, see [PUBLISH.md](PUBLISH.md)
@@ -150,6 +167,48 @@ PID Process Port State
150
167
  ✓ Total connections: 3
151
168
  ```
152
169
 
170
+ ### Inspect multiple ports
171
+
172
+ Check multiple ports at once:
173
+
174
+ ```bash
175
+ kport -im 3000 3001 8080 8081
176
+ ```
177
+
178
+ Example output:
179
+ ```
180
+ 🔍 Inspecting 4 port(s)...
181
+
182
+ Port PID Process
183
+ ────────────────────────────────────────────────────────────
184
+ 3000 12345 node.exe
185
+ 3001 12346 node.exe
186
+ 8080 12347 python.exe
187
+
188
+ ✓ Found processes on 3/4 port(s)
189
+ ```
190
+
191
+ ### Inspect port range
192
+
193
+ Scan a range of ports:
194
+
195
+ ```bash
196
+ kport -ir 3000-3010
197
+ ```
198
+
199
+ Example output:
200
+ ```
201
+ 🔍 Inspecting port range 3000-3010 (11 ports)...
202
+
203
+ Port PID Process
204
+ ────────────────────────────────────────────────────────────
205
+ 3000 12345 node.exe
206
+ 3001 12346 node.exe
207
+ 3005 12347 python.exe
208
+
209
+ ✓ Found processes on 3/11 port(s) in range
210
+ ```
211
+
153
212
  ### Kill a process on a port
154
213
 
155
214
  Terminate the process using a specific port:
@@ -249,6 +308,34 @@ Are you sure you want to kill 3 process(es)? (y/N): y
249
308
  Ports freed: 3000, 3001, 3002
250
309
  ```
251
310
 
311
+ ### Kill port range
312
+
313
+ Kill all processes on a range of ports:
314
+
315
+ ```bash
316
+ kport -kr 3000-3010
317
+ ```
318
+
319
+ Example output:
320
+ ```
321
+ 🔪 Killing processes on port range 3000-3010 (11 ports)...
322
+
323
+ Found processes on 3 port(s) in range:
324
+ ──────────────────────────────────────────────────
325
+ Port 3000: PID 12345 (node.exe)
326
+ Port 3001: PID 12346 (node.exe)
327
+ Port 3005: PID 12347 (python.exe)
328
+
329
+ Are you sure you want to kill 3 process(es)? (y/N): y
330
+
331
+ ✓ Killed process on port 3000 (PID 12345)
332
+ ✓ Killed process on port 3001 (PID 12346)
333
+ ✓ Killed process on port 3005 (PID 12347)
334
+
335
+ ✓ Successfully killed 3/3 process(es)
336
+ Ports freed: 3000, 3001, 3005
337
+ ```
338
+
252
339
  ### Show help
253
340
 
254
341
  ```bash
@@ -266,10 +353,13 @@ kport -v
266
353
  | Option | Long Form | Description |
267
354
  |--------|-----------|-------------|
268
355
  | `-i PORT` | `--inspect PORT` | Inspect which process is using the specified port |
356
+ | `-im PORT [PORT ...]` | `--inspect-multiple PORT [PORT ...]` | Inspect multiple ports at once |
357
+ | `-ir RANGE` | `--inspect-range RANGE` | Inspect port range (e.g., 3000-3010) |
269
358
  | `-ip NAME` | `--inspect-process NAME` | Inspect all processes matching the given name and their ports |
270
359
  | `-k PORT` | `--kill PORT` | Kill the process using the specified port |
271
360
  | `-kp NAME` | `--kill-process NAME` | Kill all processes matching the given name |
272
361
  | `-ka PORT [PORT ...]` | `--kill-all PORT [PORT ...]` | Kill processes on multiple ports at once |
362
+ | `-kr RANGE` | `--kill-range RANGE` | Kill processes on port range (e.g., 3000-3010) |
273
363
  | `-l` | `--list` | List all listening ports and their processes |
274
364
  | `-v` | `--version` | Show version information |
275
365
  | `-h` | `--help` | Show help message |
@@ -0,0 +1,7 @@
1
+ kport.py,sha256=v477f5G3vcvW9SpKmx27agTIzqVXXrB6xM5kK8S39Y4,24192
2
+ kport-2.1.1.dist-info/licenses/LICENSE,sha256=QQ8MyuCI55RKsPJcc50I2sT59jvpRtD9kvA031BtYs8,1083
3
+ kport-2.1.1.dist-info/METADATA,sha256=-cY-7DN_BeBvIXKDQ9I8rerFxSJs6JpmqinwPP_3RjQ,13427
4
+ kport-2.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
5
+ kport-2.1.1.dist-info/entry_points.txt,sha256=ppZIgJ1vrmYs2EO9NcVSFCaZj7oj7t6RnJo8ArPQiRo,37
6
+ kport-2.1.1.dist-info/top_level.txt,sha256=yzlMBPZ7a-pcCN4DR5MRPO-VjY3fWnILtFUQpEuA2xY,6
7
+ kport-2.1.1.dist-info/RECORD,,
kport.py CHANGED
@@ -50,6 +50,35 @@ def validate_port(port):
50
50
  sys.exit(1)
51
51
 
52
52
 
53
+ def parse_port_range(port_range):
54
+ """Parse port range string (e.g., '3000-3010') into list of ports"""
55
+ try:
56
+ if '-' in port_range:
57
+ start, end = port_range.split('-')
58
+ start_port = int(start.strip())
59
+ end_port = int(end.strip())
60
+
61
+ if start_port > end_port:
62
+ print(colorize(f"Error: Invalid range {port_range}. Start port must be less than end port.", Colors.RED))
63
+ sys.exit(1)
64
+
65
+ if end_port - start_port > 1000:
66
+ print(colorize(f"Error: Range too large ({end_port - start_port} ports). Maximum 1000 ports allowed.", Colors.RED))
67
+ sys.exit(1)
68
+
69
+ ports = list(range(start_port, end_port + 1))
70
+ for port in ports:
71
+ validate_port(port)
72
+ return ports
73
+ else:
74
+ port = int(port_range)
75
+ validate_port(port)
76
+ return [port]
77
+ except ValueError:
78
+ print(colorize(f"Error: Invalid port or range format: {port_range}", Colors.RED))
79
+ sys.exit(1)
80
+
81
+
53
82
  def find_pid(port):
54
83
  """Find process ID using given port"""
55
84
  system = platform.system()
@@ -230,16 +259,23 @@ def main():
230
259
  parser = argparse.ArgumentParser(
231
260
  description="🔪 kport - Cross-platform port inspector and killer",
232
261
  epilog="Examples:\n"
233
- " kport -i 8080 Inspect port 8080\n"
234
- " kport -ip node Inspect all processes matching 'node'\n"
235
- " kport -k 8080 Kill process using port 8080\n"
236
- " kport -l List all listening ports\n"
237
- " kport -kp node Kill all processes matching 'node'\n"
238
- " kport -ka 3000 3001 3002 Kill processes on multiple ports\n",
262
+ " kport -i 8080 Inspect port 8080\n"
263
+ " kport -im 3000 3001 3002 Inspect multiple ports\n"
264
+ " kport -ir 3000-3010 Inspect port range\n"
265
+ " kport -ip node Inspect all processes matching 'node'\n"
266
+ " kport -k 8080 Kill process using port 8080\n"
267
+ " kport -ka 3000 3001 3002 Kill processes on multiple ports\n"
268
+ " kport -kr 3000-3010 Kill processes on port range\n"
269
+ " kport -kp node Kill all processes matching 'node'\n"
270
+ " kport -l List all listening ports\n",
239
271
  formatter_class=argparse.RawDescriptionHelpFormatter
240
272
  )
241
273
  parser.add_argument("-i", "--inspect", type=int, metavar="PORT",
242
274
  help="Inspect which process is using the specified port")
275
+ parser.add_argument("-im", "--inspect-multiple", type=int, nargs="+", metavar="PORT",
276
+ help="Inspect multiple ports")
277
+ parser.add_argument("-ir", "--inspect-range", type=str, metavar="RANGE",
278
+ help="Inspect port range (e.g., 3000-3010)")
243
279
  parser.add_argument("-ip", "--inspect-process", type=str, metavar="NAME",
244
280
  help="Inspect all processes matching the given name")
245
281
  parser.add_argument("-k", "--kill", type=int, metavar="PORT",
@@ -248,20 +284,67 @@ def main():
248
284
  help="Kill all processes matching the given name")
249
285
  parser.add_argument("-ka", "--kill-all", type=int, nargs="+", metavar="PORT",
250
286
  help="Kill processes on multiple ports")
287
+ parser.add_argument("-kr", "--kill-range", type=str, metavar="RANGE",
288
+ help="Kill processes on port range (e.g., 3000-3010)")
251
289
  parser.add_argument("-l", "--list", action="store_true",
252
290
  help="List all listening ports and their processes")
253
- parser.add_argument("-v", "--version", action="version", version="kport 2.0.0")
291
+ parser.add_argument("-v", "--version", action="version", version="kport 2.1.1")
254
292
 
255
293
  args = parser.parse_args()
256
294
 
257
295
  # If no arguments provided, show help
258
- if not (args.inspect or args.inspect_process or args.kill or args.list or args.kill_process or args.kill_all):
296
+ if not (args.inspect or args.inspect_multiple or args.inspect_range or args.inspect_process or
297
+ args.kill or args.list or args.kill_process or args.kill_all or args.kill_range):
259
298
  parser.print_help()
260
299
  sys.exit(0)
261
300
 
262
301
  if args.list:
263
302
  list_all_ports()
264
303
 
304
+ if args.inspect_multiple:
305
+ print(colorize(f"\n🔍 Inspecting {len(args.inspect_multiple)} port(s)...\n", Colors.CYAN + Colors.BOLD))
306
+
307
+ results = []
308
+ for port in args.inspect_multiple:
309
+ validate_port(port)
310
+ pid, info = find_pid(port)
311
+ if pid:
312
+ proc_name = get_process_name(pid)
313
+ results.append((port, pid, proc_name))
314
+
315
+ if not results:
316
+ print(colorize(f"❌ No processes found on any of the specified ports", Colors.RED))
317
+ else:
318
+ print(colorize(f"{'Port':<10} {'PID':<10} {'Process':<30}", Colors.BOLD))
319
+ print("─" * 60)
320
+
321
+ for port, pid, proc_name in results:
322
+ print(f"{colorize(str(port), Colors.CYAN):<19} {pid:<10} {proc_name:<30}")
323
+
324
+ print(colorize(f"\n✓ Found processes on {len(results)}/{len(args.inspect_multiple)} port(s)", Colors.GREEN))
325
+
326
+ if args.inspect_range:
327
+ ports = parse_port_range(args.inspect_range)
328
+ print(colorize(f"\n🔍 Inspecting port range {args.inspect_range} ({len(ports)} ports)...\n", Colors.CYAN + Colors.BOLD))
329
+
330
+ results = []
331
+ for port in ports:
332
+ pid, info = find_pid(port)
333
+ if pid:
334
+ proc_name = get_process_name(pid)
335
+ results.append((port, pid, proc_name))
336
+
337
+ if not results:
338
+ print(colorize(f"❌ No processes found in port range {args.inspect_range}", Colors.RED))
339
+ else:
340
+ print(colorize(f"{'Port':<10} {'PID':<10} {'Process':<30}", Colors.BOLD))
341
+ print("─" * 60)
342
+
343
+ for port, pid, proc_name in results:
344
+ print(f"{colorize(str(port), Colors.CYAN):<19} {pid:<10} {proc_name:<30}")
345
+
346
+ print(colorize(f"\n✓ Found processes on {len(results)}/{len(ports)} port(s) in range", Colors.GREEN))
347
+
265
348
  if args.inspect_process:
266
349
  print(colorize(f"\n🔍 Inspecting processes matching '{args.inspect_process}'...\n", Colors.CYAN + Colors.BOLD))
267
350
 
@@ -381,6 +464,50 @@ def main():
381
464
  print(colorize(f"\n✓ Successfully killed {killed_count}/{len(port_pid_map)} process(es)", Colors.GREEN + Colors.BOLD))
382
465
  print(colorize(f"Ports freed: {', '.join(map(str, port_pid_map.keys()))}", Colors.GREEN))
383
466
 
467
+ if args.kill_range:
468
+ ports = parse_port_range(args.kill_range)
469
+ print(colorize(f"\n🔪 Killing processes on port range {args.kill_range} ({len(ports)} ports)...\n", Colors.CYAN + Colors.BOLD))
470
+
471
+ # Find all PIDs in range
472
+ port_pid_map = {}
473
+ for port in ports:
474
+ pid, info = find_pid(port)
475
+ if pid:
476
+ port_pid_map[port] = (pid, info)
477
+
478
+ if not port_pid_map:
479
+ print(colorize(f"❌ No processes found in port range {args.kill_range}", Colors.RED))
480
+ else:
481
+ print(colorize(f"Found processes on {len(port_pid_map)} port(s) in range:", Colors.YELLOW))
482
+ print("─" * 50)
483
+
484
+ for port, (pid, info) in port_pid_map.items():
485
+ proc_name = get_process_name(pid)
486
+ print(colorize(f" Port {port}: PID {pid} ({proc_name})", Colors.WHITE))
487
+
488
+ # Ask for confirmation
489
+ try:
490
+ confirm = input(colorize(f"\nAre you sure you want to kill {len(port_pid_map)} process(es)? (y/N): ", Colors.MAGENTA))
491
+ if confirm.lower() not in ['y', 'yes']:
492
+ print(colorize("Operation cancelled.", Colors.YELLOW))
493
+ sys.exit(0)
494
+ except KeyboardInterrupt:
495
+ print(colorize("\n\nOperation cancelled.", Colors.YELLOW))
496
+ sys.exit(0)
497
+
498
+ # Kill all processes
499
+ killed_count = 0
500
+ for port, (pid, info) in port_pid_map.items():
501
+ result = kill_pid(pid, silent=True)
502
+ if result or "SUCCESS" in str(result) or "killed" in str(result).lower():
503
+ killed_count += 1
504
+ print(colorize(f"✓ Killed process on port {port} (PID {pid})", Colors.GREEN))
505
+ else:
506
+ print(colorize(f"✗ Failed to kill process on port {port} (PID {pid})", Colors.RED))
507
+
508
+ print(colorize(f"\n✓ Successfully killed {killed_count}/{len(port_pid_map)} process(es)", Colors.GREEN + Colors.BOLD))
509
+ print(colorize(f"Ports freed: {', '.join(map(str, port_pid_map.keys()))}", Colors.GREEN))
510
+
384
511
  if args.inspect:
385
512
  validate_port(args.inspect)
386
513
  print(colorize(f"\n🔍 Inspecting port {args.inspect}...\n", Colors.CYAN + Colors.BOLD))
@@ -1,7 +0,0 @@
1
- kport.py,sha256=pAqmxwtRO0FxyjYek9yFZDNBAeG1k8071h_ghGf5DiA,18043
2
- kport-2.0.0.dist-info/licenses/LICENSE,sha256=QQ8MyuCI55RKsPJcc50I2sT59jvpRtD9kvA031BtYs8,1083
3
- kport-2.0.0.dist-info/METADATA,sha256=m5wW2TWDKHoZ7HRFmqEbJVH_4wdJ0Q40wzFBbF_DArM,10182
4
- kport-2.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
5
- kport-2.0.0.dist-info/entry_points.txt,sha256=ppZIgJ1vrmYs2EO9NcVSFCaZj7oj7t6RnJo8ArPQiRo,37
6
- kport-2.0.0.dist-info/top_level.txt,sha256=yzlMBPZ7a-pcCN4DR5MRPO-VjY3fWnILtFUQpEuA2xY,6
7
- kport-2.0.0.dist-info/RECORD,,
File without changes