Re: [master 1/6] analog: handle a config file we can't open.

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

 



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

On 05/20/2010 08:22 AM, Ales Kozumplik wrote:
> ---
>  scripts/analog |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/analog b/scripts/analog
> index 7f2ba02..b392acd 100755
> --- a/scripts/analog
> +++ b/scripts/analog
> @@ -157,8 +157,12 @@ if __name__ == "__main__":
>      options.output = os.path.abspath(options.output)
>      config = generate_rsyslog_config(options.port, directory)
>      if options.output:
> -        with open(options.output, 'w') as file:
> -            file.write(config)
> +        try:
> +            with open(options.output, 'w') as file:
> +                file.write(config)
> +        except IOError as e:
> +            print >> sys.stderr, "Can't write into file %s" % options.output
> +            sys.exit(1)
>          if options.stdout:
>              pid = pid_location(options.port)
>              print HINT % {

I really dislike the 'print >> sys.sterr', reminds me of C++ I suppose.
Also, it is going away in Python 3.0 (which we should at least be
thinking about).

I'd rather see us start doing this:

from __future__ import print_function

print("Can't write into file %s" % options.output, file=sys.stderr)

Docs are here:

http://docs.python.org/library/functions.html#print

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

iQEVAwUBS/V8yRF+jBaO/jp/AQJJiAf/UQ3exyq/aWeYq+fa/TDZ8adTPUyBgNpS
0ON5t2ECK/h+nlR7pvGvGHaTuF9FvJzxjnxtkQ1BJUcN2P7urT1qTHchr6vqcng6
7qUKlGjtIsi9WPLJtdbqS/lCtj/5IbQ/46mlH3H11aXFd9HQbnKhQFGZHkr2ourC
8VTKMWyJfJpZrBEOmuf3P9FoPD7QuuH04A8pj2e34vupzp/yeiSzB8LtTavcoCAG
2i9362aMNOYxi6hTBhwPU9NwUW6/mx3ZO7aO9eR0HdJrMf2FZ1Ba8QDBUQ8smhvN
5735hn+iB7tQIup6lDN/qVxQUazwvIsbR1O+gFVcmAqIehcEB2Jtvw==
=m5I5
-----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