Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[software-manager] add option to restore your settings
  • Loading branch information
koivo committed Oct 7, 2018
1 parent 76a098d commit f3fb075
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 2 deletions.
45 changes: 44 additions & 1 deletion lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py
Expand Up @@ -44,7 +44,8 @@
from BackupRestore import BackupSelection, RestoreMenu, BackupScreen, RestoreScreen, getBackupPath, getOldBackupPath, getBackupFilename
from SoftwareTools import iSoftwareTools
import os
from boxbranding import getBoxType, getMachineBrand, getMachineName, getBrandOEM
import shutil
from boxbranding import getBoxType, getMachineBrand, getMachineName, getBrandOEM, getImageDistro

boxtype = getBoxType()
brandoem = getBrandOEM()
Expand Down Expand Up @@ -141,6 +142,16 @@ def load_cache(cache_file):
fd.close()
return cache_data

def getBackupPath():
backuppath = config.plugins.configurationbackup.backuplocation.value
if backuppath.endswith('/'):
return backuppath + 'backup_' + getImageDistro() + '_'+ getBoxType()
else:
return backuppath + '/backup_' + getImageDistro() + '_'+ getBoxType()

def getBackupFilename():
return "enigma2settingsbackup.tar.gz"

class UpdatePluginMenu(Screen):

skin = """
Expand Down Expand Up @@ -219,6 +230,7 @@ def __init__(self, session, args = 0):
self.list.append(("backuplocation", _("Select backup location"), _("\nSelect your backup device.\nCurrent device: " ) + config.plugins.configurationbackup.backuplocation.value + self.oktext, None))
self.list.append(("backupfiles", _("Select backup files"), _("Select files for backup.") + self.oktext + "\n\n" + self.infotext, None))
self.list.append(("resetbackupfiles",_("Set backupfiles to defaults"), _("\nReset selection of files for backup to default." ) + self.oktext, None))
self.list.append(("autorestorebackup",_("Restore settings backup after restart"), _("\nRestore automatically your saved settings after Enigma restart." ) + self.oktext, None))
if config.usage.setup_level.index >= 2: # expert+
self.list.append(("ipkg-manager", _("Packet management"), _("\nView, install and remove available or installed packages." ) + self.oktext, None))
self.list.append(("ipkg-source",_("Select upgrade source"), _("\nEdit the upgrade source address." ) + self.oktext, None))
Expand Down Expand Up @@ -406,6 +418,9 @@ def go(self, num = None):
elif (currentEntry == "resetbackupfiles"):
restartbox = self.session.openWithCallback(self.coldrestartGUI,MessageBox,_("Set selected files for backup to default \nand restart Enigma now?"), MessageBox.TYPE_YESNO)
restartbox.setTitle(_("Restart Enigma"))
elif (currentEntry == "autorestorebackup"):
restartbox = self.session.openWithCallback(self.autorestorebackup,MessageBox,_("Do you want to restore your settings after Enigma restart?"), MessageBox.TYPE_YESNO)
restartbox.setTitle(_("Restore after Restart Enigma"))
elif (currentEntry == "advancedrestore"):
self.session.open(RestoreMenu, self.skin_path)
elif (currentEntry == "ipkg-source"):
Expand All @@ -420,6 +435,31 @@ def coldrestartGUI(self, answer):
else:
self.close()

def autorestorebackup(self, answer):
if answer is True:
try:
if not os.path.exists('/media/hdd/images'):
os.makedirs('/media/hdd/images')
print "AfterFlashAction: create /media/hdd/images/hdfrestore"
print "AfterFlashAction: filename:",self.fullbackupfilename
backupsourcefile = self.fullbackupfilename
backupdestfile = '/media/hdd/images/hdfrestore'
if not os.path.exists(backupsourcefile):
print "AfterFlashAction: No settings found."
else:
shutil.copyfile(backupsourcefile, backupdestfile)
self.session.open(MessageBox, _("Please restart Enigma now to restore your settings."), MessageBox.TYPE_INFO, timeout = 10)
except:
print "AfterFlashAction: failed to create /media/hdd/images/hdfrestore"
else:
try:
if os.path.exists('/media/hdd/images/hdfrestore'):
os.unlink('/media/hdd/images/hdfrestore')
print "AfterFlashAction: delete /media/hdd/images/hdfrestore"
except:
print "AfterFlashAction: failed to delete /media/hdd/images/hdfrestore"
self.close()

def backupfiles_choosen(self, ret):
self.backupdirs = ' '.join( config.plugins.configurationbackup.backupdirs.value )
config.plugins.configurationbackup.backupdirs.save()
Expand Down Expand Up @@ -517,6 +557,9 @@ def __init__(self, session, skin_path = None):
self.overwriteSpinnerfilesEntry = None
self.updatetypeEntry = None
self.epgcacheEntry = None
self.backuppath = getBackupPath()
self.backupfile = getBackupFilename()
self.fullbackupfilename = self.backuppath + "/" + self.backupfile

self.list = [ ]
ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changedEntry)
Expand Down
21 changes: 20 additions & 1 deletion po/de.po
Expand Up @@ -5,7 +5,7 @@ msgstr ""
"Project-Id-Version: tuxbox-enigma 0.0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-05-19 23:44+0100\n"
"PO-Revision-Date: 2018-09-29 17:01+0200\n"
"PO-Revision-Date: 2018-10-07 08:25+0200\n"
"Last-Translator: Koivo <koivo@hdfreaks.cc>\n"
"Language-Team: openHDF\n"
"Language: de\n"
Expand Down Expand Up @@ -2120,6 +2120,25 @@ msgstr "Einstellungen sichern"
msgid "Set backupfiles to defaults"
msgstr "Zurücksetzen der Dateien"

msgid "Restore settings backup after restart"
msgstr "Automatische Wiederherstellung"

msgid "Restore after Restart Enigma"
msgstr "Wiederherstellung nach Enigma Neustart"

msgid "Please restart Enigma now to restore your settings."
msgstr "Bitte Enigma neustarten um die Wiederherstellung zu starten."

msgid "Do you want to restore your settings after Enigma restart?"
msgstr "Sollen die gesicherten Einstellungen nach einem Neustart automatisch wiederhergestellt werden?"

msgid ""
"\n"
"Restore automatically your saved settings after Enigma restart."
msgstr ""
"\n"
"Automatisches Wiederherstellen der gesicherten Settings nach einem Enigma Neustart."

msgid ""
"\n"
"Reset selection of files for backup to default."
Expand Down

0 comments on commit f3fb075

Please sign in to comment.