fix warning:'Namespace' object is not iterable 93/279693/5
authorbiao716.wang <biao716.wang@samsung.com>
Tue, 16 Aug 2022 08:53:42 +0000 (17:53 +0900)
committerbiao716.wang <biao716.wang@samsung.com>
Wed, 17 Aug 2022 08:52:10 +0000 (17:52 +0900)
kickstart: allow partitions without mount points
https://review.tizen.org/gerrit/gitweb?p=tools/mic.git;a=commit;h=86d6bfc99a34380e4f9576bbd4c6d332ccd15f0c
Change-Id: I1be64d0ecec6f69e126a90dde5c84add9bd699ab
Signed-off-by: biao716.wang <biao716.wang@samsung.com>
mic/3rdparty/pykickstart/base.py
mic/3rdparty/pykickstart/commands/partition.py
mic/3rdparty/pykickstart/commands/snapshot.py
mic/3rdparty/pykickstart/sections.py
mic/cmd_create.py
mic/kickstart/custom_commands/desktop.py
mic/kickstart/custom_commands/installerfw.py

index 31f7301be56ac170bce3a62d9ab3ccee8412608b..b1b7c1993d8394421cf30715559bae1ac71d26d9 100644 (file)
@@ -178,7 +178,7 @@ class KickstartCommand(KickstartObject):
            of objects (like partitions, network devices, etc.) and need to populate
            a Data object.
         """
-        for (key, val) in list(vars(namespace).items()):
+        for (key, val) in vars(namespace).items():
             if val is not None:
                 setattr(obj, key, val)
 
index a4d6fc00ecfefbb193f948f653b8791ebc9c2298..703f29090a1f5d7141018fb6779abf190671862e 100644 (file)
@@ -343,42 +343,6 @@ class FC3_Partition(KickstartCommand):
                             If partitioning fails for any reason, diagnostic
                             messages will appear on virtual console 3.""",
                             version=FC3)
