openmedialibrary/oml/__main__.py

32 lines
886 B
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
import sys
if sys.platform == 'win32':
from os.path import normpath, dirname, abspath, join
import site
base = normpath(dirname(dirname(abspath(__file__))))
for site_packages in (
base,
normpath(join(base, '..', 'platform', 'Shared', 'lib', 'python3.4', 'site-packages')),
normpath(join(base, '..', 'platform', 'win32', 'Lib', 'site-packages')),
):
site.addsitedir(site_packages)
sys.path.append(normpath(join(base, '..', 'platform', 'win32')))
import api
import commands
import server
if len(sys.argv) > 1 and sys.argv[1] == 'server':
server.run()
else:
commands.main()
if sys.platform == 'win32':
# Work around pyopenssl exception to shutdown
def handle_exception(*args, **kwargs):
pass
sys.excepthook = handle_exception