class Main:
    """
    Main plugin class
    """

    def __init__( self, *args, **kwargs ):

        self.pluginMgr = PluginMgr()
        self.parameters = self.pluginMgr.parse_params()

        self._createLocalRepoDir()

        self.pluginMgr.add_sort_methods( True )
        self.pluginMgr.end_of_directory( True, update=False )


    def _createLocalRepoDir ( self ):
        """
        List of installed repositories
        """
        for repoId in os.listdir( DIR_ADDON_REPO ):

            itemInfo = getInstalledAddonInfo( os.path.join( DIR_ADDON_REPO, repoId) )
            if itemInfo:
                # Dic Not empty
                paramsRepo = {}
                paramsRepo[PARAM_REPO_ID]  = repoId
                paramsRepo[PARAM_LISTTYPE] = VALUE_LIST_CATEGORY
                urlRepo = self.pluginMgr.create_param_url( paramsRepo )
                if urlRepo:
                    self.pluginMgr.addDir( itemInfo [ "name" ], urlRepo, iconimage=itemInfo [ "icon" ] )
    def __init__( self, *args, **kwargs ):
        self.pluginMgr = PluginMgr()

        # Install from zip file
        status = self._install_addon_zip()

        self.pluginMgr.end_of_directory( True, update=False )
Exemplo n.º 3
0
    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 )
class Main:
    """
    Main plugin class
    """

    def __init__( self, *args, **kwargs ):
        self.pluginMgr = PluginMgr()

        # Install from zip file
        status = self._install_addon_zip()

        self.pluginMgr.end_of_directory( True, update=False )


    def _install_addon_zip( self ):
        """
        Install an addon from a local zip file
        """
        installMgr = InstallMgr()

        # Install from zip file
        status, itemName, destination, addonInstaller = installMgr.install_from_zip()

        #Check if install went well
        status, destination = installMgr.check_install(status, itemName, destination, addonInstaller)

        if status == "OK":
            requiredLibs = addonInstaller.itemInfo[ "required_lib" ]
            status = installMgr._getAddonRequiredLibs( requiredLibs )
            
            from datetime import datetime

            #Install OK so save information for future update
            addonInstallName = addonInstaller.getItemInstallName()
            addonVersion = addonInstaller.getItemVersion()
            addonInfo = {}
            addonInfo['name'] = addonInstallName
            addonInfo['date'] = datetime.now()
            addonInfo['version'] = addonVersion
            addonInfo['repository'] = None
            addonInfo['installer_version'] = __version__

            PersistentDataCreator( addonInfo, os.path.join( destination, "a4x.psdt" ) )

        return status
    def __init__( self, *args, **kwargs ):

        self.pluginMgr = PluginMgr()
        self.parameters = self.pluginMgr.parse_params()

        self._createLocalRepoDir()

        self.pluginMgr.add_sort_methods( True )
        self.pluginMgr.end_of_directory( True, update=False )
    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 __init__( self, *args, **kwargs ):

        self.fileMgr   = fileMgr()
        self.pluginMgr = PluginMgr()
        self.parameters = self.pluginMgr.parse_params()

        # Install from remote server
        status = self._install_addon_remote()

        self.pluginMgr.end_of_directory( True, update=False )
    def __init__(self, *args, **kwargs):

        self.pluginMgr = PluginMgr()
        self.parameters = self.pluginMgr.parse_params()

        print "List of repositories from XBMC wiki page"
        self._createRepo2InstallListDir()

        self.pluginMgr.add_sort_methods(True)
        self.pluginMgr.end_of_directory(True)
    def __init__( self, *args, **kwargs ):

        self.pluginMgr = PluginMgr()
        self.parameters = self.pluginMgr.parse_params()

        repoId = self.parameters[ PARAM_REPO_ID ]
        self._createAddonCatDir( repoId )

        self.pluginMgr.add_sort_methods( True )
        self.pluginMgr.end_of_directory( True, update=False )
Exemplo n.º 10
0
class Main:
    """
    Main plugin class
    """

    def __init__( self, *args, **kwargs ):

        self.pluginMgr = PluginMgr()
        self.parameters = self.pluginMgr.parse_params()

        try:
            repoWindow = DialogRepoInfo( "DialogRepoInfo.xml", ROOTDIR, "Default", "720p" )

            del repoWindow
        except:
            print_exc()
        #TODO: call DialogRepoInfo
        #status = self._install_addon_remote()

        print "_end_of_directory"
        self.pluginMgr.end_of_directory( False )
