Merge commit 'origin/vuplus_experimental' into WirelessLanSetup
[vuplus_dvbapp] / lib / python / Plugins / SystemPlugins / SoftwareManager / plugin.py
index 707663a..3f40025 100755 (executable)
@@ -28,7 +28,7 @@ from Components.Network import iNetwork
 from Tools.Directories import pathExists, fileExists, resolveFilename, SCOPE_PLUGINS, SCOPE_CURRENT_PLUGIN, SCOPE_CURRENT_SKIN, SCOPE_METADIR
 from Tools.LoadPixmap import LoadPixmap
 from Tools.NumericalTextInput import NumericalTextInput
-from enigma import eTimer, quitMainloop, RT_HALIGN_LEFT, RT_VALIGN_CENTER, eListboxPythonMultiContent, eListbox, gFont, getDesktop, ePicLoad, eRCInput, getPrevAsciiCode
+from enigma import eTimer, quitMainloop, RT_HALIGN_LEFT, RT_VALIGN_CENTER, eListboxPythonMultiContent, eListbox, gFont, getDesktop, ePicLoad, eRCInput, getPrevAsciiCode, eEnv
 from cPickle import dump, load
 from os import path as os_path, system as os_system, unlink, stat, mkdir, popen, makedirs, listdir, access, rename, remove, W_OK, R_OK, F_OK
 from time import time, gmtime, strftime, localtime
@@ -43,7 +43,7 @@ from SoftwareTools import iSoftwareTools
 
 config.plugins.configurationbackup = ConfigSubsection()
 config.plugins.configurationbackup.backuplocation = ConfigText(default = '/media/hdd/', visible_width = 50, fixed_size = False)
