Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
```


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

Journalctl -f
![alt text](images/journal.png)


### Packaging
```bash
Expand Down
Binary file modified images/editor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/journal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/v_player.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/v_select.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 24 additions & 8 deletions py_config_gs/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -12,15 +16,25 @@
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:
settings = json.load(f)

# 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}')
Expand Down Expand Up @@ -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/<filename>', methods=['GET', 'POST'])
def edit(filename):
Expand Down Expand Up @@ -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/<filename>')
def play(filename):
return render_template('play.html', filename=filename)

# @app.route('/play/<filename>')
# 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():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
3 changes: 3 additions & 0 deletions py_config_gs/static/js/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@



38 changes: 38 additions & 0 deletions py_config_gs/templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!-- templates/base.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}My Flask App{% endblock %}</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/styles.css') }}">
</head>
<body>

<!-- Header Section -->
<header>
<h1>Welcome to the Configuration Manager</h1>

<div class="tabs">
<ul>
<li><a href="{{ url_for('home') }}">Home</a></li>
<li><a href="{{ url_for('journal') }}">Journal</a></li>
<li><a href="{{ url_for('videos') }}">Videos</a></li>
</ul>
</div>

</header>

<!-- Main Content Block -->
<main>
{% block content %}
{% endblock %}
</main>

<!-- Footer Section -->
<footer>
<p>&copy; 2024 PyConfig Groundstation, version: {{ version }}</p>
</footer>

</body>
</html>
25 changes: 4 additions & 21 deletions py_config_gs/templates/edit.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
<!-- templates/edit.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edit {{ filename }}</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
</head>
<body>
<h1>Welcome to the Configuration Manager</h1>

<div class="tabs">
<ul>
<li><a href="{{ url_for('home') }}">Home</a></li>
<li><a href="{{ url_for('journal') }}">Journal</a></li>
<li><a href="{{ url_for('videos') }}">Videos</a></li>
</ul>
</div>
{% extends "base.html" %}

{% block content %}
<div class="content">
<h2>Edit Configuration File: {{ filename }}</h2>
<form method="POST">
Expand All @@ -25,6 +10,4 @@ <h2>Edit Configuration File: {{ filename }}</h2>
</form>
<a href="{{ url_for('home') }}">Cancel</a>
</div>
{% include 'footer.html' %}
</body>
</html>
{% endblock %}
2 changes: 1 addition & 1 deletion py_config_gs/templates/footer.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- templates/footer.html -->
<footer>
<p>&copy; 2024 PyConfig Groundstation</p>
<p>&copy; 2024 PyConfig Groundstation, version: {{ version }}</p>
</footer>
72 changes: 29 additions & 43 deletions py_config_gs/templates/home.html
Original file line number Diff line number Diff line change
@@ -1,43 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
<script>
async function fetchTemperatures() {
try {
const response = await fetch('/temperature');
const data = await response.json();

if (response.ok) {
document.getElementById('soc-temp').innerText = `SOC Temperature: ${data.soc_temperature} °C`;
document.getElementById('gpu-temp').innerText = `GPU Temperature: ${data.gpu_temperature} °C`;
document.getElementById('soc-temp-f').innerText = `SOC Temperature: ${data.soc_temperature_f} °F`;
document.getElementById('gpu-temp-f').innerText = `GPU Temperature: ${data.gpu_temperature_f} °F`;
} else {
console.error('Error fetching temperature:', data.error);
}
} catch (error) {
console.error('Fetch error:', error);
}
}

setInterval(fetchTemperatures, 5000); // Update every 5 seconds
</script>
</head>
<body>
<h1>Welcome to the Configuration Manager</h1>

<div class="tabs">
<ul>
<li><a href="{{ url_for('home') }}">Home</a></li>
<li><a href="{{ url_for('journal') }}">Journal</a></li>
<li><a href="{{ url_for('videos') }}">Videos</a></li>
</ul>
</div>
<!-- templates/home.html -->
{% extends "base.html" %}

{% block content %}
<h2>Configuration Files</h2>
{% if config_files %}
<ul>
Expand All @@ -59,11 +23,33 @@ <h2>Radxa Temps</h2>
<li><div id="soc-temp-f">SOC Temperature: N/A</div></li>
<li><div id="gpu-temp-f">GPU Temperature: N/A</div></li>
</ul>

{% include 'footer.html' %}


<script>

async function fetchTemperatures() {
try {
const response = await fetch('/temperature');
const data = await response.json();

if (response.ok) {
document.getElementById('soc-temp').innerText = `SOC Temperature: ${data.soc_temperature} °C`;
document.getElementById('gpu-temp').innerText = `GPU Temperature: ${data.gpu_temperature} °C`;
document.getElementById('soc-temp-f').innerText = `SOC Temperature: ${data.soc_temperature_f} °F`;
document.getElementById('gpu-temp-f').innerText = `GPU Temperature: ${data.gpu_temperature_f} °F`;
} else {
console.error('Error fetching temperature:', data.error);
}
} catch (error) {
console.error('Fetch error:', error);
}
}

setInterval(fetchTemperatures, 5000); // Update every 5 seconds



fetchTemperatures(); // Initial fetch
</script>
</body>
</html>

{% endblock %}
67 changes: 27 additions & 40 deletions py_config_gs/templates/journal.html
Original file line number Diff line number Diff line change
@@ -1,46 +1,33 @@
<!-- templates/journal.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Journal Logs</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
<script>
function startStream() {
const eventSource = new EventSource("/stream");
const logBox = document.getElementById("logBox");

eventSource.onmessage = function(event) {
logBox.value += event.data + "\n";
logBox.scrollTop = logBox.scrollHeight; // Auto-scroll to the bottom
};
{% extends "base.html" %}

eventSource.onerror = function() {
console.error("EventSource failed.");
eventSource.close();
};
}
{% block content %}
<div class="content">
<h2>Journal Logs</h2>
<textarea id="logBox" rows="20" cols="100" readonly></textarea>
</div>

window.onload = startStream;
</script>
</head>
<body>
<h1>Welcome to the Configuration Manager</h1>


<!-- Include the JavaScript file -->
<script>
function startStream() {
const eventSource = new EventSource("/stream");
const logBox = document.getElementById("logBox");

<div class="tabs">
<ul>
<li><a href="{{ url_for('home') }}">Home</a></li>
<li><a href="{{ url_for('journal') }}">Journal</a></li>
<li><a href="{{ url_for('videos') }}">Videos</a></li>
</ul>
</div>
eventSource.onmessage = function(event) {
logBox.value += event.data + "\n";
logBox.scrollTop = logBox.scrollHeight; // Auto-scroll to the bottom
};

eventSource.onerror = function() {
console.error("EventSource failed.");
eventSource.close();
};
}

window.onload = startStream;
</script>
<!-- <script src="{{ url_for('static', filename='js/script.js') }}"></script> -->

<div class="content">
<h2>Journal Logs</h2>
<textarea id="logBox" rows="20" cols="100" readonly></textarea>
</div>
{% include 'footer.html' %}
</body>
</html>
{% endblock %}
Loading