Created
August 30, 2012 08:52
-
-
Save KitWallace/3524417 to your computer and use it in GitHub Desktop.
simple switch to control processes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from persistant import * | |
class Switch(Persistant) : | |
def __init__(self,name) : | |
self.name = name | |
self.on = True | |
def switch_on(self) : | |
self.on= True | |
return self | |
def switch_off(self) : | |
self.on= False | |
return self | |
def toggle(self) : | |
self.on = not self.on | |
return self | |
@property | |
def status(self) : | |
if self.on is None : | |
return "unset" | |
elif self.on : | |
return "on" | |
else : | |
return "off" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment