bazarr/bazarr/libs.py

31 lines
848 B
Python
Raw Normal View History

# coding=utf-8
import os
2019-06-11 18:45:48 +00:00
import sys
2019-10-08 01:18:24 +00:00
from shutil import rmtree
def clean_libs():
libs_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'libs')
# Delete the old module almost empty directory compatible only with Python 2.7.x that cause bad magic number error
# if they are present in Python 3.x.
module_list = ['enum', 'concurrent']
for module in module_list:
module_path = os.path.join(libs_dir, module)
if os.path.isdir(module_path):
rmtree(module_path)
def set_libs():
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../libs/'))
2019-09-28 16:38:26 +00:00
from six import PY3
2019-09-28 04:22:17 +00:00
if PY3:
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../libs3/'))
else:
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../libs2/'))
2019-10-08 01:18:24 +00:00
clean_libs()
set_libs()