Пример #1
0
 def __init__(self, local_km=None,
              host=u'127.0.0.1', port=8080, start=False,
              web_interface=False, dbase=u'default'):
     """
     Arguments:
     - `local_km`: Local KnowledgeManager instance to hook up to.
       If set to `None`, KnowledgeManager.getInstance() is used.
     - `host`: hostname to listen on
     - `port`: port to listen on
     - `start`: flag that indicates whether to start the server
     - `web_interface`: flag that indicates whether to enable
       the web interface. You can enable/disable it anytime by
       setting (KN instance).web_interface.enabled to `True`/`False`.
     - `dbase`: leave this to 'default', other values are allowed for
                debug purposes
     """
     RoutingHTTPServer.__init__(self, host, port, start)
     if local_km == None:
         local_km = KnowledgeManager.getInstance()
     self.km = local_km
     self.remotes = []
     if dbase == u'default':
         self._dbase = os.path.join(getPyphantPath('sqlite3'),
                                    'kn_remotes.sqlite3')
     else:
         self._dbase = dbase
     self._restore_remotes()
     self._setup_routes()
     self._tempdir = mkdtemp(prefix='HDF5Wrap')
     tpl_path = pkg_resources.resource_filename('pyphant', 'web/templates')
     if not tpl_path in pyphant.core.bottle.TEMPLATE_PATH:
         pyphant.core.bottle.TEMPLATE_PATH.append(tpl_path)
     from pyphant.core.WebInterface import WebInterface
     self.web_interface = WebInterface(self, web_interface)
     self.km.node = self
Пример #2
0
 def stop(self):
     RoutingHTTPServer.stop(self)
     if not hasattr(self, '_tempdir'):
         return
     if os.path.isdir(self._tempdir):
         from shutil import rmtree
         try:
             rmtree(self._tempdir)
         except OSError:
             km.logger.warn("Could not delete '%s'." % self._tempdir)
Пример #3
0
 def stop(self):
     RoutingHTTPServer.stop(self)
     if not hasattr(self, '_tempdir'):
         return
     if os.path.isdir(self._tempdir):
         from shutil import rmtree
         try:
             rmtree(self._tempdir)
         except OSError:
             self.km.logger.warn("Could not delete '%s'." % self._tempdir)
Пример #4
0
 def __init__(self,
              local_km=None,
              host=u'127.0.0.1',
              port=8080,
              start=False,
              web_interface=False,
              dbase=u'default'):
     """
     Arguments:
     - `local_km`: Local KnowledgeManager instance to hook up to.
       If set to `None`, KnowledgeManager.getInstance() is used.
     - `host`: hostname to listen on
     - `port`: port to listen on
     - `start`: flag that indicates whether to start the server
     - `web_interface`: flag that indicates whether to enable
       the web interface. You can enable/disable it anytime by
       setting (KN instance).web_interface.enabled to `True`/`False`.
     - `dbase`: leave this to 'default', other values are allowed for
                debug purposes
     """
     RoutingHTTPServer.__init__(self, host, port, start)
     if local_km == None:
         local_km = KnowledgeManager.getInstance()
     self.km = local_km
     self.remotes = []
     if dbase == u'default':
         self._dbase = os.path.join(getPyphantPath('sqlite3'),
                                    'kn_remotes.sqlite3')
     else:
         self._dbase = dbase
     self._restore_remotes()
     self._setup_routes()
     self._tempdir = mkdtemp(prefix='HDF5Wrap')
     tpl_path = os.path.join(pyphant_source_path[0], 'web', 'templates')
     if not tpl_path in pyphant.core.bottle.TEMPLATE_PATH:
         pyphant.core.bottle.TEMPLATE_PATH.append(tpl_path)
     from pyphant.core.WebInterface import WebInterface
     self.web_interface = WebInterface(self, web_interface)
     self.km.node = self