[rhel6-branch][pykickstart][PATCH] Raise an error if part and autopart are used together (#886010)

Chris Lumens clumens at redhat.com
Tue Aug 6 18:01:00 UTC 2013


> diff --git a/pykickstart/parser.py b/pykickstart/parser.py
> index 18e7559..f797cd9 100644
> --- a/pykickstart/parser.py
> +++ b/pykickstart/parser.py
> @@ -733,6 +733,27 @@ class KickstartParser:
>              elif self._state == STATE_END:
>                  break
>  
> +        # Check if autopart and part/partition are used at the same time,
> +        # if they are used at the same time, raise an error
> +
> +        # to check if a command has been "seen" by the parser,
> +        # we need to check their properties
> +        partSeen = self.handler.commands["partition"].dataList()
> +        # if dataList() returns a nonempty list, the part/partition
> +        # command has been "seen" in the kickstart
> +        autopart = self.handler.commands["autopart"]
> +        autopartSeen = autopart.autopart
> +        # if the "autopart" property is True, the autopart command
> +        # has been "seen" in the kickstart
> +
> +        if partSeen and autopartSeen:
> +            # as we can only report one line number, report the line number
> +            # of the autopart command
> +            lineno = autopart.lineno
> +            errorMsg = _("The part and autopart commands can't be used at the same time")
> +            raise KickstartParseError, formatErrorMsg(lineno, msg=errorMsg)
> +
> +
>      def readKickstartFromString (self, str, reset=True):
>          """Process a kickstart file, provided as the string str."""
>          if reset:

The proper check for this kind of check is in the parse method of the
command in question.  So, the autopart command's parse method should
check if any of the other part commands have been seen.  And the other
part commands should check if autopart has been seen.

- Chris


More information about the anaconda-patches mailing list