class Main:
    """
    Main plugin class
    """

    def __init__(self, *args, **kwargs):

        self.pluginMgr = PluginMgr()
        self.parameters = self.pluginMgr.parse_params()

        print "List of repositories from XBMC wiki page"
        self._createRepo2InstallListDir()

        self.pluginMgr.add_sort_methods(True)
        self.pluginMgr.end_of_directory(True)

    def _createRepo2InstallListDir(self):
        """
        Creates list for install of the Unofficial repositories available on XBMC wiki
        """

        print "createRepo2InstallListDir"

        wiki_server_id = int(__settings__("wiki_server"))
        print "Loading wiki page: %s" % REPO_LIST_URL_LIST[wiki_server_id]
        listRepoWiki = ListItemFromWiki(REPO_LIST_URL_LIST[wiki_server_id])
        keepParsing = True
        while keepParsing:
            item = listRepoWiki.getNextItem()
            if item:
                if "repo_url" in item and item["repo_url"]:
                    paramsAddons = {}
                    paramsAddons[PARAM_INSTALL_FROM_REPO] = "true"
                    paramsAddons[PARAM_ADDON_ID] = "None"  # No ID at this stage in case of repo from the wiki
                    paramsAddons[PARAM_ADDON_NAME] = item["name"]
                    paramsAddons[PARAM_URL] = item["repo_url"]
                    paramsAddons[PARAM_DATADIR] = "None"
                    paramsAddons[PARAM_TYPE] = "zip"
                    paramsAddons[PARAM_REPO_ID] = "None"

                    url = self.pluginMgr.create_param_url(paramsAddons)

                    if url:
                        item["PluginUrl"] = url
                        self.pluginMgr.addItemLink(item)
            else:
                keepParsing = False
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"
Exemplo n.º 13
0
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._createManageAddonsDir()

        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 _createManageAddonsDir(self):
        """
        Creates manage addons list options
        """
        paramsDicRepo = {}
        paramsDicRepo[PARAM_LISTTYPE] = VALUE_LIST_MISSING_MODULES
        urlRepo = self.pluginMgr.create_param_url(paramsDicRepo)
        if urlRepo:
            self.pluginMgr.addDir(__language__(30250), urlRepo)
Exemplo n.º 15
0
class Main:
    """
    Main plugin class
    """
    def __init__(self, *args, **kwargs):

        self.fileMgr = fileMgr()
        self.pluginMgr = PluginMgr()
        self.parameters = self.pluginMgr.parse_params()

        # Install from remote server
        status = self._install_addon_remote()

        self.pluginMgr.end_of_directory(True, update=False)

    def _install_addon_remote(self):
        """
        Install an addon from a remote/web repository
        """
        xbmc.log("_install_addon_remote", xbmc.LOGDEBUG)
        status = "OK"
        installMgr = InstallMgr()

        #TODO: solve encoding pb on name

        addonName = unicode(self.parameters[PARAM_ADDON_NAME],
                            'ISO 8859-1',
                            errors='ignore')
        addonId = '%s' % self.parameters[PARAM_ADDON_ID]
        addonUrl = self.parameters[PARAM_URL].replace(' ', '%20')
        addonFormat = self.parameters[PARAM_TYPE]
        repoId = self.parameters[PARAM_REPO_ID]
        dataDir = self.parameters[PARAM_DATADIR].replace(
            ' ', '%20')  #self.repoList[repoId]['datadir']

        if (xbmcgui.Dialog().yesno(addonName, __language__(30050), "", "")):

            # Check if we install repo
            if "None" != repoId:
                # Retrieve addon info from persitence
                pdr = PersistentDataRetriever(
                    os.path.join(DIR_CACHE, repoId + ".txt"))
                addonDic = pdr.get_data()
                requiredLibs = addonDic[addonId]['required_lib']
                status = installMgr._getAddonRequiredLibs(requiredLibs, repoId)

            if status == "OK":
                # TODO: check repo ID
                status, itemName, destination, addonInstaller = installMgr.install_from_repo(
                    addonName, addonUrl, addonFormat, dataDir)
            else:
                # The install of required addons was not full
                itemName = addonDic[addonId]["name"]
                destination = None
                addonInstaller = None

            # Check if install went well
            status, destination = installMgr.check_install(
                status, itemName, destination, addonInstaller)

            if status == "OK":  # and "None" != repoId:
                saveLocalAddonInfo(repoId, destination, addonInstaller)

                # Check is addon is a module and if it was part of the missing modules list
                if "None" != repoId:
                    installedModuleItem = addonDic[addonId]
                    if TYPE_ADDON_MODULE == installedModuleItem["type"]:
                        # We just installed successfully a module
                        # Check if it was part of the missing modules list and remove it if it is the case
                        removeMissingModule2DB(installedModuleItem)

        return status
