From 0230b2647d088776fe7b99f56a78e2928099f56c Mon Sep 17 00:00:00 2001 From: onkelandy Date: Sat, 30 Dec 2023 08:50:11 +0100 Subject: [PATCH] operationlog plugin: remove webinterface code as there is no webif supported --- operationlog/__init__.py | 110 --------------------------------------- 1 file changed, 110 deletions(-) diff --git a/operationlog/__init__.py b/operationlog/__init__.py index 06f621785..0e45584e2 100755 --- a/operationlog/__init__.py +++ b/operationlog/__init__.py @@ -134,14 +134,10 @@ def __init__(self, sh): except Exception as e: self.logger.warning("OperationLog {}: problem reading cache: {}".format(self._path, e)) - # give some info to the user via webinterface - self.init_webinterface() - if self.logger.isEnabledFor(logging.DEBUG): self.logger.debug("init {} done".format(__name__)) self._init_complete = True - def update_logfilename(self): if self.__date == datetime.datetime.today() and self.__fname is not None: return @@ -422,46 +418,6 @@ def log(self, logvalues, level='INFO'): if self.additional_logger: self.additional_logger.log(logging.getLevelName(level), ' '.join(map(str, logvalues))) - def init_webinterface(self): - """" - Initialize the web interface for this plugin - - This method is only needed if the plugin is implementing a web interface - """ - try: - self.mod_http = Modules.get_instance().get_module( - 'http') # try/except to handle running in a core version that does not support modules - except: - self.mod_http = None - if self.mod_http == None: - self.logger.error("Not initializing the web interface") - return False - - import sys - if not "SmartPluginWebIf" in list(sys.modules['lib.model.smartplugin'].__dict__): - self.logger.warning("Web interface needs SmartHomeNG v1.5 and up. Not initializing the web interface") - return False - - # set application configuration for cherrypy - webif_dir = self.path_join(self.get_plugin_dir(), 'webif') - config = { - '/': { - 'tools.staticdir.root': webif_dir, - }, - '/static': { - 'tools.staticdir.on': True, - 'tools.staticdir.dir': 'static' - } - } - - # Register the web interface as a cherrypy app - self.mod_http.register_webif(WebInterface(webif_dir, self), - self.get_shortname(), - config, - self.get_classname(), self.get_instance_name(), - description='') - - return True ##################################################################### @@ -490,69 +446,3 @@ def _cache_write(logger, filename, value): pickle.dump(value, f) except IOError: logger.warning("Could not write to {}".format(filename)) - -# ------------------------------------------ -# Webinterface of the plugin -# ------------------------------------------ - -import cherrypy -from jinja2 import Environment, FileSystemLoader - - -class WebInterface(SmartPluginWebIf): - - def __init__(self, webif_dir, plugin): - """ - Initialization of instance of class WebInterface - - :param webif_dir: directory where the webinterface of the plugin resides - :param plugin: instance of the plugin - :type webif_dir: str - :type plugin: object - """ - self.logger = logging.getLogger(__name__) - self.webif_dir = webif_dir - self.plugin = plugin - self.tplenv = self.init_template_environment() - - self.items = Items.get_instance() - - @cherrypy.expose - def index(self, reload=None): - """ - Build index.html for cherrypy - - Render the template and return the html file to be delivered to the browser - - :return: contents of the template after beeing rendered - """ - tmpl = self.tplenv.get_template('index.html') - # add values to be passed to the Jinja2 template eg: tmpl.render(p=self.plugin, interface=interface, ...) - return tmpl.render(p=self.plugin, items=sorted(self.items.return_items(), key=lambda k: str.lower(k['_path']))) - - - @cherrypy.expose - def get_data_html(self, dataSet=None): - """ - Return data to update the webpage - - For the standard update mechanism of the web interface, the dataSet to return the data for is None - - :param dataSet: Dataset for which the data should be returned (standard: None) - :return: dict with the data needed to update the web page. - """ - if dataSet is None: - # get the new data - data = {} - - # data['item'] = {} - # for i in self.plugin.items: - # data['item'][i]['value'] = self.plugin.getitemvalue(i) - # - # return it as json the the web page - # try: - # return json.dumps(data) - # except Exception as e: - # self.logger.error("get_data_html exception: {}".format(e)) - return {} -