42
42
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
43
43
# SOFTWARE.
44
44
45
+ import argparse
45
46
import atexit
46
47
import datetime
47
48
import time
@@ -63,7 +64,7 @@ def platform_is_windows():
63
64
import win32api # For catching user closing the app window via the X icon
64
65
65
66
SCRIPT_NAME = "AutoProcPrio"
66
- SCRIPT_VERSION = "6.0 .0"
67
+ SCRIPT_VERSION = "6.1 .0"
67
68
68
69
69
70
def add_app (executable_name ):
@@ -335,13 +336,7 @@ def _try_psutil_set(self, fn, val):
335
336
return False
336
337
337
338
338
- print (f"\n \t == { SCRIPT_NAME } version { SCRIPT_VERSION } ==\n " )
339
-
340
339
PROCS = []
341
- for procname in BAD_PROCNAMES :
342
- PROCS .append (TargetProcs (procname , BAD_NICENESS , BAD_AFFINITY , VERBOSE ))
343
- for procname in GOOD_PROCNAMES :
344
- PROCS .append (TargetProcs (procname , GOOD_NICENESS , GOOD_AFFINITY , VERBOSE ))
345
340
346
341
347
342
def conditional (decorator , condition ):
@@ -372,7 +367,76 @@ def restore_original_ps_values():
372
367
373
368
374
369
def main ():
375
- """Entry point."""
370
+ parser = argparse .ArgumentParser (
371
+ prog = SCRIPT_NAME ,
372
+ description = "Automatically set processes' CPU priority and affinity "
373
+ "by process name" ,
374
+ epilog = f"Version { SCRIPT_VERSION } " ,
375
+ )
376
+ parser .add_argument (
377
+ "-g" ,
378
+ "--good" ,
379
+ help = "comma-delimited list of app(s) to prioritize (optional)" ,
380
+ )
381
+ parser .add_argument (
382
+ "-b" ,
383
+ "--bad" ,
384
+ help = "comma-delimited list of app(s) to deprioritize (optional)" ,
385
+ )
386
+ parser .add_argument (
387
+ "-G" ,
388
+ "--appendgood" ,
389
+ action = "store_true" ,
390
+ help = "if set, will append the good apps list instead of overwriting" ,
391
+ )
392
+ parser .add_argument (
393
+ "-B" ,
394
+ "--appendbad" ,
395
+ action = "store_true" ,
396
+ help = "if set, will append the bad apps list instead of overwriting" ,
397
+ )
398
+ args = parser .parse_args ()
399
+
400
+ print (f"\n \t == { SCRIPT_NAME } version { SCRIPT_VERSION } ==\n " )
401
+
402
+ global PROCS
403
+ if args .good is None or args .appendgood :
404
+ for procname in GOOD_PROCNAMES :
405
+ PROCS .append (
406
+ TargetProcs (procname , GOOD_NICENESS , GOOD_AFFINITY , VERBOSE )
407
+ )
408
+ try :
409
+ for procname in [
410
+ x
411
+ for x in list (set (args .good .split ("," )))
412
+ if add_app (x ) not in GOOD_PROCNAMES
413
+ ]:
414
+ PROCS .append (
415
+ TargetProcs (
416
+ add_app (procname ), GOOD_NICENESS , GOOD_AFFINITY , VERBOSE
417
+ )
418
+ )
419
+ except AttributeError :
420
+ pass
421
+
422
+ if args .bad is None or args .appendbad :
423
+ for procname in BAD_PROCNAMES :
424
+ PROCS .append (
425
+ TargetProcs (procname , BAD_NICENESS , BAD_AFFINITY , VERBOSE )
426
+ )
427
+ try :
428
+ for procname in [
429
+ x
430
+ for x in list (set (args .bad .split ("," )))
431
+ if add_app (x ) not in BAD_PROCNAMES
432
+ ]:
433
+ PROCS .append (
434
+ TargetProcs (add_app (procname ), BAD_NICENESS , BAD_AFFINITY ,
435
+ VERBOSE )
436
+ )
437
+ except AttributeError :
438
+ pass
439
+
376
440
global EXITING
377
441
while not EXITING :
378
442
print_info ("Proc update..." )
0 commit comments