SHARE
TWEET

Untitled

a guest Mar 25th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import os
  2. import psutil
  3. import time
  4. from colorconsole import terminal
  5. screen = terminal.get_terminal(conEmu=False)
  6.  
  7. process_names = ['xxx.exe','xxx1.exe']
  8.  
  9.  
  10. def show_process_inc(procesies):
  11.     back_doc = dict()
  12.     for process in psutil.process_iter():
  13.         process_name = process.name()
  14.         process_id = process.pid
  15.  
  16.         if process_name in procesies:
  17.             process_key, _ = os.path.splitext(process_name)
  18.  
  19.             if process_key not in back_doc.keys():
  20.                 back_doc.update({ process_key.lower(): {'pid': [] , 'inc':0}})
  21.  
  22.             back_doc[process_key.lower()]['inc'] += 1
  23.             back_doc[process_key.lower()]['pid'].append(str(process_id))
  24.  
  25.     return back_doc
  26.  
  27.  
  28. while True:
  29.     time.sleep(3)
  30.     process_doc = show_process_inc(process_names)
  31.     print(time.time(), end='\t')
  32.     for key in process_doc.keys():
  33.         screen.set_color(2, 0)
  34.         print(key , end='  ')
  35.         screen.set_color(4, 0)
  36.         print(process_doc[key]["inc"], end='  ')
  37.         screen.reset_colors()
  38.         print(','.join(process_doc[key]['pid']), end='\t')
  39.  
  40.     print('')
  41.  
  42. print('done')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top