git.cweiske.de
/
enigma2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add missing inc/decref for multicontent template
[enigma2.git]
/
lib
/
python
/
Components
/
config.py
diff --git
a/lib/python/Components/config.py
b/lib/python/Components/config.py
index 1f8709b38cbe28741b7100781199997fca8b4663..6e5608570b7d7b7410c7d010414fdfb822930301 100755
(executable)
--- a/
lib/python/Components/config.py
+++ b/
lib/python/Components/config.py
@@
-1,6
+1,6
@@
from enigma import getPrevAsciiCode
from Tools.NumericalTextInput import NumericalTextInput
from enigma import getPrevAsciiCode
from Tools.NumericalTextInput import NumericalTextInput
-from Tools.Directories import resolveFilename, SCOPE_CONFIG
+from Tools.Directories import resolveFilename, SCOPE_CONFIG
, fileExists
from Components.Harddisk import harddiskmanager
from copy import copy as copy_copy
from os import path as os_path
from Components.Harddisk import harddiskmanager
from copy import copy as copy_copy
from os import path as os_path
@@
-29,6
+29,7
@@
from time import localtime, strftime
class ConfigElement(object):
def __init__(self):
self.saved_value = None
class ConfigElement(object):
def __init__(self):
self.saved_value = None
+ self.save_forced = False
self.last_value = None
self.save_disabled = False
self.__notifiers = None
self.last_value = None
self.save_disabled = False
self.__notifiers = None
@@
-83,7
+84,7
@@
class ConfigElement(object):
# you need to override this if str(self.value) doesn't work
def save(self):
# you need to override this if str(self.value) doesn't work
def save(self):
- if self.save_disabled or
self.value == self.default
:
+ if self.save_disabled or
(self.value == self.default and not self.save_forced)
:
self.saved_value = None
else:
self.saved_value = self.tostring(self.value)
self.saved_value = None
else:
self.saved_value = self.tostring(self.value)
@@
-1138,6
+1139,9
@@
class ConfigDirectory(ConfigText):
else:
return ConfigText.getMulti(self, selected)
else:
return ConfigText.getMulti(self, selected)
+ def onSelect(self, session):
+ self.allmarked = (self.value != "")
+
# a slider.
class ConfigSlider(ConfigElement):
def __init__(self, default = 0, increment = 1, limits = (0, 100)):
# a slider.
class ConfigSlider(ConfigElement):
def __init__(self, default = 0, increment = 1, limits = (0, 100)):
@@
-1283,7
+1287,6
@@
class ConfigLocations(ConfigElement):
self.default = default
self.locations = []
self.mountpoints = []
self.default = default
self.locations = []
self.mountpoints = []
- harddiskmanager.on_partition_list_change.append(self.mountpointsChanged)
self.value = default[:]
def setValue(self, value):
self.value = default[:]
def setValue(self, value):
@@
-1320,7
+1323,7
@@
class ConfigLocations(ConfigElement):
locations = [[x, None, False, False] for x in tmp]
self.refreshMountpoints()
for x in locations:
locations = [[x, None, False, False] for x in tmp]
self.refreshMountpoints()
for x in locations:
- if
os_path.e
xists(x[0]):
+ if
fileE
xists(x[0]):
x[1] = self.getMountpoint(x[0])
x[2] = True
self.locations = locations
x[1] = self.getMountpoint(x[0])
x[2] = True
self.locations = locations
@@
-1339,20
+1342,11
@@
class ConfigLocations(ConfigElement):
return False
return self.tostring([x[0] for x in locations]) != sv
return False
return self.tostring([x[0] for x in locations]) != sv
- def mountpointsChanged(self, action, dev):
- print "Mounts changed: ", action, dev
- mp = dev.mountpoint+"/"
- if action == "add":
- self.addedMount(mp)
- elif action == "remove":
- self.removedMount(mp)
- self.refreshMountpoints()
-
def addedMount(self, mp):
for x in self.locations:
if x[1] == mp:
x[2] = True
def addedMount(self, mp):
for x in self.locations:
if x[1] == mp:
x[2] = True
- elif x[1] == None and
os_path.e
xists(x[0]):
+ elif x[1] == None and
fileE
xists(x[0]):
x[1] = self.getMountpoint(x[0])
x[2] = True
x[1] = self.getMountpoint(x[0])
x[2] = True
@@
-1362,7
+1356,7
@@
class ConfigLocations(ConfigElement):
x[2] = False
def refreshMountpoints(self):
x[2] = False
def refreshMountpoints(self):
- self.mountpoints = [p.mountpoint
+ "/"
for p in harddiskmanager.getMountedPartitions() if p.mountpoint != "/"]
+ self.mountpoints = [p.mountpoint for p in harddiskmanager.getMountedPartitions() if p.mountpoint != "/"]
self.mountpoints.sort(key = lambda x: -len(x))
def checkChangedMountpoints(self):
self.mountpoints.sort(key = lambda x: -len(x))
def checkChangedMountpoints(self):
@@
-1630,16
+1624,17
@@
class Config(ConfigSubsection):
self.pickle_this("config", self.saved_value, result)
return ''.join(result)
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('=')
tree = { }
for l in lines:
if not l or l[0] == '#':
continue
n = l.find('=')
+ name = l[:n]
val = l[n+1:].strip()
val = l[n+1:].strip()
- names =
l[:n]
.split('.')
+ names =
name
.split('.')
# if val.find(' ') != -1:
# val = val[:val.find(' ')]
# if val.find(' ') != -1:
# val = val[:val.find(' ')]
@@
-1650,6
+1645,15
@@
class Config(ConfigSubsection):
base[names[-1]] = val
base[names[-1]] = val
+ if not base_file: # not the initial config file..
+ #update config.x.y.value when exist
+ try:
+ configEntry = eval(name)
+ if configEntry is not None:
+ configEntry.value = val
+ except (SyntaxError, KeyError):
+ pass
+
# we inherit from ConfigSubsection, so ...
#object.__setattr__(self, "saved_value", tree["config"])
if "config" in tree:
# we inherit from ConfigSubsection, so ...
#object.__setattr__(self, "saved_value", tree["config"])
if "config" in tree:
@@
-1661,9
+1665,9
@@
class Config(ConfigSubsection):
f.write(text)
f.close()
f.write(text)
f.close()
- def loadFromFile(self, filename):
+ def loadFromFile(self, filename
, base_file=False
):
f = open(filename, "r")
f = open(filename, "r")
- self.unpickle(f.readlines())
+ self.unpickle(f.readlines()
, base_file
)
f.close()
config = Config()
f.close()
config = Config()
@@
-1674,7
+1678,7
@@
class ConfigFile:
def load(self):
try:
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)
except IOError, e:
print "unable to load config (%s), assuming defaults..." % str(e)