示例#1
0
def IsUpdateNeededForHostsChangesCommit(enabledHostsListOld, enabledHostsList=None, hostsFromFolder=None):
    if enabledHostsList == None: 
        enabledHostsList = GetEnabledHostsList()
    if hostsFromFolder == None: 
        hostsFromFolder = GetHostsList(fromList=False, fromHostFolder=True)

    bRet = False
    if config.plugins.iptvplayer.remove_diabled_hosts.value and enabledHostsList != enabledHostsListOld:
        hostsFromList = GetHostsList(fromList=True, fromHostFolder=False)
        diffDisabledHostsList = set(enabledHostsListOld).difference(set(enabledHostsList))
        diffList = set(enabledHostsList).symmetric_difference(set(enabledHostsListOld))
        for hostItem in diffList:
            if hostItem in hostsFromList:
                if hostItem in diffDisabledHostsList:
                    if hostItem in hostsFromFolder:
                        # standard host has been disabled but it is still in folder
                        bRet = True
                        break
                else:
                    if hostItem not in hostsFromFolder:
                        # standard host has been enabled but it is not in folder
                        bRet = True
                        break
    if bRet:
        SetGraphicsHash("")
        SetIconsHash("")
    return bRet
示例#2
0
 def __init__(self, session):
     printDBG("ConfigMenu.__init__ -------------------------------")
     self.list = [ ]
     ConfigBaseWidget.__init__(self, session)
     # remember old
     self.showcoverOld = config.plugins.iptvplayer.showcover.value
     self.SciezkaCacheOld = config.plugins.iptvplayer.SciezkaCache.value
     self.remove_diabled_hostsOld = config.plugins.iptvplayer.remove_diabled_hosts.value
     self.enabledHostsListOld = GetEnabledHostsList()
    def stepRemoveUnnecessaryFiles(self):
        printDBG("stepRemoveUnnecessaryFiles")
        playerSelectorPath = os_path.join(self.ExtensionTmpPath,
                                          'IPTVPlayer/icons/PlayerSelector/')
        logosPath = os_path.join(self.ExtensionTmpPath,
                                 'IPTVPlayer/icons/logos/')
        hostsPath = os_path.join(self.ExtensionTmpPath, 'IPTVPlayer/hosts/')
        webPath = os_path.join(self.ExtensionTmpPath, 'IPTVPlayer/Web/')
        cmds = []
        iconSize = int(config.plugins.iptvplayer.IconsSize.value)
        if not config.plugins.iptvplayer.ListaGraficzna.value:
            iconSize = 0
        for size in [135, 120, 100]:
            if size != iconSize:
                cmds.append('rm -f %s' %
                            (playerSelectorPath + '*{0}.png'.format(size)))
                cmds.append(
                    'rm -f %s' %
                    (playerSelectorPath + 'marker{0}.png'.format(size + 45)))

        # remove Web iterface module if not needed
        if not config.plugins.iptvplayer.IPTVWebIterface.value:
            cmds.append('rm -rf %s' % (webPath))

        # removing not needed hosts
        if config.plugins.iptvplayer.remove_diabled_hosts.value:
            enabledHostsList = GetEnabledHostsList()
            hostsFromList = GetHostsList(fromList=True, fromHostFolder=False)
            hostsFromFolder = GetHostsList(fromList=False, fromHostFolder=True)
            hostsToRemove = []
            for hostItem in hostsFromList:
                if hostItem not in enabledHostsList and hostItem in hostsFromFolder:
                    cmds.append(
                        'rm -f %s' %
                        (playerSelectorPath + '{0}*.png'.format(hostItem)))
                    cmds.append('rm -f %s' %
                                (logosPath + '{0}logo.png'.format(hostItem)))
                    cmds.append('rm -f %s' %
                                (hostsPath + 'host{0}.py*'.format(hostItem)))

            # we need to prepare temporary file with removing cmds because cmd can be to long
            cmdFilePath = GetTmpDir('.iptv_remove_cmds.sh')
            cmds.insert(0, '#!/bin/sh')
            cmds.append('exit 0\n')
            text = '\n'.join(cmds)
            WriteTextFile(cmdFilePath, text, 'ascii')
            cmd = '/bin/sh "{0}" '.format(cmdFilePath)
            #cmd = '/bin/sh "{0}" && rm -rf "{1}" '.format(cmdFilePath, cmdFilePath)
        else:
            cmd = ' && '.join(cmds)
        printDBG("stepRemoveUnnecessaryFiles cmdp[%s]" % cmd)
        self.cmd = iptv_system(cmd, self.__removeUnnecessaryFilesCmdFinished)
