added general getsig routine to get the correct signals from anywhere in the code.
This commit is contained in:
parent
4acb7d92db
commit
a995129df5
|
@ -6,6 +6,9 @@ from media.monitor.pure import LazyProperty
|
||||||
from media.monitor.config import MMConfig
|
from media.monitor.config import MMConfig
|
||||||
from api_clients.api_client import AirtimeApiClient
|
from api_clients.api_client import AirtimeApiClient
|
||||||
|
|
||||||
|
# poor man's phantom types...
|
||||||
|
class SignalString(str): pass
|
||||||
|
|
||||||
class AirtimeInstance(object):
|
class AirtimeInstance(object):
|
||||||
""" AirtimeInstance is a class that abstracts away every airtime
|
""" AirtimeInstance is a class that abstracts away every airtime
|
||||||
instance by providing all the necessary objects required to interact
|
instance by providing all the necessary objects required to interact
|
||||||
|
@ -29,6 +32,10 @@ class AirtimeInstance(object):
|
||||||
self.config_paths = config_paths
|
self.config_paths = config_paths
|
||||||
self.root_path = root_path
|
self.root_path = root_path
|
||||||
|
|
||||||
|
def signal(self, sig):
|
||||||
|
if isinstance(sig, SignalString): return sig
|
||||||
|
else: return SignalString("%s_%s" % (self.name, sig))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s,%s(%s)" % (self.name, self.root_path, self.config_paths)
|
return "%s,%s(%s)" % (self.name, self.root_path, self.config_paths)
|
||||||
|
|
||||||
|
|
|
@ -23,3 +23,5 @@ def user():
|
||||||
except AttributeError: raise UserlessThread()
|
except AttributeError: raise UserlessThread()
|
||||||
|
|
||||||
def apc(): return user().api_client
|
def apc(): return user().api_client
|
||||||
|
|
||||||
|
def getsig(s): return user().signal(s)
|
||||||
|
|
Loading…
Reference in New Issue