<s> '''<STR_LIT>''' <EOL> import logging <EOL> import signal <EOL> import sys <EOL> import time <EOL> from polyglot . config_manager import ConfigManager <EOL> from polyglot . element_manager import ElementManager <EOL> from polyglot . nodeserver_manager import NodeServerManager <EOL> from polyglot . version import PGVERSION <EOL> _LOGGER = logging . getLogger ( __name__ ) <EOL> class Polyglot ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , config_dir ) : <EOL> _LOGGER . info ( '<STR_LIT>' , PGVERSION ) <EOL> sys . modules [ '<STR_LIT>' ] = self <EOL> self . config = ConfigManager ( config_dir ) <EOL> self . elements = ElementManager ( self ) <EOL> self . nodeservers = NodeServerManager ( self ) <EOL> self . running = False <EOL> self . isy_version = self . config . get_isy_version ( ) <EOL> signal . signal ( signal . SIGTERM , self . stop ) <EOL> def setup ( self ) : <EOL> """<STR_LIT>""" <EOL> _LOGGER . info ( '<STR_LIT>' ) <EOL> self . elements . load ( ) <EOL> self . nodeservers . load ( ) <EOL> def run ( self ) : <EOL> """<STR_LIT>""" <EOL> self . running = True <EOL> try : <EOL> while self . running : <EOL> time . sleep ( <NUM_LIT:1> ) <EOL> except KeyboardInterrupt : <EOL> self . stop ( ) <EOL> def stop ( self , * args ) : <EOL> """<STR_LIT>""" <EOL> self . update_config ( ) <EOL> self . running = False <EOL> _LOGGER . info ( '<STR_LIT>' ) <EOL> self . nodeservers . unload ( ) <EOL> self . elements . unload ( ) <EOL> def update_config ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . running : <EOL> _LOGGER . info ( '<STR_LIT>' ) <EOL> return <EOL> _LOGGER . debug ( '<STR_LIT>' ) <EOL> config = { '<STR_LIT>' : self . nodeservers . config , <EOL> '<STR_LIT>' : self . elements . config } <EOL> self . config . update ( config ) <EOL> def get_log ( self ) : <EOL> """<STR_LIT>""" <EOL> fname = self . config . make_path ( '<STR_LIT>' ) <EOL> return open ( fname ) . read ( ) </s>
