2018-03-28 16:07:35 +00:00
|
|
|
import subprocess
|
|
|
|
from subprocess import check_output
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
import sys
|
2017-12-30 05:09:51 +00:00
|
|
|
|
|
|
|
try:
|
2018-03-28 16:07:35 +00:00
|
|
|
logging.info('Installing Python modules required for Bazarr...')
|
2018-01-10 16:44:47 +00:00
|
|
|
|
2018-04-11 16:49:54 +00:00
|
|
|
command = sys.executable + ' -m pip --disable-pip-version-check -q -q install --user -r ' + os.path.join(os.path.dirname(__file__), 'requirements.txt')
|
2018-01-23 04:25:58 +00:00
|
|
|
|
2018-03-28 16:07:35 +00:00
|
|
|
if os.name == 'nt':
|
|
|
|
codepage = check_output("chcp", shell=True, stderr=subprocess.STDOUT)
|
|
|
|
encoding = codepage.split(':')[-1].strip()
|
2018-03-10 04:17:51 +00:00
|
|
|
|
2018-03-28 16:07:35 +00:00
|
|
|
process = check_output(command, shell=True, stderr=subprocess.STDOUT)
|
|
|
|
|
|
|
|
if os.name == 'nt':
|
|
|
|
process = process.decode(encoding)
|
|
|
|
except:
|
|
|
|
logging.error('Unable to install requirements using command line PIP. Is PIP installed and included in system path?')
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
if process == "":
|
|
|
|
logging.info('Required Python modules installed if missing.')
|
|
|
|
else:
|
|
|
|
for line in process.splitlines():
|
|
|
|
logging.error(line)
|