diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 735c649..0fe0202 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,13 +3,11 @@ name: Build and Release on: push: tags: - - 'v*.*.*' # This will trigger the workflow on version tags, e.g., v1.0.0 + - 'v*.*.*' jobs: build: runs-on: ubuntu-latest - permissions: - contents: write steps: - name: Checkout code @@ -18,21 +16,21 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: '3.8' # Specify your Python version + python-version: '3.8' + + - name: Get version from tag + id: vars + run: echo "VERSION=${GITHUB_REF#refs/tags/} >> $GITHUB_ENV" - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel + pip install setuptools wheel setuptools-scm - name: Build package run: | python setup.py sdist bdist_wheel - - name: "Build Changelog" - id: build_changelog - uses: mikepenz/release-changelog-builder-action@v5 - - name: Upload Package to Release uses: softprops/action-gh-release@v1 with: diff --git a/README.md b/README.md index 2ff2bf2..3f76ffe 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ I wanted an easy way to edit files and watch videos on the Radxa python -m venv .venv source .venv/bin/activate pip install -r requirements.txt + +echo "FLASK_ENV=development > .env" ``` @@ -24,6 +26,9 @@ Video file selector Player ![alt text](images/v_player.png) +Journalctl -f +![alt text](images/journal.png) + ### Packaging ```bash diff --git a/images/editor.png b/images/editor.png index 7d86db4..da38103 100644 Binary files a/images/editor.png and b/images/editor.png differ diff --git a/images/home.png b/images/home.png index 32e3042..8b671de 100644 Binary files a/images/home.png and b/images/home.png differ diff --git a/images/journal.png b/images/journal.png new file mode 100644 index 0000000..b0a8db4 Binary files /dev/null and b/images/journal.png differ diff --git a/images/v_player.png b/images/v_player.png index 738aad9..18acb0e 100644 Binary files a/images/v_player.png and b/images/v_player.png differ diff --git a/images/v_select.png b/images/v_select.png index eda7410..045801d 100644 Binary files a/images/v_select.png and b/images/v_select.png differ diff --git a/py_config_gs/app.py b/py_config_gs/app.py index 0bf4b7d..60b8abb 100644 --- a/py_config_gs/app.py +++ b/py_config_gs/app.py @@ -3,6 +3,10 @@ import json import os import subprocess +from importlib.metadata import version + + +app_version = version('py-config-gs') # Configure logging logging.basicConfig(level=logging.DEBUG, # Set the log level to DEBUG @@ -12,7 +16,17 @@ app = Flask(__name__) #SETTINGS_FILE = "/Users/mcarr/config/settings.json" -SETTINGS_FILE = "/config/settings.json" +#SETTINGS_FILE = "/config/settings.json" +if os.getenv('FLASK_ENV') == 'development': + # In development, use the home folder settings file + SETTINGS_FILE = os.path.expanduser('~/config/settings.json') +else: + # In production, use the config folder + SETTINGS_FILE = '/config/settings.json' + +# Log the SETTINGS_FILE path +logger.info(f'Settings file path: {SETTINGS_FILE}') +logger.info(f'App version: {app_version}') # Load settings.json with open(SETTINGS_FILE, 'r') as f: @@ -20,7 +34,7 @@ # Access configuration files and video directory config_files = settings['config_files'] -VIDEO_DIR = settings['VIDEO_DIR'] +VIDEO_DIR = os.path.expanduser(settings['VIDEO_DIR']) SERVER_PORT = settings['SERVER_PORT'] logger.debug(f'Loaded settings: {settings}') @@ -52,7 +66,7 @@ def stream(): @app.route('/') def home(): - return render_template('home.html', config_files=config_files) + return render_template('home.html', config_files=config_files, version=app_version) @app.route('/edit/', methods=['GET', 'POST']) def edit(filename): @@ -86,13 +100,15 @@ def videos(): logger.debug(f'Video files found: {video_files}') return render_template('videos.html', video_files=video_files) + @app.route('/play/') def play(filename): - return render_template('play.html', filename=filename) - -# @app.route('/play/') -# def play(filename): -# return send_from_directory(VIDEO_DIR, filename) + try: + # Ensure the file exists in the VIDEO_DIR and is served from there + return send_from_directory(VIDEO_DIR, filename) + except FileNotFoundError: + logger.error(f'Video file not found: {filename}') + return "File not found", 404 @app.route('/temperature') def get_temperature(): diff --git a/py_config_gs/static/styles.css b/py_config_gs/static/css/styles.css similarity index 89% rename from py_config_gs/static/styles.css rename to py_config_gs/static/css/styles.css index 5aa49e5..958c01f 100644 --- a/py_config_gs/static/styles.css +++ b/py_config_gs/static/css/styles.css @@ -86,9 +86,17 @@ p { } /* Footer Styles */ -footer { +/* footer { margin-top: 20px; text-align: center; font-size: 0.8em; color: #666; +} */ +footer { + position: fixed; + bottom: 0; + width: 100%; + background-color: #f1f1f1; + text-align: center; + padding: 10px; } diff --git a/py_config_gs/static/js/script.js b/py_config_gs/static/js/script.js new file mode 100644 index 0000000..11f9098 --- /dev/null +++ b/py_config_gs/static/js/script.js @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/py_config_gs/templates/base.html b/py_config_gs/templates/base.html new file mode 100644 index 0000000..0cb0c06 --- /dev/null +++ b/py_config_gs/templates/base.html @@ -0,0 +1,38 @@ + + + + + + + {% block title %}My Flask App{% endblock %} + + + + + +
+

