Skip to content

Commit

Permalink
Fix the enable/disable actions
Browse files Browse the repository at this point in the history
Now that __set() and __unset() have moved to the ExtConfig class, they can
no longer be called from child classes because of their leading "__"
flagging them as internals.

Rename the methods to set_line() and unset_line() so they can be used from
Svc.
  • Loading branch information
cvaroqui committed Jan 20, 2018
1 parent 94ea90f commit db78201
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions lib/extconfig.py
Expand Up @@ -68,13 +68,13 @@ def _unset(self, section, option):
Delete an option in the service configuration file specified section.
"""
lines = self._read_cf().splitlines()
lines = self.__unset(lines, section, option)
lines = self.unset_line(lines, section, option)
try:
self._write_cf(lines)
except (IOError, OSError) as exc:
raise ex.excError(str(exc))

def __unset(self, lines, section, option):
def unset_line(self, lines, section, option):
section = "[%s]" % section
need_write = False
in_section = False
Expand Down Expand Up @@ -295,7 +295,7 @@ def _set_multi(self, changes):
if change is None:
continue
section, option, value = change
lines = self.__set(lines, section, option, value)
lines = self.set_line(lines, section, option, value)
changed = True
if not changed:
# all changes were None
Expand All @@ -305,7 +305,7 @@ def _set_multi(self, changes):
except (IOError, OSError) as exc:
raise ex.excError(str(exc))

def __set(self, lines, section, option, value):
def set_line(self, lines, section, option, value):
"""
Set <option> to <value> in <section> of the configuration file.
"""
Expand Down
6 changes: 3 additions & 3 deletions lib/svc.py
Expand Up @@ -4117,10 +4117,10 @@ def set_disable(self, rids=None, disable=True):

if disable:
self.log.info("set %s.disable = true", rid)
lines = self.__set(lines, rid, "disable", "true")
lines = self.set_line(lines, rid, "disable", "true")
elif self.config.has_option(rid, "disable"):
self.log.info("remove %s.disable", rid)
lines = self.__unset(lines, rid, "disable")
lines = self.unset_line(lines, rid, "disable")

#
# if we set <section>.disable = <bool>,
Expand All @@ -4136,7 +4136,7 @@ def set_disable(self, rids=None, disable=True):
if value == True:
continue
self.log.info("remove %s.%s = false", rid, option)
lines = self.__unset(lines, rid, option)
lines = self.unset_line(lines, rid, option)


unset_lazy(self, "disabled")
Expand Down

0 comments on commit db78201

Please sign in to comment.