2014-05-04 17:26:43 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
2014-09-02 22:32:44 +00:00
|
|
|
|
2016-02-01 11:09:35 +00:00
|
|
|
import os
|
2014-05-04 17:26:43 +00:00
|
|
|
import sys
|
2019-01-31 13:41:13 +00:00
|
|
|
from os.path import normpath, dirname, abspath, join
|
|
|
|
import site
|
|
|
|
|
|
|
|
base = normpath(dirname(dirname(dirname(abspath(__file__)))))
|
2014-05-04 17:26:43 +00:00
|
|
|
|
2016-01-31 08:39:21 +00:00
|
|
|
if sys.platform == 'win32':
|
2016-09-29 08:35:47 +00:00
|
|
|
for site_packages in (
|
2016-02-01 11:09:35 +00:00
|
|
|
join(base, 'openmedialibrary'),
|
|
|
|
join(base, 'platform', 'Shared', 'lib', 'python3.4', 'site-packages'),
|
2019-01-20 11:16:46 +00:00
|
|
|
join(base, 'platform', 'Shared', 'lib', 'python3.7', 'site-packages'),
|
2016-02-01 11:09:35 +00:00
|
|
|
join(base, 'platform_win32', 'Lib', 'site-packages'),
|
2016-01-31 08:39:21 +00:00
|
|
|
):
|
|
|
|
site.addsitedir(site_packages)
|
2016-02-01 11:09:35 +00:00
|
|
|
sys.path.append(join(base, 'platform_win32'))
|
|
|
|
os.environ['oxCACHE'] = join(base, 'data', 'ox')
|
2019-01-29 10:41:35 +00:00
|
|
|
unrar_dll = join(base, 'platform_win32', 'unrar.dll')
|
|
|
|
if os.path.exists(unrar_dll):
|
|
|
|
os.environ['UNRAR_LIB_PATH'] = unrar_dll
|
2019-01-31 13:41:13 +00:00
|
|
|
os.environ['TCL_LIBRARY'] = join(base, 'platform_win32', 'tcl', 'tcl8.6')
|
2016-01-31 08:39:21 +00:00
|
|
|
|
2014-08-09 17:06:53 +00:00
|
|
|
import api
|
|
|
|
import commands
|
2014-05-04 17:26:43 +00:00
|
|
|
import server
|
|
|
|
|
|
|
|
if len(sys.argv) > 1 and sys.argv[1] == 'server':
|
|
|
|
server.run()
|
2019-01-31 13:41:13 +00:00
|
|
|
if len(sys.argv) > 1 and sys.argv[1] == 'ui':
|
|
|
|
import ui
|
|
|
|
ui.main(sys.argv[2:])
|
2014-05-04 17:26:43 +00:00
|
|
|
else:
|
2014-08-17 17:17:14 +00:00
|
|
|
commands.main()
|
2016-01-31 13:29:17 +00:00
|
|
|
if sys.platform == 'win32':
|
|
|
|
# Work around pyopenssl exception to shutdown
|
|
|
|
def handle_exception(*args, **kwargs):
|
|
|
|
pass
|
|
|
|
sys.excepthook = handle_exception
|