forked from pimoroni/enviro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-on-device-fs
executable file
·68 lines (51 loc) · 1.37 KB
/
install-on-device-fs
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
#!/usr/bin/env bash
DEVICES=$(mpremote connect list | grep MicroPython | cut -d " " -f 1)
if [ -z $DEVICES ] ; then
echo "No MicroPython devices found in FS mode"
exit 1
fi
DEVICE=${DEVICES[0]}
echo "Copying Enviro firmware files to ${DEVICE}"
function create_directory {
echo -n "> creating directory $1"
RESULT=$(mpremote connect ${DEVICE} mkdir $1)
ERROR=$?
if [ $ERROR -eq 0 ] ; then
echo " .. done!"
else
if [[ "$RESULT" == *"EEXIST"* ]] ; then
echo " .. already exists, skipping."
else
echo " .. failed!"
echo "! it looks like this device is already in use - is Thonny running?"
exit 1
fi
fi
}
function copy {
for file in $1
do
echo -n "> copying file $file"
mpremote connect ${DEVICE} cp $file $2 > /dev/null
if [ $? -eq 0 ] ; then
echo " .. done!"
else
echo " .. failed!"
fi
done
}
create_directory enviro
create_directory enviro/boards
create_directory enviro/destinations
create_directory enviro/html
create_directory enviro/html/images
create_directory phew
create_directory phew/phew
copy "main.py" :
copy "enviro/*.py" :enviro/
copy "enviro/boards/*.py" :enviro/boards/
copy "enviro/destinations/*.py" :enviro/destinations/
copy "enviro/html/*.html" :enviro/html/
copy "enviro/html/images/*" :enviro/html/images/
copy "phew/__init__.py" :phew/
copy "phew/phew/*.py" :phew/phew/