summaryrefslogtreecommitdiffhomepage
path: root/update_modules.py
blob: 4f1c25a891100403a734de10ab5376036687ad9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import subprocess
from subprocess import check_output
import logging
import os
import sys

try:
    logging.info('Installing Python modules required for Bazarr...')

    command = sys.executable + ' -m pip --disable-pip-version-check -q -q install --user -r "' + os.path.join(os.path.dirname(__file__), 'requirements.txt"')

    if os.name == 'nt':
        codepage = check_output("chcp", shell=True, stderr=subprocess.STDOUT)
        encoding = codepage.split(':')[-1].strip()

    process = check_output(command, shell=True, stderr=subprocess.STDOUT)

    if os.name == 'nt':
        process = process.decode(encoding)
except Exception as e:
    logging.exception('Unable to install requirements using command line PIP.')
    pass
else:
    if process == "":
        logging.info('Required Python modules installed if missing.')
    else:
        for line in process.splitlines():
            logging.error(line)