class Main: """ Main plugin class """ def __init__( self, *args, **kwargs ): if True: #self._check_compatible(): self.pluginMgr = PluginMgr() self.parameters = self.pluginMgr.parse_params() self._createMissingModulesDir() self.pluginMgr.add_sort_methods( False ) self.pluginMgr.end_of_directory( True, update=False ) def _check_addon_lib(self): """ Check id xbmcaddon module is available Returns 1 if success, 0 otherwise """ ok = 1 try: import xbmcaddon except ImportError: ok = 0 return ok def _createMissingModulesDir ( self ): """ Creates list of missing modules For now this is retrieve from local DB (persistent file) TODO: implement option in order to check each installed addon """ if os.path.exists(MISSING_MODULES_PATH): pdr = PersistentDataRetriever( MISSING_MODULES_PATH ) missingModules = pdr.get_data() print missingModules for lib in missingModules: self.pluginMgr.addLink( lib["id"], "" ) else: print "No missing modules found"
class Main: """ Main plugin class """ def __init__(self, *args, **kwargs): if True: #self._check_compatible(): self.pluginMgr = PluginMgr() self.parameters = self.pluginMgr.parse_params() self._createMissingModulesDir() self.pluginMgr.add_sort_methods(False) self.pluginMgr.end_of_directory(True, update=False) def _check_addon_lib(self): """ Check id xbmcaddon module is available Returns 1 if success, 0 otherwise """ ok = 1 try: import xbmcaddon except ImportError: ok = 0 return ok def _createMissingModulesDir(self): """ Creates list of missing modules For now this is retrieve from local DB (persistent file) TODO: implement option in order to check each installed addon """ if os.path.exists(MISSING_MODULES_PATH): pdr = PersistentDataRetriever(MISSING_MODULES_PATH) missingModules = pdr.get_data() print missingModules for lib in missingModules: self.pluginMgr.addLink(lib["id"], "") else: print "No missing modules found"
class Main: """ Main plugin class """ def __init__( self, *args, **kwargs ): if True: #self._check_compatible(): self.pluginMgr = PluginMgr() self.parameters = self.pluginMgr.parse_params() # if 1st start create missing directories self.fileMgr = fileMgr() self.fileMgr.verifrep( DIR_ADDON_MODULE ) self.fileMgr.verifrep( DIR_ADDON_REPO ) self.fileMgr.verifrep( DIR_CACHE ) self.fileMgr.verifrep( DIR_CACHE_ADDONS ) # Check settings if xbmcplugin.getSetting('first_run') == 'true': # Check (only the 1st time) is xbmcaddon module is available print( " **First run") if self._check_addon_lib(): print( " XBMC Addon 4 XBOX Addon Library already installed") print( " Installing default repositories") if ( self._installRepos() ): xbmcplugin.setSetting('first_run','false') self._createRootDir() else: print( " ERROR - XBMC Addon 4 XBOX Addon Library MISSING") dialog = xbmcgui.Dialog() dialog.ok( __language__(30000), __language__(30091) ,__language__(30092)) else: self._createRootDir() self.pluginMgr.add_sort_methods( False ) self.pluginMgr.end_of_directory( True, update=False ) def _check_addon_lib(self): """ Check id xbmcaddon module is available Returns 1 if success, 0 otherwise """ ok = 1 try: import xbmcaddon except ImportError: ok = 0 return ok def _check_compatible(self): """ Check if XBMC version is compatible with the plugin """ xbmcgui = None try: # spam plugin statistics to log print( "[PLUGIN] '%s: Version - %s-r%s' initialized!" % ( __plugin__, __version__, __svn_revision__.replace( "$", "" ).replace( "Revision", "" ).strip( ": " ) ) ) # get xbmc revision xbmc_version = xbmc.getInfoLabel( "System.BuildVersion" ) xbmc_rev = int( xbmc_version.split( " " )[ 1 ].replace( "r", "" ) ) # compatible? ok = xbmc_rev >= int( __XBMC_Revision__ ) print xbmc_rev print __XBMC_Revision__ except: # error, so unknown, allow to run print_exc() xbmc_rev = 0 ok = 2 # spam revision info print( " ** Required XBMC Revision: r%s **" % ( __XBMC_Revision__, ) ) print( " ** Found XBMC Revision: r%d [%s] **" % ( xbmc_rev, ( "Not Compatible", "Compatible", "Unknown", )[ ok ], ) ) # if not compatible, inform user if ( not ok ): xbmcgui.Dialog().ok( "%s - %s: %s" % ( __plugin__, __language__( 30900 ), __version__, ), __language__( 30901 ) % ( __plugin__, ), __language__( 30902 ) % ( __XBMC_Revision__, ), __language__( 30903 ) ) #if not xbmc run under xbox, inform user # get xbmc run under? platform = os.environ.get( "OS", "xbox" ) if ( platform.upper() not in __platform__ ): ok = 0 print( "system::os.environ [%s], This plugin run under %s only." % ( platform, __platform__, ) ) if xbmcgui == None: xbmcgui.Dialog().ok( __plugin__, "%s: system::os.environ [[COLOR=ffe2ff43]%s[/COLOR]]" % ( __language__( 30904 ), platform, ), __language__( 30905 ) % __platform__ ) return ok def _installRepos(self): """ Install default repositories in the plugin data directory """ ok = 0 repo_source = os.path.join( ROOTDIR, "resources", "repositories" ) try: if os.path.exists( repo_source ): self.fileMgr.copyDir( repo_source, DIR_ADDON_REPO ) print "SUCCESS: Repositories copied %s"%DIR_ADDON_REPO ok = 1 else: dialog = xbmcgui.Dialog() dialog.ok( __language__(30000), __language__(30006), __language__(30007) ) print "ERROR: impossible to copy repositories" print "Repositories are missing in the plugin structure" except: dialog = xbmcgui.Dialog() dialog.ok( __language__(30000), __language__(30006), __language__(30007) ) print "ERROR: impossible to copy repositories to %s"%DIR_ADDON_REPO print_exc() return ok def _createRootDir ( self ): """ Creates root list of the plugin """ paramsDicRepo = {} paramsDicRepo[PARAM_LISTTYPE] = VALUE_LIST_LOCAL_REPOS urlRepo = self.pluginMgr.create_param_url( paramsDicRepo ) if urlRepo: self.pluginMgr.addDir( __language__( 30202 ), urlRepo ) paramsDicZip = {} paramsDicZip[PARAM_INSTALL_FROM_ZIP] = "true" urlZip = self.pluginMgr.create_param_url( paramsDicZip ) if urlZip: self.pluginMgr.addLink( __language__( 30203 ), urlZip ) paramsDicRepo = {} paramsDicRepo[PARAM_LISTTYPE] = VALUE_LIST_WIKI_REPOS urlRepo = self.pluginMgr.create_param_url( paramsDicRepo ) if urlRepo: self.pluginMgr.addDir( __language__( 30204 ), urlRepo ) paramsDicRepo = {} paramsDicRepo[PARAM_LISTTYPE] = VALUE_LIST_MANAGE_ADDONS urlRepo = self.pluginMgr.create_param_url( paramsDicRepo ) if urlRepo: self.pluginMgr.addDir( __language__( 30205 ), urlRepo )
class Main: """ Main plugin class """ def __init__(self, *args, **kwargs): if True: #self._check_compatible(): self.pluginMgr = PluginMgr() self.parameters = self.pluginMgr.parse_params() # if 1st start create missing directories self.fileMgr = fileMgr() self.fileMgr.verifrep(DIR_ADDON_MODULE) self.fileMgr.verifrep(DIR_ADDON_REPO) self.fileMgr.verifrep(DIR_CACHE) self.fileMgr.verifrep(DIR_CACHE_ADDONS) # Check settings if xbmcplugin.getSetting('first_run') == 'true': # Check (only the 1st time) is xbmcaddon module is available print(" **First run") if self._check_addon_lib(): print( " XBMC Addon 4 XBOX Addon Library already installed" ) print(" Installing default repositories") if (self._installRepos()): xbmcplugin.setSetting('first_run', 'false') self._createRootDir() else: print( " ERROR - XBMC Addon 4 XBOX Addon Library MISSING" ) dialog = xbmcgui.Dialog() dialog.ok(__language__(30000), __language__(30091), __language__(30092)) else: self._createRootDir() self.pluginMgr.add_sort_methods(False) self.pluginMgr.end_of_directory(True, update=False) def _check_addon_lib(self): """ Check id xbmcaddon module is available Returns 1 if success, 0 otherwise """ ok = 1 try: import xbmcaddon except ImportError: ok = 0 return ok def _check_compatible(self): """ Check if XBMC version is compatible with the plugin """ xbmcgui = None try: # spam plugin statistics to log print("[PLUGIN] '%s: Version - %s-r%s' initialized!" % (__plugin__, __version__, __svn_revision__.replace( "$", "").replace("Revision", "").strip(": "))) # get xbmc revision xbmc_version = xbmc.getInfoLabel("System.BuildVersion") xbmc_rev = int(xbmc_version.split(" ")[1].replace("r", "")) # compatible? ok = xbmc_rev >= int(__XBMC_Revision__) print xbmc_rev print __XBMC_Revision__ except: # error, so unknown, allow to run print_exc() xbmc_rev = 0 ok = 2 # spam revision info print(" ** Required XBMC Revision: r%s **" % (__XBMC_Revision__, )) print(" ** Found XBMC Revision: r%d [%s] **" % ( xbmc_rev, ( "Not Compatible", "Compatible", "Unknown", )[ok], )) # if not compatible, inform user if (not ok): xbmcgui.Dialog().ok( "%s - %s: %s" % ( __plugin__, __language__(30900), __version__, ), __language__(30901) % (__plugin__, ), __language__(30902) % (__XBMC_Revision__, ), __language__(30903)) #if not xbmc run under xbox, inform user # get xbmc run under? platform = os.environ.get("OS", "xbox") if (platform.upper() not in __platform__): ok = 0 print("system::os.environ [%s], This plugin run under %s only." % ( platform, __platform__, )) if xbmcgui == None: xbmcgui.Dialog().ok( __plugin__, "%s: system::os.environ [[COLOR=ffe2ff43]%s[/COLOR]]" % ( __language__(30904), platform, ), __language__(30905) % __platform__) return ok def _installRepos(self): """ Install default repositories in the plugin data directory """ ok = 0 repo_source = os.path.join(ROOTDIR, "resources", "repositories") try: if os.path.exists(repo_source): self.fileMgr.copyDir(repo_source, DIR_ADDON_REPO) print "SUCCESS: Repositories copied %s" % DIR_ADDON_REPO ok = 1 else: dialog = xbmcgui.Dialog() dialog.ok(__language__(30000), __language__(30006), __language__(30007)) print "ERROR: impossible to copy repositories" print "Repositories are missing in the plugin structure" except: dialog = xbmcgui.Dialog() dialog.ok(__language__(30000), __language__(30006), __language__(30007)) print "ERROR: impossible to copy repositories to %s" % DIR_ADDON_REPO print_exc() return ok def _createRootDir(self): """ Creates root list of the plugin """ paramsDicRepo = {} paramsDicRepo[PARAM_LISTTYPE] = VALUE_LIST_LOCAL_REPOS urlRepo = self.pluginMgr.create_param_url(paramsDicRepo) if urlRepo: self.pluginMgr.addDir(__language__(30202), urlRepo) paramsDicZip = {} paramsDicZip[PARAM_INSTALL_FROM_ZIP] = "true" urlZip = self.pluginMgr.create_param_url(paramsDicZip) if urlZip: self.pluginMgr.addLink(__language__(30203), urlZip) paramsDicRepo = {} paramsDicRepo[PARAM_LISTTYPE] = VALUE_LIST_WIKI_REPOS urlRepo = self.pluginMgr.create_param_url(paramsDicRepo) if urlRepo: self.pluginMgr.addDir(__language__(30204), urlRepo) paramsDicRepo = {} paramsDicRepo[PARAM_LISTTYPE] = VALUE_LIST_MANAGE_ADDONS urlRepo = self.pluginMgr.create_param_url(paramsDicRepo) if urlRepo: self.pluginMgr.addDir(__language__(30205), urlRepo)