-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to new web-based configuration method
This commit adds a config page served with CherryPy on port 8888. As part of this the config format was also changed to JSON. A migration script is included and run by Puppet automatically.
- Loading branch information
Showing
15 changed files
with
1,190 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.vscode/ | ||
config.py | ||
config.json | ||
*.pyc | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# this file is managed by Puppet | ||
[Unit] | ||
Description=PiWeatherRock Config Service | ||
After=network.target | ||
|
||
[Service] | ||
Type=simple | ||
User=pi | ||
Group=pi | ||
WorkingDirectory=/home/pi/PiWeatherRock | ||
Environment='DISPLAY=:0' | ||
ExecStart=/usr/bin/python3 /home/pi/PiWeatherRock/config_page.py | ||
Restart=always | ||
RestartSec=5 | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"version": "0.0.13", | ||
"ds_api_key": "API_KEY_HERE", | ||
"lat": 0.112358, | ||
"lon": 0.246810, | ||
"units": "us", | ||
"lang": "en", | ||
"fullscreen": true, | ||
"icon_offset": -23.5, | ||
"update_freq": 300, | ||
"info_pause": 300, | ||
"info_delay": 900, | ||
"plugins": { | ||
"daily": { | ||
"enabled": true, | ||
"pause": 60 | ||
}, | ||
"hourly": { | ||
"enabled": true, | ||
"pause": 60 | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# BEGIN LICENSE | ||
|
||
# Permission is hereby granted, free of charge, to any person | ||
# obtaining a copy of this software and associated documentation | ||
# files (the "Software"), to deal in the Software without | ||
# restriction, including without limitation the rights to use, | ||
# copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the | ||
# Software is furnished to do so, subject to the following | ||
# conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be | ||
# included in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
# OTHER DEALINGS IN THE SOFTWARE. | ||
# END LICENSE | ||
|
||
""" Configuration page for PiWeatherRock. """ | ||
|
||
__version__ = "0.0.13" | ||
|
||
############################################################################### | ||
# Raspberry Pi Weather Display Config Page Plugin | ||
# Original By: github user: metaMMA 2020-03-15 | ||
############################################################################### | ||
|
||
# standard imports | ||
import os | ||
import json | ||
|
||
# third-party imports | ||
import cherrypy | ||
|
||
with open(os.path.join(os.getcwd(), 'html/config.html'), 'r') as f: | ||
html = f.read() | ||
|
||
|
||
class Config: | ||
|
||
@cherrypy.expose() | ||
def index(self): | ||
return html | ||
|
||
@cherrypy.tools.json_in() | ||
@cherrypy.expose | ||
def upload(self): | ||
dst = f"{os.getcwd()}/config.json" | ||
|
||
input_json = cherrypy.request.json | ||
with open(dst, 'w') as f: | ||
json.dump(input_json, f, indent=2, separators=(',', ': ')) | ||
self.index() | ||
|
||
|
||
if __name__ == '__main__': | ||
cherrypy.quickstart(Config(), config={ | ||
'global': { | ||
'server.socket_port': 8888, | ||
'server.socket_host': '0.0.0.0' | ||
}, | ||
'/serialize_script.js': { | ||
'tools.staticfile.on': True, | ||
'tools.staticfile.filename': os.path.join( | ||
os.getcwd(), "html/serialize_script.js") | ||
}, | ||
'/style.css': { | ||
'tools.staticfile.on': True, | ||
'tools.staticfile.filename': os.path.join( | ||
os.getcwd(), "html/style.css") | ||
}, | ||
'/chancetstorms.png': { | ||
'tools.staticfile.on': True, | ||
'tools.staticfile.filename': os.path.join( | ||
os.getcwd(), "icons/256/chancetstorms.png") | ||
}, | ||
'/bg.png': { | ||
'tools.staticfile.on': True, | ||
'tools.staticfile.filename': os.path.join( | ||
os.getcwd(), "icons/bg.png") | ||
}, | ||
'/config.json': { | ||
'tools.staticfile.on': True, | ||
'tools.staticfile.filename': os.path.join( | ||
os.getcwd(), "config.json") | ||
} | ||
}) |
Oops, something went wrong.