Skip to content
Browse files

auto-update feature improvement

  • Loading branch information...
adangert committed May 4, 2019
1 parent ddba911 commit bcf66767f552a3c28487df0bd96bbbc9604f72ab
Showing with 38 additions and 11 deletions.
  1. +1 −0 .gitignore
  2. BIN audio/Menu/joustmania_failed.wav
  3. +1 −0
  4. +17 −3
  5. +19 −8
@@ -1,3 +1,4 @@
# Byte-compiled / optimized / DLL files
Binary file not shown.
@@ -521,6 +521,7 @@ def check_update(self):
if move_opt[Opts.selection.value] == Selections.update.value:
if self.big_update:
self.big_update = False

def game_loop(self):
self.play_menu_music = True
@@ -1,17 +1,20 @@

setup() {
# Prevent apt from prompting us about restarting services.
export DEBIAN_FRONTEND=noninteractive

sudo apt-get install -y espeak

espeak "starting software upgrade"
#update OS
sudo cp -v conf/sources.list /etc/apt/sources.list || exit -1
sudo cp -v conf/apt.conf /etc/apt/apt.conf.d/10joustmania-conf || exit -1
sudo apt-get update -y || exit -1
sudo apt-get upgrade -y || exit -1
sudo apt-get dist-upgrade -y || exit -1
cd /home/pi

espeak "Installing Joustmania software updates"
#TODO: remove pyaudio and dependencies
#install components
sudo apt-get install -y \
@@ -26,6 +29,7 @@ setup() {
alsa-utils alsa-tools libasound2-dev \
python-dbus-dev libdbus-glib-1-dev espeak || exit -1

espeak "starting PS move A.P.I. software updates"
#install components for psmoveapi
sudo apt-get install -y \
build-essential \
@@ -35,7 +39,7 @@ setup() {

espeak "starting Joustmania software updates"
# We install nearly all python deps in the virtualenv to avoid concflicts with system, except
# numpy and scipy because they take forever to build.
@@ -45,17 +49,21 @@ setup() {
sudo apt-get install -y python3-dev || exit -1
sudo python3 -m pip install --upgrade virtualenv || exit -1

espeak "installing virtual environment"
# Rebuilding this is pretty cheap, so just do it every time.
rm -rf $VENV
/usr/bin/python3 -m virtualenv --system-site-packages $VENV || exit -1
espeak "installing virtual environment software"
$PYTHON -m pip install --ignore-installed psutil flask Flask-WTF pyalsaaudio pydub pygame pyaudio pyyaml dbus-python || exit -1

espeak "downloading PS move API"
#install psmoveapi
rm -rf psmoveapi
git clone --recursive git://
cd psmoveapi

espeak "making PS move API components"
mkdir build
cd build
# we definitely don't need java, opengj, csharp, etc
@@ -82,6 +90,12 @@ setup() {
#Use amixer to set sound output to 100%
amixer sset PCM,0 100%
sudo alsactl store

#This will disable on-board bluetooth
#This will allow only class one long range btdongles to connect to psmove controllers
sudo grep -qxF 'dtoverlay=pi3-disable-bt' /boot/config.txt || echo "dtoverlay=pi3-disable-bt" | sudo tee -a /boot/config.txt
sudo systemctl disable hciuart || exit -1

# Pause a second before rebooting so we can see all the output from this script.
(sleep 1; sudo reboot) &
@@ -1,12 +1,14 @@
import subprocess
from piaudio import Audio, InitAudio

import time
import shlex

if __name__ == "__main__":

def run_command(command):
process = subprocess.Popen(command.split(" "), stdout=subprocess.PIPE)
process = subprocess.Popen(shlex.split(command), stdout=subprocess.PIPE)
outout = ""
while True:

@@ -21,24 +23,33 @@ def run_command(command):

def big_update():
run_command("git pull")
current_hash = run_command("sudo runuser -l pi -c 'cd /home/pi/JoustMania/;git rev-parse HEAD'").strip()
run_command("sudo runuser -l pi -c 'cd /home/pi/JoustMania/;git checkout master'")
run_command("sudo runuser -l pi -c 'cd /home/pi/JoustMania/;git pull'")
run_command("sudo /home/pi/JoustMania/")
#it failed if it got this far
run_command("sudo runuser -l pi -c 'cd /home/pi/JoustMania/;git checkout {}'".format(current_hash))

def tester():
current_hash = run_command("sudo runuser -l pi -c 'git rev-parse HEAD'").strip()

def check_for_update():
process = run_command("git fetch")
diff_files = run_command("git diff origin/master --name-only").split()
process = run_command("sudo runuser -l pi -c 'cd /home/pi/JoustMania/;pwd'")
process = run_command("sudo runuser -l pi -c 'cd /home/pi/JoustMania/;git fetch'")
diff_files = run_command("sudo runuser -l pi -c 'cd /home/pi/JoustMania/;git diff origin/master --name-only'").split()

if('' in diff_files):
print('big updtae available')
return True

elif (len(diff_files) >= 1):
print("doing small pull")
pull = run_command("git pull")
pull = run_command("sudo runuser -l pi -c 'cd /home/pi/JoustMania/;git pull'")
return False

0 comments on commit bcf6676

Please sign in to comment.
You can’t perform that action at this time.