From c280268486e9a48e8b02b885e5b70d7249eb8dd1 Mon Sep 17 00:00:00 2001 From: Hidden Z Date: Thu, 26 Sep 2013 16:52:52 +0000 Subject: [PATCH] py-i2phosts-fetcher: add error handling for invoking injector py-i2phosts-injector may not be launched correctly, so we want to catch the errors. --- bin/py-i2phosts-fetcher | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/py-i2phosts-fetcher b/bin/py-i2phosts-fetcher index 9b244c7..1f9341d 100755 --- a/bin/py-i2phosts-fetcher +++ b/bin/py-i2phosts-fetcher @@ -4,6 +4,7 @@ import re import os import os.path import sys +import errno import datetime import urllib2 import subprocess @@ -117,8 +118,14 @@ for source in all_sources: log.info('%s: adding hosts...', source.name) sp_args = ['py-i2phosts-injector', '-s', '-f', tmpfile, '-d', 'Auto-added from ' + source.name] - p = subprocess.Popen(sp_args, shell=False, stdin=None, - stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + try: + p = subprocess.Popen(sp_args, shell=False, stdin=None, + stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + except OSError, e: + log.error('failed to exec py-i2phosts-injector: %s', e) + if e.errno == errno.ENOENT: + log.error('check your PATH environment variable') + sys.exit(1) out = p.communicate()[0] os.remove(tmpfile) log.info('%s: injector output: \n%s', source.name, out)