diff --git a/addon.xml b/addon.xml index 5608cd7..752b4d6 100644 --- a/addon.xml +++ b/addon.xml @@ -1,6 +1,6 @@  + name="XBMC Backup" version="0.1.3" provider-name="robweber"> diff --git a/changelog.txt b/changelog.txt index 94a32db..adcab57 100644 --- a/changelog.txt +++ b/changelog.txt @@ -46,4 +46,13 @@ added check for key in vfs.py - Thanks Martijn! added French language translation - thanks mikebzh44 -added some utf-8 encoding tags to filenames \ No newline at end of file +added some utf-8 encoding tags to filenames + +[b]Version 0.1.3[/b] + +added German translations - thanks dersphere + +removed need for separate verbose logging setting + +updated utf-8 encoding for all logging + diff --git a/default.py b/default.py index d11ce98..e7491da 100644 --- a/default.py +++ b/default.py @@ -74,7 +74,7 @@ class FileManager: def addFile(self,filename): #write the full remote path name of this file - xbmc.log("Add File: " + filename.encode("utf-8"),level=xbmc.LOGDEBUG) + log("Add File: " + filename,xbmc.LOGDEBUG) self.fileArray.append(filename) def getFileList(self): @@ -95,24 +95,22 @@ class XbmcBackup: def __init__(self,__Addon): self.addon = __Addon - self.local_path = xbmc.translatePath("special://home").encode("utf-8"); + self.local_path = xbmc.makeLegalFilename(xbmc.translatePath("special://home"),False); - if(self.addon.getSetting('remote_selection') == '1' and vfs.exists(self.addon.getSetting('remote_path_2'))): + if(self.addon.getSetting('remote_selection') == '1'): self.remote_path = self.addon.getSetting('remote_path_2') self.addon.setSetting("remote_path","") - elif(self.addon.getSetting('remote_selection') == '0' and vfs.exists(self.addon.getSetting("remote_path"))): + elif(self.addon.getSetting('remote_selection') == '0'): self.remote_path = self.addon.getSetting("remote_path") if(self.addon.getSetting("backup_name") != '' and self.remote_path != ''): self.remote_path = self.remote_path + self.addon.getSetting("backup_name") + "/" else: self.remote_path = "" - - self.remote_path = self.remote_path.encode("utf-8"); - self.log(self.addon.getLocalizedString(30046)) - self.log(self.addon.getLocalizedString(30047) + " :" + self.local_path) - self.log(self.addon.getLocalizedString(30048) + " :" + self.remote_path) + log(self.addon.getLocalizedString(30046)) + log(self.addon.getLocalizedString(30047) + ": " + self.local_path) + log(self.addon.getLocalizedString(30048) + ": " + self.remote_path) def run(self): #check if we should use the progress bar @@ -131,12 +129,12 @@ class XbmcBackup: def syncFiles(self): if(vfs.exists(self.remote_path)): #this will fail - need a disclaimer here - self.log(self.addon.getLocalizedString(30050)) + log(self.addon.getLocalizedString(30050)) #make the remote directory vfs.mkdir(self.remote_path) - self.log(self.addon.getLocalizedString(30051)) + log(self.addon.getLocalizedString(30051)) self.fileManager.createFileList(self.addon) allFiles = self.fileManager.getFileList() @@ -147,7 +145,7 @@ class XbmcBackup: def restoreFiles(self): self.fileManager.createFileList(self.addon) - self.log(self.addon.getLocalizedString(30051)) + log(self.addon.getLocalizedString(30051)) allFiles = self.fileManager.getFileList() #write list from remote to local @@ -157,19 +155,19 @@ class XbmcBackup: xbmc.executebuiltin('UpdateLocalAddons') def writeFiles(self,fileList,source,dest): - self.log("Writing files to: " + dest) + log("Writing files to: " + dest) self.filesTotal = len(fileList) self.filesLeft = self.filesTotal #write each file from source to destination for aFile in fileList: if(not self.checkCancel()): - xbmc.log(self.addon.getLocalizedString(30052) + ": " + source + aFile, level=xbmc.LOGDEBUG) + log('Writing file: ' + source + aFile,xbmc.LOGDEBUG) self.updateProgress(aFile) if (aFile.startswith("-")): - vfs.mkdir(dest + aFile[1:]) + vfs.mkdir(xbmc.makeLegalFilename(dest + aFile[1:],False)) else: - vfs.copy(source + aFile,dest + aFile) + vfs.copy(xbmc.makeLegalFilename(source + aFile),xbmc.makeLegalFilename(dest + aFile,False)) if(self.addon.getSetting('run_silent') == 'false'): self.progressBar.close() @@ -188,13 +186,18 @@ class XbmcBackup: result = self.progressBar.iscanceled() return result - - def log(self,message): - xbmc.log(self.addon.getLocalizedString(30010) + ": " + message) def isReady(self): return True if self.remote_path != '' else False +#global functions for logging and encoding +def log(message,loglevel=xbmc.LOGNOTICE): + xbmc.log(encode(__Addon.getLocalizedString(30010) + ": " + message),level=loglevel) + +def encode(string): + return string.encode('UTF-8','replace') + + #run the profile backup backup = XbmcBackup(__Addon) diff --git a/resources/language/French/strings.xml b/resources/language/French/strings.xml index 4a8262c..e06365d 100644 --- a/resources/language/French/strings.xml +++ b/resources/language/French/strings.xml @@ -4,10 +4,10 @@ Général Sélection des fichiers - Sauvegarde - Restauration - Parcourir - Saisir + Sauvegarde + Restauration + Parcourir + Saisir Parcourir le chemin de sauvegarde Nom du répertoire de sauvegarde Mode silencieux @@ -22,7 +22,7 @@ Miniatures / Fanart Fichiers de configuration - Erreur : Le chemin distant ne peut pas être vide. + Erreur : Le chemin distant ne peut pas être vide. Démarrage Dossier Local Dossier Distant