Flushing stdout buffer

pull/222/head
Louis Vézina 6 years ago
parent 9c28c30ec8
commit 8a1dc9e275

@ -2,16 +2,9 @@ import subprocess as sp
import threading
import time
import os
import logging
import sys
import getopt
log = logging.getLogger()
log.setLevel(logging.DEBUG)
out_hdlr = logging.StreamHandler(sys.stdout)
out_hdlr.setLevel(logging.INFO)
log.addHandler(out_hdlr)
arguments = []
try:
opts, args = getopt.getopt(sys.argv[1:],"h:",["no-update", "config="])
@ -30,10 +23,11 @@ def start_bazarr():
script = [sys.executable, os.path.normcase(os.path.join(globals()['dir_name'], 'bazarr/main.py'))] + globals()['arguments']
ep = sp.Popen(script, stdout=sp.PIPE, stderr=sp.STDOUT, stdin=sp.PIPE)
logging.info("Bazarr starting...")
print "Bazarr starting..."
try:
for line in iter(ep.stdout.readline, ''):
sys.stdout.write(line)
sys.stdout.flush()
except KeyboardInterrupt:
pass
@ -58,16 +52,16 @@ if __name__ == '__main__':
try:
os.remove(stopfile)
except:
logging.error('Unable to delete stop file.')
print 'Unable to delete stop file.'
else:
logging.info('Bazarr exited.')
print 'Bazarr exited.'
os._exit(0)
if os.path.exists(restartfile):
try:
os.remove(restartfile)
except:
logging.error('Unable to delete restart file.')
print 'Unable to delete restart file.'
else:
start_bazarr()

@ -1692,9 +1692,10 @@ import warnings
warnings.simplefilter("ignore", DeprecationWarning)
server = CherryPyWSGIServer((str(ip), int(port)), app)
logging.info('Bazarr is started and waiting for request on http://' + str(ip) + ':' + str(port) + str(base_url))
try:
print('Bazarr is started and waiting for request on http://' + str(ip) + ':' + str(port) + str(base_url))
logging.info('Bazarr is started and waiting for request on http://' + str(ip) + ':' + str(port) + str(base_url))
print 'Bazarr is started and waiting for request on http://' + str(ip) + ':' + str(port) + str(base_url)
sys.stdout.flush()
server.start()
except KeyboardInterrupt:
shutdown()

Loading…
Cancel
Save