Improve packaging, use package.json for all package info
This commit is contained in:
parent
c13e2105da
commit
2c498ff65c
17 changed files with 95 additions and 39 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -9,6 +9,7 @@ venv/
|
||||||
build/build-exe-config.json
|
build/build-exe-config.json
|
||||||
build/build-exe-pyinstaller-command.bat
|
build/build-exe-pyinstaller-command.bat
|
||||||
build/build-exe-pyinstaller-command.sh
|
build/build-exe-pyinstaller-command.sh
|
||||||
|
build/BAPSicle.platypus
|
||||||
build/build/BAPSicle/
|
build/build/BAPSicle/
|
||||||
build/output/
|
build/output/
|
||||||
*.spec
|
*.spec
|
||||||
|
|
|
@ -76,7 +76,11 @@
|
||||||
{
|
{
|
||||||
"optionDest": "datas",
|
"optionDest": "datas",
|
||||||
"value": "/presenter-build;presenter-build/"
|
"value": "/presenter-build;presenter-build/"
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"optionDest": "datas",
|
||||||
|
"value": "/package.json;./"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"nonPyinstallerOptions": {
|
"nonPyinstallerOptions": {
|
||||||
"increaseRecursionLimit": false,
|
"increaseRecursionLimit": false,
|
||||||
|
|
|
@ -21,3 +21,5 @@ bash ./build-exe-pyinstaller-command.sh
|
||||||
|
|
||||||
rm ./*.spec
|
rm ./*.spec
|
||||||
|
|
||||||
|
rm ../build.py
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ cd "$(dirname "$0")"
|
||||||
|
|
||||||
build_commit="$(git rev-parse --short HEAD)"
|
build_commit="$(git rev-parse --short HEAD)"
|
||||||
echo "BUILD: str = \"$build_commit\"" > ../build.py
|
echo "BUILD: str = \"$build_commit\"" > ../build.py
|
||||||
sed -i '' -e "s/BUILD_COMMIT/$build_commit/" "../config.py"
|
|
||||||
|
|
||||||
python3 -m venv ../venv
|
python3 -m venv ../venv
|
||||||
source ../venv/bin/activate
|
source ../venv/bin/activate
|
||||||
|
@ -20,6 +19,12 @@ bash ./build-exe-pyinstaller-command.sh
|
||||||
|
|
||||||
rm ./*.spec
|
rm ./*.spec
|
||||||
|
|
||||||
|
cd ../
|
||||||
|
python3 build/generate-platypus-config.py
|
||||||
|
cd build
|
||||||
|
|
||||||
brew install platypus
|
brew install platypus
|
||||||
|
|
||||||
platypus --load-profile ./BAPSicle.platypus --overwrite ./output/BAPSicle.app
|
platypus --load-profile ./BAPSicle.platypus --overwrite ./output/BAPSicle.app
|
||||||
|
|
||||||
|
rm ../build.py
|
||||||
|
|
|
@ -28,5 +28,7 @@ build-exe-pyinstaller-command.bat
|
||||||
|
|
||||||
del *.spec /q
|
del *.spec /q
|
||||||
|
|
||||||
|
del ..\build.py /q
|
||||||
|
|
||||||
echo "Output file should be located in 'output/' folder."
|
echo "Output file should be located in 'output/' folder."
|
||||||
TIMEOUT 5
|
TIMEOUT 5
|
||||||
|
|
16
build/generate-platypus-config.py
Executable file
16
build/generate-platypus-config.py
Executable file
|
@ -0,0 +1,16 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
from plistlib import load, dump
|
||||||
|
import package
|
||||||
|
import os
|
||||||
|
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
with open(dir_path + "/BAPSicle.template.platypus", 'rb') as temp:
|
||||||
|
pl = load(temp)
|
||||||
|
pl["Version"] = "{}~{}".format(package.VERSION, package.BUILD)
|
||||||
|
pl["Name"] = package.NICE_NAME
|
||||||
|
pl["StatusItemTitle"] = package.NICE_NAME
|
||||||
|
pl["Author"] = package.AUTHOR
|
||||||
|
pl["Identifier"] = "org.{}.{}".format(package.AUTHOR.lower().replace(" ", ""), package.NAME)
|
||||||
|
|
||||||
|
with open(dir_path + "/BAPSicle.platypus", 'wb') as out:
|
||||||
|
dump(pl, out)
|
|
@ -1,25 +1,26 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
if [ "$1" == "" ]
|
if [ "$1" == "" ]; then
|
||||||
then
|
|
||||||
echo "DISABLED|BAPSicle Server"
|
echo "DISABLED|BAPSicle Server"
|
||||||
|
echo "----"
|
||||||
|
if curl --output /dev/null --silent --fail --max-time 1 "http://localhost:13500/"
|
||||||
|
then
|
||||||
|
echo "Presenter"
|
||||||
|
echo "Server"
|
||||||
echo "----"
|
echo "----"
|
||||||
if curl --output /dev/null --silent --head --fail --max-time 1 "http://localhost:13500"
|
echo "Restart Server"
|
||||||
then
|
echo "Stop Server"
|
||||||
echo "Presenter"
|
else
|
||||||
echo "Server"
|
echo "DISABLED|Presenter"
|
||||||
echo "----"
|
echo "DISABLED|Server"
|
||||||
echo "Stop Server"
|
echo "----"
|
||||||
else
|
echo "Start Server"
|
||||||
echo "DISABLED|Presenter"
|
fi
|
||||||
echo "DISABLED|Server"
|
|
||||||
echo "----"
|
|
||||||
echo "Start Server"
|
|
||||||
fi
|
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
if [ "$1" == "Stop Server" ]
|
if [ "$1" == "Stop Server" ]; then
|
||||||
then
|
curl --output /dev/null --silent "http://localhost:13500/quit"
|
||||||
curl "http://localhost:13500/quit"
|
elif [ "$1" == "Restart Server" ]; then
|
||||||
|
curl --output /dev/null --silent "http://localhost:13500/restart"
|
||||||
else
|
else
|
||||||
./BAPSicle "$1"
|
./BAPSicle "$1"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
# BAPSicle Details
|
|
||||||
VERSION: str = "0.1.0"
|
|
|
@ -31,7 +31,6 @@ def resolve_local_file_path(relative_path: str):
|
||||||
try:
|
try:
|
||||||
# PyInstaller creates a temp folder and stores path in _MEIPASS
|
# PyInstaller creates a temp folder and stores path in _MEIPASS
|
||||||
base_path: str = sys._MEIPASS
|
base_path: str = sys._MEIPASS
|
||||||
print("MEI", base_path)
|
|
||||||
except Exception:
|
except Exception:
|
||||||
base_path = os.path.abspath(".")
|
base_path = os.path.abspath(".")
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,13 @@ from typing import Any
|
||||||
import webbrowser
|
import webbrowser
|
||||||
from setproctitle import setproctitle
|
from setproctitle import setproctitle
|
||||||
|
|
||||||
from server import BAPSicleServer
|
|
||||||
from helpers.the_terminator import Terminator
|
from helpers.the_terminator import Terminator
|
||||||
|
|
||||||
|
|
||||||
def startServer(notifications=False):
|
def startServer(notifications=False):
|
||||||
|
# Only spend the time importing the Server if we want to start the server. Speeds up web browser opens.
|
||||||
|
from server import BAPSicleServer
|
||||||
|
|
||||||
server = multiprocessing.Process(target=BAPSicleServer)
|
server = multiprocessing.Process(target=BAPSicleServer)
|
||||||
server.start()
|
server.start()
|
||||||
|
|
||||||
|
@ -60,6 +62,7 @@ if __name__ == "__main__":
|
||||||
# We got an argument! It's probably Platypus's UI.
|
# We got an argument! It's probably Platypus's UI.
|
||||||
try:
|
try:
|
||||||
if (sys.argv[1]) == "Start Server":
|
if (sys.argv[1]) == "Start Server":
|
||||||
|
print("NOTIFICATION:BAPSicle is starting, please wait...")
|
||||||
webbrowser.open("http://localhost:13500/")
|
webbrowser.open("http://localhost:13500/")
|
||||||
startServer(notifications=True)
|
startServer(notifications=True)
|
||||||
if sys.argv[1] == "Server":
|
if sys.argv[1] == "Server":
|
||||||
|
@ -67,7 +70,7 @@ if __name__ == "__main__":
|
||||||
if sys.argv[1] == "Presenter":
|
if sys.argv[1] == "Presenter":
|
||||||
webbrowser.open("http://localhost:13500/presenter/")
|
webbrowser.open("http://localhost:13500/presenter/")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("ALERT:BAPSicle failed with exception:\n", e)
|
print("ALERT:BAPSicle failed with exception of type {}:\n{}".format(type(e).__name__, str(e)))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
{
|
{
|
||||||
"name": "bapsicle",
|
"name": "bapsicle",
|
||||||
|
"nice_name": "BAPSicle",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"description": "Broadcast Playout System",
|
"description": "BAPS3, the third generation of University Radio York's Broadcast and Presenting Suite. This package includes the Server (BAPSicle) and Presenter (WebStudio)",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
"doc": "docs",
|
"doc": "docs",
|
||||||
|
@ -17,7 +18,7 @@
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/universityradioyork/bapsicle.git"
|
"url": "git+https://github.com/universityradioyork/bapsicle.git"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "University Radio York",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/universityradioyork/bapsicle/issues"
|
"url": "https://github.com/universityradioyork/bapsicle/issues"
|
||||||
|
|
20
package.py
Normal file
20
package.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# BAPSicle Details
|
||||||
|
from json import loads
|
||||||
|
from helpers.os_environment import resolve_local_file_path
|
||||||
|
|
||||||
|
with open(resolve_local_file_path("package.json")) as file:
|
||||||
|
config = loads(file.read())
|
||||||
|
VERSION: str = config["version"]
|
||||||
|
NAME: str = config["name"]
|
||||||
|
NICE_NAME: str = config["nice_name"]
|
||||||
|
DESCRIPTION: str = config["description"]
|
||||||
|
AUTHOR: str = config["author"]
|
||||||
|
LICENSE: str = config["license"]
|
||||||
|
|
||||||
|
build_commit = "Dev"
|
||||||
|
try:
|
||||||
|
import build
|
||||||
|
build_commit = build.BUILD
|
||||||
|
except (ModuleNotFoundError, AttributeError):
|
||||||
|
pass
|
||||||
|
BUILD: str = build_commit
|
12
server.py
12
server.py
|
@ -28,7 +28,7 @@ if not isMacOS():
|
||||||
if isBundelled():
|
if isBundelled():
|
||||||
import build
|
import build
|
||||||
|
|
||||||
import config
|
import package
|
||||||
from typing import Dict, List
|
from typing import Dict, List
|
||||||
from helpers.state_manager import StateManager
|
from helpers.state_manager import StateManager
|
||||||
from helpers.logging_manager import LoggingManager
|
from helpers.logging_manager import LoggingManager
|
||||||
|
@ -162,15 +162,11 @@ class BAPSicleServer:
|
||||||
|
|
||||||
self.state.update("running_state", "running")
|
self.state.update("running_state", "running")
|
||||||
|
|
||||||
build_commit = "Dev"
|
|
||||||
if isBundelled():
|
|
||||||
build_commit = build.BUILD
|
|
||||||
|
|
||||||
print("Launching BAPSicle...")
|
print("Launching BAPSicle...")
|
||||||
|
|
||||||
# TODO: Check these match, if not, trigger any upgrade noticies / welcome
|
# TODO: Check these match, if not, trigger any upgrade noticies / welcome
|
||||||
self.state.update("server_version", config.VERSION)
|
self.state.update("server_version", package.VERSION)
|
||||||
self.state.update("server_build", build_commit)
|
self.state.update("server_build", package.BUILD)
|
||||||
|
|
||||||
channel_count = self.state.get()["num_channels"]
|
channel_count = self.state.get()["num_channels"]
|
||||||
self.player = [None] * channel_count
|
self.player = [None] * channel_count
|
||||||
|
@ -183,7 +179,7 @@ class BAPSicleServer:
|
||||||
self.websocket_to_q.append(multiprocessing.Queue())
|
self.websocket_to_q.append(multiprocessing.Queue())
|
||||||
self.controller_to_q.append(multiprocessing.Queue())
|
self.controller_to_q.append(multiprocessing.Queue())
|
||||||
|
|
||||||
print("Welcome to BAPSicle Server version: {}, build: {}.".format(config.VERSION, build_commit))
|
print("Welcome to BAPSicle Server version: {}, build: {}.".format(package.VERSION, package.BUILD))
|
||||||
print("The Server UI is available at http://{}:{}".format(self.state.get()["host"], self.state.get()["port"]))
|
print("The Server UI is available at http://{}:{}".format(self.state.get()["host"], self.state.get()["port"]))
|
||||||
|
|
||||||
# TODO Move this to player or installer.
|
# TODO Move this to player or installer.
|
||||||
|
|
9
setup.py
9
setup.py
|
@ -1,3 +1,10 @@
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
import package
|
||||||
|
|
||||||
setup(name="bapsicle", version="0.0.1", packages=find_packages())
|
setup(
|
||||||
|
name=package.NAME,
|
||||||
|
version=package.VERSION,
|
||||||
|
description=package.DESCRIPTION,
|
||||||
|
author=package.AUTHOR,
|
||||||
|
license=package.LICENSE,
|
||||||
|
packages=find_packages())
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
{% block head %}
|
{% block head %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
<title>BAPSicle {% if data.ui_title %} | {{data.ui_title}}{% endif %}</title>
|
<title>BAPSicle{% if data.ui_title %} | {{data.ui_title}}{% endif %}</title>
|
||||||
|
|
||||||
<!-- Custom fonts for this template-->
|
<!-- Custom fonts for this template-->
|
||||||
<link href="/static/vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
|
<link href="/static/vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
|
||||||
|
|
|
@ -20,7 +20,7 @@ from time import sleep
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from helpers.os_environment import resolve_local_file_path
|
from helpers.os_environment import isBundelled, resolve_local_file_path
|
||||||
from helpers.logging_manager import LoggingManager
|
from helpers.logging_manager import LoggingManager
|
||||||
from helpers.device_manager import DeviceManager
|
from helpers.device_manager import DeviceManager
|
||||||
from helpers.state_manager import StateManager
|
from helpers.state_manager import StateManager
|
||||||
|
@ -386,8 +386,9 @@ def WebServer(player_to: List[Queue], player_from: List[Queue], state: StateMana
|
||||||
sync(app.run(
|
sync(app.run(
|
||||||
host=server_state.get()["host"],
|
host=server_state.get()["host"],
|
||||||
port=server_state.get()["port"],
|
port=server_state.get()["port"],
|
||||||
debug=True,
|
debug=(not isBundelled()),
|
||||||
auto_reload=False
|
auto_reload=False,
|
||||||
|
access_log=(not isBundelled())
|
||||||
))
|
))
|
||||||
except Exception:
|
except Exception:
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in a new issue