forked from fl4p/batmon-ha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_bleak.py
45 lines (33 loc) · 1.28 KB
/
install_bleak.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import subprocess
import sys
from bmslib.bt import bleak_version
from bmslib.store import load_user_config
from bmslib.util import get_logger
user_config = load_user_config()
logger = get_logger()
if user_config.get('install_newer_bleak'):
ver = '0.22.2'
args = ['install', 'bleak==0.22.2']
else:
ver = '0.13.1a1'
args = ['install', 'git+https://github.com/jpeters-ml/bleak@feature/windowsPairing']
try:
import influxdb
influxdb_installed = True
except ImportError:
influxdb_installed = False
need_influxdb = bool(user_config.get('influxdb_host') or user_config.get('telemetry'))
if need_influxdb:
args.append('influxdb')
installed_ver = bleak_version()
if installed_ver == ver and (influxdb_installed or not need_influxdb):
sys.exit(0)
logger.info(f'bleak {installed_ver} installed, want {ver}, running pip3 ' + ' '.join(args))
logger.info('influxdb installed=%s need=%s', influxdb_installed, need_influxdb)
p = subprocess.Popen(["pip3"] + args, stdout=sys.stdout, stderr=sys.stderr) # , stdout=subprocess.PIPE)
# configurable timeout since 120 wasn't long enough
install_timeout = float(user_config.get('bleak_install_timeout', 120.0))
p.wait(timeout=install_timeout)
#sys.exit(p.returncode)
# we continue to run the add-on even if pip command fails
sys.exit(0)