From 3db339da35053fedc239758e4b835e9735ce21be Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Thu, 1 Nov 2012 17:38:31 -0400 Subject: [PATCH] zephyr_mirror: Don't open /dev/null to disable logging (imported from commit 804e627d6d70bbf2ae1ee2f467b79ed0582ced0f) --- bots/zephyr_mirror.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/bots/zephyr_mirror.py b/bots/zephyr_mirror.py index 067b9ed..d15b0f0 100755 --- a/bots/zephyr_mirror.py +++ b/bots/zephyr_mirror.py @@ -272,8 +272,9 @@ def process_notice(notice, log): print "%s: zephyr=>humbug: received a message on %s/%s from %s..." % \ (datetime.datetime.now(), zephyr_class, notice.instance, notice.sender) - log.write(simplejson.dumps(zeph) + '\n') - log.flush() + if log is not None: + log.write(simplejson.dumps(zeph) + '\n') + log.flush() res = send_humbug(zeph) if res.get("result") != "success": @@ -342,12 +343,10 @@ def zephyr_to_humbug(options): print "%s: zephyr=>humbug: Starting receive loop." % (datetime.datetime.now(),) if options.log_path is not None: - log_file = options.log_path + with open(options.log_path, 'a') as log: + process_loop(log) else: - log_file = "/dev/null" - - with open(log_file, 'a') as log: - process_loop(log) + process_loop(None) def forward_to_zephyr(message): zsig = u"%s@(@color(blue))" % (username_to_fullname(message["sender_email"]),)