Permalink
Browse files

More verbose error information.

  • Loading branch information...
1 parent f73c175 commit 85876e4a8f0a21781420eb95708523a3544a8f84 @mattdeboard committed May 8, 2011
Showing with 23 additions and 13 deletions.
  1. +23 −13 srchupdate.py
View
@@ -14,30 +14,40 @@ def update():
datefmt='%m/%d/%Y %H:%M:%S')
logging.info('Starting index update.')
try:
- mattwhoosh = subprocess.call(['sudo', 'chown', '-R',
- 'matt:matt', whoosh_dir])
- update_index = subprocess.call([domain_dir+'bin/python',
- appdir+'manage.py', 'update_index'])
- apachewhsh = subprocess.call(['sudo', 'chown', '-R',
- 'www-data:www-data', whoosh_dir])
- apachereload = subprocess.call(['sudo',
+ mattwhoosh = subprocess.Popen(['sudo', 'chown', '-R',
+ 'matt:matt', whoosh_dir],
+ stdout=subprocess.PIPE,
+ stderr=suprocess.STDOUT)
+ update_index = subprocess.Popen([domain_dir+'bin/python',
+ appdir+'manage.py', 'update_index'],
+ stdout=subprocess.PIPE,
+ stderr=suprocess.STDOUT)
+ apachewhsh = subprocess.Popen(['sudo', 'chown', '-R',
+ 'www-data:www-data', whoosh_dir],
+ stdout=subprocess.PIPE,
+ stderr=suprocess.STDOUT)
+ apachereload = subprocess.Popen(['sudo',
'/etc/init.d/apache2',
- 'force-reload'])
+ 'force-reload'],
+ stdout=subprocess.PIPE,
+ stderr=suprocess.STDOUT)
if sum([int(mattwhoosh), int(update_index), int(apachewhsh),
int(apachereload)]) == 0:
logging.info('Index successfully updated.')
- logging.info('The following exit codes were returned:')
- logging.info('- mattwhoosh: %s' % mattwhoosh)
- logging.info('- update_index: %s' % update_index)
- logging.info('- apachewhsh: %s' % apachewhsh)
- logging.info('- apachereload: %s' % apachereload)
else:
+ subs = [mattwhoosh, update_index, apachewhsh, apachereload]
logging.error('**INDEX UPDATE FAILED**')
logging.error('The following exit codes were returned:')
logging.error('- mattwhoosh: %s' % mattwhoosh)
logging.error('- update_index: %s' % update_index)
logging.error('- apachewhsh: %s' % apachewhsh)
logging.error('- apachereload: %s' % apachereload)
+ for sub in subs:
+ if sub.returncode:
+ logging.error('Error information:')
+ logging.error('stdout: %s' % sub.communicate()[0])
+ logging.error('stderr: %s' % sub.communicate()[1])
+
except:
logging.error("Exception received: ",
sys.exc_info()[0],

0 comments on commit 85876e4

Please sign in to comment.