The branch, eden has been updated
via 9d918ed08573e2b57c55ccb5909a497b9f217ccb (commit)
from 54c54ac74db8782831197a90bd77b30965e5ce6f (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=9d918ed08573e2b57c55ccb5909a497b9f217ccb
commit 9d918ed08573e2b57c55ccb5909a497b9f217ccb
Author: amet <[email protected]>
Date: Thu Aug 30 10:55:42 2012 +0400
[script.xbmcbackup] -v0.1.3
added some additional logging, utf-8 encoding for filenames, all backups
now in dated folders
diff --git a/script.xbmcbackup/README.txt b/script.xbmcbackup/README.txt
index 3c8679d..750f69b 100644
--- a/script.xbmcbackup/README.txt
+++ b/script.xbmcbackup/README.txt
@@ -5,15 +5,15 @@ I've had to recover my database, thumbnails, and source
configuration enough tim
Usage:
-In the addon settings you can define a remote path for the destination of your
xbmc files. You must also include a backup folder name, all of your files will
be in this folder once the backup runs.
+In the addon settings you can define a remote path for the destination of your
xbmc files. Each backup will create a folder named in a month, day, year format
so you can create multiple backups.
On the Backup Selection page you can select which items from your user profile
folder will be sent to the backup location. By default all are turned on except
the Addon Data directory.
-To restore your data simply switch the Mode from "backup" to "restore" and the
files will be copied from your remote directory to the local path. The file
selection criteria will be used for the restore as well.
+To restore your data simply switch the Mode from "backup" to "restore" and
type the date of the backup you wish to restore from . The files will be copied
from your remote directory to the local path. The file selection criteria will
be used for the restore as well.
What this Addon Will Not Do:
This is not meant as an XBMC file sync solution. If you have multiple
frontends you want to keep in sync this addon may work in a "poor man's" sort
of way but it is not intended for that.
-Your remote folder will not be "pruned" of files you have deleted. This
behavior may change in the future but right now it is up to you to remove
obsolete items from the remote path. The easiest way is to just delete the
remote folder before doing a full backup.
+This backup will not check the backup destination and delete files that do not
match. It is best to only do one backup per day so that each folder is correct.
diff --git a/script.xbmcbackup/addon.xml b/script.xbmcbackup/addon.xml
index e3d6a80..752b4d6 100644
--- a/script.xbmcbackup/addon.xml
+++ b/script.xbmcbackup/addon.xml
@@ -1,6 +1,6 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.xbmcbackup"
- name="XBMC Backup" version="0.1.1" provider-name="robweber">
+ name="XBMC Backup" version="0.1.3" provider-name="robweber">
<requires>
<import addon="xbmc.python" version="2.0"/>
</requires>
@@ -8,9 +8,13 @@
<provides>executable</provides>
</extension>
<extension point="xbmc.addon.metadata">
+ <summary lang="fr">Sauvegarder et restaurer vos bases de données XBMC et
vos fichiers de configuration en cas de crash ou de fichiers
corrompus.</summary>
+ <summary lang="de">Die XBMC Datenbank sichern und bei Dateiverlust oder
Beschädigung wiederherstellen.</summary>
<summary lang="en">Backup and restore your XBMC database and configuration
files in the event of a crash or file corruption.</summary>
+ <description lang="fr">Avez-vous déjà perdu votre configuration XBMC
et espéré avoir fait une sauvegarde ? Maintenant, vous pouvez le faire en un
simple click. Vous pouvez exporter vos bases de données, playlists,
miniatures, addons et autres fichiers de configuration vers n'importe quel
endroit accessible depuis XBMC.</description>
+ <description lang="de">Jemals deine XBMC Konfiguration zerschossen und dir
dann gewünscht, dass ein Backup existiert? Jetzt kannst du eine Sicherung mit
nur einem Klick erzeugen. Du kannst deine Datenbanen, Playlisten, Thumbnails,
Addons und andere Details zu einem Ort deiner Wahl sichern.</description>
<description lang="en">Ever hosed your XBMC configuration and wished you'd
had a backup? Now you can with one easy click. You can export your database,
playlist, thumbnails, addons and other configuration details to any source
writeable by XBMC.</description>
<platform>all</platform>
- <language>en</language>
+ <language></language>
</extension>
</addon>
diff --git a/script.xbmcbackup/changelog.txt b/script.xbmcbackup/changelog.txt
index 2d00af8..4c1fd67 100644
--- a/script.xbmcbackup/changelog.txt
+++ b/script.xbmcbackup/changelog.txt
@@ -1,43 +1,68 @@
-[b]Version 0.0.2[/b]
+[b]Version 0.1.3[/b]
-First version, should backup directories as needed
+backup folder format - thanks zeroram
-[b]Version 0.0.3[/b]
+added German translations - thanks dersphere
-Added progress bar and "silent" option for running on startup or as a script
+removed need for separate verbose logging setting
-[b]Version 0.0.4[/b]
+updated utf-8 encoding for all logging
-Finished code for restore mode.
+backup now uses date as folder name, restore allows user to type date of last
backup
-[b]Version 0.0.5[/b]
+[b]Version 0.1.2[/b]
-Added option to manually type a path rather than browse for one (only one used)
-Show progress bar right away so you know this is doing something
+added French language translation - thanks mikebzh44
+
+added some utf-8 encoding tags to filenames
+
+[b]Version 0.1.1[/b]
+
+added check for key in vfs.py - Thanks Martijn!
+
+[b]Version 0.1.0[/b]
+
+removed transparency from icon.png
+
+[b]Version 0.0.9 [/b]
+
+modified vfs.py again to filter out xsp files (smart playlists). Created
running list for these types of compressed files
+
+added enable/disable logging toggle in settings
+
+[b]Version 0.0.8[/b]
+
+modified vfs.py script to exclude handling zip files as directories, added
keymap and peripheral data folders in the "config" section
+
+[b]Version 0.0.7[/b]
+
+removed "restore.txt" file and now write file listing to memory list instead
[b]Version 0.0.6[/b]
Added the vfs module created by paddycarey
File Selection is now followed for both backup and restore options
-[b]Version 0.0.7[/b]
+[b]Version 0.0.5[/b]
-removed "restore.txt" file and now write file listing to memory list instead
+Added option to manually type a path rather than browse for one (only one used)
+Show progress bar right away so you know this is doing something
-[b]Version 0.0.8[/b]
+[b]Version 0.0.4[/b]
-modified vfs.py script to exclude handling zip files as directories, added
keymap and peripheral data folders in the "config" section
+Finished code for restore mode.
+
+[b]Version 0.0.3[/b]
+
+Added progress bar and "silent" option for running on startup or as a script
+
+[b]Version 0.0.2[/b]
+
+First version, should backup directories as needed
-[b]Version 0.0.9 [/b]
-modified vfs.py again to filter out xsp files (smart playlists). Created
running list for these types of compressed files
-added enable/disable logging toggle in settings
-[b]Version 0.1.0[/b]
-removed transparency from icon.png
-[b]Version 0.1.1[/b]
-added check for key in vfs.py - Thanks Martijn!
\ No newline at end of file
diff --git a/script.xbmcbackup/default.py b/script.xbmcbackup/default.py
index 9cff77f..7c82791 100644
--- a/script.xbmcbackup/default.py
+++ b/script.xbmcbackup/default.py
@@ -3,6 +3,10 @@ import xbmcaddon
import xbmcgui
import resources.lib.vfs as vfs
import os
+import time
+
+__addon_id__ = 'script.xbmcbackup'
+__Addon = xbmcaddon.Addon(__addon_id__)
class FileManager:
walk_path = ''
@@ -71,16 +75,14 @@ class FileManager:
def addFile(self,filename):
#write the full remote path name of this file
- if(self.verbose_log):
- xbmc.log("Add File: " + filename)
+ log("Add File: " + filename,xbmc.LOGDEBUG)
self.fileArray.append(filename)
def getFileList(self):
return self.fileArray
class XbmcBackup:
- __addon_id__ = 'script.xbmcbackup'
- Addon = xbmcaddon.Addon(__addon_id__)
+ addon = None
local_path = ''
remote_path = ''
restoreFile = None
@@ -92,49 +94,64 @@ class XbmcBackup:
fileManager = None
- def __init__(self):
- self.local_path = xbmc.translatePath("special://home")
+ def __init__(self,__Addon):
+ self.addon = __Addon
+ 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'))):
- xbmc.log(str(self.Addon.getSetting('remote_path_2')))
- 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"))):
- 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") + "/"
+ 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'):
+ self.remote_path = self.addon.getSetting("remote_path")
+
+ #check if trailing slash is included
+ if(self.remote_path[-1:] != "/"):
+ self.remote_path = self.remote_path + "/"
+
+ #append backup folder name
+ if(int(self.addon.getSetting('addon_mode')) == 0 and self.remote_path
!= ''):
+ self.remote_path = self.remote_path + time.strftime("%Y%m%d") + "/"
+ elif(int(self.addon.getSetting('addon_mode')) == 1 and
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.log("Starting")
- self.log('Local Dir: ' + self.local_path)
- self.log('Remote Dir: ' + 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
- if(self.Addon.getSetting('run_silent') == 'false'):
+ if(self.addon.getSetting('run_silent') == 'false'):
self.progressBar = xbmcgui.DialogProgress()
- self.progressBar.create('XBMC Backup','Gathering file list.....')
+
self.progressBar.create(self.addon.getLocalizedString(30010),self.addon.getLocalizedString(30049)
+ "......")
#check what mode were are in
- if(int(self.Addon.getSetting('addon_mode')) == 0):
- self.fileManager =
FileManager(self.local_path,self.Addon.getAddonInfo('profile'))
+ if(int(self.addon.getSetting('addon_mode')) == 0):
+ self.fileManager =
FileManager(self.local_path,self.addon.getAddonInfo('profile'))
+
+ #for backups check if remote path exists
+ if(vfs.exists(self.remote_path)):
+ #this will fail - need a disclaimer here
+ log(self.addon.getLocalizedString(30050))
+
self.syncFiles()
else:
- self.fileManager =
FileManager(self.remote_path,self.Addon.getAddonInfo('profile'))
- self.restoreFiles()
+ self.fileManager =
FileManager(self.remote_path,self.addon.getAddonInfo('profile'))
+
+ #for restores remote path must exist
+ if(vfs.exists(self.remote_path)):
+ self.restoreFiles()
+ else:
+
xbmcgui.Dialog().ok(self.addon.getLocalizedString(30010),self.addon.getLocalizedString(30045))
def syncFiles(self):
- if(vfs.exists(self.remote_path)):
- #this will fail - need a disclaimer here
- self.log("Remote Path exists - may have old files in it!")
-
+
#make the remote directory
vfs.mkdir(self.remote_path)
- self.log("Creating Files List")
- self.fileManager.createFileList(self.Addon)
+ log(self.addon.getLocalizedString(30051))
+ self.fileManager.createFileList(self.addon)
allFiles = self.fileManager.getFileList()
@@ -142,9 +159,9 @@ class XbmcBackup:
self.writeFiles(allFiles,self.local_path,self.remote_path)
def restoreFiles(self):
- self.fileManager.createFileList(self.Addon)
+ self.fileManager.createFileList(self.addon)
- self.log("Creating Files List")
+ log(self.addon.getLocalizedString(30051))
allFiles = self.fileManager.getFileList()
#write list from remote to local
@@ -154,21 +171,21 @@ 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('Writing file: ' + 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'):
+ if(self.addon.getSetting('run_silent') == 'false'):
self.progressBar.close()
def updateProgress(self,message=''):
@@ -185,17 +202,22 @@ class XbmcBackup:
result = self.progressBar.iscanceled()
return result
-
- def log(self,message):
- xbmc.log(self.__addon_id__ + ": " + 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()
+backup = XbmcBackup(__Addon)
if(backup.isReady()):
backup.run()
else:
- xbmcgui.Dialog().ok('XBMC Backup','Error: Remote path cannot be empty')
+
xbmcgui.Dialog().ok(__Addon.getLocalizedString(30010),__Addon.getLocalizedString(30045))
diff --git a/script.xbmcbackup/icon.png b/script.xbmcbackup/icon.png
index 824b86b..8ae6004 100644
Binary files a/script.xbmcbackup/icon.png and b/script.xbmcbackup/icon.png
differ
diff --git a/script.xbmcbackup/resources/language/English/strings.xml
b/script.xbmcbackup/resources/language/English/strings.xml
index ac91e1c..b88f105 100644
--- a/script.xbmcbackup/resources/language/English/strings.xml
+++ b/script.xbmcbackup/resources/language/English/strings.xml
@@ -4,13 +4,16 @@
<string id="30011">General</string>
<string id="30012">File Selection</string>
+ <string id="30016">Backup</string>
+ <string id="30017">Restore</string>
+ <string id="30018">Browse Path</string>
+ <string id="30019">Type Path</string>
<string id="30020">Browse Remote Path</string>
<string id="30021">Backup Folder Name</string>
<string id="30022">Run Silent</string>
<string id="30023">Mode</string>
<string id="30024">Type Remote Path</string>
<string id="30025">Remote Path Type</string>
- <string id="30026">Verbose Logging</string>
<string id="30030">User Addons</string>
<string id="30031">Addon Data</string>
@@ -19,4 +22,13 @@
<string id="30034">Thumbnails/Fanart</string>
<string id="30035">Config Files</string>
+ <string id="30045">Error: Remote path doesn't exist</string>
+ <string id="30046">Starting</string>
+ <string id="30047">Local Dir</string>
+ <string id="30048">Remote Dir</string>
+ <string id="30049">Gathering file list</string>
+ <string id="30050">Remote Path exists - may have old files in
it!</string>
+ <string id="30051">Creating Files List</string>
+ <string id="30052">Writing file</string>
+
</strings>
diff --git a/script.xbmcbackup/resources/settings.xml
b/script.xbmcbackup/resources/settings.xml
index 555c4ee..d6cad5a 100644
--- a/script.xbmcbackup/resources/settings.xml
+++ b/script.xbmcbackup/resources/settings.xml
@@ -1,13 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<settings>
<category id="general" label="30011">
- <setting id="addon_mode" type="enum" values="Backup|Restore"
default="Backup" label="30023" />
- <setting id="remote_selection" type="enum" values="Browse
Path|Type Path" defaults="Browse Path" label="30025"/>
+ <setting id="addon_mode" type="enum" lvalues="30016|30017"
default="0" label="30023" />
+ <setting id="remote_selection" type="enum"
lvalues="30018|30019" default="0" label="30025"/>
<setting id="remote_path_2" type="text" label="30024"
default="" visible="eq(-1,1)" />
<setting id="remote_path" type="folder" label="30020"
visible="eq(-2,0)" />
- <setting id="backup_name" type="text" label="30021"
default="xbmc_backup"/>
+ <setting id="backup_name" type="text" label="30021"
default="backup_date" visible="eq(-4,1)"/>
<setting id="run_silent" type="bool" label="30022"
default="false" />
- <setting id="verbose_log" type="bool" label="30026"
default="false" />
</category>
<category id="selection" label="30012">
<setting id="backup_addons" type="bool" label="30030"
default="true" />
-----------------------------------------------------------------------
Summary of changes:
script.xbmcbackup/README.txt | 6 +-
script.xbmcbackup/addon.xml | 10 ++-
script.xbmcbackup/changelog.txt | 65 ++++++++----
script.xbmcbackup/default.py | 106 ++++++++++++--------
script.xbmcbackup/icon.png | Bin 43609 -> 48793 bytes
.../resources/language/English/strings.xml | 14 +++-
.../resources/language/French/strings.xml | 33 ++++++
.../resources/language/German/strings.xml | 33 ++++++
script.xbmcbackup/resources/settings.xml | 7 +-
9 files changed, 201 insertions(+), 73 deletions(-)
create mode 100644 script.xbmcbackup/resources/language/French/strings.xml
create mode 100644 script.xbmcbackup/resources/language/German/strings.xml
hooks/post-receive
--
Scripts
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons