Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import psutil
- import subprocess
- import time
- import datetime
- search = "peerblock.exe"
- delay_seconds = 30
- print("peerblock python script")
- while(1):
- found = False
- print("searching ...")
- for proc in psutil.process_iter():
- try:
- pinfo = proc.as_dict(attrs=['pid', 'name', 'username'])
- except psutil.NoSuchProcess:
- pass
- else:
- if pinfo["name"] == search:
- found = True
- print("peerblock is running")
- if(not(found)):
- try:
- print("running peerblock...", datetime.datetime.now())
- subprocess.call([r"C:\Program Files\PeerBlock\peerblock.exe"])
- except ErrorType as e:
- print(e)
- print("going to sleep")
- time.sleep(delay_seconds)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement