aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Components
diff options
context:
space:
mode:
authorghost <andreas.monzner@multimedia-labs.de>2010-11-15 21:10:22 +0100
committerghost <andreas.monzner@multimedia-labs.de>2010-11-15 21:10:22 +0100
commita99a91815b5b9b09e06dbc79e7a8cf7e1d3911ab (patch)
tree6dac38a9ba9831e6b063f879caead50fa68d6c8e /lib/python/Components
parent25cd1a7f5232f31b7e9dc6f36daebcf1c03196f1 (diff)
parent53c44df02c114d2160fc35c304d278ca3e54e7bd (diff)
downloadenigma2-a99a91815b5b9b09e06dbc79e7a8cf7e1d3911ab.tar.gz
enigma2-a99a91815b5b9b09e06dbc79e7a8cf7e1d3911ab.zip
Merge branch 'master' into 3.0
Diffstat (limited to 'lib/python/Components')
-rw-r--r--[-rwxr-xr-x]lib/python/Components/Harddisk.py47
-rwxr-xr-xlib/python/Components/config.py17
2 files changed, 45 insertions, 19 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)