Advertisement
emerginginstance

Untitled

Sep 9th, 2021
5,021
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. import psutil
  2. import subprocess
  3. import time
  4. import datetime
  5.  
  6. search = "peerblock.exe"
  7. delay_seconds = 30
  8.  
  9. print("peerblock python script")
  10.  
  11. while(1):
  12.     found = False
  13.     print("searching ...")
  14.     for proc in psutil.process_iter():
  15.         try:
  16.             pinfo = proc.as_dict(attrs=['pid', 'name', 'username'])
  17.         except psutil.NoSuchProcess:
  18.             pass
  19.         else:
  20.             if pinfo["name"] == search:
  21.                 found = True
  22.                 print("peerblock is running")              
  23.                
  24.     if(not(found)):
  25.         try:
  26.             print("running peerblock...", datetime.datetime.now())
  27.             subprocess.call([r"C:\Program Files\PeerBlock\peerblock.exe"])
  28.         except ErrorType as e:
  29.             print(e)
  30.        
  31.     print("going to sleep")
  32.     time.sleep(delay_seconds)
  33.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement