Skip to content

Commit

Permalink
exit with error if device already in use (for example if Thonny is ru…
Browse files Browse the repository at this point in the history
…nning)
  • Loading branch information
lowfatcode committed Sep 1, 2022
1 parent 4b130ba commit 4d98a57
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions install-on-device-fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,21 @@ echo "Copying Enviro firmware files to ${DEVICE}"

function create_directory {
echo -n "> creating directory $1"
mpremote connect ${DEVICE} mkdir $1 > /dev/null
if [ $? -eq 0 ] ; then

RESULT=$(mpremote connect ${DEVICE} mkdir $1)
ERROR=$?


if [ $ERROR -eq 0 ] ; then
echo " .. done!"
else
echo " .. already exists, skipping."
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
}

Expand All @@ -26,7 +36,11 @@ function copy {
do
echo -n "> copying file $file"
mpremote connect ${DEVICE} cp $file $2 > /dev/null
echo " .. done!"
if [ $? -eq 0 ] ; then
echo " .. done!"
else
echo " .. failed!"
fi
done
}

Expand Down

0 comments on commit 4d98a57

Please sign in to comment.