Initial commit.

This commit is contained in:
Alexis Werefox 2021-08-04 20:35:36 -05:00
commit 31682e9b62
5 changed files with 44 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
**.pyc
**/__pycache__/**

7
Dockerfile Normal file
View file

@ -0,0 +1,7 @@
FROM python:alpine
ENV PYTHONUNBUFFERED=1
WORKDIR /powerpanel-webview
COPY requirements.txt /powerpanel-webview/
RUN pip install -r requirements.txt
COPY . /powerpanel-webview/

19
docker-compose.yml Normal file
View file

@ -0,0 +1,19 @@
---
version: "3"
services:
powerpanel-webview:
build: .
image: powerpanel-webview:latest
command: python manage.py runserver 0.0.0.0:8000
ports: "8000:8000"
volumes: .:/powerpanel-webview
depends_on: db
db:
image: postgres:alpine
volumes: ./data/db:/var/lib/postgresql/data
environment:
- POSTGRES_DB=powerpanel-db
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=1t3ySxqFnqb8KrCAecIHb34v

14
powerpanel_manage.py Normal file
View file

@ -0,0 +1,14 @@
#!/bin/python
from subprocess import check_output as co
def get_status_dict():
output = co('pwrstat -status'.split(' ')).decode('UTF-8').replace('\t', '').split('\n')[4:]
output = [x for x in [ [ x for x in line if x ] for line in [ line.split('.') for line in output ] ] if x]
output.remove(['Current UPS status:'])
output_dict = dict(zip([o[0] for o in output], [o[1][1:] for o in output]))
return output_dict
def print_status_dict(dict):
for i in dict.keys():
print('{}\t\t\t{}'.format(i, dict[i]))

2
requirements.txt Normal file
View file

@ -0,0 +1,2 @@
Django>=3.0
psycopg2-binary>=2.8