Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added a stderr to subprocess.call for update_index in srchupdate.py

  • Loading branch information...
commit bea6ea6417b5396952aa7eed7251988d3d4591b8 1 parent 9f40242
@mattdeboard authored
Showing with 31 additions and 28 deletions.
  1. +31 −28 srchupdate.py
View
59 srchupdate.py
@@ -13,34 +13,37 @@ def update():
format='%(asctime)s %(levelname)s:%(message)s',
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',
- '/etc/init.d/apache2', 'force-reload'])
- 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:
- 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)
- except:
- logging.error("Exception received: ",
- sys.exc_info()[0],
- sys.exc_info()[1])
+ with open('/a/mattdeboard.net/src/index.log') as f:
+ try:
+ mattwhoosh = subprocess.call(['sudo', 'chown', '-R',
+ 'matt:matt', whoosh_dir], stderr=f)
+ update_index = subprocess.call([domain_dir+'bin/python',
+ appdir+'manage.py', 'update_index'],
+ stdout=f)
+ apachewhsh = subprocess.call(['sudo', 'chown', '-R',
+ 'www-data:www-data', whoosh_dir])
+ apachereload = subprocess.call(['sudo',
+ '/etc/init.d/apache2',
+ 'force-reload'])
+ 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:
+ 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)
+ except:
+ logging.error("Exception received: ",
+ sys.exc_info()[0],
+ sys.exc_info()[1])
if __name__ == '__main__':
Please sign in to comment.
Something went wrong with that request. Please try again.