class Main:
    """
    Main plugin class
    """

    def __init__( self, *args, **kwargs ):

        self.pluginMgr = PluginMgr()
        self.parameters = self.pluginMgr.parse_params()

        repoId = self.parameters[ PARAM_REPO_ID ]
        self._createAddonCatDir( repoId )

        self.pluginMgr.add_sort_methods( True )
        self.pluginMgr.end_of_directory( True, update=False )


    def _createAddonCatDir ( self, repoId ):
        """
        Creates list of addon categories for a specific repository
        """
        params = {}
        params[PARAM_REPO_ID] = str(repoId)
        params[PARAM_LISTTYPE] = VALUE_LIST_ADDONS
        params[PARAM_TYPE] = VALUE_LIST_ALL_ADDONS
        url = self.pluginMgr.create_param_url( params )
        if url:
            self.pluginMgr.addDir( __language__( 30107 ), url )

        params = {}
        params[PARAM_REPO_ID] = str(repoId)
        params[PARAM_LISTTYPE] = VALUE_LIST_ADDONS
        params[PARAM_TYPE] = TYPE_ADDON_SCRIPT
        url = self.pluginMgr.create_param_url( params )
        self.pluginMgr.addDir( __language__( 30101 ), url )

        params = {}
        params[PARAM_REPO_ID] = str(repoId)
        params[PARAM_LISTTYPE] = VALUE_LIST_ADDONS
        params[PARAM_TYPE] = TYPE_ADDON_MUSIC
        url = self.pluginMgr.create_param_url( params )
        if url:
            self.pluginMgr.addDir( __language__( 30102 ), url )

        params = {}
        params[PARAM_REPO_ID] = str(repoId)
        params[PARAM_LISTTYPE] = VALUE_LIST_ADDONS
        params[PARAM_TYPE] = TYPE_ADDON_PICTURES
        url = self.pluginMgr.create_param_url( params )
        if url:
            self.pluginMgr.addDir( __language__( 30103 ), url )

        params = {}
        params[PARAM_REPO_ID] = str(repoId)
        params[PARAM_LISTTYPE] = VALUE_LIST_ADDONS
        params[PARAM_TYPE] = TYPE_ADDON_PROGRAMS
        url = self.pluginMgr.create_param_url( params )
        if url:
            self.pluginMgr.addDir( __language__( 30104 ), url )

        params = {}
        params[PARAM_REPO_ID] = str(repoId)
        params[PARAM_LISTTYPE] = VALUE_LIST_ADDONS
        params[PARAM_TYPE] = TYPE_ADDON_VIDEO
        url = self.pluginMgr.create_param_url( params )
        if url:
            self.pluginMgr.addDir( __language__( 30105 ), url )

        params = {}
        params[PARAM_REPO_ID] = str(repoId)
        params[PARAM_LISTTYPE] = VALUE_LIST_ADDONS
        params[PARAM_TYPE] = TYPE_ADDON_WEATHER
        url = self.pluginMgr.create_param_url( params )
        if url:
            self.pluginMgr.addDir( __language__( 30106 ), url )

        params = {}
        params[PARAM_REPO_ID] = str(repoId)
        params[PARAM_LISTTYPE] = VALUE_LIST_ADDONS
        params[PARAM_TYPE] = TYPE_ADDON_MODULE
        url = self.pluginMgr.create_param_url( params )
        if url:
            self.pluginMgr.addDir( __language__( 30108 ), url )
