1 from Wizard import wizardManager
2 from Screens.WizardLanguage import WizardLanguage
3 from Tools.Directories import pathExists, resolveFilename, SCOPE_DEFAULTDIR, SCOPE_DEFAULTPARTITIONMOUNTDIR, SCOPE_DEFAULTPARTITION
5 from Components.Pixmap import Pixmap, MovingPixmap
6 from Components.config import config, ConfigBoolean, configfile, ConfigYesNo, getConfigListEntry
7 from Components.DreamInfoHandler import DreamInfoHandler
8 from Components.PluginComponent import plugins
9 from Plugins.Plugin import PluginDescriptor
10 from os import system as os_system, path as os_path, mkdir
12 config.misc.defaultchosen = ConfigBoolean(default = True)
14 class DefaultWizard(WizardLanguage, DreamInfoHandler):
15 def __init__(self, session, silent = True, showSteps = False, neededTag = None):
16 DreamInfoHandler.__init__(self, self.statusCallback, neededTag = neededTag)
20 WizardLanguage.__init__(self, session, showSteps = False)
21 self["wizard"] = Pixmap()
22 self["rc"] = MovingPixmap()
23 self["arrowdown"] = MovingPixmap()
24 self["arrowup"] = MovingPixmap()
25 self["arrowup2"] = MovingPixmap()
27 def setDirectory(self):
28 os_system("mount %s %s" % (resolveFilename(SCOPE_DEFAULTPARTITION), resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR)))
29 self.directory = resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR)
30 self.xmlfile = "defaultwizard.xml"
33 config.misc.defaultchosen.value = 0
34 config.misc.defaultchosen.save()
37 def statusCallback(self, status, progress):
38 print "statusCallback:", status, progress
39 if status == DreamInfoHandler.STATUS_DONE:
40 self["text"].setText(_("The installation of the default settings is finished. You can now continue configuring your Dreambox by pressing the OK button on the remote control."))
42 self.disableKeys = False
44 def getConfigList(self):
45 self.packageslist = []
47 self.fillPackagesList()
48 self.packagesConfig = []
49 for x in range(len(self.packageslist)):
51 self.packagesConfig.append(entry)
52 configList.append(getConfigListEntry(self.packageslist[x][0]["attributes"]["name"], entry))
55 def selectionMade(self):
56 print "selection made"
57 #self.installPackage(int(index))
59 for x in range(len(self.packagesConfig)):
60 if self.packagesConfig[x].value:
61 self.indexList.append(x)
63 class DreamPackageWizard(DefaultWizard):
64 def __init__(self, session, packagefile, silent = False):
65 if not pathExists("/tmp/package"):
67 os_system("tar xpzf %s -C /tmp/package" % packagefile)
68 self.packagefile = packagefile
69 DefaultWizard.__init__(self, session, silent)
71 def setDirectory(self):
72 self.directory = "/tmp/package"
73 self.xmlfile = "dreampackagewizard.xml"
75 class ImageDefaultInstaller(DreamInfoHandler):
77 DreamInfoHandler.__init__(self, self.statusCallback, blocking = True)
78 self.directory = resolveFilename(SCOPE_DEFAULTDIR)
79 self.fillPackagesList()
80 self.installPackage(0)
82 def statusCallback(self, status, progress):
86 if choice is not None:
87 #os_system("mkdir /tmp/package && tar xpzf %s ")
88 choice[2].open(DreamPackageWizard, choice[1])
90 def filescan_open(list, session, **kwargs):
91 from Screens.ChoiceBox import ChoiceBox
92 print "open default wizard"
93 filelist = [(os_path.split(x.path)[1], x.path, session) for x in list]
95 session.openWithCallback(install, ChoiceBox, title = _("Please choose he package..."), list=filelist)
97 def filescan(**kwargs):
98 from Components.Scanner import Scanner, ScanPath
100 Scanner(mimetypes = ["application/x-dream-package"],
103 ScanPath(path = "dmpkg", with_subdirs = True),
104 ScanPath(path = "", with_subdirs = False),
106 name = "Dream-Package",
107 description = _("Install settings, skins, software..."),
108 openfnc = filescan_open, )
110 print "add dreampackage scanner plugin"
111 plugins.addPlugin(PluginDescriptor(name="Dream-Package", where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan, internal = True))
114 wizardManager.registerWizard(DefaultWizard, config.misc.defaultchosen.value, priority = 6)
116 if config.misc.defaultchosen.value:
117 print "Installing image defaults"
118 installer = ImageDefaultInstaller()
119 print "installing done!"