def _start_services(self): """starts JSON RPC server if service layer needs to be enabled for current app. this should be STEP 3 for starting application.""" if self.get_conf('webServiceEnabled'): self._service_publisher = ServicePublisher( self, self._xoze_context._xoze.services, self._xoze_context._action_controller, self.get_conf('webServicePath'), self.get_conf('webServicePort'), self._addon_path) self._service_publisher.publish_services()
def _start_services(self): """starts JSON RPC server if service layer needs to be enabled for current app. this should be STEP 3 for starting application.""" if self.get_conf('webServiceEnabled'): self._service_publisher = ServicePublisher(self, self._xoze_context._xoze.services, self._xoze_context._action_controller, self.get_conf('webServicePath'), self.get_conf('webServicePort'), self._addon_path) self._service_publisher.publish_services()
class AddonContext(Singleton): """Context contains bridge to access addon information such as version, settings, startup configurations""" def __initialize__(self, addon_id, conf={'webServiceEnabled': False}): system.show_busy_dialog() self._addon_id = addon_id self._addon = system.get_addon(addon_id) self._addon_ver = self._addon.getAddonInfo('version') self._addon_path = self._addon.getAddonInfo('path') self._addon_profile_path = self._addon.getAddonInfo('profile') self._configurations = conf self._current_addon = None self._current_addon_id = None self._service_publisher = None logging.getLogger().debug('context to be initialized...') self._xoze_context = XozeContext(self.get_conf('contextFiles'), self.get_addon(), self.get_addon_path(), self.get_addon_data_path()) logging.getLogger().debug('snapvideo to be initialized...') SnapVideo(context=self) # To initialize logging.getLogger().debug('web services to be initialized...') self._start_services() def _start_services(self): """starts JSON RPC server if service layer needs to be enabled for current app. this should be STEP 3 for starting application.""" if self.get_conf('webServiceEnabled'): self._service_publisher = ServicePublisher( self, self._xoze_context._xoze.services, self._xoze_context._action_controller, self.get_conf('webServicePath'), self.get_conf('webServicePort'), self._addon_path) self._service_publisher.publish_services() def enterServiceAddonMode(self): while not system.exit_signal: time.sleep(1) logging.getLogger().debug( 'exit signal received, going to stop JSON RPC Server instance for service path: %s' % (self._context_root)) self._service_publisher.unpublish_services() def set_current_addon(self, addon_id, context_files): if (self._current_addon_id is None): logging.getLogger().info('going to load addon: <%s>' % addon_id) elif (self._current_addon_id == addon_id): return else: logging.getLogger().info( 'going to load addon: <%s> ; unload existing addon: <%s>' % (addon_id, self._current_addon_id)) del self._current_addon_id del self._current_addon self._current_addon_id = addon_id addon = system.get_addon(addon_id) addon_ver = addon.getAddonInfo('version') addon_path = addon.getAddonInfo('path') addon_data_path = addon.getAddonInfo('profile') logging.getLogger().info( 'set current addon: <%s>, version: <%s>, addon-path: <%s>, addon-data-path: <%s>' % (addon_id, addon_ver, addon_path, addon_data_path)) self._current_addon = XozeContext(context_files, addon, addon_path, addon_data_path) def get_current_addon(self): if (self._current_addon is None): return self._xoze_context else: return self._current_addon def get_addon(self): return self._addon def get_addon_path(self): return self._addon_path def get_addon_data_path(self): return self._addon_profile_path def get_conf(self, key): if self._configurations.has_key(key): return self._configurations[key] else: return None def do_clean(self): logging.getLogger().debug( 'addon exiting, deleting objects as part of exit plan...') self._xoze_context.do_clean() if self._current_addon is not None: self._current_addon.do_clean() del self._current_addon del self._current_addon_id if self._service_publisher is not None: self._service_publisher.unpublish_services() self._service_publisher.do_clean() del self._service_publisher del self._addon del self._addon_id del self._addon_ver del self._addon_path del self._addon_profile_path del self._configurations del self._xoze_context http_client = HttpClient() http_client.do_clean() del http_client cache_manager = CacheManager() cache_manager.do_clean() del cache_manager snap_video = SnapVideo() snap_video.do_clean() del snap_video
class AddonContext(Singleton): """Context contains bridge to access addon information such as version, settings, startup configurations""" def __initialize__(self, addon_id, conf={'webServiceEnabled':False}): system.show_busy_dialog() self._addon_id = addon_id self._addon = system.get_addon(addon_id) self._addon_ver = self._addon.getAddonInfo('version') self._addon_path = self._addon.getAddonInfo('path') self._addon_profile_path = self._addon.getAddonInfo('profile') self._configurations = conf self._current_addon = None self._current_addon_id = None self._service_publisher = None logging.getLogger().debug('context to be initialized...') self._xoze_context = XozeContext(self.get_conf('contextFiles'), self.get_addon(), self.get_addon_path(), self.get_addon_data_path()) logging.getLogger().debug('snapvideo to be initialized...') SnapVideo(context=self) # To initialize logging.getLogger().debug('web services to be initialized...') self._start_services() def _start_services(self): """starts JSON RPC server if service layer needs to be enabled for current app. this should be STEP 3 for starting application.""" if self.get_conf('webServiceEnabled'): self._service_publisher = ServicePublisher(self, self._xoze_context._xoze.services, self._xoze_context._action_controller, self.get_conf('webServicePath'), self.get_conf('webServicePort'), self._addon_path) self._service_publisher.publish_services() def enterServiceAddonMode(self): while not system.exit_signal: time.sleep(1) logging.getLogger().debug('exit signal received, going to stop JSON RPC Server instance for service path: %s' % (self._context_root)) self._service_publisher.unpublish_services() def set_current_addon(self, addon_id, context_files): if(self._current_addon_id is None): logging.getLogger().info('going to load addon: <%s>' % addon_id) elif(self._current_addon_id == addon_id): return else: logging.getLogger().info('going to load addon: <%s> ; unload existing addon: <%s>' % (addon_id, self._current_addon_id)) del self._current_addon_id del self._current_addon self._current_addon_id = addon_id addon = system.get_addon(addon_id) addon_ver = addon.getAddonInfo('version') addon_path = addon.getAddonInfo('path') addon_data_path = addon.getAddonInfo('profile') logging.getLogger().info('set current addon: <%s>, version: <%s>, addon-path: <%s>, addon-data-path: <%s>' % (addon_id, addon_ver, addon_path, addon_data_path)) self._current_addon = XozeContext(context_files, addon, addon_path, addon_data_path) def get_current_addon(self): if(self._current_addon is None): return self._xoze_context else: return self._current_addon def get_addon(self): return self._addon def get_addon_path(self): return self._addon_path def get_addon_data_path(self): return self._addon_profile_path def get_conf(self, key): if self._configurations.has_key(key): return self._configurations[key] else: return None def do_clean(self): logging.getLogger().debug('addon exiting, deleting objects as part of exit plan...') self._xoze_context.do_clean() if self._current_addon is not None: self._current_addon.do_clean() del self._current_addon del self._current_addon_id if self._service_publisher is not None: self._service_publisher.unpublish_services() self._service_publisher.do_clean() del self._service_publisher del self._addon del self._addon_id del self._addon_ver del self._addon_path del self._addon_profile_path del self._configurations del self._xoze_context http_client = HttpClient() http_client.do_clean() del http_client cache_manager = CacheManager() cache_manager.do_clean() del cache_manager snap_video = SnapVideo() snap_video.do_clean() del snap_video