Exemplo n.º 17
0
class Main:
    """
    Main plugin class
    """
    def __init__(self, *args, **kwargs):

        self.pluginMgr = PluginMgr()
        self.parameters = self.pluginMgr.parse_params()

        repoId = self.parameters[PARAM_REPO_ID]
        addonCat = self.parameters[PARAM_TYPE]
        self._createAddonsDir(repoId, addonCat)

        self.pluginMgr.add_sort_methods(True)
        self.pluginMgr.end_of_directory(True)

    def _createAddonsDir(self, repoId, cat):
        """
        Display the addons to install for a repository
        """
        # Retrieve info from  addon.xml for the repository
        repoInfo = getInstalledAddonInfo(os.path.join(DIR_ADDON_REPO, repoId))

        addonDic = {}

        # Retrieving addons.xml from remote repository
        xmlInfofPath = os.path.join(DIR_CACHE, repoId + ".xml")
        if fileOlderThan(xmlInfofPath, 60 * 30):
            data = readURL(repoInfo["repo_url"],
                           save=True,
                           localPath=xmlInfofPath)

        if (os.path.exists(xmlInfofPath)):
            try:
                xmlData = open(os.path.join(xmlInfofPath), "r")
                listAddonsXml = ListItemFromXML(xmlData)
                xmlData.close()
            except:
                print_exc()

            filter = "False"
            if cat == VALUE_LIST_ALL_ADDONS:
                filter = "item['type'] in supportedAddonList"
            elif cat in supportedAddonList:
                filter = "item['type'] == '%s'" % cat

            keepParsing = True
            while (keepParsing):
                item = listAddonsXml.getNextItem()
                if item:
                    if eval(filter):
                        endRepoChar = "/"
                        if repoInfo["repo_datadir"].endswith("/"):
                            endRepoChar = ""

                        if repoInfo["repo_format"] == 'zip':
                            downloadUrl = (repoInfo["repo_datadir"] +
                                           endRepoChar + item["id"] + '/' +
                                           item["id"] + '-' + item["version"] +
                                           ".zip").replace(' ', '%20')
                            changelog = (repoInfo["repo_datadir"] +
                                         endRepoChar + item["id"] + '/' +
                                         "changelog" + '-' + item["version"] +
                                         ".txt").replace(' ', '%20')
                            iconimage = (repoInfo["repo_datadir"] +
                                         endRepoChar + item["id"] + '/' +
                                         "icon.png").replace(' ', '%20')
                        else:
                            downloadUrl = (repoInfo["repo_datadir"] +
                                           endRepoChar + item["id"] +
                                           '/').replace(' ', '%20')
                            changelog = (repoInfo["repo_datadir"] +
                                         endRepoChar + item["id"] + '/' +
                                         "changelog" + ".txt").replace(
                                             ' ', '%20')
                            iconimage = (repoInfo["repo_datadir"] +
                                         endRepoChar + item["id"] + '/' +
                                         "icon.png").replace(' ', '%20')
                        item["ImageUrl"] = iconimage
                        item["changelog"] = changelog

                        paramsAddons = {}
                        paramsAddons[PARAM_INSTALL_FROM_REPO] = "true"
                        paramsAddons[PARAM_ADDON_ID] = item["id"]
                        paramsAddons[PARAM_ADDON_NAME] = item['name']
                        paramsAddons[PARAM_URL] = downloadUrl
                        paramsAddons[PARAM_DATADIR] = repoInfo["repo_datadir"]
                        paramsAddons[PARAM_TYPE] = repoInfo["repo_format"]
                        paramsAddons[PARAM_REPO_ID] = repoId
                        url = self.pluginMgr.create_param_url(paramsAddons)

                        if (url):
                            #self._addLink( item['name'], url, iconimage=iconimage)
                            item["PluginUrl"] = url
                            self.pluginMgr.addItemLink(item)
                            #addonList.append( item )
                            addonDic[item["id"]] = item
                else:
                    keepParsing = False
            # Save the list of addons
            PersistentDataCreator(addonDic,
                                  os.path.join(DIR_CACHE, repoId + ".txt"))
