1 from Wizard import wizardManager
2 from Screens.WizardLanguage import WizardLanguage
3 from Tools.Directories import 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
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 os_system("mkdir /tmp/package")
66 os_system("tar xpzf %s -C /tmp/package" % packagefile)
67 self.packagefile = packagefile
68 DefaultWizard.__init__(self, session, silent)
70 def setDirectory(self):
71 self.directory = "/tmp/package"
72 self.xmlfile = "dreampackagewizard.xml"
74 class ImageDefaultInstaller(DreamInfoHandler):
76 DreamInfoHandler.__init__(self, self.statusCallback, blocking = True)
77 self.directory = resolveFilename(SCOPE_DEFAULTDIR)
78 self.fillPackagesList()
79 self.installPackage(0)
81 def statusCallback(self, status, progress):
85 if choice is not None:
86 #os_system("mkdir /tmp/package && tar xpzf %s ")
87 choice[2].open(DreamPackageWizard, choice[1])
89 def filescan_open(list, session, **kwargs):
90 from Screens.ChoiceBox import ChoiceBox
91 print "open default wizard"
92 filelist = [(os_path.split(x.path)[1], x.path, session) for x in list]
94 session.openWithCallback(install, ChoiceBox, title = _("Please choose he package..."), list=filelist)
96 def filescan(**kwargs):
97 from Components.Scanner import Scanner, ScanPath
98 from mimetypes import add_type
99 add_type("application/x-dream-package", "dmpkg")
101 Scanner(mimetypes = ["application/x-dream-package"],
104 ScanPath(path = "dmpkg", with_subdirs = True),
105 ScanPath(path = "", with_subdirs = False),
107 name = "Dream-Package",
108 description = "Install settings, skins, software...",
109 openfnc = filescan_open, )
111 print "add dreampackage scanner plugin"
112 plugins.addPlugin(PluginDescriptor(name="Dream-Package", where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan, internal = True))
115 wizardManager.registerWizard(DefaultWizard, config.misc.defaultchosen.value, priority = 6)
117 if config.misc.defaultchosen.value:
118 print "Installing image defaults"
119 installer = ImageDefaultInstaller()
120 print "installing done!"