Skip to content

Commit

Permalink
Merge pull request #46 from metaMMA/new-config
Browse files Browse the repository at this point in the history
  • Loading branch information
genebean committed Apr 8, 2020
2 parents f9a509a + 8740e5d commit 01bbc57
Show file tree
Hide file tree
Showing 15 changed files with 1,190 additions and 83 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vscode/
config.py
config.json
*.pyc
*.swp
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ install:
- pip install -r requirements.txt
- pip install pylint
script:
- pylint config.py.sample
- pylint weather.py

17 changes: 17 additions & 0 deletions PiWeatherRockConfig.service
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
23 changes: 23 additions & 0 deletions config.json-sample
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
}
}
}
47 changes: 0 additions & 47 deletions config.py.sample

This file was deleted.

95 changes: 95 additions & 0 deletions config_page.py
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")
}
})
Loading

0 comments on commit 01bbc57

Please sign in to comment.