1 from Wizard import wizardManager
2 from Screens.WizardLanguage import WizardLanguage
3 from Tools.Directories import crawlDirectory, 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, InfoHandler, InfoHandlerParseError
8 from Components.PluginComponent import plugins
9 from Plugins.Plugin import PluginDescriptor
12 config.misc.defaultchosen = ConfigBoolean(default = True)
16 class DefaultWizard(WizardLanguage, DreamInfoHandler):
17 def __init__(self, session, silent = True):
18 DreamInfoHandler.__init__(self, self.statusCallback)
22 WizardLanguage.__init__(self, session, showSteps = False)
23 self["wizard"] = Pixmap()
24 self["rc"] = MovingPixmap()
25 self["arrowdown"] = MovingPixmap()
26 self["arrowup"] = MovingPixmap()
27 self["arrowup2"] = MovingPixmap()
29 def setDirectory(self):
30 os.system("mount %s %s" % (resolveFilename(SCOPE_DEFAULTPARTITION), resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR)))
31 self.directory = resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR)
32 self.xmlfile = "defaultwizard.xml"
35 config.misc.defaultchosen.value = 0
36 config.misc.defaultchosen.save()
39 def statusCallback(self, status, progress):
40 print "statusCallback:", status, progress
41 if status == DreamInfoHandler.STATUS_DONE:
42 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."))
44 self.disableKeys = False
46 def getConfigList(self):
47 self.packageslist = []
49 self.fillPackagesList()
50 self.packagesConfig = []
51 for x in range(len(self.packageslist)):
53 self.packagesConfig.append(entry)
54 configList.append(getConfigListEntry(self.packageslist[x][0]["attributes"]["name"], entry))
57 def selectionMade(self):
58 print "selection made"
59 #self.installPackage(int(index))
61 for x in range(len(self.packagesConfig)):
62 if self.packagesConfig[x].value:
64 self.installPackages(indexList)
66 class DreamPackageWizard(DefaultWizard):
67 def __init__(self, session, packagefile, silent = False):
68 os.system("mkdir /tmp/package")
69 os.system("tar xpzf %s -C /tmp/package" % packagefile)
70 self.packagefile = packagefile
71 DefaultWizard.__init__(self, session, silent)
73 def setDirectory(self):
74 self.directory = "/tmp/package"
75 self.xmlfile = "dreampackagewizard.xml"
77 class ImageDefaultInstaller(DreamInfoHandler):
79 DreamInfoHandler.__init__(self, self.statusCallback, blocking = True)
80 self.directory = resolveFilename(SCOPE_DEFAULTDIR)
81 self.fillPackagesList()
82 self.installPackage(0)
84 def statusCallback(self, status, progress):
88 if choice is not None:
89 #os.system("mkdir /tmp/package && tar xpzf %s ")
90 choice[2].open(DreamPackageWizard, choice[1])
92 def filescan_open(list, session, **kwargs):
93 from Screens.ChoiceBox import ChoiceBox
94 print "open default wizard"
95 filelist = [(os.path.split(x.path)[1], x.path, session) for x in list]
97 session.openWithCallback(install, ChoiceBox, title = _("Please choose he package..."), list=filelist)
99 def filescan(**kwargs):
100 from Components.Scanner import Scanner, ScanPath
101 from mimetypes import add_type
102 add_type("application/x-dream-package", "dmpkg")
104 Scanner(mimetypes = ["application/x-dream-package"],
107 ScanPath(path = "dmpkg", with_subdirs = True),
108 ScanPath(path = "", with_subdirs = False),
110 name = "Dream-Package",
111 description = "Install settings, skins, software...",
112 openfnc = filescan_open, )
114 print "add dreampackage scanner plugin"
115 plugins.addPlugin(PluginDescriptor(name="Dream-Package", where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan, internal = True))
118 wizardManager.registerWizard(DefaultWizard, config.misc.defaultchosen.value, priority = 6)
120 if config.misc.defaultchosen.value:
121 print "Installing image defaults"
122 installer = ImageDefaultInstaller()
123 print "installing done!"