Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/future3/develop' into fu…
Browse files Browse the repository at this point in the history
…ture3/feature/docstring2markdown
  • Loading branch information
s-martin committed Dec 10, 2023
2 parents 53092e3 + 02c63ed commit b65a926
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 40 deletions.
1 change: 1 addition & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ services:
restart: unless-stopped
tty: true
volumes:
- ../src/jukebox:/root/RPi-Jukebox-RFID/src/jukebox
- ../shared:/root/RPi-Jukebox-RFID/shared
- ./config/docker.pulse.mpd.conf:/root/.config/mpd/mpd.conf
command: python run_jukebox.py
Expand Down
2 changes: 1 addition & 1 deletion documentation/developers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Getting started

* [Development Environment](./development-environment.md)
* [Setting up Docker](./docker.md)
* [Python Development Notes](pyhton.md)

## Reference

Expand Down
59 changes: 22 additions & 37 deletions documentation/developers/development-environment.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
# Development Environment

You have 3 development options:

## Directly on Raspberry Pi

The full setup is running on the RPi and you access files via SSH.
Pretty easy to set up as you simply do a normal install and switch to
the `future3/develop` branch.
You have 3 development options. Each option has its pros and cons. To interact with GPIO or other hardware, it's required to develop directly on a Raspberry Pi. For general development of Python code (Jukebox) or JavaScript (Webapp), we recommend Docker. Developing on your local machine (Linux, Mac, Windows) works as well and requires all dependencies to be installed locally.

* [Develop in Docker](#develop-in-docker)
* [Develop on Raspberry Pi](#develop-on-raspberry-pi)
* [Develop on local machine](#develop-on-local-machine)

## Develop in Docker

There is a complete [Docker setup](./docker.md).

## Develop on Raspberry Pi

The full setup is running on the RPi and you access files via SSH. Pretty easy to set up as you simply do a normal install and switch to the `future3/develop` branch.

### Steps to install

We recommend to use at least a Pi 3 or Pi Zero 2 for development. This
hardware won\'t be needed in production, but it can be slow while
developing.
We recommend to use at least a Pi 3 or Pi Zero 2 for development. This hardware won\'t be needed in production, but it can be slow while developing.

1. Install the latest Pi OS on a SD card.
2. Boot up your Raspberry Pi.
3. [Install](../builders/installation.md) the Jukebox software as if you were building a
Phoniebox. You can install from your own fork and feature branch if
you wish which can be changed later as well. The original repository
will be set as `upstream`.
3. [Install](../builders/installation.md) the Jukebox software as if you were building a Phoniebox. You can install from your own fork and feature branch you wish which can be changed later as well. The original repository will be set as `upstream`.
4. Once the installation has successfully ran, reboot your Pi.
5. Due to some resource constraints, the Webapp does not build the
latest changes and instead consumes the latest official release. To
change that, you need to install NodeJS and build the Webapp
locally.
5. Due to some resource constraints, the Webapp does not build the latest changes and instead consumes the latest official release. To change that, you need to install NodeJS and build the Webapp locally.
6. Install NodeJS using the existing installer

``` bash
Expand All @@ -34,39 +34,24 @@ developing.
```

7. To free up RAM, reboot your Pi.
8. Build the Webapp using the existing build command. If the build
fails, you might have forgotten to reboot.
8. Build the Webapp using the existing build command. If the build fails, you might have forgotten to reboot.

``` bash
cd ~/RPi-Jukebox-RFID/src/webapp; \
./run_rebuild.sh -u
```

9. The Webapp should now be updated.
10. To continuously update Webapp, pull the latest changes from your
repository and rerun the command above.
10. To continuously update Webapp, pull the latest changes from your repository and rerun the command above.

## Locally on any Linux machine
## Develop on local machine

The jukebox also runs on any Linux machine. The Raspberry Pi specific
stuff will not work of course. That is no issue depending our your
development area. USB RFID Readers, however, will work. You will have
to install and configure [MPD (Music Player
Daemon)](https://www.musicpd.org/).
The jukebox also runs on any Linux machine. The Raspberry Pi specific stuff will not work of course. That is no issue depending our your development area. USB RFID Readers, however, will work. You will have to install and configure [MPD (Music Player Daemon)](https://www.musicpd.org/).

In addition to the `requirements.txt`, you will this
dependency. On the Raspberry PI, the latest stable release of ZMQ does
not support WebSockets. We need to compile the latest version from
Github, which is taken care of by the installation script. For regular
machines, the normal package can be installed:
In addition to the `requirements.txt`, you will this dependency. On the Raspberry PI, the latest stable release of ZMQ does not support WebSockets. We need to compile the latest version from Github, which is taken care of by the installation script. For regular machines, the normal package can be installed:

``` bash
pip install pyzmq
```

You will have to start Jukebox core application and the WebUI
separately. The MPD usually runs as a service.

## Using Docker container

There is a complete [Docker setup](./docker.md).
You will have to start Jukebox core application and the WebUI separately. The MPD usually runs as a service.
18 changes: 18 additions & 0 deletions documentation/developers/pyhton.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Python Development Notes

## Prerequisites

> [!NOTE]
> All Python scripts must be run within a [virtual environment](https://docs.python.org/3/library/venv.html) (`.venv`). All Python plugins are installed encapsulated within this environment.
Before you can run Python code, you need to enable the virtual environment. On the Raspberry Pi, it's located in the project root `~/RPi-Jukebox-RFID/.venv`. Depending on your setup, the absolute path can vary.

```
$ ~/RPi-Jukebox-RFID/.venv/bin/activate
```

If the virtual environment has been activated correctly, your terminal will now show a prefix (`.venv`). If you want to leave the venv again execute deactivate.

```
$ ~/RPi-Jukebox-RFID/.venv/bin/deactivate
```
6 changes: 6 additions & 0 deletions src/jukebox/components/playermpd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
# Toggle (und 2nd Swipe generell) ist immer vom Status des Zielsystems abhängig und kann damit nur vom Zielsystem geändert
# werden. Bei Wifi also braucht man 3 Funktionen: on / off / toggle. Toggle ist dann first swipe / second swipe

import os
import mpd
import threading
import logging
Expand Down Expand Up @@ -574,6 +575,11 @@ def list_song_by_artist_and_album(self, albumartist, album):

@plugs.tag
def get_song_by_url(self, song_url):
# MPD can play absolute paths but can find songs in its database only by relative path
# In certain situations, `song_url` can be an absolute path. Then, it will be trimed to be relative
_music_library_path_absolute = os.path.expanduser(components.player.get_music_library_path())
song_url = song_url.replace(f'{_music_library_path_absolute}/', '')

with self.mpd_lock:
song = self.mpd_retry_with_mutex(self.mpd_client.find, 'file', song_url)

Expand Down
4 changes: 2 additions & 2 deletions src/webapp/src/components/Library/lists/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const LibraryLists = () => {
const [cardId] = useState(searchParams.get('cardId'));
const [musicFilter, setMusicFilter] = useState('');

const handleMusicFilder = (event) => {
const handleMusicFolder = (event) => {
setMusicFilter(event.target.value);
};

Expand All @@ -49,7 +49,7 @@ const LibraryLists = () => {
{isSelecting && <SelectorHeader />}
<Grid container sx={{ padding: '10px' }}>
<LibraryHeader
handleMusicFilder={handleMusicFilder}
handleMusicFolder={handleMusicFolder}
musicFilter={musicFilter}
/>
<Grid
Expand Down

0 comments on commit b65a926

Please sign in to comment.