[f21/master v3] Avoid the possibility of size variables being unset (#1146585)

Anne Mulhern amulhern at redhat.com
Fri Sep 26 11:54:40 UTC 2014





----- Original Message -----
> From: "David Shea" <dshea at redhat.com>
> To: anaconda-patches at lists.fedorahosted.org
> Sent: Thursday, September 25, 2014 4:46:38 PM
> Subject: [f21/master v3] Avoid the possibility of size variables being unset	(#1146585)
> 
> Check for missing sizes in the logvol and part commands. If unset in
> logvol and not using --percent, raise an error. If unset in part, set
> size to None and let blivet figure it out.
> 
> Remove the TypeError checks for the %d operation failing since
> pykickstart already checks for integer validity.
> ---
>  pyanaconda/kickstart.py | 25 ++++++++++++-------------
>  1 file changed, 12 insertions(+), 13 deletions(-)
> 
> diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py
> index fadc501..37ee1ad 100644
> --- a/pyanaconda/kickstart.py
> +++ b/pyanaconda/kickstart.py
> @@ -770,13 +770,14 @@ class LogVolData(commands.logvol.F20_LogVolData):
>          if self.percent:
>              size = Size(0)
>          else:
> +            if not self.size:
> +                raise KickstartValueError(formatErrorMsg(self.lineno,
> +                    msg="Size must be specified."))
>              try:
>                  size = Size("%d MiB" % self.size)
>              except ValueError:
>                  raise KickstartValueError(formatErrorMsg(self.lineno,
>                          msg="The size \"%s\" is invalid." % self.size))
> -            except TypeError:
> -                pass
>  
>          if self.mountpoint == "swap":
>              ty = "swap"
> @@ -926,8 +927,6 @@ class LogVolData(commands.logvol.F20_LogVolData):
>                  except ValueError:
>                      raise KickstartValueError(formatErrorMsg(self.lineno,
>                              msg="The maximum size \"%s\" is invalid." %
>                              self.maxSizeMB))
> -                except TypeError:
> -                    pass
>              else:
>                  maxsize = None
>  
> @@ -1014,13 +1013,15 @@ class PartitionData(commands.partition.F18_PartData):
>  
>          storage.doAutoPart = False
>  
> -        try:
> -            size = Size("%d MiB" % self.size)
> -        except ValueError:
> -            raise KickstartValueError(formatErrorMsg(self.lineno,
> -                    msg=_("The size \"%s\" is invalid.") % self.size))
> -        except TypeError:
> -            pass
> +        if self.size:
> +            try:
> +                size = Size("%d MiB" % self.size)
> +            except ValueError:
> +                raise KickstartValueError(formatErrorMsg(self.lineno,
> +                        msg=_("The size \"%s\" is invalid.") % self.size))
> +        else:
> +            # Have blivet determine a default value
> +            size = None
>  
>          if self.onbiosdisk != "":
>              for (disk, biosdisk) in storage.eddDict.iteritems():
> @@ -1189,8 +1190,6 @@ class PartitionData(commands.partition.F18_PartData):
>              except ValueError:
>                  raise KickstartValueError(formatErrorMsg(self.lineno,
>                          msg=_("The maximum size \"%s\" is invalid.") %
>                          self.maxSizeMB))
> -            except TypeError:
> -                pass
>          else:
>              maxsize = None
>  
> --
> 2.1.0
> 
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> 

Can you make it also Related to #1116435? Might help slightly if rebasing or something.

- mulhern
 



More information about the anaconda-patches mailing list