aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--[-rwxr-xr-x]lib/python/Components/Harddisk.py47
-rwxr-xr-xlib/python/Components/config.py17
-rwxr-xr-xlib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py60
3 files changed, 89 insertions, 35 deletions
diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py
index e8e612a4..7f837565 100755..100644
--- a/lib/python/Components/Harddisk.py
+++ b/lib/python/Components/Harddisk.py
@@ -5,6 +5,10 @@ from SystemInfo import SystemInfo
import time
from Components.Console import Console
+def MajorMinor(path):
+ rdev = stat(path).st_rdev
+ return (major(rdev),minor(rdev))
+
def readFile(filename):
file = open(filename)
data = file.read().strip()
@@ -125,13 +129,15 @@ class Harddisk:
for line in lines:
parts = line.strip().split(" ")
- if path.realpath(parts[0]).startswith(self.dev_path):
- try:
+ real_path = path.realpath(parts[0])
+ if not real_path[-1].isdigit():
+ continue
+ try:
+ if MajorMinor(real_path) == MajorMinor(self.partitionPath(real_path[-1])):
stat = statvfs(parts[1])
- except OSError:
- continue
- return stat.f_bfree/1000 * stat.f_bsize/1000
-
+ return stat.f_bfree/1000 * stat.f_bsize/1000
+ except OSError:
+ pass
return -1
def numPartitions(self):
@@ -168,10 +174,17 @@ class Harddisk:
cmd = "umount"
- for line in lines:
- parts = line.strip().split(" ")
- if path.realpath(parts[0]).startswith(self.dev_path):
- cmd = ' ' . join([cmd, parts[1]])
+ for line in lines:
+ parts = line.strip().split(" ")
+ real_path = path.realpath(parts[0])
+ if not real_path[-1].isdigit():
+ continue
+ try:
+ if MajorMinor(real_path) == MajorMinor(self.partitionPath(real_path[-1])):
+ cmd = ' ' . join([cmd, parts[1]])
+ break
+ except OSError:
+ pass
res = system(cmd)
return (res >> 8)
@@ -201,10 +214,16 @@ class Harddisk:
res = -1
for line in lines:
parts = line.strip().split(" ")
- if path.realpath(parts[0]) == self.partitionPath("1"):
- cmd = "mount -t ext3 " + parts[0]
- res = system(cmd)
- break
+ real_path = path.realpath(parts[0])
+ if not real_path[-1].isdigit():
+ continue
+ try:
+ if MajorMinor(real_path) == MajorMinor(self.partitionPath(real_path[-1])):
+ cmd = "mount -t ext3 " + parts[0]
+ res = system(cmd)
+ break
+ except OSError:
+ pass
return (res >> 8)
diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py
index d7506e31..44ad6d2a 100755
--- a/lib/python/Components/config.py
+++ b/lib/python/Components/config.py
@@ -1624,16 +1624,17 @@ class Config(ConfigSubsection):
self.pickle_this("config", self.saved_value, result)
return ''.join(result)
- def unpickle(self, lines):
+ def unpickle(self, lines, base_file=True):
tree = { }
for l in lines:
if not l or l[0] == '#':
continue
n = l.find('=')
+ name = l[:n]
val = l[n+1:].strip()
- names = l[:n].split('.')
+ names = name.split('.')
# if val.find(' ') != -1:
# val = val[:val.find(' ')]
@@ -1644,6 +1645,12 @@ class Config(ConfigSubsection):
base[names[-1]] = val
+ if not base_file: # not the initial config file..
+ #update config.x.y.value when exist
+ configEntry = eval(name)
+ if configEntry is not None:
+ configEntry.value = val
+
# we inherit from ConfigSubsection, so ...
#object.__setattr__(self, "saved_value", tree["config"])
if "config" in tree:
@@ -1655,9 +1662,9 @@ class Config(ConfigSubsection):
f.write(text)
f.close()
- def loadFromFile(self, filename):
+ def loadFromFile(self, filename, base_file=False):
f = open(filename, "r")
- self.unpickle(f.readlines())
+ self.unpickle(f.readlines(), base_file)
f.close()
config = Config()
@@ -1668,7 +1675,7 @@ class ConfigFile:
def load(self):
try:
- config.loadFromFile(self.CONFIG_FILE)
+ config.loadFromFile(self.CONFIG_FILE, True)
except IOError, e:
print "unable to load config (%s), assuming defaults..." % str(e)
diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py
index 00608ee2..707663a0 100755
--- a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py
+++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py
@@ -1679,6 +1679,7 @@ class PacketManager(Screen, NumericalTextInput):
self.list_updating = True
self.packetlist = []
self.installed_packetlist = {}
+ self.upgradeable_packages = {}
self.Console = Console()
self.cmdList = []
self.cachelist = []
@@ -1686,6 +1687,7 @@ class PacketManager(Screen, NumericalTextInput):
self.cache_file = '/usr/lib/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)
@@ -1847,14 +1849,19 @@ class PacketManager(Screen, NumericalTextInput):
def IpkgList_Finished(self, result, retval, extra_args = None):
if result:
self.packetlist = []
+ last_name = ""
for x in result.splitlines():
- tokens = x.split(' - ') #self.blacklisted_packages
+ tokens = x.split(' - ')
name = tokens[0].strip()
if not any(name.endswith(x) for x in self.unwanted_extensions):
l = len(tokens)
version = l > 1 and tokens[1].strip() or ""
descr = l > 2 and tokens[2].strip() or ""
+ if name == last_name:
+ continue
+ last_name = name
self.packetlist.append([name, version, descr])
+
if not self.Console:
self.Console = Console()
cmd = "ipkg list_installed"
@@ -1864,30 +1871,47 @@ class PacketManager(Screen, NumericalTextInput):
if result:
self.installed_packetlist = {}
for x in result.splitlines():
- tokens = x.split(' - ') #self.blacklisted_packages
+ tokens = x.split(' - ')
name = tokens[0].strip()
if not any(name.endswith(x) for x in self.unwanted_extensions):
l = len(tokens)
version = l > 1 and tokens[1].strip() or ""
self.installed_packetlist[name] = version
- self.buildPacketList()
+ if self.opkgAvail:
+ if not self.Console:
+ self.Console = Console()
+ cmd = "opkg list-upgradable"
+ self.Console.ePopen(cmd, self.OpkgListUpgradeable_Finished)
+ else:
+ self.buildPacketList()
+ def OpkgListUpgradeable_Finished(self, result, retval, extra_args = None):
+ if result:
+ self.upgradeable_packages = {}
+ for x in result.splitlines():
+ tokens = x.split(' - ')
+ name = tokens[0].strip()
+ if not any(name.endswith(x) for x in self.unwanted_extensions):
+ l = len(tokens)
+ version = l > 2 and tokens[2].strip() or ""
+ self.upgradeable_packages[name] = version
+ self.buildPacketList()
+
def buildEntryComponent(self, name, version, description, state):
divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png"))
if state == 'installed':
installedpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installed.png"))
- return((name, version, description, state, installedpng, divpng))
+ return((name, version, _(description), state, installedpng, divpng))
elif state == 'upgradeable':
upgradeablepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/upgradeable.png"))
- return((name, version, description, state, upgradeablepng, divpng))
+ return((name, version, _(description), state, upgradeablepng, divpng))
else:
installablepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installable.png"))
- return((name, version, description, state, installablepng, divpng))
+ return((name, version, _(description), state, installablepng, divpng))
def buildPacketList(self):
self.list = []
self.cachelist = []
-
if self.cache_ttl > 0 and self.vc != 0:
print 'Loading packagelist cache from ',self.cache_file
try:
@@ -1903,24 +1927,28 @@ class PacketManager(Screen, NumericalTextInput):
print 'rebuilding fresh package list'
for x in self.packetlist:
status = ""
- if self.installed_packetlist.has_key(x[0].strip()):
- if self.installed_packetlist[x[0].strip()] == x[1].strip():
- status = "installed"
- self.list.append(self.buildEntryComponent(x[0].strip(), x[1].strip(), x[2].strip(), 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"
else:
- status = "upgradeable"
- self.list.append(self.buildEntryComponent(x[0].strip(), x[1].strip(), x[2].strip(), status))
+ if self.installed_packetlist[x[0]] == x[1]:
+ status = "installed"
+ else:
+ status = "upgradeable"
else:
status = "installable"
- self.list.append(self.buildEntryComponent(x[0].strip(), x[1].strip(), x[2].strip(), status))
- if not any(x[0].strip().endswith(x) for x in self.unwanted_extensions):
- self.cachelist.append([x[0].strip(), x[1].strip(), x[2].strip(), status])
+ self.list.append(self.buildEntryComponent(x[0], x[1], x[2], status))
+ self.cachelist.append([x[0], x[1], x[2], status])
write_cache(self.cache_file, self.cachelist)
self['list'].setList(self.list)
def reloadPluginlist(self):
plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
+
class IpkgInstaller(Screen):
skin = """
<screen name="IpkgInstaller" position="center,center" size="550,450" title="Install extensions" >