示例#4
0
 def getMessageBeforeClose(self, afterSave):
     needPluginUpdate = False
     if afterSave and config.plugins.iptvplayer.ListaGraficzna.value and 0 == GetAvailableIconSize(False):
         needPluginUpdate = True
     else:
         enabledHostsList = GetEnabledHostsList()
         hostsFromFolder  = GetHostsList(fromList=False, fromHostFolder=True)
         if self.remove_diabled_hostsOld != config.plugins.iptvplayer.remove_diabled_hosts.value:
             if config.plugins.iptvplayer.remove_diabled_hosts.value:
                 for folderItem in hostsFromFolder:
                     if folderItem in enabledHostsList:
                         continue
                     else:
                         # there is host file which is not enabled, 
                         # so we need perform update to remove it
                         needPluginUpdate = True
                         break
             else:
                 hostsFromList = GetHostsList(fromList=True, fromHostFolder=False)
                 if not set(hostsFromList).issubset(set(hostsFromFolder)):
                     # there is missing hosts files, we need updated does not matter 
                     # if these hosts are enabled or disabled
                     needPluginUpdate = True
             
         elif config.plugins.iptvplayer.remove_diabled_hosts.value and enabledHostsList != self.enabledHostsListOld:
             hostsFromList = GetHostsList(fromList=True, fromHostFolder=False)
             diffDisabledHostsList = set(self.enabledHostsListOld).difference(set(enabledHostsList))
             diffList = set(enabledHostsList).symmetric_difference(set(self.enabledHostsListOld))
             for hostItem in diffList:
                 if hostItem in hostsFromList:
                     if hostItem in diffDisabledHostsList:
                         if hostItem in hostsFromFolder:
                             # standard host has been disabled but it is still in folder
                             needPluginUpdate = True
                             break
                     else:
                         if hostItem not in hostsFromFolder:
                             # standard host has been enabled but it is not in folder
                             needPluginUpdate = True
                             break
         
     if needPluginUpdate:
         return _('Some changes will be applied only after plugin update.\nDo you want to perform update now?')
     else:
         return ''
示例#5
0
 def getMessageBeforeClose(self, afterSave):
     needPluginUpdate = False
     if afterSave and config.plugins.iptvplayer.ListaGraficzna.value and 0 == GetAvailableIconSize(False):
         needPluginUpdate = True
     else:
         enabledHostsList = GetEnabledHostsList()
         hostsFromFolder  = GetHostsList(fromList=False, fromHostFolder=True)
         if self.remove_diabled_hostsOld != config.plugins.iptvplayer.remove_diabled_hosts.value:
             if config.plugins.iptvplayer.remove_diabled_hosts.value:
                 for folderItem in hostsFromFolder:
                     if folderItem in enabledHostsList:
                         continue
                     else:
                         # there is host file which is not enabled, 
                         # so we need perform update to remove it
                         needPluginUpdate = True
                         break
             else:
                 hostsFromList = GetHostsList(fromList=True, fromHostFolder=False)
                 if not set(hostsFromList).issubset(set(hostsFromFolder)):
                     # there is missing hosts files, we need updated does not matter 
                     # if these hosts are enabled or disabled
                     needPluginUpdate = True
         elif IsUpdateNeededForHostsChangesCommit(self.enabledHostsListOld, enabledHostsList, hostsFromFolder):
             needPluginUpdate = True
     
     if needPluginUpdate:
         SetGraphicsHash("")
         SetIconsHash("")
     
     if not needPluginUpdate and config.plugins.iptvplayer.IPTVWebIterface.value != IsWebInterfaceModuleAvailable(True):
         needPluginUpdate = True
         
     if needPluginUpdate:
         return _('Some changes will be applied only after plugin update.\nDo you want to perform update now?')
     else:
         return ''