X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fpython%2FPlugins%2FSystemPlugins%2FSoftwareManager%2FBackupRestore.py;h=01649bb379ba52dc58fab500fc7a172a3409f8dd;hp=327f08ed63b5bfb84d28deaac79d24815f30a60e;hb=879d60c88e24c2c3f2aab9dff73192c901f63f31;hpb=bce53d4a67d1655a496eebe5912c8573e880114e diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py index 327f08e..01649bb 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py @@ -4,13 +4,14 @@ from Screens.Console import Console from Components.ActionMap import ActionMap, NumberActionMap from Components.Pixmap import Pixmap from Components.Label import Label +from Components.Sources.StaticText import StaticText from Components.MenuList import MenuList from Components.config import getConfigListEntry, configfile, ConfigSelection, ConfigSubsection, ConfigText, ConfigLocations from Components.config import config from Components.ConfigList import ConfigList,ConfigListScreen from Components.FileList import MultiFileSelectList from Plugins.Plugin import PluginDescriptor -from enigma import eTimer +from enigma import eTimer, eEnv from Tools.Directories import * from os import popen, path, makedirs, listdir, access, stat, rename, remove, W_OK, R_OK from time import gmtime, strftime, localtime @@ -19,7 +20,7 @@ from datetime import date config.plugins.configurationbackup = ConfigSubsection() config.plugins.configurationbackup.backuplocation = ConfigText(default = '/media/hdd/', visible_width = 50, fixed_size = False) -config.plugins.configurationbackup.backupdirs = ConfigLocations(default=['/etc/enigma2/', '/etc/network/interfaces', '/etc/wpa_supplicant.conf']) +config.plugins.configurationbackup.backupdirs = ConfigLocations(default=[eEnv.resolve('${sysconfdir}/enigma2/'), '/etc/network/interfaces', '/etc/wpa_supplicant.conf', '/etc/resolv.conf', '/etc/default_gw', '/etc/hostname']) def getBackupPath(): backuppath = config.plugins.configurationbackup.backuplocation.value @@ -34,7 +35,7 @@ def getBackupFilename(): class BackupScreen(Screen, ConfigListScreen): skin = """ - + """ @@ -62,9 +63,10 @@ class BackupScreen(Screen, ConfigListScreen): self.setWindowTitle() def setWindowTitle(self): - self.setTitle(_("Backup running...")) + self.setTitle(_("Backup is running...")) def doBackup(self): + configfile.save() try: if (path.exists(self.backuppath) == False): makedirs(self.backuppath) @@ -76,14 +78,14 @@ class BackupScreen(Screen, ConfigListScreen): remove(self.newfilename) rename(self.fullbackupfilename,self.newfilename) if self.finished_cb: - self.session.openWithCallback(self.finished_cb, Console, title = _("Backup running"), cmdlist = ["tar -czvf " + self.fullbackupfilename + " " + self.backupdirs],finishedCallback = self.backupFinishedCB,closeOnSuccess = True) + self.session.openWithCallback(self.finished_cb, Console, title = _("Backup is running..."), cmdlist = ["tar -czvf " + self.fullbackupfilename + " " + self.backupdirs],finishedCallback = self.backupFinishedCB,closeOnSuccess = True) else: - self.session.open(Console, title = _("Backup running"), cmdlist = ["tar -czvf " + self.fullbackupfilename + " " + self.backupdirs],finishedCallback = self.backupFinishedCB, closeOnSuccess = True) + self.session.open(Console, title = _("Backup is running..."), cmdlist = ["tar -czvf " + self.fullbackupfilename + " " + self.backupdirs],finishedCallback = self.backupFinishedCB, closeOnSuccess = True) except OSError: if self.finished_cb: - self.session.openWithCallback(self.finished_cb, MessageBox, _("Sorry your backup destination is not writeable.\nPlease choose an other one."), MessageBox.TYPE_INFO) + self.session.openWithCallback(self.finished_cb, MessageBox, _("Sorry your backup destination is not writeable.\nPlease choose an other one."), MessageBox.TYPE_INFO, timeout = 10 ) else: - self.session.openWithCallback(self.backupErrorCB,MessageBox, _("Sorry your backup destination is not writeable.\nPlease choose an other one."), MessageBox.TYPE_INFO) + self.session.openWithCallback(self.backupErrorCB,MessageBox, _("Sorry your backup destination is not writeable.\nPlease choose an other one."), MessageBox.TYPE_INFO, timeout = 10 ) def backupFinishedCB(self,retval = None): self.close(True) @@ -98,21 +100,21 @@ class BackupScreen(Screen, ConfigListScreen): class BackupSelection(Screen): skin = """ - - - - - - - - - """ + + + + + + + + + """ def __init__(self, session): Screen.__init__(self, session) - self["key_red"] = Label(_("Cancel")) - self["key_green"] = Label(_("Save")) - self["key_yellow"] = Label() + self["key_red"] = StaticText(_("Cancel")) + self["key_green"] = StaticText(_("Save")) + self["key_yellow"] = StaticText() self.selectedFiles = config.plugins.configurationbackup.backupdirs.value defaultDir = '/' @@ -143,7 +145,7 @@ class BackupSelection(Screen): self.selectionChanged() def setWindowTitle(self): - self.setTitle(_("Select files/folders to backup...")) + self.setTitle(_("Select files/folders to backup")) def selectionChanged(self): current = self["checkList"].getCurrent()[0] @@ -186,22 +188,23 @@ class BackupSelection(Screen): class RestoreMenu(Screen): skin = """ - - - - - - + + + + + + + + """ def __init__(self, session, plugin_path): Screen.__init__(self, session) self.skin_path = plugin_path - self["canceltext"] = Label(_("Cancel")) - self["restoretext"] = Label(_("Restore")) - self["restore"] = Pixmap() - self["cancel"] = Pixmap() + self["key_red"] = StaticText(_("Cancel")) + self["key_green"] = StaticText(_("Restore")) + self["key_yellow"] = StaticText(_("Delete")) self.sel = [] self.val = [] @@ -219,7 +222,8 @@ class RestoreMenu(Screen): self["shortcuts"] = ActionMap(["ShortcutActions"], { "red": self.keyCancel, - "yellow": self.KeyOk, + "green": self.KeyOk, + "yellow": self.deleteFile, }) self.flist = [] self["filelist"] = MenuList(self.flist) @@ -230,7 +234,7 @@ class RestoreMenu(Screen): self.setWindowTitle() def setWindowTitle(self): - self.setTitle(_("Restore backups...")) + self.setTitle(_("Restore backups")) def fill_list(self): @@ -242,13 +246,14 @@ class RestoreMenu(Screen): if (file.endswith(".tar.gz")): self.flist.append((file)) self.entry = True - self["filelist"].l.setList(self.flist) + self["filelist"].l.setList(self.flist) def KeyOk(self): if (self.exe == False) and (self.entry == True): self.sel = self["filelist"].getCurrent() - self.val = self.path + self.sel - self.session.openWithCallback(self.startRestore, MessageBox, _("Are you sure you want to restore\nfollowing backup:\n" + self.sel + "\nSystem will restart after the restore!")) + if self.sel: + self.val = self.path + "/" + self.sel + self.session.openWithCallback(self.startRestore, MessageBox, _("Are you sure you want to restore\nfollowing backup:\n") + self.sel + _("\nSystem will restart after the restore!")) def keyCancel(self): self.close() @@ -258,12 +263,25 @@ class RestoreMenu(Screen): self.exe = True self.session.open(Console, title = _("Restore running"), cmdlist = ["tar -xzvf " + self.path + "/" + self.sel + " -C /", "killall -9 enigma2"]) - def Exit(self): - self.close() + def deleteFile(self): + if (self.exe == False) and (self.entry == True): + self.sel = self["filelist"].getCurrent() + if self.sel: + self.val = self.path + "/" + self.sel + self.session.openWithCallback(self.startDelete, MessageBox, _("Are you sure you want to delete\nfollowing backup:\n" + self.sel )) + + def startDelete(self, ret = False): + if (ret == True): + self.exe = True + print "removing:",self.val + if (path.exists(self.val) == True): + remove(self.val) + self.exe = False + self.fill_list() class RestoreScreen(Screen, ConfigListScreen): skin = """ - + """ @@ -271,7 +289,7 @@ class RestoreScreen(Screen, ConfigListScreen): Screen.__init__(self, session) self.session = session self.runRestore = runRestore - self["actions"] = ActionMap(["WizardActions", "DirectionActions"], + self["actions"] = ActionMap(["WizardActions", "DirectionActions"], { "ok": self.close, "back": self.close, @@ -291,13 +309,17 @@ class RestoreScreen(Screen, ConfigListScreen): self.setWindowTitle() def setWindowTitle(self): - self.setTitle(_("Restore running...")) + self.setTitle(_("Restore is running...")) def doRestore(self): + if path.exists("/proc/stb/vmpeg/0/dst_width"): + restorecmdlist = ["tar -xzvf " + self.fullbackupfilename + " -C /", "echo 0 > /proc/stb/vmpeg/0/dst_height", "echo 0 > /proc/stb/vmpeg/0/dst_left", "echo 0 > /proc/stb/vmpeg/0/dst_top", "echo 0 > /proc/stb/vmpeg/0/dst_width", "killall -9 enigma2"] + else: + restorecmdlist = ["tar -xzvf " + self.fullbackupfilename + " -C /", "killall -9 enigma2"] if self.finished_cb: - self.session.openWithCallback(self.finished_cb, Console, title = _("Restore running"), cmdlist = ["tar -xzvf " + self.fullbackupfilename + " -C /", "killall -9 enigma2"]) + self.session.openWithCallback(self.finished_cb, Console, title = _("Restore is running..."), cmdlist = restorecmdlist) else: - self.session.open(Console, title = _("Restore running"), cmdlist = ["tar -xzvf " + self.fullbackupfilename + " -C /", "killall -9 enigma2"]) + self.session.open(Console, title = _("Restore is running..."), cmdlist = restorecmdlist) def backupFinishedCB(self,retval = None): self.close(True)