Re: [PATCH 01/22] Add class for handling ifcfg files (#520146)

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

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/27/2010 01:49 AM, Radek Vykydal wrote:

> +    def read(self):
> +        """Reads values from ifcfg file.
> +
> +        returns: number of values read
> +        """

if not os.access(self.path, os.R_OK):
    return None

> +        f = open(self.path, "r")
> +        lines = f.readlines()
> +        f.close()
> +
> +        for line in lines:
> +            line = line.strip()
> +            if line.startswith("#") or line == '':
> +                continue
> +            fields = line.strip().split('=', 2)

line is already stripped, so make this:

fields = line.split('=', 2)

> +            # XXX hack
> +            value = value.replace('"', '')
> +            value = value.replace("'", '')

value = value.translate(None, "'\"")

> +        fd, newifcfg = tempfile.mkstemp(prefix="ifcfg-%s" % self.iface, text=False)

I think it is possible for this to fail. You may want to wrap it in a
try: except: check


- -- 
Brian C. Lane <bcl@xxxxxxxxxx>
Red Hat / Port Orchard, WA
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQEVAwUBS9cnZRF+jBaO/jp/AQIhhQf+N5E3zq8x4Vehhi12W0Q5eeTSH6/q4/Sd
RL+zEVd3Eq005wMnHixx+yqh11e0fOBv/iaAw/B7eP81LkBmMV51jq+hG5zZAMvn
umUHeY12x/F72iJHr5Fnc9wiR3LfTI+KJ6dXwGi5men88KYBqVwiJtiJOOzt94dl
bMKOk+YaUKrXhd1IDogEvN1XOi4NFv4ozlilJtblS/a48STOmh/hXoC6uf7Voett
Qk/bJ1gjB8//FV6xyaLZ6X7z7JrTyhePd5q0zB4UlJ6lCoi12x0Jc21SrFT7zv3V
rt1vSjXt57zXgXcqDUtXc/aSnWH632nqvxW/EG5818/wWf+GWvfEFA==
=OyEI
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux