Skip to content

Commit

Permalink
Merge pull request #314 from eichblatt/dev
Browse files Browse the repository at this point in the history
Updates take effect without restart
  • Loading branch information
eichblatt authored Aug 23, 2022
2 parents 6604971 + e825947 commit b906da1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 23 deletions.
12 changes: 11 additions & 1 deletion timemachine/Archivary.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,14 @@ def resort_tape_date(self, date):
return bt

def load_archive(self, reload_ids, with_latest):
logger.info("Loading Archivary")
for a in self.archives:
logger.info(f"Archivary loading {a.archive_type}")
a.load_archive(reload_ids=reload_ids, with_latest=with_latest)
logger.info(f"Archivary now contains {len(self.tape_dates)} tapes")
# reload the tape dates, so that the Time Machine knows about the new stuff.
self.tape_dates = self.get_tape_dates()
self.dates = sorted(self.tape_dates.keys())

def year_artists(self, start_year, end_year=None):
for a in self.archives:
Expand Down Expand Up @@ -281,6 +287,10 @@ def __repr__(self):
def year_list(self):
return sorted(set([to_date(x).year for x in self.dates]))

def build_idpath(self): # This may be needed for dynamic update of COLLECTIONS
self.idpath = [os.path.join(self.dbpath, f'{x}_ids') for x in self.collection_list]
return self.idpath

def tape_at_date(self, dt, which_tape=0):
then_date = dt.date()
then = then_date.strftime('%Y-%m-%d')
Expand Down Expand Up @@ -1490,7 +1500,7 @@ def __init__(self, state, interval: float, event: Event, scr=None, lock: Optiona
self.scr = scr
self.stop_on_exception = stop_on_exception
self.last_update_time = datetime.datetime.now()
self.min_time_between_updates = 6 * 3600
self.min_time_between_updates = 5 * 3600

def check_for_updates(self, playstate) -> bool:
"""Check for updates.
Expand Down
44 changes: 24 additions & 20 deletions timemachine/bin/make_image.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash -x

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
version=v2
Expand Down Expand Up @@ -51,38 +51,42 @@ system () {


echo "Removing previous git folders"
system "cd $media_folder/rootfs/home/deadhead"
cd $media_folder/rootfs/home/deadhead
current_env=$(basename `readlink -f timemachine`)
files=`find . -maxdepth 1 -mindepth 1 -name env_\* -a -not -name $current_env -printf "%f "`
system "sudo rm -rf $files"
system "sudo mv .knob_sense $HOME/.knob_sense"
system "sudo mv .timemachine_options.txt $HOME/.timemachine_options.txt"
system "sudo mv .ssh $HOME/timemachine_dot_ssh"
system "sudo rm -rf .ssh .bash_history .python_history .viminfo .wget-hsts .gnupg .lesshst .ipython .local .gitconfig .xsession*"
system "sudo rm -rf .factory_env"
system "sudo cp -r $current_env .factory_env"
system "sudo cp $HOME/test_sound.ogg ."
sudo rm -rf $files
sudo mv .knob_sense $HOME/.knob_sense
sudo mv .timemachine_options.txt $HOME/.timemachine_options.txt
sudo mv .ssh $HOME/timemachine_dot_ssh
sudo rm -rf .ssh .bash_history .python_history .viminfo .wget-hsts .gnupg .lesshst .ipython .local .gitconfig .xsession*
sudo rm -rf .factory_env
sudo cp -r $current_env .factory_env
sudo cp $HOME/test_sound.ogg .


echo "Removing wpa_supplicant"
system "sudo mv $media_folder/rootfs/etc/wpa_supplicant/wpa_supplicant.conf $HOME/wpa_supplicant.conf"
system "sudo rm $media_folder/rootfs/etc/wpa_supplicant/wpa_supplicant.conf*"
#echo "Removing wpa_supplicant"
#sudo mv $media_folder/rootfs/etc/wpa_supplicant/wpa_supplicant.conf $HOME/wpa_supplicant.conf
#sudo rm $media_folder/rootfs/etc/wpa_supplicant/wpa_supplicant.conf*
wpa_supplicant_path=$HOME/wpa_supplicant.conf
if [ -f $wpa_supplicant_path ]; then
sudo cp $wpa_supplicant_path $media_folder/rootfs/etc/wpa_supplicant/wpa_supplicant.conf
fi

media_dirs="/dev/sdb1 /dev/sdb2"

for dir in $media_dirs; do
system "sudo umount $dir"
sudo umount $dir
done

system "sudo rm $image_file"
sudo rm $image_file
critical_command "sudo dd if=/dev/sdb of=$image_file bs=4M status=progress"

system "sudo pishrink.sh $image_file"
sudo pishrink.sh $image_file
echo "Replacing wpa_supplicant and knob_sense files"
system "sudo mv $HOME/wpa_supplicant.conf $media_folder/rootfs/etc/wpa_supplicant/wpa_supplicant.conf"
system "sudo mv $HOME/.knob_sense $media_folder/rootfs/home/deadhead/."
system "sudo mv $HOME/.timemachine_options.txt $media_folder/rootfs/home/deadhead/."
system "sudo mv $HOME/timemachine_dot_ssh $media_folder/rootfs/home/deadhead/.ssh"
sudo mv $HOME/wpa_supplicant.conf $media_folder/rootfs/etc/wpa_supplicant/wpa_supplicant.conf
sudo mv $HOME/.knob_sense $media_folder/rootfs/home/deadhead/.
sudo mv $HOME/.timemachine_options.txt $media_folder/rootfs/home/deadhead/.
sudo mv $HOME/timemachine_dot_ssh $media_folder/rootfs/home/deadhead/.ssh

# NOTE: to burn an image use the command (or similar):
# sudo sh -c "pv v2_20210625.img > /dev/sdb"
Expand Down
11 changes: 9 additions & 2 deletions timemachine/livemusic.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,12 @@ def select_button_longpress(button, state):
for i in range(0, max(1, len(tape_id)), 2):
show_venue_text(tapes[itape], color=id_color, show_id=True, offset=i, force=True)
# TMB.scr.show_venue(tape_id[i:], color=id_color, force=True)
sleep(0.25)
if not button.is_held:
break
tape_id = tapes[itape].identifier
sbd = tapes[itape].stream_only()
id_color = (0, 255, 255) if sbd else (0, 0, 255)
TMB.scr.show_venue(tape_id, color=id_color)
tape = tapes[itape]
state = select_tape(tape, state, autoplay=AUTO_PLAY)
Expand Down Expand Up @@ -1028,8 +1032,11 @@ def main(parms_arg):
archive_updater.start()
if config.UPDATE_COLLECTIONS:
archive_updater.update() # Do it now
eloop.run()
exit()
if parms.debug:
eloop.start()
else:
eloop.run()
sys.exit()


def main_test_update(parms_arg):
Expand Down

0 comments on commit b906da1

Please sign in to comment.