class Main:
    """
    Main plugin class
    """
    def __init__(self, *args, **kwargs):

        self.pluginMgr = PluginMgr()
        self.parameters = self.pluginMgr.parse_params()

        repoId = self.parameters[PARAM_REPO_ID]
        self._createAddonCatDir(repoId)

        self.pluginMgr.add_sort_methods(True)
        self.pluginMgr.end_of_directory(True, update=False)

    def _createAddonCatDir(self, repoId):
        """
        Creates list of addon categories for a specific repository
        """
        params = {}
        params[PARAM_REPO_ID] = str(repoId)
        params[PARAM_LISTTYPE] = VALUE_LIST_ADDONS
        params[PARAM_TYPE] = VALUE_LIST_ALL_ADDONS
        url = self.pluginMgr.create_param_url(params)
        if url:
            self.pluginMgr.addDir(__language__(30107), url)

        params = {}
        params[PARAM_REPO_ID] = str(repoId)
        params[PARAM_LISTTYPE] = VALUE_LIST_ADDONS
        params[PARAM_TYPE] = TYPE_ADDON_SCRIPT
        url = self.pluginMgr.create_param_url(params)
        self.pluginMgr.addDir(__language__(30101), url)

        params = {}
        params[PARAM_REPO_ID] = str(repoId)
        params[PARAM_LISTTYPE] = VALUE_LIST_ADDONS
        params[PARAM_TYPE] = TYPE_ADDON_MUSIC
        url = self.pluginMgr.create_param_url(params)
        if url:
            self.pluginMgr.addDir(__language__(30102), url)

        params = {}
        params[PARAM_REPO_ID] = str(repoId)
        params[PARAM_LISTTYPE] = VALUE_LIST_ADDONS
        params[PARAM_TYPE] = TYPE_ADDON_PICTURES
        url = self.pluginMgr.create_param_url(params)
        if url:
            self.pluginMgr.addDir(__language__(30103), url)

        params = {}
        params[PARAM_REPO_ID] = str(repoId)
        params[PARAM_LISTTYPE] = VALUE_LIST_ADDONS
        params[PARAM_TYPE] = TYPE_ADDON_PROGRAMS
        url = self.pluginMgr.create_param_url(params)
        if url:
            self.pluginMgr.addDir(__language__(30104), url)

        params = {}
        params[PARAM_REPO_ID] = str(repoId)
        params[PARAM_LISTTYPE] = VALUE_LIST_ADDONS
        params[PARAM_TYPE] = TYPE_ADDON_VIDEO
        url = self.pluginMgr.create_param_url(params)
        if url:
            self.pluginMgr.addDir(__language__(30105), url)

        params = {}
        params[PARAM_REPO_ID] = str(repoId)
        params[PARAM_LISTTYPE] = VALUE_LIST_ADDONS
        params[PARAM_TYPE] = TYPE_ADDON_WEATHER
        url = self.pluginMgr.create_param_url(params)
        if url:
            self.pluginMgr.addDir(__language__(30106), url)

        params = {}
        params[PARAM_REPO_ID] = str(repoId)
        params[PARAM_LISTTYPE] = VALUE_LIST_ADDONS
        params[PARAM_TYPE] = TYPE_ADDON_MODULE
        url = self.pluginMgr.create_param_url(params)
        if url:
            self.pluginMgr.addDir(__language__(30108), url)
class Main:
    """
    Main plugin class
    """

    def __init__( self, *args, **kwargs ):

        self.fileMgr   = fileMgr()
        self.pluginMgr = PluginMgr()
        self.parameters = self.pluginMgr.parse_params()

        # Install from remote server
        status = self._install_addon_remote()

        self.pluginMgr.end_of_directory( True, update=False )


    def _install_addon_remote( self ):
        """
        Install an addon from a remote/web repository
        """
        xbmc.log("_install_addon_remote", xbmc.LOGDEBUG)
        status = "OK"
        installMgr = InstallMgr()

        #TODO: solve encoding pb on name

        addonName = unicode( self.parameters[ PARAM_ADDON_NAME ] , 'ISO 8859-1', errors='ignore' )
        addonId = '%s'%self.parameters[ PARAM_ADDON_ID ]
        addonUrl = self.parameters[ PARAM_URL ].replace( ' ', '%20' )
        addonFormat = self.parameters[ PARAM_TYPE ]
        repoId = self.parameters[ PARAM_REPO_ID ]
        dataDir = self.parameters[ PARAM_DATADIR ].replace( ' ', '%20' ) #self.repoList[repoId]['datadir']

        if ( xbmcgui.Dialog().yesno( addonName, __language__( 30050 ), "", "" ) ):

            # Check if we install repo
            if "None" != repoId:
                # Retrieve addon info from persitence
                pdr = PersistentDataRetriever( os.path.join( DIR_CACHE, repoId + ".txt" ) )
                addonDic = pdr.get_data()
                requiredLibs = addonDic[addonId]['required_lib']
                status = installMgr._getAddonRequiredLibs( requiredLibs, repoId )

            if status == "OK":
                # TODO: check repo ID
                status, itemName, destination, addonInstaller = installMgr.install_from_repo( addonName, addonUrl, addonFormat, dataDir )
            else:
                # The install of required addons was not full
                itemName       = addonDic[addonId]["name"]
                destination    = None
                addonInstaller = None

            # Check if install went well
            status, destination = installMgr.check_install(status, itemName, destination, addonInstaller)

            if status == "OK": # and "None" != repoId:
                saveLocalAddonInfo(repoId, destination, addonInstaller)

                # Check is addon is a module and if it was part of the missing modules list
                if "None" != repoId:
                    installedModuleItem = addonDic[addonId]
                    if TYPE_ADDON_MODULE == installedModuleItem["type"]:
                        # We just installed successfully a module
                        # Check if it was part of the missing modules list and remove it if it is the case
                        removeMissingModule2DB(installedModuleItem)


        return status