Welcome to the Configuration Manager

+ +
+ +
+ +
+ + +
+ {% block content %} + {% endblock %} +
+ + +
+

© 2024 PyConfig Groundstation, version: {{ version }}

+
+ + + diff --git a/py_config_gs/templates/edit.html b/py_config_gs/templates/edit.html index 5c6f5e7..87f238c 100644 --- a/py_config_gs/templates/edit.html +++ b/py_config_gs/templates/edit.html @@ -1,22 +1,7 @@ - - - - - - Edit {{ filename }} - - - -

Welcome to the Configuration Manager

- -
- -
+{% extends "base.html" %} + +{% block content %}

Edit Configuration File: {{ filename }}

@@ -25,6 +10,4 @@

Edit Configuration File: {{ filename }}

Cancel
- {% include 'footer.html' %} - - +{% endblock %} \ No newline at end of file diff --git a/py_config_gs/templates/footer.html b/py_config_gs/templates/footer.html index 32bc372..84de5d2 100644 --- a/py_config_gs/templates/footer.html +++ b/py_config_gs/templates/footer.html @@ -1,4 +1,4 @@
-

© 2024 PyConfig Groundstation

+

© 2024 PyConfig Groundstation, version: {{ version }}

\ No newline at end of file diff --git a/py_config_gs/templates/home.html b/py_config_gs/templates/home.html index 701d9fd..bb357d5 100644 --- a/py_config_gs/templates/home.html +++ b/py_config_gs/templates/home.html @@ -1,43 +1,7 @@ - - - - - - Home - - - - -

Welcome to the Configuration Manager

- -
- -
+ +{% extends "base.html" %} +{% block content %}

Configuration Files

{% if config_files %}
    @@ -59,11 +23,33 @@

    Radxa Temps

  • SOC Temperature: N/A
  • GPU Temperature: N/A
- - {% include 'footer.html' %} + - - + +{% endblock %} diff --git a/py_config_gs/templates/journal.html b/py_config_gs/templates/journal.html index 664051a..2776b79 100644 --- a/py_config_gs/templates/journal.html +++ b/py_config_gs/templates/journal.html @@ -1,46 +1,33 @@ - - - - - - Journal Logs - - - - -

Welcome to the Configuration Manager

+ + + + + -
-

Journal Logs

- -
- {% include 'footer.html' %} - - +{% endblock %} \ No newline at end of file diff --git a/py_config_gs/templates/play.html b/py_config_gs/templates/play.html index 7f55d44..cd1aee3 100644 --- a/py_config_gs/templates/play.html +++ b/py_config_gs/templates/play.html @@ -1,31 +1,11 @@ - - - - - - Play Video - - - -

Welcome to the Configuration Manager

- -
- -
- + +{% extends "base.html" %} +{% block content %} +

Playing Video: {{ filename }}

-
+{% endblock %} \ No newline at end of file diff --git a/py_config_gs/templates/videos.html b/py_config_gs/templates/videos.html index 5bc97e9..ac5d16f 100644 --- a/py_config_gs/templates/videos.html +++ b/py_config_gs/templates/videos.html @@ -1,22 +1,7 @@ - - - - - - Videos - - - -

Welcome to the Configuration Manager

+{% extends "base.html" %} -
- -
+{% block content %}

Available Videos

@@ -32,6 +17,4 @@

Available Videos

No video files found.

{% endif %}
- {% include 'footer.html' %} - - +{% endblock %} diff --git a/requirements.txt b/requirements.txt index f485b1c..0d3f12b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,5 @@ itsdangerous==2.2.0 jinja2==3.1.4 MarkupSafe==2.1.5 werkzeug==3.0.4 -zipp==3.20.2 \ No newline at end of file +zipp==3.20.2 +setuptools-scm==8.1.0 \ No newline at end of file diff --git a/setup.py b/setup.py index b055cc8..8bc949b 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ import os -from setuptools import setup, find_packages +from setuptools import setup, find_packages, setuptools_scm # Define the relative path for the settings file and systemd service file settings_file = 'py_config_gs/settings.json' # Ensure this is a relative path @@ -7,7 +7,8 @@ setup( name='py-config-gs', - version='0.1', + use_scm_version=True, # This tells setuptools to use scm for version + setup_requires=['setuptools_scm'], packages=find_packages(), include_package_data=True, # Include files from MANIFEST.in install_requires=[ @@ -21,6 +22,7 @@ 'MarkupSafe==2.1.5', 'werkzeug==3.0.4', 'zipp==3.20.2', + 'setuptools-scm==8.1.0' ], entry_points={ 'console_scripts': [ diff --git a/systemd/py-config-gs.service b/systemd/py-config-gs.service index 0cbd19d..971bff4 100644 --- a/systemd/py-config-gs.service +++ b/systemd/py-config-gs.service @@ -6,6 +6,8 @@ After=network.target ExecStart=py_config_gs WorkingDirectory=/usr/local/lib/python3.9/dist-packages/py_config_gs Restart=always +StandardOutput=syslog +StandardError=syslog [Install] WantedBy=multi-user.target