Hallo,
was ich wirklich vermisse an sh.py ist die Möglichkeit im Webinterface Zugriff auf IPython zu haben.
Ich hatte damals sogar an einem Plugin begonnen
Aber da reichten meine Fähigkeiten nicht aus.
Ich denke aus dem code oben ist am nützlich sind v.a. die zwei Links.
Was denkt ihr?
Gruß,
Hendrik
was ich wirklich vermisse an sh.py ist die Möglichkeit im Webinterface Zugriff auf IPython zu haben.
Ich hatte damals sogar an einem Plugin begonnen
Code:
import logging
from lib.model.smartplugin import SmartPlugin
import sys
from IPython.terminal.ipapp import launch_new_instance
from IPython.lib import passwd
from socket import gethostname
import warnings
class IpythonServer(SmartPlugin):
PLUGIN_VERSION = "1.1.2"
ALLOW_MULTIINSTANCE = False
def __init__(self, smarthome):
self._sh = smarthome
self.logger = logging.getLogger(__name__)
self.start_server()
def run(self):
self.alive = True
# if you want to create child threads, do not make them daemon = True!
# They will not shutdown properly. (It's a python bug)
def start_server(self):
#http://stackoverflow.com/questions/26338688/start-ipython-notebook-with-python-file
#http://www.xavierdupre.fr/app/pyquickhelper/helpsphinx/ipython_notebook_args.html
warnings.filterwarnings("ignore", module = "zmq.*")
sys.argv.append("notebook")
sys.argv.append("--IPKernelApp.pylab='inline'")
sys.argv.append("--NotebookApp.ip=" + gethostname())
sys.argv.append("--NotebookApp.open_browser=False")
sys.argv.append("--NotebookApp.password="+passwd("dummy"))
sys.argv.append("--ip=\"*\"")
self.logger.info("[IPython] Starting server")
launch_new_instance()
def stop(self):
self.alive = False
def parse_item(self, item):
if 'plugin_attr' in item.conf:
logger.debug("parse item: {0}".format(item))
return self.update_item
else:
return None
def parse_logic(self, logic):
if 'xxx' in logic.conf:
# self.function(logic['name'])
pass
def update_item(self, item, caller=None, source=None, dest=None):
if caller != 'plugin':
logger.info("update item: {0}".format(item.id()))
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
myplugin = IpythonServer('smarthome-dummy')
myplugin.run()
Ich denke aus dem code oben ist am nützlich sind v.a. die zwei Links.
Was denkt ihr?
Gruß,
Hendrik


Kommentar