You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bazarr/bazarr.py

66 lines
1.5 KiB

# coding=utf-8
import subprocess as sp
import time
import os
import sys
from bazarr import libs
from bazarr.get_args import args
dir_name = os.path.dirname(__file__)
def start_bazarr():
script = [sys.executable, "-u", os.path.normcase(os.path.join(dir_name, 'bazarr', 'main.py'))] + sys.argv[1:]
5 years ago
ep = sp.Popen(script, stdout=sp.PIPE, stderr=sp.STDOUT, stdin=sp.PIPE)
print "Bazarr starting..."
try:
for line in iter(ep.stdout.readline, ''):
sys.stdout.write(line)
except KeyboardInterrupt:
pass
if __name__ == '__main__':
restartfile = os.path.normcase(os.path.join(args.config_dir, 'bazarr.restart'))
stopfile = os.path.normcase(os.path.join(args.config_dir, 'bazarr.stop'))
5 years ago
try:
os.remove(restartfile)
except:
pass
5 years ago
try:
os.remove(stopfile)
except:
pass
5 years ago
def daemon():
if os.path.exists(stopfile):
try:
os.remove(stopfile)
except:
print 'Unable to delete stop file.'
else:
print 'Bazarr exited.'
os._exit(0)
5 years ago
if os.path.exists(restartfile):
try:
os.remove(restartfile)
except:
print 'Unable to delete restart file.'
else:
start_bazarr()
5 years ago
start_bazarr()
5 years ago
# Keep the script running forever.
while True:
daemon()
time.sleep(1)