Skip to content

Instantly share code, notes, and snippets.

@KitWallace
Created August 30, 2012 08:52
Show Gist options
  • Save KitWallace/3524417 to your computer and use it in GitHub Desktop.
Save KitWallace/3524417 to your computer and use it in GitHub Desktop.
simple switch to control processes
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