<s> from ajenti . api import * <EOL> from ajenti . util import cache_value <EOL> @ plugin <EOL> @ persistent <EOL> class ServiceMultiplexor ( object ) : <EOL> """<STR_LIT>""" <EOL> def init ( self ) : <EOL> self . managers = ServiceManager . get_all ( ) <EOL> @ cache_value ( <NUM_LIT:1> ) <EOL> def get_all ( self ) : <EOL> """<STR_LIT>""" <EOL> r = [ ] <EOL> for mgr in self . managers : <EOL> r += mgr . get_all ( ) <EOL> return r <EOL> def get_one ( self , name ) : <EOL> """<STR_LIT>""" <EOL> for mgr in self . managers : <EOL> s = mgr . get_one ( name ) <EOL> if s : <EOL> return s <EOL> return None <EOL> @ interface <EOL> @ persistent <EOL> class ServiceManager ( object ) : <EOL> def get_all ( self ) : <EOL> return [ ] <EOL> def get_one ( self , name ) : <EOL> """<STR_LIT>""" <EOL> for s in self . get_all ( ) : <EOL> if s . name == name : <EOL> return s <EOL> return None <EOL> class Service ( object ) : <EOL> source = '<STR_LIT>' <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . name = None <EOL> self . running = False <EOL> @ property <EOL> def icon ( self ) : <EOL> return '<STR_LIT>' if self . running else None <EOL> def start ( self ) : <EOL> pass <EOL> def stop ( self ) : <EOL> pass <EOL> def restart ( self ) : <EOL> pass <EOL> def command ( self , cmd ) : <EOL> pass </s>
