switch to opkg
[enigma2.git] / lib / python / Plugins / SystemPlugins / SoftwareManager / plugin.py
index e1f3e1deffe15ed2e9d595acc36e9e7254a7bcc3..480707d07d36bd37cece35ee2d745d667df4a874 100755 (executable)
@@ -261,9 +261,6 @@ class UpdatePluginMenu(Screen):
                                        for x in parts:
                                                if not access(x[1], F_OK|R_OK|W_OK) or x[1] == '/':
                                                        parts.remove(x)
-                                       for x in parts:
-                                               if x[1].startswith('/autofs/'):
-                                                       parts.remove(x)
                                        if len(parts):
                                                self.session.openWithCallback(self.backuplocation_choosen, ChoiceBox, title = _("Please select medium to use as backup location"), list = parts)
                                elif (currentEntry == "backupfiles"):
@@ -278,14 +275,20 @@ class UpdatePluginMenu(Screen):
 
        def backupfiles_choosen(self, ret):
                self.backupdirs = ' '.join( config.plugins.configurationbackup.backupdirs.value )
-
+               config.plugins.configurationbackup.backupdirs.save()
+               config.plugins.configurationbackup.save()
+               config.save()
+               
        def backuplocation_choosen(self, option):
+               oldpath = config.plugins.configurationbackup.backuplocation.getValue()
                if option is not None:
                        config.plugins.configurationbackup.backuplocation.value = str(option[1])
                config.plugins.configurationbackup.backuplocation.save()
                config.plugins.configurationbackup.save()
                config.save()
-               self.createBackupfolders()
+               newpath = config.plugins.configurationbackup.backuplocation.getValue()
+               if newpath != oldpath:
+                       self.createBackupfolders()
 
        def runUpgrade(self, result):
                if result:
@@ -1335,9 +1338,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 +1351,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
@@ -1440,6 +1458,9 @@ class UpdatePlugin(Screen):
                                self.session.openWithCallback(self.exitAnswer, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your Dreambox?"))
                        else:
                                self.close()
+               else:
+                       if not self.updating:
+                               self.close()
 
        def exitAnswer(self, result):
                if result is not None and result:
@@ -1496,7 +1517,7 @@ class IPKGMenu(Screen):
 
        def fill_list(self):
                self.flist = []
-               self.path = '/etc/ipkg/'
+               self.path = '/etc/opkg/'
                if (os_path.exists(self.path) == False):
                        self.entry = False
                        return
@@ -1687,7 +1708,6 @@ class PacketManager(Screen, NumericalTextInput):
                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')
 
                self.ipkg = IpkgComponent()
                self.ipkg.addCallback(self.ipkgCallback)
@@ -1841,7 +1861,7 @@ class PacketManager(Screen, NumericalTextInput):
                                self.list_updating = False
                                if not self.Console:
                                        self.Console = Console()
-                               cmd = "ipkg list"
+                               cmd = "opkg list"
                                self.Console.ePopen(cmd, self.IpkgList_Finished)
                #print event, "-", param
                pass
@@ -1864,7 +1884,7 @@ class PacketManager(Screen, NumericalTextInput):
 
                if not self.Console:
                        self.Console = Console()
-               cmd = "ipkg list_installed"
+               cmd = "opkg list_installed"
                self.Console.ePopen(cmd, self.IpkgListInstalled_Finished)
 
        def IpkgListInstalled_Finished(self, result, retval, extra_args = None):
@@ -1877,13 +1897,10 @@ class PacketManager(Screen, NumericalTextInput):
                                        l = len(tokens)
                                        version = l > 1 and tokens[1].strip() or ""
                                        self.installed_packetlist[name] = version
-               if self.opkgAvail:
-                       if not self.Console:
-                               self.Console = Console()
-                       cmd = "opkg list-upgradable"
-                       self.Console.ePopen(cmd, self.OpkgListUpgradeable_Finished)
-               else:
-                       self.buildPacketList()
+               if not self.Console:
+                       self.Console = Console()
+               cmd = "opkg list-upgradable"
+               self.Console.ePopen(cmd, self.OpkgListUpgradeable_Finished)
 
        def OpkgListUpgradeable_Finished(self, result, retval, extra_args = None):
                if result:
@@ -1928,16 +1945,10 @@ class PacketManager(Screen, NumericalTextInput):
                        for x in self.packetlist:
                                status = ""
                                if self.installed_packetlist.has_key(x[0]):
-                                       if self.opkgAvail:
-                                               if self.upgradeable_packages.has_key(x[0]):
-                                                       status = "upgradeable"
-                                               else:
-                                                       status = "installed"
+                                       if self.upgradeable_packages.has_key(x[0]):
+                                               status = "upgradeable"
                                        else:
-                                               if self.installed_packetlist[x[0]] == x[1]:
-                                                       status = "installed"
-                                               else:
-                                                       status = "upgradeable"
+                                               status = "installed"
                                else:
                                        status = "installable"
                                self.list.append(self.buildEntryComponent(x[0], x[1], x[2], status))