Skip to content

Commit

Permalink
Merge pull request #1 from UniversityRadioYork/dev
Browse files Browse the repository at this point in the history
This is BAPS3 (3.0.0 Release)
  • Loading branch information
mstratford authored May 27, 2021
2 parents 7435eca + e821df5 commit 7d2757a
Show file tree
Hide file tree
Showing 101 changed files with 4,441 additions and 73,394 deletions.
86 changes: 67 additions & 19 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,83 @@
name: Python package

name: Package
on: [push]

jobs:
build:
build-macos:

runs-on: ubuntu-latest
runs-on: macos-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8]
python-version: [3.9]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
- name: Build .app
run: |
python -m pip install --upgrade pip
pip install flake8
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install bapsicle as module
run: |
pip install -e .
- name: Lint with flake8
npm run presenter-make
build/build-macos.sh
zip -r build/output/BAPSicle.zip build/output/BAPSicle.app
- name: Archive Build
uses: actions/upload-artifact@v2
with:
name: Package - MacOS
path: |
build/output/BAPSicle.zip
build-ubuntu:

runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
python-version: [3.9]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Build executable
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with unittest
npm run presenter-make
build/build-linux.sh
- name: Archive Build
uses: actions/upload-artifact@v2
with:
name: Package - Ubuntu
path: |
build/output/BAPSicle
build-windows:

runs-on: windows-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
python-version: [3.9]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Build .exe
run: |
python -m unittest
npm run presenter-make
build/build-windows.bat no-venv
- name: Archive Build
uses: actions/upload-artifact@v2
with:
name: Package - Windows
path: |
build/output/BAPSicle.exe
install/
50 changes: 50 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Python test

on: [push]

jobs:
test-macos:

