def doInitInterfaces(self, *args, **kwargs): if _Debug: lg.out(_DebugLevel, 'initializer.doInitInterfaces') # if settings.enableFTPServer(): # try: # from interface import ftp_server # ftp_server.init() # except: # lg.exc() if settings.enableAPIAuthSecret(): current_secret = local_fs.ReadTextFile(settings.APISecretFile()) if not current_secret: new_secret = cipher.generate_secret_text(10) local_fs.WriteTextFile(settings.APISecretFile(), new_secret) lg.info('generated new API auth secret text and stored in %r' % settings.APISecretFile()) if settings.enableRESTHTTPServer(): try: from interface import api_rest_http_server api_rest_http_server.init(port=settings.getRESTHTTPServerPort()) except: lg.exc() if settings.enableWebSocketServer(): try: from interface import api_web_socket api_web_socket.init(port=settings.getWebSocketServerPort()) except: lg.exc() reactor.callLater(0, self.automat, 'init-interfaces-done') # @UndefinedVariable
def read_api_secret(): global _APISecret _APISecret = local_fs.ReadTextFile(settings.APISecretFile())