1 from Screens.Wizard import WizardSummary
2 from Screens.WizardLanguage import WizardLanguage
3 from Screens.Wizard import wizardManager
4 from Screens.Rc import Rc
5 from Components.Label import Label
6 from Components.MenuList import MenuList
7 from Components.PluginComponent import plugins
8 from Plugins.Plugin import PluginDescriptor
9 from Tools.Directories import fileExists, resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE
10 from Components.Pixmap import Pixmap, MovingPixmap, MultiPixmap
11 from os import popen, path, makedirs, listdir, access, stat, rename, remove, W_OK, R_OK
13 from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigText, ConfigLocations, ConfigBoolean
14 from Components.Harddisk import harddiskmanager
15 config.misc.firstrun = ConfigBoolean(default = True)
16 config.plugins.configurationbackup = ConfigSubsection()
17 config.plugins.configurationbackup.backuplocation = ConfigText(default = '/media/hdd/', visible_width = 50, fixed_size = False)
18 config.plugins.configurationbackup.backupdirs = ConfigLocations(default=['/etc/enigma2/', '/etc/network/interfaces', '/etc/wpa_supplicant.conf'])
21 backupfile = "enigma2settingsbackup.tar.gz"
23 def checkConfigBackup():
24 parts = [ (r.description, r.mountpoint) for r in harddiskmanager.getMountedPartitions(onlyhotplug = False)]
30 if x[1].endswith('/'):
31 fullbackupfile = x[1] + 'backup/' + backupfile
32 if fileExists(fullbackupfile):
33 config.plugins.configurationbackup.backuplocation.value = str(x[1])
34 config.plugins.configurationbackup.backuplocation.save()
35 config.plugins.configurationbackup.save()
38 fullbackupfile = x[1] + '/backup/' + backupfile
39 if fileExists(fullbackupfile):
40 config.plugins.configurationbackup.backuplocation.value = str(x[1])
41 config.plugins.configurationbackup.backuplocation.save()
42 config.plugins.configurationbackup.save()
46 def checkBackupFile():
47 backuplocation = config.plugins.configurationbackup.backuplocation.value
48 if backuplocation.endswith('/'):
49 fullbackupfile = backuplocation + 'backup/' + backupfile
50 if fileExists(fullbackupfile):
55 fullbackupfile = backuplocation + '/backup/' + backupfile
56 if fileExists(fullbackupfile):
61 if checkConfigBackup() is None:
66 class ImageWizard(WizardLanguage, Rc):
68 <screen name="ImageWizard" position="0,0" size="720,576" title="Welcome..." flags="wfNoBorder" >
69 <widget name="text" position="153,40" size="340,330" font="Regular;22" />
70 <widget source="list" render="Listbox" position="43,340" size="490,180" scrollbarMode="showOnDemand" >
71 <convert type="StringList" />
73 <widget name="config" position="53,340" zPosition="1" size="440,180" transparent="1" scrollbarMode="showOnDemand" />
74 <ePixmap pixmap="skin_default/buttons/button_red.png" position="40,225" zPosition="0" size="15,16" transparent="1" alphatest="on" />
75 <widget name="languagetext" position="55,225" size="95,30" font="Regular;18" />
76 <widget name="wizard" pixmap="skin_default/wizard.png" position="40,50" zPosition="10" size="110,174" alphatest="on" />
77 <widget name="rc" pixmaps="skin_default/rc.png,skin_default/rcold.png" position="530,50" zPosition="10" size="154,500" alphatest="on" />
78 <widget name="arrowdown" pixmap="skin_default/arrowdown.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on" />
79 <widget name="arrowdown2" pixmap="skin_default/arrowdown.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on" />
80 <widget name="arrowup" pixmap="skin_default/arrowup.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on" />
81 <widget name="arrowup2" pixmap="skin_default/arrowup.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on" />
83 def __init__(self, session):
84 self.xmlfile = resolveFilename(SCOPE_PLUGINS, "SystemPlugins/SoftwareManager/imagewizard.xml")
85 WizardLanguage.__init__(self, session, showSteps = False, showStepSlider = False)
87 self.session = session
88 self["wizard"] = Pixmap()
89 self.selectedDevice = None
94 def listDevices(self):
95 list = [ (r.description, r.mountpoint) for r in harddiskmanager.getMountedPartitions(onlyhotplug = False)]
97 result = access(x[1], W_OK) and access(x[1], R_OK)
98 if result is False or x[1] == '/':
101 if x[1].startswith('/autofs/'):
105 def deviceSelectionMade(self, index):
106 self.deviceSelect(index)
108 def deviceSelectionMoved(self):
109 self.deviceSelect(self.selection)
111 def deviceSelect(self, device):
112 self.selectedDevice = device
113 config.plugins.configurationbackup.backuplocation.value = self.selectedDevice
114 config.plugins.configurationbackup.backuplocation.save()
115 config.plugins.configurationbackup.save()
118 if config.misc.firstrun.value:
119 wizardManager.registerWizard(ImageWizard, backupAvailable, priority = 10)