forked from ev3dev/ev3dev-lang-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto.py
More file actions
41 lines (32 loc) · 1.01 KB
/
auto.py
File metadata and controls
41 lines (32 loc) · 1.01 KB
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
"""
Use platform.machine() to determine the platform type, cache the
results in /tmp/current_platform so that we do not have to import
platform and run platform.machine() each time someone imports ev3dev.auto
"""
import os
filename = '/tmp/current_platform'
current_platform = None
if os.path.exists(filename):
with open(filename, 'r') as fh:
current_platform = fh.read().strip()
if not current_platform:
import platform
def get_current_platform():
"""
Guess platform we are running on
"""
machine = platform.machine()
if machine == 'armv5tejl':
return 'ev3'
elif machine == 'armv6l':
return 'brickpi'
else:
return 'unsupported'
current_platform = get_current_platform()
with open(filename, 'w') as fh:
fh.write(current_platform + '\n')
if current_platform == 'brickpi':
from .brickpi import *
else:
# Import ev3 by default, so that it is covered by documentation.
from .ev3 import *