Skip to content

Commit aecff22

Browse files
authored
Merge pull request #2 from mikecarr/settings-file
Settings file
2 parents 603d96b + 55ee212 commit aecff22

File tree

20 files changed

+166
-174
lines changed

20 files changed

+166
-174
lines changed

.github/workflows/release.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ name: Build and Release
33
on:
44
push:
55
tags:
6-
- 'v*.*.*' # This will trigger the workflow on version tags, e.g., v1.0.0
6+
- 'v*.*.*'
77

88
jobs:
99
build:
1010
runs-on: ubuntu-latest
11-
permissions:
12-
contents: write
1311

1412
steps:
1513
- name: Checkout code
@@ -18,21 +16,21 @@ jobs:
1816
- name: Set up Python
1917
uses: actions/setup-python@v2
2018
with:
21-
python-version: '3.8' # Specify your Python version
19+
python-version: '3.8'
20+
21+
- name: Get version from tag
22+
id: vars
23+
run: echo "VERSION=${GITHUB_REF#refs/tags/} >> $GITHUB_ENV"
2224

2325
- name: Install dependencies
2426
run: |
2527
python -m pip install --upgrade pip
26-
pip install setuptools wheel
28+
pip install setuptools wheel setuptools-scm
2729
2830
- name: Build package
2931
run: |
3032
python setup.py sdist bdist_wheel
3133
32-
- name: "Build Changelog"
33-
id: build_changelog
34-
uses: mikepenz/release-changelog-builder-action@v5
35-
3634
- name: Upload Package to Release
3735
uses: softprops/action-gh-release@v1
3836
with:

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ I wanted an easy way to edit files and watch videos on the Radxa
88
python -m venv .venv
99
source .venv/bin/activate
1010
pip install -r requirements.txt
11+
12+
echo "FLASK_ENV=development > .env"
1113
```
1214

1315

@@ -24,6 +26,9 @@ Video file selector
2426
Player
2527
![alt text](images/v_player.png)
2628

29+
Journalctl -f
30+
![alt text](images/journal.png)
31+
2732

2833
### Packaging
2934
```bash

images/editor.png

-27.4 KB
Loading

images/home.png

61.6 KB
Loading

images/journal.png

252 KB
Loading

images/v_player.png

4.32 MB
Loading

images/v_select.png

45.6 KB
Loading

py_config_gs/app.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import json
44
import os
55
import subprocess
6+
from importlib.metadata import version
7+
8+
9+
app_version = version('py-config-gs')
610

711
# Configure logging
812
logging.basicConfig(level=logging.DEBUG, # Set the log level to DEBUG
@@ -12,15 +16,25 @@
1216
app = Flask(__name__)
1317

1418
#SETTINGS_FILE = "/Users/mcarr/config/settings.json"
15-
SETTINGS_FILE = "/config/settings.json"
19+
#SETTINGS_FILE = "/config/settings.json"
20+
if os.getenv('FLASK_ENV') == 'development':
21+
# In development, use the home folder settings file
22+
SETTINGS_FILE = os.path.expanduser('~/config/settings.json')
23+
else:
24+
# In production, use the config folder
25+
SETTINGS_FILE = '/config/settings.json'
26+
27+
# Log the SETTINGS_FILE path
28+
logger.info(f'Settings file path: {SETTINGS_FILE}')
29+
logger.info(f'App version: {app_version}')
1630

1731
# Load settings.json
1832
with open(SETTINGS_FILE, 'r') as f:
1933
settings = json.load(f)
2034

2135
# Access configuration files and video directory
2236
config_files = settings['config_files']
23-
VIDEO_DIR = settings['VIDEO_DIR']
37+
VIDEO_DIR = os.path.expanduser(settings['VIDEO_DIR'])
2438
SERVER_PORT = settings['SERVER_PORT']
2539

2640
logger.debug(f'Loaded settings: {settings}')
@@ -52,7 +66,7 @@ def stream():
5266

5367
@app.route('/')
5468
def home():
55-
return render_template('home.html', config_files=config_files)
69+
return render_template('home.html', config_files=config_files, version=app_version)
5670

5771
@app.route('/edit/<filename>', methods=['GET', 'POST'])
5872
def edit(filename):
@@ -86,13 +100,15 @@ def videos():
86100
logger.debug(f'Video files found: {video_files}')
87101
return render_template('videos.html', video_files=video_files)
88102

103+
89104
@app.route('/play/<filename>')
90105
def play(filename):
91-
return render_template('play.html', filename=filename)
92-
93-
# @app.route('/play/<filename>')
94-
# def play(filename):
95-
# return send_from_directory(VIDEO_DIR, filename)
106+
try:
107+
# Ensure the file exists in the VIDEO_DIR and is served from there
108+
return send_from_directory(VIDEO_DIR, filename)
109+
except FileNotFoundError:
110+
logger.error(f'Video file not found: {filename}')
111+
return "File not found", 404
96112

97113
@app.route('/temperature')
98114
def get_temperature():

py_config_gs/static/styles.css renamed to py_config_gs/static/css/styles.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,17 @@ p {
8686
}
8787

8888
/* Footer Styles */
89-
footer {
89+
/* footer {
9090
margin-top: 20px;
9191
text-align: center;
9292
font-size: 0.8em;
9393
color: #666;
94+
} */
95+
footer {
96+
position: fixed;
97+
bottom: 0;
98+
width: 100%;
99+
background-color: #f1f1f1;
100+
text-align: center;
101+
padding: 10px;
94102
}

py_config_gs/static/js/script.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
3+

0 commit comments

Comments
 (0)