res += "<html><h2>Basecamp Logbook:</h2><pre>" for line in reversed(open(tools.logfile_name).readlines()): res += line res += "</pre></html>" return res # ======================================================= # main loop if __name__ == "__main__": # initialize config/logs tools.load_config(optional_service_name="logbook") # .ini # startup_wait = tools.config.getint('startup', 'wait') # hostname = tools.config.get('main', 'hostname') # port = tools.config.getint('main', 'port') pushover_url = tools.config.get('pushover', 'pushover_url') pushover_timeout = tools.config.getint('pushover', 'pushover_timeout') sms_url = tools.config.get('sms', 'sms_url') admin_msisdn = tools.config.get('sms', 'admin_msisdn') sms_timeout = tools.config.getint('sms', 'sms_timeout') # also: getfloat, getint, getboolean tools.init_logs(formatter='%(asctime)s - %(message)s') influx_json_body = db.init() # no startup sync for logbook tools.log.info("WARNING [%s] [%s] : %s - (re)started!" % (tools.machine_name, tools.service_name, tools.service_version)) # run baby, run! alive_check() run(host=tools.hostname, port=tools.port, server='gevent')
res += line res += "</pre></html>" return res # ======================================================= # main loop if __name__ == "__main__": # initialize config/logs tools.load_config(optional_service_name="logbook") # .ini # startup_wait = tools.config.getint('startup', 'wait') # hostname = tools.config.get('main', 'hostname') # port = tools.config.getint('main', 'port') pushover_url = tools.config.get('pushover', 'pushover_url') pushover_timeout = tools.config.getint('pushover', 'pushover_timeout') sms_url = tools.config.get('sms', 'sms_url') admin_msisdn = tools.config.get('sms', 'admin_msisdn') sms_timeout = tools.config.getint('sms', 'sms_timeout') # also: getfloat, getint, getboolean tools.init_logs(formatter='%(asctime)s - %(message)s') influx_json_body = db.init() # no startup sync for logbook tools.log.info( "WARNING [%s] [%s] : %s - (re)started!" % (tools.machine_name, tools.service_name, tools.service_version)) # run baby, run! alive_check() run(host=tools.hostname, port=tools.port, server='gevent')
if request.params.alias in BT_aliases: (result, rssi) = scan_alias(request.params.alias) return({'alias': request.params.alias, 'result': result, 'rssi': str(rssi)}) else: return("ERROR: alias unknown!") else: return("ERROR: alias field not found!") # ======================================================= # main loop - load config, init logs, wait and run if __name__ == "__main__": # initialize config/logs tools.load_config() tools.init_logs() # .ini startup_wait = tools.config.getint('startup', 'wait') # also: getfloat, getint, getboolean # read the aliases & BT_addresses BT_aliases = {} for key in tools.config['BT']: BT_aliases[key] = tools.config['BT'][key] # startup sync & notification tools.log.info("--= Restarting =--") tools.log.info("sleeping {} seconds for startup sync between services...".format(startup_wait)) time.sleep(startup_wait) tools.notify("WARNING", tools.service_version+" - (re)started!") # run baby, run! regular_check() run(host=tools.hostname, port=tools.port, server='gevent')
@get('/alive') def do_alive(): return(tools.service_version) @get('/turn_mellotron_on') def turn_mellotron_on(): print("YES!!! :)") return("OK") # ======================================================= # main loop if __name__ == "__main__": # initialize config/logs tools.load_config(optional_service_name="alexa_interface") # .ini startup_wait = tools.config.getint('startup', 'wait') # also: getfloat, getint, getboolean tools.init_logs() influx_json_body = db.init() # startup sync & notification tools.log.info("--= Restarting =--") tools.log.info("sleeping {} seconds for startup sync between services...".format(startup_wait)) time.sleep(startup_wait) tools.notify("WARNING", tools.service_version+" - (re)started!") # alive_check() run(host=tools.hostname, port=tools.port, server='gevent')