def start(addon_id, service_name, context_root, default_port, allowed_port_range): try: global __addon_id__ global __registered_services__ global __context_root__ global __port__ global __port_range__ global __service_name__ __addon_id__ = addon_id __context_root__ = context_root __port__ = default_port __port_range__ = allowed_port_range __service_name__ = service_name containerObj = Container(addon_id=addon_id) iconimage = AddonUtils.getCompleteFilePath( baseDirPath=containerObj.getAddonContext().addonPath, filename='icon.png') serviceport = int( containerObj.getAddonContext().addon.getSetting('serviceport')) XBMCInterfaceUtils.setSuppressDialogMsg(True) if serviceport < __port_range__[0] or serviceport > __port_range__[1]: containerObj.getAddonContext().addon.setSetting( 'serviceport', str(__port__)) serviceport = __port__ XBMCInterfaceUtils.displayNotification( __service_name__ + ' Service: Port updated', 'Service port set to default value 8181', iconimage=iconimage) server = JSONRPCServer(context_root=__context_root__, server_port=serviceport) server.registerService('serviceName', serviceMethod) defined_services = containerObj.getAddonContext().getTurtleServices() if len(defined_services) == 0: print __service_name__ + ' Service :: There are no services defined for registration, end this service program now.' return for service in defined_services: server.registerService(service.get_service_name(), serviceMethod) __registered_services__[ service.get_service_name()] = service.get_action_id() print __service_name__ + ' Service :: service registered = %s @ %s' % ( service.get_service_name(), __context_root__) server.start() XBMCInterfaceUtils.displayNotification( __service_name__ + ' Service has started', 'Use safari extension to play video remotely', iconimage=iconimage) while not xbmc.abortRequested: time.sleep(5) print __service_name__ + ' Service :: ABORT request received from XBMC. PlayIt service will stop now.' except Exception, e: print __service_name__ + ' Service :: ERROR OCCURRED: ' + str(e) ExceptionHandler.handle(e)
def start(addon_id, service_name, context_root, default_port, allowed_port_range): server = None try: sys.argv = None # To handle the situations where some library expects system arguments. Main change made for t0mm0 urlresolver library. global __addon_id__ global __registered_services__ global __context_root__ global __port__ global __port_range__ global __service_name__ __addon_id__ = addon_id __context_root__ = context_root __port__ = default_port __port_range__ = allowed_port_range __service_name__ = service_name containerObj = Container(addon_id=addon_id) iconimage = AddonUtils.getCompleteFilePath(baseDirPath=containerObj.getAddonContext().addonPath, filename='icon.png') serviceport = int(containerObj.getAddonContext().addon.getSetting('serviceport')) XBMCInterfaceUtils.setSuppressDialogMsg(True) if serviceport < __port_range__[0] or serviceport > __port_range__[1] : containerObj.getAddonContext().addon.setSetting('serviceport', str(__port__)) serviceport = __port__ XBMCInterfaceUtils.displayNotification(__service_name__ + ' Service: Port updated', 'Service port set to default value 8181', iconimage=iconimage) server = JSONRPCServer(context_root=__context_root__, server_port=serviceport) server.registerService('serviceName', serviceMethod) defined_services = containerObj.getAddonContext().getTurtleServices() if len(defined_services) == 0: Logger.logError(__service_name__ + ' Service :: There are no services defined for registration, end this service program now.') return for service in defined_services: server.registerService(service.get_service_name(), serviceMethod) __registered_services__[service.get_service_name()] = service.get_action_id() Logger.logInfo(__service_name__ + ' Service :: service registered = %s @ %s' % (service.get_service_name(), __context_root__)) server.start() # XBMCInterfaceUtils.displayNotification(__service_name__ + ' Service has started', 'Use web browser PlayIt extension to play video.', iconimage=iconimage) while not xbmc.abortRequested: time.sleep(1) Logger.logInfo(__service_name__ + ' Service :: ABORT request received from XBMC. PlayIt service will stop now.') except Exception, e: Logger.logFatal(__service_name__ + ' Service :: ERROR OCCURRED: ' + str(e)) ExceptionHandler.handle(e)
def start(addon_id, service_name, context_root, default_port, allowed_port_range): try: global __addon_id__ global __registered_services__ global __context_root__ global __port__ global __port_range__ global __service_name__ __addon_id__ = addon_id __context_root__ = context_root __port__ = default_port __port_range__ = allowed_port_range __service_name__ = service_name containerObj = Container(addon_id=addon_id) iconimage = AddonUtils.getCompleteFilePath(baseDirPath=containerObj.getAddonContext().addonPath, filename='icon.png') serviceport = int(containerObj.getAddonContext().addon.getSetting('serviceport')) XBMCInterfaceUtils.setSuppressDialogMsg(True) if serviceport < __port_range__[0] or serviceport > __port_range__[1] : containerObj.getAddonContext().addon.setSetting('serviceport', str(__port__)) serviceport = __port__ XBMCInterfaceUtils.displayNotification(__service_name__ + ' Service: Port updated', 'Service port set to default value 8181', iconimage=iconimage) server = JSONRPCServer(context_root=__context_root__, server_port=serviceport) server.registerService('serviceName', serviceMethod) defined_services = containerObj.getAddonContext().getTurtleServices() if len(defined_services) == 0: print __service_name__ + ' Service :: There are no services defined for registration, end this service program now.' return for service in defined_services: server.registerService(service.get_service_name(), serviceMethod) __registered_services__[service.get_service_name()] = service.get_action_id() print __service_name__ + ' Service :: service registered = %s @ %s' % (service.get_service_name(), __context_root__) server.start() XBMCInterfaceUtils.displayNotification(__service_name__ + ' Service has started', 'Use safari extension to play video remotely', iconimage=iconimage) while not xbmc.abortRequested: time.sleep(5) print __service_name__ + ' Service :: ABORT request received from XBMC. PlayIt service will stop now.' except Exception, e: print __service_name__ + ' Service :: ERROR OCCURRED: ' + str(e) ExceptionHandler.handle(e)
''' Created on Dec 27, 2011 @author: ajju ''' try: import TurtlePlugin from common import XBMCInterfaceUtils XBMCInterfaceUtils.setSuppressDialogMsg(True) except: import xbmcgui # @UnresolvedImport dialog = xbmcgui.Dialog() dialog.ok('[B][COLOR red]ALERT: [/COLOR][/B] RESTART XBMC', 'A new update has recently installed or add-on reconfigured.', 'Please restart XBMC to reflect the changes.', 'You will not be able to access until restart.') TurtlePlugin.start('plugin.playitx')