Initial commit.
This commit is contained in:
commit
31682e9b62
5 changed files with 44 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
**.pyc
|
||||
**/__pycache__/**
|
7
Dockerfile
Normal file
7
Dockerfile
Normal 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
19
docker-compose.yml
Normal 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
14
powerpanel_manage.py
Normal 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
2
requirements.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
Django>=3.0
|
||||
psycopg2-binary>=2.8
|
Reference in a new issue