[PATCH 10/14] Use booleans and direct assignments for flags
Martin Kolman
mkolman at redhat.com
Thu Aug 21 20:10:31 UTC 2014
The argument parser options return booleans anyway
and all newly added flags & all flags in Blivet already use booleans.
So use booleans instead of 1/0 and use direct assignments for flags where possible,
and also move the assignments to a common place.
Related: rhbz:#1088459
Signed-off-by: Martin Kolman <mkolman at redhat.com>
---
anaconda | 60 +++++++++++++++--------------------------------------
pyanaconda/flags.py | 12 +++++------
2 files changed, 23 insertions(+), 49 deletions(-)
diff --git a/anaconda b/anaconda
index cb26825..4ab6076 100755
--- a/anaconda
+++ b/anaconda
@@ -453,7 +453,7 @@ def setupDisplay(anaconda, opts, addon_paths=None):
anaconda.isHeadless = arch.isS390()
if opts.vnc:
- flags.usevnc = 1
+ flags.usevnc = True
anaconda.displayMode = 'g'
vncS.password = opts.vncpassword
@@ -473,7 +473,7 @@ def setupDisplay(anaconda, opts, addon_paths=None):
return
if anaconda.ksdata.vnc.enabled:
- flags.usevnc = 1
+ flags.usevnc = True
anaconda.displayMode = 'g'
if vncS.password == "":
@@ -547,7 +547,7 @@ def setupDisplay(anaconda, opts, addon_paths=None):
if anaconda.ksdata.vnc.enabled:
anaconda.displayMode = 'g'
- flags.usevnc = 1
+ flags.usevnc = True
vncS.password = anaconda.ksdata.vnc.password
else:
# user has explicitly specified text mode
@@ -610,7 +610,7 @@ def setupDisplay(anaconda, opts, addon_paths=None):
if anaconda.ksdata.vnc.enabled:
anaconda.displayMode = 'g'
- flags.usevnc = 1
+ flags.usevnc = True
vncS.password = anaconda.ksdata.vnc.password
# if they want us to use VNC do that now
@@ -712,9 +712,6 @@ if __name__ == "__main__":
from pyanaconda.flags import flags, can_touch_runtime_system
(opts, depr) = parseArguments(boot_cmdline=flags.cmdline)
- if opts.askmethod:
- flags.askmethod = True
-
# Set up logging as early as possible.
import logging
from pyanaconda import anaconda_log
@@ -814,44 +811,27 @@ if __name__ == "__main__":
# Default is to prompt to mount the installed system.
anaconda.rescue_mount = not opts.rescue_nomount
- if opts.noipv4:
- flags.useIPv4 = False
-
- if opts.noipv6:
- flags.useIPv6 = False
-
- if opts.proxy:
- anaconda.proxy = opts.proxy
-
- if opts.updateSrc:
- anaconda.updateSrc = opts.updateSrc
+ # assign the other anaconda variables from options
+ anaconda.proxy = opts.proxy
+ anaconda.updateSrc = opts.updateSrc
+ anaconda.methodstr = opts.method
+ anaconda.stage2 = opts.stage2
+ anaconda.rescue = opts.rescue
- if opts.method:
- anaconda.methodstr = opts.method
-
- if opts.stage2:
- anaconda.stage2 = opts.stage2
-
- if opts.noverifyssl:
- flags.noverifyssl = True
if opts.liveinst:
flags.livecdInstall = True
- if opts.ibft:
- flags.ibft = 1
-
- if opts.armPlatform:
- flags.armPlatform = opts.armPlatform
-
- if opts.extlinux:
- flags.extlinux = opts.extlinux
-
- flags.mpathFriendlyNames = opts.mpathfriendlynames
-
# set flags
+ flags.noverifyssl = opts.noverifyssl
+ flags.armPlatform = opts.armPlatform
+ flags.extlinux = opts.extlinux
+ flags.mpathFriendlyNames = opts.mpathfriendlynames
+ flags.debug = opts.debug
+ flags.askmethod = opts.askmethod
flags.dmraid = opts.dmraid
flags.mpath = opts.mpath
+ flags.ibft = opts.ibft
flags.selinux = opts.selinux
flags.eject = opts.eject
@@ -867,12 +847,6 @@ if __name__ == "__main__":
except OSError:
pass
- if opts.debug:
- flags.debug = True
-
- if opts.rescue:
- anaconda.rescue = True
-
log.info("anaconda called with cmdline = %s", sys.argv)
log.info("Default encoding = %s ", sys.getdefaultencoding())
diff --git a/pyanaconda/flags.py b/pyanaconda/flags.py
index 01933ee..0eedc15 100644
--- a/pyanaconda/flags.py
+++ b/pyanaconda/flags.py
@@ -44,14 +44,14 @@ class Flags(object):
def __init__(self, read_cmdline=True):
self.__dict__['_in_init'] = True
- self.livecdInstall = 0
- self.ibft = 1
- self.usevnc = 0
+ self.livecdInstall = False
+ self.ibft = True
+ self.usevnc = False
self.vncquestion = True
- self.mpath = 1
- self.dmraid = 1
+ self.mpath = True
+ self.dmraid = True
self.selinux = SELINUX_DEFAULT
- self.debug = 0
+ self.debug = False
self.useIPv4 = True
self.useIPv6 = True
self.armPlatform = None
--
1.9.3
More information about the anaconda-patches
mailing list