-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathros_setup.py
executable file
·78 lines (72 loc) · 2.29 KB
/
ros_setup.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2020-2021 by Murray Altheim. All rights reserved. This file is part
# of the Robot Operating System project, released under the MIT License. Please
# see the LICENSE file included as part of this package.
#
# author: Murray Altheim
# created: 2021-02-18
# modified: 2021-02-18
#
# For some reason 'pimoroni-ioexpander' installs but continues to show up here
# as uninstalled. A bug?
#
# You may also need to install various libraries via apt.
#
# sudo apt install i2c-tools
# sudo apt install evtest tslib libts-bin
# sudo apt install pigpio
#
import importlib, sys
import subprocess as sp
from lib.confirm import confirm
libraries = [ \
'numpy', \
'pytest', \
'pyyaml', \
'colorama', \
'gpiozero', \
'board', \
'readchar', \
# 'pyquaternion', \
# 'rpi.gpio', \
# 'adafruit-extended-bus', \
# 'pymessagebus==1.*', \
# 'ht0740', \
# 'pimoroni-ioexpander', \
# 'adafruit-circuitpython-bno08x', \
# 'matrix11x7', \
# 'rgbmatrix5x5', \
]
for name in libraries:
try:
print('-- processing {}...'.format(name))
_index = name.find('=')
if _index == -1:
print(' importing: {}'.format(name))
importlib.import_module(name, package=None)
else:
name = name[:_index].strip()
print(' importing: {}'.format(name))
importlib.import_module(name, package=None)
except RuntimeError as e:
print('error on import of {}: {}'.format(name, e))
except ImportError:
print('')
_command = 'pip3 install --user {}'.format(name, name)
print('This script requires the {} module.\nInstall with: {}'.format(name, _command))
confirmed = confirm(True)
if confirmed:
_comleted_process = sp.run(_command, shell=True)
print('-- return code {}'.format(_comleted_process.returncode))
if _comleted_process.returncode == 0:
print('-- installation successful.')
else:
print('-- returned error code \'{}\' on command \'{}\''.format(_comleted_process.returncode, _command))
sys.exit(_comleted_process.returncode)
else:
print('-- exiting loop.')
sys.exit(0)
print('-- complete.')
#EOF