def download( self, pathsrc, type, progressbar_cb=None, dialogProgressWin=None ): """ Telecharge les elements a un chemin specifie ( repertoires, sous repertoires et fichiers ) a dans un repertorie local dependant du type de telechargement ( theme, scraper, script ... ) pathsrc : chemin sur le serveur de l'element a telecharger rootdirsrc : Repertoire root sur le server ( correspondant a un type de download ) - Exemple : "/Scraper/" pour les scrapers typeIndex : Index correspondant au type de telechargement, permet notamment de definir le repertorie local de telechargement Renvoi le status du download: - ( -1 ) pour telechargement annule - ( 1 ) pour telechargement OK """ typeIndex = Item.get_type_index(type) #self.curLocalDirRoot = self.localdirList[ typeIndex ] self.curLocalDirRoot = self.CACHEDIR # Downloading in cache directory first #self.curRemoteDirRoot = rootdirsrc self.curRemoteDirRoot = self.remotedirList[ typeIndex ] #if typeIndex == "Themes": if typeIndex == Item.TYPE_SKIN: isSingleFile = False else: isSingleFile = True # Appel de la fonction privee en charge du download - on passe en parametre l'index correspondant au type status = self._download( self.curRemoteDirRoot+pathsrc, isSingleFile, progressbar_cb, dialogProgressWin, 0, 1 ) #TODO: disconenct form server once big downlaod is done #self.closeConnection() print "FtpDownloadCtrl - download - status: %s"%status return status # retour du status du download recupere
def getNextList(self, index=0): """ Returns the list of item (dictionary) on the server depending on the location we are on the server Retrieves list of the items and information about each item Other possible name: down """ # Check type of selected item list = [] # TODO: manage exception try: if len(self.curList) > 0: if self.curList[index]["type"] == "CAT": if self.curList[index]["xbmc_type"] == Item.TYPE_PLUGIN: # root plugin case self.type = Item.TYPE_PLUGIN self.curCategory, list = self._createPluginList() elif self.curList[index]["xbmc_type"] == Item.TYPE_SCRAPER: # root scraper case self.type = Item.TYPE_SCRAPER self.curCategory, list = self._createScraperList() else: # List of item to download self.type = self.curList[index]["xbmc_type"] self.curCategory = Item.get_type_title(self.type) listOfItem = self.passionFTPCtrl.getDirList(self.remotedirList[Item.get_type_index(self.type)]) print "listOfItem in a cat" print listOfItem for elt in listOfItem: item = {} item["name"] = os.path.basename(elt).replace("_", " ") item["downloadurl"] = elt item["type"] = "FIC" item["xbmc_type"] = self.type item["previewpictureurl"] = None item["description"] = _(604) item["language"] = "" item["version"] = "" item["author"] = "" item["date"] = "" item["added"] = "" # TODO: have different icon between cat and item without thumb # item['thumbnail'] = Item.THUMB_NOT_AVAILABLE item["thumbnail"] = Item.get_thumb(item["xbmc_type"]) item["previewpicture"] = "" # Item.THUMB_NOT_AVAILABLE item[ "image2retrieve" ] = ( False ) # Temporary patch for reseting the flag after download (would be better in the thread in charge of the download) self._set_item_infos(item) # Update infos list.append(item) print item # Save the current item name as category self.curCategory = self.curList[index]["name"] else: # Return the current list # TODO: start download here? print "This is not a category but an item (download)" list = self.curList else: # len(self.curList)<= 0 # 1st time (init), we display root list self.type = Item.TYPE_ROOT # List the main categorie at the root level self.curCategory, list = self._createRootList() except Exception, e: print "Exception during getNextList" print_exc()
def getNextList(self, index=0): """ Returns the list of item (dictionary) on the server depending on the location we are on the server Retrieves list of the items and information about each item Other possible name: down """ # Check type of selected item list = [] #TODO: manage exception try: if len(self.curList) > 0: if self.curList[index]['type'] == 'CAT': if self.curList[index]['xbmc_type'] == Item.TYPE_PLUGIN: # root plugin case self.type = Item.TYPE_PLUGIN self.curCategory, list = self._createPluginList() elif self.curList[index]['xbmc_type'] == Item.TYPE_SCRAPER: # root scraper case self.type = Item.TYPE_SCRAPER self.curCategory, list = self._createScraperList() else: # List of item to download self.type = self.curList[index]['xbmc_type'] self.curCategory = Item.get_type_title(self.type) listOfItem = self.passionFTPCtrl.getDirList( self.remotedirList[Item.get_type_index(self.type)]) print "listOfItem in a cat" print listOfItem for elt in listOfItem: item = {} item['name'] = os.path.basename(elt).replace( "_", " ") item['downloadurl'] = elt item['type'] = 'FIC' item['xbmc_type'] = self.type item['previewpictureurl'] = None item['description'] = _(604) item['language'] = "" item['version'] = "" item['author'] = "" item['date'] = "" item['added'] = "" #TODO: have different icon between cat and item without thumb #item['thumbnail'] = Item.THUMB_NOT_AVAILABLE item['thumbnail'] = Item.get_thumb( item['xbmc_type']) item[ 'previewpicture'] = "" #Item.THUMB_NOT_AVAILABLE item[ 'image2retrieve'] = False # Temporary patch for reseting the flag after download (would be better in the thread in charge of the download) self._set_item_infos(item) # Update infos list.append(item) print item # Save the current item name as category self.curCategory = self.curList[index]['name'] else: # Return the current list #TODO: start download here? print "This is not a category but an item (download)" list = self.curList else: # len(self.curList)<= 0 # 1st time (init), we display root list self.type = Item.TYPE_ROOT # List the main categorie at the root level self.curCategory, list = self._createRootList() except Exception, e: print "Exception during getNextList" print_exc()