runs-on: macos-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
pip install -r build/requirements.txt
pip install -r build/requirements-macos.txt
- name: Install bapsicle as module
run: |
pip install -e .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --ignore=E402,E226,E24,W50,W690 --max-complexity=20 --max-line-length=127 --statistics
- name: Test with unittest
if: ${{ always() }}
timeout-minutes: 10
run: |
python -m sounddevice
python -m unittest
- name: Archive test logs
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: Logs - Python ${{ matrix.python-version }}
path: |
logs/*
25 changes: 14 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@


.vscode/settings.json

__pycache__/

state/

*.egg-info/
*.pyo
venv/

build/build-exe-config.json
build/build-exe-pyinstaller-command.bat
build/build-exe-pyinstaller-command.sh
build/BAPSicle.platypus
build/build/BAPSicle/
build/output/
*.spec

install/*.exe
install/nssm

*.pyo

*.spec
build.py

build/build-exe-pyinstaller-command.bat
dev/welcome.mp3

build/build/BAPSicle/
music-tmp/

build/output/

build/build-exe-pyinstaller-command.sh
presenter-build
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "presenter"]
path = presenter
url = https://github.com/michael-grace/WebStudio.git
10 changes: 5 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
"version": "0.2.0",
"configurations": [
{
"name": "Python: Launch Player Standalone",
"name": "Python: Launch Server",
"type": "python",
"request": "launch",
"program": "./player.py",
"program": "./launch.py",
"console": "integratedTerminal"
},
{
"name": "Python: Launch Server Standalone",
"name": "Python: Launch Tests: Player",
"type": "python",
"request": "launch",
"program": "./launch_standalone.py",
"module": "tests.test_player",
"console": "integratedTerminal"
}
]
}
}
31 changes: 18 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# BAPSicle

### a.k.a. The Next-Gen BAPS server

!["BAPSicle logo, a pink melting ice lolly."](docs/images/logo.png "BAPSicle Logo")
Expand All @@ -11,20 +12,21 @@ Just want to install BAPSicle?

### Windows

Currently there's just a batch script. Simply run ``install.bat`` as administrator. If you've just built BAPSicle yourself, it'll be in the ``/install`` folder.
Currently there's just a batch script. Simply run `install.bat` as administrator. If you've just built BAPSicle yourself, it'll be in the `/install` folder.

This will:
* Copy BAPSicle into ``C:\Program Files\BAPSicle``
* Install BAPSicle.exe as a Windows Service with NSSM.
* If all goes well, open [http://localhost:13500](localhost:13500) for the server UI.

- Copy BAPSicle into `C:\Program Files\BAPSicle`
- Install BAPSicle.exe as a Windows Service with NSSM.
- If all goes well, open [http://localhost:13500](localhost:13500) for the server UI.

### Linux

Installed service for linux is coming soon. Testing is primarily on Ubuntu 20.04. Your milage with other distros will vary.

### MacOS

Currently there's no installer for MacOS, so you'll have to move the ``build/output/BAPSicle.app`` you've built and make it start automatically (if you want).
Currently there's no installer for MacOS, so you'll have to move the `build/output/BAPSicle.app` you've built and make it start automatically (if you want).

Starting and stopping the server, as well as UI links, are available in the System Menu once opening the app.

Expand All @@ -35,29 +37,32 @@ Starting and stopping the server, as well as UI links, are available in the Syst
### Requirements

On all platforms:
* Python 3.7 (3.8 may also work, 3.9 is unlikely to.)
* Git (Obviously)

- Python 3.8 - 3.9 Tested
- Git (Obviously)

On MacOS:
* Homebrew (To install command line Platypus)

- Homebrew (To install command line Platypus)

### Running
To just run the server standaline without installing, run ``python ./launch_standalone.py``.

To just run the server standalone without installing, run `python ./launch.py`.

## Building

### Windows

To build a ``BAPSicle.exe``, run ``build\build-exe.bat``. The resulting file will appear in ``build\output``. You can then use the install instructions above to install it, or just run it standalone.
To build a `BAPSicle.exe`, run `build\build-exe.bat`. The resulting file will appear in `build\output`. You can then use the install instructions above to install it, or just run it standalone.

### Linux

To build a ``BAPSicle`` executable, run ``build/build-linux.sh``. The resulting file will appear in ``build/output``.
To build a `BAPSicle` executable, run `build/build-linux.sh`. The resulting file will appear in `build/output`.

### MacOS

To build a ``BAPSicle.app``, run ``build/build-macos.sh``. The resulting file will appear in ``build/output``.
To build a `BAPSicle.app`, run `build/build-macos.sh`. The resulting file will appear in `build/output`.

### Other bits

Provided is a VScode debug config to let you debug live, as well as ``dev\install-githook.{bat,sh}`` that will help git to clean your code up as you're committing!
Provided is a VScode debug config to let you debug live, as well as `dev\install-githook.{bat,sh}` that will help git to clean your code up as you're committing!
5 changes: 3 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# see
import logging

logging.getLogger(__name__).addHandler(logging.NullHandler())
logging.basicConfig(filename='bapsicle_log.log', level=logging.INFO)
logging.info('Started Logging')
logging.basicConfig(filename="bapsicle_log.log", level=logging.INFO)
logging.info("Started Logging")
Empty file added baps_types/__init__.py
Empty file.
68 changes: 68 additions & 0 deletions baps_types/marker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import json
from typing import Dict, Literal, Optional, Union

POSITIONS = ["start", "mid", "end"]
PARAMS = ["name", "time", "position", "section"]


class Marker:
marker: Dict

def __init__(self, new_marker: Union[str, dict]):
marker: dict
try:
if isinstance(new_marker, str):
marker = json.loads(new_marker)
else:
marker = new_marker
except Exception as e:
raise ValueError("Failed to decode JSON for marker: {}".format(e))

for key in marker.keys():
if key not in PARAMS:
raise ValueError("Key {} is not a valid marker parameter.".format(key))

if not isinstance(marker["name"], str):
raise ValueError("Name is not str.")

if not (isinstance(marker["time"], int) or isinstance(marker["time"], float)):
raise ValueError("Time is not a float or int")

if marker["position"] not in POSITIONS:
raise ValueError("Position is not in allowed values.")

if not (marker["section"] is None or isinstance(marker["section"], str)):
raise ValueError("Section name is not str or None.")

marker["time"] = float(marker["time"])
# If everything checks out, let's save it.
self.marker = marker

@property
def __str__(self) -> str:
return json.dumps(self.marker)

@property
def __dict__(self) -> dict:
return self.marker

@property
def name(self) -> str:
return self.marker["name"]

@property
def time(self) -> float:
return float(self.marker["time"])

@property
def position(self) -> str:
return self.marker["position"]

@property
def section(self) -> Optional[str]:
return self.marker["section"]

def same_type(self, o: object) -> bool:
if not isinstance(o, Marker):
return False
return o.position == self.position and o.section == self.section
Loading

0 comments on commit 7d2757a

Please sign in to comment.