logs_basedir = "%s/logs" % basedir if not os.path.exists(logs_basedir): os.mkdir(logs_basedir) logfile = "%s/piautomator.log" % logs_basedir formatting = logging.Formatter(log_format, None) handler = RotatingFileHandler(logfile, maxBytes=1024 * 1024 * 100, backupCount=3) handler.setFormatter(formatting) logging.root.addHandler(handler) else: logging.basicConfig(format=log_format) # Initialize all components global automation_context automation_context = AutomationContext(config) automation_context.receivers = receivers.init(automation_context) automation_context.inputs = inputs.init(automation_context) automation_context.rule_context = rules.init(automation_context) automation_context.start() # Setup the handler that will terminate our event loops. global running running = True def signal_handler(signal, frame): global running running = False automation_context.stop()
def setUp(self): mock = Mock() mock.getSetting = MagicMock(return_value = False) self.context = AutomationContext(mock) self.context.__start_publish_queue__()