def on_message(self, msgid, content): #logger.info(u"MQ: New pub message {0}".format(msgid)) #logger.info(u"MQ: {0}".format(content)) # If sensor stat, we update the sensor last value if msgid == 'device-stats': if isinstance(content["stored_value"], list): content["stored_value"] = content["stored_value"][0] logger.error(u"MQ: PATCH for issue #1976") Sensor.update(content["sensor_id"], content["timestamp"], content["stored_value"]) WSHandler.sendAllMessage([msgid, content]) elif msgid == 'device.update': logger.info("MQ: message 'device.update' catched! Reloading the devices list") mqDataLoader.loadDevices(options.develop)
options.parse_config_file(SERVER_CONFIG) logger.info("Running from : %s" % domoweb.PROJECTPATH) packLoader.loadWidgets(domoweb.PACKSPATH, options.develop) packLoader.loadThemes(domoweb.PACKSPATH, options.develop) # TODO #packLoader.loadIcons(domoweb.PACKSPATH, options.develop) if not os.path.isdir(os.path.join(domoweb.VARPATH, 'backgrounds')): os.mkdir(os.path.join(domoweb.VARPATH, 'backgrounds')) logger.info("Creating : %s" % os.path.join(domoweb.VARPATH, 'backgrounds')) if not os.path.isdir(os.path.join(domoweb.VARPATH, 'backgrounds', 'thumbnails')): os.mkdir(os.path.join(domoweb.VARPATH, 'backgrounds', 'thumbnails')) mqDataLoader.loadDatatypes(options.develop) mqDataLoader.loadDevices(options.develop) logger.info("Starting tornado web server") # https if options.use_ssl: logger.info("SSL activated") logger.info("SSL certificate file : {0}".format(options.ssl_certificate)) logger.info("SSL certificate file : {0}".format(options.ssl_key)) http_server_ssl = tornado.httpserver.HTTPServer(application, ssl_options = { "certfile": os.path.join(options.ssl_certificate), "keyfile": os.path.join(options.ssl_key) }) logger.info("Start https server on port '{0}'".format(options.ssl_port)) http_server_ssl.listen(options.ssl_port) else:
# Check config file SERVER_CONFIG = '/etc/domoweb.cfg' if not os.path.isfile(SERVER_CONFIG): sys.stderr.write("Error: Can't find the file '%s'\n" % SERVER_CONFIG) sys.exit(1) options.define("sqlite_db", default="/var/lib/domoweb/db.sqlite", help="Database file path", type=str) options.define("port", default=40404, help="Launch on the given port", type=int) options.define("debut", default=False, help="Debug mode", type=bool) options.parse_config_file("/etc/domoweb.cfg") logger.info("Running from : %s" % domoweb.PROJECTPATH) packLoader.loadWidgets(domoweb.PACKSPATH) packLoader.loadIconsets(domoweb.PACKSPATH) if not os.path.isdir(os.path.join(domoweb.VARPATH, 'backgrounds')): os.mkdir(os.path.join(domoweb.VARPATH, 'backgrounds')) logger.info("Creating : %s" % os.path.join(domoweb.VARPATH, 'backgrounds')) if not os.path.isdir(os.path.join(domoweb.VARPATH, 'backgrounds', 'thumbnails')): os.mkdir(os.path.join(domoweb.VARPATH, 'backgrounds', 'thumbnails')) mqDataLoader.loadDatatypes() mqDataLoader.loadDevices() logger.info("Starting tornado web server") application.listen(options.port) logger.info("Starting MQ Handler") MQHandler() ioloop.IOLoop.instance().start()
logger.info("Running from : %s" % domoweb.PROJECTPATH) packLoader.loadWidgets(domoweb.PACKSPATH, options.develop) packLoader.loadThemes(domoweb.PACKSPATH, options.develop) # TODO #packLoader.loadIcons(domoweb.PACKSPATH, options.develop) if not os.path.isdir(os.path.join(domoweb.VARPATH, 'backgrounds')): os.mkdir(os.path.join(domoweb.VARPATH, 'backgrounds')) logger.info("Creating : %s" % os.path.join(domoweb.VARPATH, 'backgrounds')) if not os.path.isdir( os.path.join(domoweb.VARPATH, 'backgrounds', 'thumbnails')): os.mkdir(os.path.join(domoweb.VARPATH, 'backgrounds', 'thumbnails')) mqDataLoader.loadDatatypes(options.develop) mqDataLoader.loadDevices(options.develop) logger.info("Starting tornado web server") # https if options.use_ssl: logger.info("SSL activated") logger.info("SSL certificate file : {0}".format( options.ssl_certificate)) logger.info("SSL certificate file : {0}".format(options.ssl_key)) http_server_ssl = tornado.httpserver.HTTPServer( application, ssl_options={ "certfile": os.path.join(options.ssl_certificate), "keyfile": os.path.join(options.ssl_key) }) logger.info("Start https server on port '{0}'".format(