FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > EPEL Development

 
 
LinkBack Thread Tools
 
Old 05-20-2010, 03:22 PM
Ales Kozumplik
 
Default analog: handle a config file we can't open.

---
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 % {
--
1.6.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 05-20-2010, 06:17 PM
"Brian C. Lane"
 
Default analog: handle a config file we can't open.

-----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@redhat.com>
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+nlR7pvGvGHaTuF9FvJzxjnxtkQ1BJUcN2P7urT1qTHchr6vq cng6
7qUKlGjtIsi9WPLJtdbqS/lCtj/5IbQ/46mlH3H11aXFd9HQbnKhQFGZHkr2ourC
8VTKMWyJfJpZrBEOmuf3P9FoPD7QuuH04A8pj2e34vupzp/yeiSzB8LtTavcoCAG
2i9362aMNOYxi6hTBhwPU9NwUW6/mx3ZO7aO9eR0HdJrMf2FZ1Ba8QDBUQ8smhvN
5735hn+iB7tQIup6lDN/qVxQUazwvIsbR1O+gFVcmAqIehcEB2Jtvw==
=m5I5
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 05-24-2010, 12:09 PM
Ales Kozumplik
 
Default analog: handle a config file we can't open.

On 05/20/2010 08:17 PM, Brian C. Lane wrote:


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



You're right, the future import is less evil than the print statement
(even though both can me be converted to python3 according to msivak).


I'll fix this.

Ales

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

Thread Tools




All times are GMT. The time now is 06:49 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org