Ejemplo n.º 1
0
 def checkForUpdates():
     updates = {}          
     common.showNotification('SportsDevil', common.translate(30275))
     xbmcUtils.showBusyAnimation()
          
     catchersUpdates = self.syncManager.getUpdates(SyncSourceType.CATCHERS, common.Paths.catchersDir)
     if len(catchersUpdates) > 0:
         updates["Catchers"] = catchersUpdates    
     modulesUpdates = self.syncManager.getUpdates(SyncSourceType.MODULES, common.Paths.modulesDir)
     if len(modulesUpdates) > 0:
         updates["Modules"] = modulesUpdates
     
     xbmcUtils.hideBusyAnimation()
     return updates
Ejemplo n.º 2
0
 def checkForUpdates():
     updates = {}          
     common.showNotification('PGLiveTV', common.translate(30275))
     xbmcUtils.showBusyAnimation()
          
     catchersUpdates = self.syncManager.getUpdates(SyncSourceType.CATCHERS, common.Paths.catchersDir)
     if len(catchersUpdates) > 0:
         updates["Catchers"] = catchersUpdates    
     modulesUpdates = self.syncManager.getUpdates(SyncSourceType.MODULES, common.Paths.modulesDir)
     if len(modulesUpdates) > 0:
         updates["Modules"] = modulesUpdates
     
     xbmcUtils.hideBusyAnimation()
     return updates
Ejemplo n.º 3
0
    def update(self):               
        common.showNotification('SportsDevil', common.translate(30275))
        xbmcUtils.showBusyAnimation()
        updates = self.syncManager.getUpdates(SyncSourceType.CATCHERS, common.Paths.catchersDir)
        xbmcUtils.hideBusyAnimation()
        count = len(updates)
        
        if count == 0:
            common.showNotification('SportsDevil', common.translate(30273))
            return
        
        head = "SportsDevil Updates"
        
        msg = common.translate(30277)
        if count == 1:
            msg = common.translate(30276)
            
        question = ("%s %s: " % (count, msg)) + ', '.join(updates.keys()) + '\n'
        question += common.translate(30278)
        
        updates = updates.values()
        
        countFailed = 0

        dlg = DialogQuestion()
        dlg.head = head
        if dlg.ask(question):
            dlg = DialogProgress()
            firstline = common.translate(30279)
            dlg.create(head, firstline, " ")
       
            for i in range(0, count):
                update = updates[i]
                percent = int((i+1.0)*100/count)
                dlg.update(percent, firstline, update.name)
                if not update.do():
                    countFailed += 1
            
            msg = " "
            if countFailed > 0:
                msg = "%s %s" % (countFailed, common.translate(30280))
                
            dlg.update(100, msg, " ")
            xbmc.sleep(500)
            dlg.close()
 def downloadCustomModules(self):
     
     def get_dir_listing(url):
         
         
         f = urllib.urlopen(url)
         response = f.read()
         f.close()
         
         text = response.split("\n")
         urls = []
         httptag = "http://"
         tag=' href="'
         for line in text:
             if tag in line.lower():
                 for i, _ in enumerate(line):
                     if tag == line[i:i+len(tag)].lower():
                         textline = line[i+len(tag):]
                         end = textline.find('"')
                         u = textline[:end]
                         if not httptag in u and not ".." in u and not "mailto:" in u and not "mailto:" in u:
                             if url[-1] != "/":
                                 u = url+"/"+u
                             else:
                                 u = url+u
                             if not "/." in u:
                                 urls.append(u)
     
         return urls
     
     
     def downloadFile(url, file_path):
         urllib.urlretrieve(url, file_path)
         return os.path.isfile(file_path)
     
     
     def extract(fileOrPath, directory):                
         if not directory.endswith(':') and not os.path.exists(directory):
             os.mkdir(directory)
     
         zf = zipfile.ZipFile(fileOrPath)
     
         for _, name in enumerate(zf.namelist()):
             if name.endswith('/'):
                 os.makedirs(os.path.join(directory, name), 0777)
             else:
                 outfile = open(os.path.join(directory, name), 'wb')
                 outfile.write(zf.read(name))
                 outfile.flush()
                 outfile.close()
                 
 
 
     repo_url = self._customModulesRepo
    
     xbmcUtils.showBusyAnimation()
     files = get_dir_listing(repo_url)
     menuItems = map(lambda x: x.replace(repo_url,'').replace('.zip',''), files)
     xbmcUtils.hideBusyAnimation()
     
     select = xbmcUtils.select('Select module', menuItems)
     if select:
         target = os.path.join(self._customModulesFolder, select + '.zip')
         
         xbmcUtils.showBusyAnimation()
         index = menuItems.index(select)
         success = downloadFile(files[index], target)
         xbmcUtils.hideBusyAnimation()
        
         if success:
             extract(target, self._customModulesFolder)
             os.remove(target)
             return True
         else:
             return False
         
     return None
 def downloadCustomModules(self):
     
     def get_dir_listing(url):
         
         
         f = urllib.urlopen(url)
         response = f.read()
         f.close()
         
         text = response.split("\n")
         urls = []
         httptag = "http://"
         tag=' href="'
         for line in text:
             if tag in line.lower():
                 for i, _ in enumerate(line):
                     if tag == line[i:i+len(tag)].lower():
                         textline = line[i+len(tag):]
                         end = textline.find('"')
                         u = textline[:end]
                         if not httptag in u and not ".." in u and not "mailto:" in u and not "mailto:" in u:
                             if url[-1] != "/":
                                 u = url+"/"+u
                             else:
                                 u = url+u
                             if not "/." in u:
                                 urls.append(u)
     
         return urls
     
     
     def downloadFile(url, file_path):
         urllib.urlretrieve(url, file_path)
         return os.path.isfile(file_path)
     
     
     def extract(fileOrPath, directory):                
         if not directory.endswith(':') and not os.path.exists(directory):
             os.mkdir(directory)
     
         zf = zipfile.ZipFile(fileOrPath)
     
         for _, name in enumerate(zf.namelist()):
             if name.endswith('/'):
                 os.makedirs(os.path.join(directory, name), 0777)
             else:
                 outfile = open(os.path.join(directory, name), 'wb')
                 outfile.write(zf.read(name))
                 outfile.flush()
                 outfile.close()
                 
 
 
     repo_url = self._customModulesRepo
    
     xbmcUtils.showBusyAnimation()
     files = get_dir_listing(repo_url)
     menuItems = map(lambda x: x.replace(repo_url,'').replace('.zip',''), files)
     xbmcUtils.hideBusyAnimation()
     
     select = xbmcUtils.select('Select module', menuItems)
     if select:
         target = os.path.join(self._customModulesFolder, select + '.zip')
         
         xbmcUtils.showBusyAnimation()
         index = menuItems.index(select)
         success = downloadFile(files[index], target)
         xbmcUtils.hideBusyAnimation()
        
         if success:
             extract(target, self._customModulesFolder)
             os.remove(target)
             return True
         else:
             return False
         
     return None