mirror of
https://github.com/Death916/minestart.git
synced 2026-04-10 03:33:43 -07:00
kill miner on game start
This commit is contained in:
parent
ffdc2dc4c1
commit
07c66a6add
1 changed files with 25 additions and 18 deletions
33
minestart.py
33
minestart.py
|
|
@ -1,10 +1,11 @@
|
||||||
"""" restart miner when gpu is low usage and kill miner if already running
|
"""" restart miner when gpu is low usage and kill miner if already running
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import GPUtil as gpu
|
|
||||||
import time
|
import time
|
||||||
import psutil
|
|
||||||
from subprocess import CREATE_NEW_CONSOLE
|
from subprocess import CREATE_NEW_CONSOLE
|
||||||
|
import GPUtil as gpu
|
||||||
|
import keyboard
|
||||||
|
import psutil
|
||||||
|
|
||||||
gameList = {"gears": "gears5.exe",
|
gameList = {"gears": "gears5.exe",
|
||||||
"outer_worlds": "IndianaWindowsStore-Win64-Shipping.exe",
|
"outer_worlds": "IndianaWindowsStore-Win64-Shipping.exe",
|
||||||
|
|
@ -14,7 +15,6 @@ gameList = {"gears": "gears5.exe",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def checkgpu():
|
def checkgpu():
|
||||||
card = gpu.getGPUs()
|
card = gpu.getGPUs()
|
||||||
isavailable = gpu.getAvailability(card, maxLoad=.6)
|
isavailable = gpu.getAvailability(card, maxLoad=.6)
|
||||||
|
|
@ -27,7 +27,7 @@ def checkgpu():
|
||||||
if isavailable == [0]:
|
if isavailable == [0]:
|
||||||
print("gpu in use")
|
print("gpu in use")
|
||||||
gpu.showUtilization()
|
gpu.showUtilization()
|
||||||
time.sleep(500)
|
time.sleep(5)
|
||||||
|
|
||||||
return 'notavailable'
|
return 'notavailable'
|
||||||
|
|
||||||
|
|
@ -63,23 +63,25 @@ def killminer():
|
||||||
|
|
||||||
|
|
||||||
def startminer():
|
def startminer():
|
||||||
|
keyboard.press_and_release('alt+x')
|
||||||
psutil.Popen(['E:/downloads/ccminer.bat'], creationflags=CREATE_NEW_CONSOLE)
|
psutil.Popen(['E:/downloads/ccminer.bat'], creationflags=CREATE_NEW_CONSOLE)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def checkgames():
|
def checkgames():
|
||||||
|
|
||||||
game = 0
|
game = 0
|
||||||
for i in gameList.values():
|
for i in gameList.values():
|
||||||
game = findProcessIdByName(i)
|
game = findProcessIdByName(i)
|
||||||
if game == []:
|
if game:
|
||||||
print(i + " is not running")
|
print("game is running")
|
||||||
pass
|
|
||||||
else:
|
|
||||||
print(i + " is running" )
|
|
||||||
print(game)
|
print(game)
|
||||||
|
miners = checkminer()
|
||||||
|
if miners == 'running':
|
||||||
killminer()
|
killminer()
|
||||||
|
keyboard.press_and_release('alt+y')
|
||||||
|
return 'gamerunning'
|
||||||
|
else:
|
||||||
|
return 'nogame'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -91,13 +93,16 @@ def checkgames():
|
||||||
"""
|
"""
|
||||||
curTime = time.time()
|
curTime = time.time()
|
||||||
while True:
|
while True:
|
||||||
checkgames()
|
|
||||||
gpus = checkgpu()
|
gpus = checkgpu()
|
||||||
miner = checkminer()
|
miner = checkminer()
|
||||||
|
checkgames()
|
||||||
usage = str(gpu.showUtilization())
|
usage = str(gpu.showUtilization())
|
||||||
#log(str(gpu.showUtilization()))
|
#log(str(gpu.showUtilization()))
|
||||||
|
|
||||||
if gpus is 'isavailable' and miner is 'notrunning':
|
if gpus is 'isavailable' and miner is 'notrunning':
|
||||||
|
x = checkgames()
|
||||||
|
if x != 'gamerunning':
|
||||||
print('starting miner')
|
print('starting miner')
|
||||||
startminer()
|
startminer()
|
||||||
time.sleep(120)
|
time.sleep(120)
|
||||||
|
|
@ -113,4 +118,6 @@ while True:
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
|
||||||
|
|
||||||
##TODO:check for games running probably best way is to make a list of all games and check against list
|
##TODO:check temp
|
||||||
|
|
||||||
|
#TODO: if no network kill and wait
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue