-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInsomnia.py
49 lines (38 loc) · 1.46 KB
/
Insomnia.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
from Deadline.Events import *
import subprocess
def GetDeadlineEventListener():
return Insomnia()
def CleanupDeadlineEventListener(deadlinePlugin):
deadlinePlugin.Cleanup()
class Insomnia(DeadlineEventListener):
def __init__(self):
self.OnSlaveStartingJobCallback += self.OnSlaveStartingJob
self.OnJobResumedCallback += self.OnJobStarted
self.OnJobStartedCallback += self.OnJobStarted
self.OnJobFinishedCallback += self.OnJobFinished
self.OnJobFailedCallback += self.OnJobFinished
self.OnSlaveIdleCallback += self.OnSlaveIdle
def Cleanup(self):
del self.OnSlaveStartingJobCallback
del self.OnJobResumedCallback
del self.OnJobStartedCallback
del self.OnJobFinishedCallback
del self.OnJobFailedCallback
del self.OnSlaveIdleCallback
def OnJobStarted(self, job):
self.Start()
def OnJobFinished(self, job):
self.Finished()
def OnSlaveIdle(self, slave):
self.Finished()
def OnSlaveStartingJob(self, job, controller):
self.Start()
def Start(self):
self.LogInfo("Started")
subprocess.call(["powercfg", "-change", "standby-timeout-ac", "0"])
self.LogInfo("SET TO MAX SPEED")
def Finished(self):
time = self.GetConfigEntryWithDefault("RegularSleepTime", "20")
subprocess.call(["powercfg", "-change", "standby-timeout-ac", time])
self.LogInfo("SET TO BALANCED")