-        op.add_argument("mntpoint", metavar="<mntpoint>", type=mountpoint, nargs=1,
-                        version=FC3, help="""
-                        The ``<mntpoint>`` is where the partition will be mounted
-                        and must be of one of the following forms:
-
-                        ``/<path>``
-
-                        For example, ``/``, ``/usr``, ``/home``
-
-                        ``swap``
-
-                        The partition will be used as swap space.
-
-                        ``raid.<id>``
-
-                        The partition will be used for software RAID.
-                        Refer to the ``raid`` command.
-
-                        ``pv.<id>``
-
-                        The partition will be used for LVM. Refer to the
-                        ``logvol`` command.
-
-                        ``btrfs.<id>``
-
-                        The partition will be used for BTRFS volume. Rerefer to
-                        the ``btrfs`` command.
-
-                        ``biosboot``
-
-                        The partition will be used for a BIOS Boot Partition. As
-                        of Fedora 16 there must be a biosboot partition for the
-                        bootloader to be successfully installed onto a disk that
-                        contains a GPT/GUID partition table. Rerefer to the
-                        ``bootloader`` command.
-                        """)
         op.add_argument("--active", action="store_true", default=False,
                         version=FC3, help="Set partition as active")
         op.add_argument("--asprimary", dest="primOnly", action="store_true",
@@ -440,7 +404,7 @@ class FC3_Partition(KickstartCommand):
         return op
 
     def parse(self, args):
-        (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
+        (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno)
 
         pd = self.dataClass()   # pylint: disable=not-callable
         self.set_to_obj(ns, pd)
@@ -451,7 +415,6 @@ class FC3_Partition(KickstartCommand):
                 warnings.warn(_("A partition with the mountpoint %s has already been defined.") % pd.mountpoint)
         else:
             pd.mountpoint = None
-
         return pd
 
     def dataList(self):
index c002a58d017e3fab23b0637646fc826029599b4d..22d687cc0656101c6979f6ee4d98e796430be737 100644 (file)
@@ -100,7 +100,7 @@ class F26_Snapshot(KickstartCommand):
                         help="""
                         Name of the newly created snapshot.""")
         # Show all possible options in meta message
-        meta_msg = "<%s>" % ("|".join(list(self.whenMap.keys())))
+        meta_msg = "<%s>" % ("|".join(self.whenMap.keys()))
         op.add_argument("--when", metavar=meta_msg, type=self._when_cb, version=F26,
                         required=True, help="""
                         You can specify two possible values: ``pre-install`` and ``post-install``.
@@ -132,9 +132,9 @@ class F26_Snapshot(KickstartCommand):
             raise KickstartParseError(msg, lineno=self.lineno)
 
         # Check if value in a '--when' param is valid
-        if snap_data.when != "" and snap_data.when not in list(self.whenMap.values()):
+        if snap_data.when != "" and snap_data.when not in self.whenMap.values():
             msg = (_("Snapshot when param must have one of these values %s!") %
-                   list(self.whenMap.keys()))
+                   self.whenMap.keys())
             raise KickstartParseError(msg, lineno=self.lineno)
 
         return snap_data
index e793dcb8a40e716c5541e810f2a90ead67af76f8..2aafd14f7343576fd3ed2bfd48a46429799b352b 100644 (file)
@@ -822,7 +822,7 @@ class PackageSection(Section):
 
         for arg in args:
             for option, new_option in \
-                list({"--instLangs": "--inst-langs", "--excludeWeakdeps": "--exclude-weakdeps"}.items()):
+                {"--instLangs": "--inst-langs", "--excludeWeakdeps": "--exclude-weakdeps"}.items():
                 if option in arg:
                     warnings.warn(_("The %(option)s option on line %(lineno)s will be deprecated in "
                                     "future releases. Please modify your kickstart file to replace "
index adc6ac06532b72626fe6bf66afcc173bbbbe2b75..c5a4827f4dea93c11cf158b493eaa03fe1748a5c 100755 (executable)
@@ -156,7 +156,7 @@ def main(parser, args, argv):
     if args.block_recommends:
         configmgr.create['block_recommends']=args.block_recommends
 
-if args.runtime:
+    if args.runtime:
         configmgr.set_runtime(args.runtime)
 
     if args.use_mic_in_bootstrap:
index bb6541777f54e5f34acde63faa00e2c6703f4b15..899483b9b6936f3375b5408baa6961293c6c2503 100644 (file)
@@ -21,6 +21,7 @@ from pykickstart.base import *
 from pykickstart.errors import *
 from pykickstart.options import *
 from pykickstart.version import DEVEL
+from pykickstart.i18n import _
 
 class Mic_Desktop(KickstartCommand):
     def __init__(self, writePriority=0,
@@ -28,10 +29,8 @@ class Mic_Desktop(KickstartCommand):
                        defaultdm=None,
                        autologinuser=None,
                        session=None):
-
         KickstartCommand.__init__(self, writePriority)
 
-        self.__new_version = False
         self.op = self._getParser()
 
         self.defaultdesktop = defaultdesktop
@@ -57,14 +56,7 @@ class Mic_Desktop(KickstartCommand):
         return retval
 
     def _getParser(self):
-        try:
-            #ingnore this pylit error, the lineno argument exist in olg version. using this way can compate old version.
-            op = KSOptionParser(prog='desktop', description='desktop', version=DEVEL, lineno=self.lineno)  #pylint: disable=unexpected-keyword-arg
-        except TypeError:
-            # the latest version has not lineno argument
-            op = KSOptionParser(prog='desktop', description='desktop', version=DEVEL)
-            self.__new_version = True
-
+        op = KSOptionParser(prog='desktop', description='desktop', version=DEVEL)
         op.add_argument("--defaultdesktop", dest="defaultdesktop",
                                           action="store",
                                           type=str,
@@ -84,14 +76,9 @@ class Mic_Desktop(KickstartCommand):
         return op
 
     def parse(self, args):
-        if self.__new_version:
-            (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
-        else:
-            (opts, extra) = self.op.parse_args(args=args)
-
-        if extra:
-            m = ("Unexpected arguments to %(command)s command: %(options)s") \
-                  % {"command": "desktop", "options": extra}
-            raise KickstartValueError  (formatErrorMsg(self.lineno, msg=m))
 
-        self._setToSelf(self.op, opts)
+        (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno)
+        if any(arg for arg in extra if arg.startswith("-")):
+            mapping = {"command": "desktop", "options": extra}
+            raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno)
+        self.set_to_self(ns)
index 51c4be2cc511de6ef2e3813939f1c84590ab42ad..bce1b8e2914d0af8461367e32124554287010069 100644 (file)
@@ -20,6 +20,8 @@ from pykickstart.options import *
 from mic import msger
 from pykickstart.version import DEVEL
 
+from pykickstart.i18n import _
+
 class Mic_installerfw(KickstartCommand):
     """ This class implements the "installerfw_plugins" KS option. The argument
     of the option is a comman-separated list of MIC features which have to be
@@ -54,13 +56,16 @@ class Mic_installerfw(KickstartCommand):
         return op
 
     def parse(self, args):
-        (_, extra) = self.op.parse_args(args=args, lineno=self.lineno)
+        print("NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN")
+        (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno)
+        self.set_to_self(ns)
 
         if len(extra) != 1:
-            msg = "Kickstart command \"%s\" requires one " \
-                  "argumet - a list of legacy features to disable" % self.currentCmd
-            raise KickstartValueError  (formatErrorMsg(self.lineno, msg = msg))
-
-        self.features = extra[0].split(",")
+            raise KickstartParseError(_("Kickstart command %s requires one argument") % "installerfw", lineno=self.lineno)
+        elif any(arg for arg in extra if arg.startswith("-")):
+            mapping = {"command": "installerfw", "options": extra}
+            raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno)
+        else:
+            self.features = extra[0].split(",")
 
         return self