Exemplo n.º 20
0
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 )
Exemplo n.º 21
0
class Main:
    """
    Main plugin class
    """

    def __init__( self, *args, **kwargs ):

        self.pluginMgr = PluginMgr()
        self.parameters = self.pluginMgr.parse_params()

        repoId = self.parameters[ PARAM_REPO_ID ]
        addonCat = self.parameters[ PARAM_TYPE ]
        self._createAddonsDir( repoId, addonCat )

        self.pluginMgr.add_sort_methods( True )
        self.pluginMgr.end_of_directory( True )


    def _createAddonsDir ( self, repoId, cat ):
        """
        Display the addons to install for a repository
        """
        # Retrieve info from  addon.xml for the repository
        repoInfo = getInstalledAddonInfo( os.path.join( DIR_ADDON_REPO, repoId) )

        addonDic = {}

        # Retrieving addons.xml from remote repository
        xmlInfofPath = os.path.join( DIR_CACHE, repoId + ".xml")
        if fileOlderThan(xmlInfofPath, 60 * 30):
            data = readURL( repoInfo [ "repo_url" ], save=True, localPath=xmlInfofPath )

        if ( os.path.exists( xmlInfofPath ) ):
            try:
                xmlData = open( os.path.join( xmlInfofPath ), "r" )
                listAddonsXml = ListItemFromXML(xmlData)
                xmlData.close()
            except:
                print_exc()

            filter = "False"
            if cat == VALUE_LIST_ALL_ADDONS:
                filter = "item['type'] in supportedAddonList"
            elif cat in supportedAddonList:
                filter = "item['type'] == '%s'"%cat

            keepParsing = True
            while (keepParsing):
                item = listAddonsXml.getNextItem()
                if item:
                    if eval(filter):
                        endRepoChar = "/"
                        if repoInfo [ "repo_datadir" ].endswith( "/" ):
                            endRepoChar = ""

                        if repoInfo [ "repo_format" ] ==  'zip':
                            downloadUrl = (repoInfo [ "repo_datadir" ] + endRepoChar + item["id"] + '/' + item["id"]  + '-' + item["version"] + ".zip").replace(' ', '%20')
                            changelog   = (repoInfo [ "repo_datadir" ] + endRepoChar + item["id"] + '/' + "changelog" + '-' + item["version"] + ".txt").replace(' ', '%20')
                            iconimage   = (repoInfo [ "repo_datadir" ] + endRepoChar + item["id"] + '/' + "icon.png").replace(' ', '%20')
                        else:
                            downloadUrl = (repoInfo [ "repo_datadir" ] + endRepoChar + item["id"] + '/').replace(' ', '%20')
                            changelog   = (repoInfo [ "repo_datadir" ] + endRepoChar + item["id"] + '/' + "changelog" + ".txt").replace(' ', '%20')
                            iconimage   = (repoInfo [ "repo_datadir" ] + endRepoChar + item["id"] + '/' + "icon.png").replace(' ', '%20')
                        item["ImageUrl"] = iconimage
                        item["changelog"] = changelog

                        paramsAddons = {}
                        paramsAddons[PARAM_INSTALL_FROM_REPO]   = "true"
                        paramsAddons[PARAM_ADDON_ID]            = item[ "id" ]
                        paramsAddons[PARAM_ADDON_NAME]          = item['name']
                        paramsAddons[PARAM_URL]                 = downloadUrl
                        paramsAddons[PARAM_DATADIR]             = repoInfo[ "repo_datadir" ]
                        paramsAddons[PARAM_TYPE]                = repoInfo[ "repo_format" ]
                        paramsAddons[PARAM_REPO_ID]             = repoId
                        url = self.pluginMgr.create_param_url( paramsAddons )

                        if ( url ):
                            #self._addLink( item['name'], url, iconimage=iconimage)
                            item["PluginUrl"] = url
                            self.pluginMgr.addItemLink( item )
                            #addonList.append( item )
                            addonDic[ item[ "id" ]] = item
                else:
                    keepParsing = False
            # Save the list of addons
            PersistentDataCreator( addonDic, os.path.join( DIR_CACHE, repoId + ".txt" ) )
Exemplo n.º 22
0
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)