-config.plugins.configurationbackup.backupdirs = ConfigLocations(default=['/etc/enigma2/', '/etc/network/interfaces', '/etc/wpa_supplicant.conf', '/etc/resolv.conf', '/etc/default_gw', '/etc/hostname'])
+config.plugins.configurationbackup.backupdirs = ConfigLocations(default=[eEnv.resolve('${sysconfdir}/enigma2/'), '/etc/network/interfaces', '/etc/wpa_supplicant.conf', '/etc/resolv.conf', '/etc/default_gw', '/etc/hostname'])
 
 config.plugins.SoftwareManager = ConfigSubsection()
 config.plugins.SoftwareManager.overwriteConfigFiles = ConfigSelection(
@@ -125,11 +125,11 @@ class UpdatePluginMenu(Screen):
                self.backupdirs = ' '.join( config.plugins.configurationbackup.backupdirs.value )
                if self.menu == 0:
                        print "building menu entries"
-                       self.list.append(("install-extensions", _("Manage extensions"), _("\nManage extensions or plugins for your Dreambox" ) + self.oktext, None))
-                       self.list.append(("software-update", _("Software update"), _("\nOnline update of your Dreambox software." ) + self.oktext, None))
-                       self.list.append(("software-restore", _("Software restore"), _("\nRestore your Dreambox with a new firmware." ) + self.oktext, None))
-                       self.list.append(("system-backup", _("Backup system settings"), _("\nBackup your Dreambox settings." ) + self.oktext + "\n\n" + self.infotext, None))
-                       self.list.append(("system-restore",_("Restore system settings"), _("\nRestore your Dreambox settings." ) + self.oktext, None))
+                       self.list.append(("install-extensions", _("Manage extensions"), _("\nManage extensions or plugins for your STB" ) + self.oktext, None))
+                       self.list.append(("software-update", _("Software update"), _("\nOnline update of your STB software." ) + self.oktext, None))
+                       self.list.append(("software-restore", _("Software restore"), _("\nRestore your STB with a new firmware." ) + self.oktext, None))
+                       self.list.append(("system-backup", _("Backup system settings"), _("\nBackup your STB settings." ) + self.oktext + "\n\n" + self.infotext, None))
+                       self.list.append(("system-restore",_("Restore system settings"), _("\nRestore your STB settings." ) + self.oktext, None))
                        self.list.append(("ipkg-install", _("Install local extension"),  _("\nScan for local extensions and install them." ) + self.oktext, None))
                        for p in plugins.getPlugins(PluginDescriptor.WHERE_SOFTWAREMANAGER):
                                if p.__call__.has_key("SoftwareSupported"):
@@ -230,7 +230,7 @@ class UpdatePluginMenu(Screen):
                        currentEntry = current[0]
                        if self.menu == 0:
                                if (currentEntry == "software-update"):
-                                       self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to update your Dreambox?")+"\n"+_("\nAfter pressing OK, please wait!"))
+                                       self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to update your STB?")+"\n"+_("\nAfter pressing OK, please wait!"))
                                elif (currentEntry == "software-restore"):
                                        self.session.open(ImageWizard)
                                elif (currentEntry == "install-extensions"):
@@ -918,7 +918,7 @@ class PluginManager(Screen, DreamInfoHandler):
                        self.close()
 
        def runExecuteFinished(self):
-               self.session.openWithCallback(self.ExecuteReboot, MessageBox, _("Install or remove finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO)
+               self.session.openWithCallback(self.ExecuteReboot, MessageBox, _("Install or remove finished.") +" "+_("Do you want to reboot your STB?"), MessageBox.TYPE_YESNO)
 
        def ExecuteReboot(self, result):
                if result is None:
@@ -1003,7 +1003,7 @@ class PluginManagerInfo(Screen):
                                elif cmd == 2:
                                        info = args['package']
                                else:
-                                       info = _("Dreambox software because updates are available.")
+                                       info = _("STB software because updates are available.")
 
                                self.list.append(self.buildEntryComponent(action,info))
                        self['list'].setList(self.list)
@@ -1284,7 +1284,7 @@ class PluginDetails(Screen, DreamInfoHandler):
                        self.session.openWithCallback(self.runUpgradeFinished, Ipkg, cmdList = self.cmdList)
 
        def runUpgradeFinished(self):
-               self.session.openWithCallback(self.UpgradeReboot, MessageBox, _("Installation finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO)
+               self.session.openWithCallback(self.UpgradeReboot, MessageBox, _("Installation finished.") +" "+_("Do you want to reboot your STB?"), MessageBox.TYPE_YESNO)
 
        def UpgradeReboot(self, result):
                if result is None:
@@ -1299,7 +1299,7 @@ class PluginDetails(Screen, DreamInfoHandler):
                        self.session.openWithCallback(self.runRemoveFinished, Ipkg, cmdList = self.cmdList)
 
        def runRemoveFinished(self):
-               self.session.openWithCallback(self.RemoveReboot, MessageBox, _("Remove finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO)
+               self.session.openWithCallback(self.RemoveReboot, MessageBox, _("Remove finished.") +" "+_("Do you want to reboot your STB?"), MessageBox.TYPE_YESNO)
 
        def RemoveReboot(self, result):
                if result is None:
@@ -1335,9 +1335,9 @@ class UpdatePlugin(Screen):
                self["slider"] = self.slider
                self.activityslider = Slider(0, 100)
                self["activityslider"] = self.activityslider
-               self.status = StaticText(_("Upgrading Dreambox... Please wait"))
+               self.status = StaticText(_("Please wait..."))
                self["status"] = self.status
-               self.package = StaticText()
+               self.package = StaticText(_("Verifying your internet connection..."))
                self["package"] = self.package
                self.oktext = _("Press OK on your remote control to continue.")
 
@@ -1348,20 +1348,35 @@ class UpdatePlugin(Screen):
                self.activity = 0
                self.activityTimer = eTimer()
                self.activityTimer.callback.append(self.doActivityTimer)
-               self.activityTimer.start(100, False)
 
                self.ipkg = IpkgComponent()
                self.ipkg.addCallback(self.ipkgCallback)
 
-               self.updating = True
-               self.package.setText(_("Package list update"))
-               self.ipkg.startCmd(IpkgComponent.CMD_UPDATE)
+               self.updating = False
 
                self["actions"] = ActionMap(["WizardActions"], 
                {
                        "ok": self.exit,
                        "back": self.exit
                }, -1)
+               
+               iNetwork.checkNetworkState(self.checkNetworkCB)
+               self.onClose.append(self.cleanup)
+               
+       def cleanup(self):
+               iNetwork.stopPingConsole()
+
+       def checkNetworkCB(self,data):
+               if data is not None:
+                       if data <= 2:
+                               self.updating = True
+                               self.activityTimer.start(100, False)
+                               self.package.setText(_("Package list update"))
+                               self.status.setText(_("Upgrading Dreambox... Please wait"))
+                               self.ipkg.startCmd(IpkgComponent.CMD_UPDATE)
+                       else:
+                               self.package.setText(_("Your network is not working. Please try again."))
+                               self.status.setText(self.oktext)
 
        def doActivityTimer(self):
                self.activity += 1
@@ -1422,11 +1437,11 @@ class UpdatePlugin(Screen):
                        else:
                                self.activityTimer.stop()
                                self.activityslider.setValue(0)
-                               error = _("your dreambox might be unusable now. Please consult the manual for further assistance before rebooting your dreambox.")
+                               error = _("your STB might be unusable now. Please consult the manual for further assistance before rebooting your STB.")
                                if self.packages == 0:
                                        error = _("No packages were upgraded yet. So you can check your network and try again.")
                                if self.updating:
-                                       error = _("Your dreambox isn't connected to the internet properly. Please check it and try again.")
+                                       error = _("Your STB isn't connected to the internet properly. Please check it and try again.")
                                self.status.setText(_("Error") +  " - " + error)
                #print event, "-", param
                pass
@@ -1437,9 +1452,12 @@ class UpdatePlugin(Screen):
        def exit(self):
                if not self.ipkg.isRunning():
                        if self.packages != 0 and self.error == 0:
-                               self.session.openWithCallback(self.exitAnswer, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your Dreambox?"))
+                               self.session.openWithCallback(self.exitAnswer, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your STB?"))
                        else:
                                self.close()
+               else:
+                       if not self.updating:
+                               self.close()
 
        def exitAnswer(self, result):
                if result is not None and result:
@@ -1684,7 +1702,7 @@ class PacketManager(Screen, NumericalTextInput):
                self.cmdList = []
                self.cachelist = []
                self.cache_ttl = 86400  #600 is default, 0 disables, Seconds cache is considered valid (24h should be ok for caching ipkgs)
-               self.cache_file = '/usr/lib/enigma2/python/Plugins/SystemPlugins/SoftwareManager/packetmanager.cache' #Path to cache directory   
+               self.cache_file = eEnv.resolve('${libdir}/enigma2/python/Plugins/SystemPlugins/SoftwareManager/packetmanager.cache') #Path to cache directory
                self.oktext = _("\nAfter pressing OK, please wait!")
                self.unwanted_extensions = ('-dbg', '-dev', '-doc', 'busybox')
                self.opkgAvail = fileExists('/usr/bin/opkg')
@@ -1793,7 +1811,7 @@ class PacketManager(Screen, NumericalTextInput):
                        self.session.openWithCallback(self.runRemoveFinished, Ipkg, cmdList = self.cmdList)
 
        def runRemoveFinished(self):
-               self.session.openWithCallback(self.RemoveReboot, MessageBox, _("Remove finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO)
+               self.session.openWithCallback(self.RemoveReboot, MessageBox, _("Remove finished.") +" "+_("Do you want to reboot your STB?"), MessageBox.TYPE_YESNO)
 
        def RemoveReboot(self, result):
                if result is None:
@@ -1815,7 +1833,7 @@ class PacketManager(Screen, NumericalTextInput):
                        self.session.openWithCallback(self.runUpgradeFinished, Ipkg, cmdList = self.cmdList)
 
        def runUpgradeFinished(self):
-               self.session.openWithCallback(self.UpgradeReboot, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO)
+               self.session.openWithCallback(self.UpgradeReboot, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your STB?"), MessageBox.TYPE_YESNO)
                
        def UpgradeReboot(self, result):
                if result is None: