puh current config pre departure
This commit is contained in:
@ -1,75 +0,0 @@
|
||||
Notes on system itself
|
||||
The service contol will have the following components:
|
||||
PHP site that will make the API calls
|
||||
I don't have time to learn something new
|
||||
It will be similar to the photo refresh site
|
||||
Flow will be get status API, draw box depending on result, if pressed execute appropriate API, return
|
||||
The API calls are to a another service running a Python script
|
||||
I think I will have the following text in Green (Red):
|
||||
- THE SERVICE IS (NOT) RUNNING
|
||||
The button will be Red (Green):
|
||||
- Stop (Start)
|
||||
I'll rip off gali for the style
|
||||
|
||||
Notes on the python service script:
|
||||
There will be the cheap API, with a start, stop, and status
|
||||
Start will initialize another service
|
||||
There will be a variable to store the time of the last start/stop API call and limit calls for 5 seconds after this time
|
||||
No such limit will exist on the status API
|
||||
|
||||
Some Timelapse and snapshot Notes
|
||||
I think I will have two services, and the snapshot recording service will be a subservice of the timelapse service
|
||||
The timelapse service will start the snapshot
|
||||
|
||||
=== Old Timelapse Code ===
|
||||
|
||||
## Script to create timelapse
|
||||
|
||||
# Set TODAY variable
|
||||
TODAY=$(date +%Y-%m-%d)
|
||||
|
||||
# Create folder for today's photos
|
||||
mkdir /var/opt/mattstream/$TODAY
|
||||
|
||||
# How long between photos
|
||||
PERIOD=1
|
||||
|
||||
# How long to record for
|
||||
LENGTH=900
|
||||
|
||||
# Calculate number of photos to take
|
||||
ITERATIONS=$((LENGTH / PERIOD))
|
||||
|
||||
# Begin capture loop
|
||||
i=1
|
||||
while [ $i -le $ITERATIONS ]
|
||||
do
|
||||
|
||||
# This variable is for the filename
|
||||
NOW=$(date +%Y%m%d-%H%M%S)
|
||||
# This variable is for the timestamp
|
||||
TIME=$(date +%Y%m%d-%H%M)
|
||||
# Download current capture
|
||||
curl http://10.55.10.1:6288/snapshot --output /var/opt/mattstream/$TODAY/$NOW.jpg
|
||||
# This should add the current time to the image and save it
|
||||
convert /var/opt/mattstream/$TODAY/$NOW.jpg -gravity NorthWest -pointsize 22 \
|
||||
-fill yellow -annotate +30+30 $TIME /var/opt/mattstream/$TODAY/$NOW-ts.jpg
|
||||
# Delete original
|
||||
rm /var/opt/mattstream/$TODAY/$NOW.jpg
|
||||
# And now we wait
|
||||
sleep $PERIOD
|
||||
# Increment the counter and start over duh
|
||||
((i++))
|
||||
# For more obvious commentary, the loop is now over
|
||||
done
|
||||
|
||||
# Generate the timelapse now
|
||||
ffmpeg -r 24 -pattern_type glob -i "/var/opt/mattstream/$TODAY/*.jpg" \
|
||||
-vf "scale=1280x720" -vcodec libx264 /var/opt/mattstream/$TODAY/$TODAY.mp4
|
||||
|
||||
# If we want to start deleting original images, uncomment this
|
||||
#rm /var/opt/mattstream/$TODAY/*.jpg
|
||||
|
||||
# Slap a copy of this somewhere convenient for me to grab it
|
||||
cp /var/opt/mattstream/$TODAY/$TODAY.mp4 /media/pleiades/matt-lapse/$TODAY.mp4
|
||||
|
||||
@ -1,85 +0,0 @@
|
||||
import subprocess
|
||||
import requests
|
||||
from lxml import html
|
||||
from flask import Flask, request, jsonify
|
||||
import json
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
def start_service():
|
||||
command = "systemctl start timelapse.service"
|
||||
try:
|
||||
# Run the command using subprocess.run()
|
||||
process = subprocess.Popen(command, shell=True)
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
return {"Error": e.strip('\n')}
|
||||
|
||||
command = "systemctl status timelapse.service | grep Active | cut -d ':' -f 2- | cut -b 2-"
|
||||
try:
|
||||
# Run the command using subprocess.run()
|
||||
result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
|
||||
return {"Message": result.stdout.strip('\n')}
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
return {"Error": e.strip('\n')}
|
||||
|
||||
def stop_service():
|
||||
command = "systemctl stop timelapse.service"
|
||||
try:
|
||||
# Run the command using subprocess.run()
|
||||
process = subprocess.Popen(command, shell=True)
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
return {"Error": e.strip('\n')}
|
||||
|
||||
command = "systemctl status timelapse.service | grep Active | cut -d ':' -f 2- | cut -b 2-"
|
||||
try:
|
||||
# Run the command using subprocess.run()
|
||||
result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
|
||||
return {"Message": result.stdout.strip('\n')}
|
||||
except subprocess.CalledProcessError as e:
|
||||
return {"Error": e.strip('\n')}
|
||||
|
||||
def service_status():
|
||||
command = "systemctl status timelapse.service | grep Active | cut -d ':' -f 2- | cut -b 2-"
|
||||
try:
|
||||
# Run the command using subprocess.run()
|
||||
result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
|
||||
command = "systemctl status timelapse.service | grep Active | cut -d ':' -f 2 | cut -d ' ' -f 2"
|
||||
status = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
|
||||
return {"Message": result.stdout.strip('\n'), "Status": status.stdout.strip('\n')}
|
||||
except subprocess.CalledProcessError as e:
|
||||
return {"Error": e.strip('\n')}
|
||||
|
||||
@app.route('/start', methods=['GET'])
|
||||
def start():
|
||||
try:
|
||||
return jsonify(start_service())
|
||||
except ValueError as e:
|
||||
print(e)
|
||||
return jsonify({'error': e}), 400
|
||||
|
||||
@app.route('/stop', methods=['GET'])
|
||||
def stop():
|
||||
try:
|
||||
return jsonify(stop_service())
|
||||
except ValueError as e:
|
||||
print(e)
|
||||
return jsonify({'error': e}), 400
|
||||
|
||||
@app.route('/status', methods=['GET'])
|
||||
def status():
|
||||
try:
|
||||
return jsonify(service_status())
|
||||
except ValueError as e:
|
||||
print(e)
|
||||
return jsonify({'error': e}), 400
|
||||
|
||||
@app.route('/test', methods=['GET'])
|
||||
def test():
|
||||
return jsonify({'message': 'Hello there'})
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True, host='0.0.0.0', port=5000)
|
||||
|
||||
@ -74,6 +74,11 @@ button:hover {
|
||||
background: radial-gradient(circle, #003699 0%, #337aff 100%);
|
||||
color: #bdc3c7; /* Dimmer text color */
|
||||
}
|
||||
.deactivating {
|
||||
background-color: #0d2b2c;
|
||||
background: radial-gradient(circle, #0d2b2c 0%, #123738 100%);
|
||||
color: #bdc3c7; /* Dimmer text color */
|
||||
}
|
||||
.unknown {
|
||||
background-color: #ec701e;
|
||||
background: radial-gradient(circle, #c9580d 0%, #ec701e 100%);
|
||||
|
||||
Reference in New Issue
Block a user