Proper loading of plugins on debug
Restarting functions
This commit is contained in:
+35
-4
@@ -5,6 +5,8 @@
|
||||
from os.path import dirname
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
|
||||
# Root path
|
||||
base_path = dirname(os.path.abspath(__file__))
|
||||
@@ -15,10 +17,39 @@ sys.path.insert(0, os.path.join(base_path, 'libs'))
|
||||
from couchpotato.core.logger import CPLog
|
||||
log = CPLog(__name__)
|
||||
|
||||
# Get options via arg
|
||||
from couchpotato.cli import getOptions
|
||||
options = getOptions(base_path, sys.argv[1:])
|
||||
|
||||
def start():
|
||||
try:
|
||||
args = [sys.executable] + sys.argv
|
||||
new_environ = os.environ.copy()
|
||||
new_environ['cp_main'] = 'true'
|
||||
|
||||
if os.name == 'nt':
|
||||
for key, value in new_environ.iteritems():
|
||||
if isinstance(value, unicode):
|
||||
new_environ[key] = value.encode('iso-8859-1')
|
||||
|
||||
subprocess.call(args, env = new_environ)
|
||||
return os.path.isfile(os.path.join(options.data_dir, 'restart'))
|
||||
except Exception, e:
|
||||
log.critical(e)
|
||||
return 0
|
||||
|
||||
from couchpotato import cli
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
cli.cmd_couchpotato(base_path, sys.argv[1:])
|
||||
except Exception, e:
|
||||
log.critical(e)
|
||||
|
||||
if os.environ.get('cp_main', 'false') == 'true':
|
||||
try:
|
||||
cli.cmd_couchpotato(options, base_path, sys.argv[1:])
|
||||
except Exception, e:
|
||||
log.critical(e)
|
||||
else:
|
||||
while 1:
|
||||
restart = start()
|
||||
if not restart:
|
||||
break
|
||||
|
||||
sys.exit()
|
||||
|
||||
Reference in New Issue
Block a user