[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH 3/4] Add flags.set_cmdline_bool and flags.read_cmdline



set_cmdline_bool replaces decideCmdlineFlag - it uses BootArgs.getbool.

read_cmdline sets a bunch of flags based on the contents of cmdline -
this code is basically just split from where it used to live at the end
of __init__.
---
 pyanaconda/flags.py |   32 +++++++++++++-------------------
 1 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/pyanaconda/flags.py b/pyanaconda/flags.py
index 9990fc3..8b5f756 100644
--- a/pyanaconda/flags.py
+++ b/pyanaconda/flags.py
@@ -34,13 +34,11 @@ class Flags(object):
     def get(self, attr, val=None):
         return getattr(self, attr, val)
 
-    def decideCmdlineFlag(self, flag):
-        if self.cmdline.has_key(flag) \
-                and not self.cmdline.has_key("no" + flag) \
-                and self.cmdline[flag] != "0":
-            setattr(self, flag, 1)
+    def set_cmdline_bool(self, flag):
+        if flag in self.cmdline:
+            setattr(self, self.cmdline.getbool(flag))
 
-    def __init__(self):
+    def __init__(self, read_cmdline=True):
         self.__dict__['_in_init'] = True
         self.test = 0
         self.livecdInstall = 0
@@ -73,25 +71,21 @@ class Flags(object):
         self.cmdline = BootArgs()
         # Lock it down: no more creating new flags!
         self.__dict__['_in_init'] = False
+        if read_cmdline:
+            self.read_cmdline()
 
-        if 'selinux' in self.cmdline:
-            if self.cmdline['selinux'] not in ("0", "off", "no"):
-                self.selinux = 1
-            else:
-                self.selinux = 0
-
-        self.decideCmdlineFlag('sshd')
-
-        if self.cmdline.has_key("debug"):
-            self.debug = self.cmdline['debug']
+    def read_cmdline(self):
+        for f in ("selinux", "sshd", "debug"):
+            self.set_cmdline_bool(f)
 
-        if self.cmdline.has_key("rpmarch"):
-            self.targetarch = self.cmdline['rpmarch']
+        if "rpmarch" in self.cmdline:
+            self.targetarch = self.cmdline.get("rpmarch")
 
         if not selinux.is_selinux_enabled():
             self.selinux = 0
 
-        self.nogpt = self.cmdline.has_key("nogpt")
+        if "nogpt" in self.cmdline:
+            self.nogpt = True
 
 cmdline_files = ['/proc/cmdline', '/run/initramfs/etc/cmdline', '/etc/cmdline']
 class BootArgs(OrderedDict):
-- 
1.7.7.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]