From 194714c7e71b8dee8fd3142a4915a72474bbc64d Mon Sep 17 00:00:00 2001 From: Adam Blackburn Date: Wed, 27 Oct 2010 11:17:15 -0500 Subject: [PATCH] =?UTF-8?q?committed=20patch=20to=20fix=20Python=202.7=20s?= =?UTF-8?q?upport=20and=20use=20python2=20instead=20of=20python=20to=20run?= =?UTF-8?q?=20monitor.py=20--=20thanks=20to=20Archlinux=20and=20R=C3=A9my?= =?UTF-8?q?=20Oudompheng?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wicd/configmanager.py | 33 ++++++++++++++++++++------------- wicd/wicd-daemon.py | 2 +- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/wicd/configmanager.py b/wicd/configmanager.py index 0dee326..fbc4c5c 100644 --- a/wicd/configmanager.py +++ b/wicd/configmanager.py @@ -35,7 +35,7 @@ from dbus import Int32 class ConfigManager(RawConfigParser): """ A class that can be used to manage a given configuration file. """ def __init__(self, path, debug=False, mark_whitespace="`'`"): - RawConfigParser.__init__(self) + RawConfigParser.__init__(self, allow_no_value=True) self.config_file = path self.debug = debug self.mrk_ws = mark_whitespace @@ -185,28 +185,35 @@ class ConfigManager(RawConfigParser): def _copy_section(self, name): - # Yes, deepcopy sucks, but it is robust to changes in both - # this class and RawConfigParser. - p = copy.deepcopy(self) - for sname in p.sections(): - if sname != name: - p.remove_section(sname) + p = ConfigManager("", self.debug, self.mrk_ws) + p.add_section(name) + for (iname, value) in self.items(name): + p.set(name, iname, value) + # Store the filename this section was read from. p.config_file = p.get_option(name, '_filename_', p.config_file) p.remove_option(name, '_filename_') return p def write(self): """ Writes the loaded config file to disk. """ - # Really don't like this deepcopy. - p = copy.deepcopy(self) - for sname in p.sections(): - fname = p.get_option(sname, '_filename_') + in_this_file = [] + for sname in self.sections(): + fname = self.get_option(sname, '_filename_') if fname and fname != self.config_file: + # Write sections from other files section = self._copy_section(sname) - p.remove_section(sname) section._write_one() + else: + # Save names of local sections + in_this_file.append(sname) - for sname in p.sections(): + # Make an instance with only these sections + p = ConfigManager("", self.debug, self.mrk_ws) + p.config_file = self.config_file + for sname in in_this_file: + p.add_section(sname) + for (iname, value) in self.items(sname): + p.set(sname, iname, value) p.remove_option(sname, '_filename_') p._write_one() diff --git a/wicd/wicd-daemon.py b/wicd/wicd-daemon.py index c4a28e7..7983926 100644 --- a/wicd/wicd-daemon.py +++ b/wicd/wicd-daemon.py @@ -1806,7 +1806,7 @@ def main(argv): wicd_bus = dbus.service.BusName('org.wicd.daemon', bus=bus) daemon = WicdDaemon(wicd_bus, auto_connect=auto_connect) if not no_poll: - child_pid = Popen([misc.find_path("python"), "-O", + child_pid = Popen([misc.find_path("python2"), "-O", os.path.join(wpath.daemon, "monitor.py")], shell=False, close_fds=True).pid atexit.register(on_exit, child_pid)