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 self.directory = resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR)
29 self.xmlfile = "defaultwizard.xml"
31 os_system("mount %s %s" % (resolveFilename(SCOPE_DEFAULTPARTITION), self.directory))
34 config.misc.defaultchosen.value = 0
35 config.misc.defaultchosen.save()
38 def statusCallback(self, status, progress):
39 print "statusCallback:", status, progress
40 if status == DreamInfoHandler.STATUS_DONE:
41 self["text"].setText(_("The installation of the default settings is finished. You can now continue configuring your STB by pressing the OK button on the remote control."))
43 self.disableKeys = False
45 def getConfigList(self):
46 self.packageslist = []
48 self.fillPackagesList()
49 self.packagesConfig = []
50 for x in range(len(self.packageslist)):
52 self.packagesConfig.append(entry)
53 configList.append(getConfigListEntry(self.packageslist[x][0]["attributes"]["name"], entry))
56 def selectionMade(self):
57 print "selection made"
58 #self.installPackage(int(index))
60 for x in range(len(self.packagesConfig)):
61 if self.packagesConfig[x].value:
62 self.indexList.append(x)
64 class DreamPackageWizard(DefaultWizard):
65 def __init__(self, session, packagefile, silent = False):
66 if not pathExists("/tmp/package"):
68 os_system("tar xpzf %s -C /tmp/package" % packagefile)
69 self.packagefile = packagefile
70 DefaultWizard.__init__(self, session, silent)
72 def setDirectory(self):
73 self.directory = "/tmp/package"
74 self.xmlfile = "dreampackagewizard.xml"
76 class ImageDefaultInstaller(DreamInfoHandler):
78 DreamInfoHandler.__init__(self, self.statusCallback, blocking = True)
79 self.directory = resolveFilename(SCOPE_DEFAULTDIR)
80 self.fillPackagesList()
81 self.installPackage(0)
83 def statusCallback(self, status, progress):
87 if choice is not None:
88 #os_system("mkdir /tmp/package && tar xpzf %s ")
89 choice[2].open(DreamPackageWizard, choice[1])
91 def filescan_open(list, session, **kwargs):
92 from Screens.ChoiceBox import ChoiceBox
93 print "open default wizard"
94 filelist = [(os_path.split(x.path)[1], x.path, session) for x in list]
96 session.openWithCallback(install, ChoiceBox, title = _("Please choose he package..."), list=filelist)
98 def filescan(**kwargs):
99 from Components.Scanner import Scanner, ScanPath
101 Scanner(mimetypes = ["application/x-dream-package"],
104 ScanPath(path = "dmpkg", with_subdirs = True),
105 ScanPath(path = "", with_subdirs = False),
107 name = "STB-Package",
108 description = _("Install settings, skins, software..."),
109 openfnc = filescan_open, )
111 print "add dreampackage scanner plugin"
112 plugins.addPlugin(PluginDescriptor(name="STB-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!"