Commit 124c9166 authored by Brenddon Gontijo Furtado's avatar Brenddon Gontijo Furtado

Merge branch 'api_server_communication' into 'master'

Api server communication

Closes #32, #31, #30, and #29

See merge request !10
parents 384e420e 98c6ad66
---
engines:
csslint:
enabled: false
duplication:
enabled: true
config:
languages:
- python
fixme:
enabled: true
radon:
enabled: true
config:
threshold: 'B'
ratings:
paths:
- "src/smi_unb/report/static/js/**.js"
- "src/smi_unb/users/static/js/**.js"
- "src/smi_unb/**/static/**/css/**.css"
- "**.py"
exclude_paths:
- "src/**/tests/test_**.py"
\ No newline at end of file
# Cached builds
__pycache__/
*.pyc
*.pyo
*.pyd
*.so
*.dll
*.egg
*.sqlite3
*.egg-info/
.sass-cache/
.coverage
# Non-required directories and files
backup/
log/
.cache/
.idea/
.git/
.gitignore
.travis.yml
# Build directories
build/
dist/
# Database
db/
# Static files
node_modules/
# Sources and documentation
static_src/
artwork/
docs/
*.egg-info
*.pot
*.py[co]
*.png
*.logging
*.pdf
__pycache__
MANIFEST
# Cached builds
__pycache__/
.cache/
.idea/
*.pyc
*.pyo
*.pyd
*.so
*.dll
*.egg
*.sqlite3
*.rdb
*.egg-info/
.cache/
.tox/
.sass-cache/
.coverage
# Logs
.cs-debug.log
geckodriver.log
ghostdriver.log
log/
# Build directories
build/
dist/
docs/_build/
docs/locale/
node_modules/
tests/coverage_html/
tests/.coverage
build/
tests/report/
docs/_build/
docker/env
htmlcov/
.vagrant/
cookbooks/
Vagrantfile
# .py generated by translations on jinja2 templates
*.jinja2.py
*.html.py
*.txt.py
.coverage
htmlcov/
\ No newline at end of file
# Sensible information
*.logging
security/*
collect/media/*
log/
backup/
# Other ignores
temp_cron
\ No newline at end of file
......@@ -14,4 +14,5 @@ test:
- apt-get install python3-pip -y -qq
- pip3 install -e .[dev]
- flake8 src/ --exclude migrations
- python3 manage.py test --settings=SMI_UnB.settings_runner
- coverage run manage.py test smi_unb --settings=smi_unb.settings_runner
- coverage report
......@@ -3,16 +3,6 @@ O que é?
O Sistema de Monitoramento de Insumos - Universidade de Brasília (SMI-UnB), consiste em uma aplicação web desenvolvida para auxiliar o monitoramento dos insumos importantes para a Universidade de Brasília. A ideia visa que cada Campus contido na UnB possa ser capaz de utilizar a ferramenta e ter um maior conhecimento de como está o consumo de seus insumos importantes ao longo do tempo, possibilitando, assim, elaborar possíveis estratégias que auxiliem em sua economia.
Principais Funcionalidades
--------
- Geração de relatórios
- Gráficos de consumo, demanda e afins
- Monitoramento temporal de transdutores
- Simulação de fatura
- Sistema de alarme para eventos indesejados
Características Técnicas
--------
......@@ -20,10 +10,10 @@ Características Técnicas
- Linguagem de programação: Python3
- Web Framework: Django
Documentação
--------
TODO
Instalação
--------
https://gitlab.com/brenddongontijo/SMI-UnB/wikis/instalation-guide
Documentação
--------
https://gitlab.com/brenddongontijo/SMI-UnB/wikis/home
\ No newline at end of file
#!/bin/bash
sudo apt-get install postgresql python-psycopg2 libpq-dev -y
ADMIN="admin"
SMIDB="smiunb"
sudo su - postgres -c "createuser vagrant --no-superuser --no-createdb --no-createrole" || true
sudo su - postgres -c "createuser $ADMIN --no-superuser --createdb --no-createrole" || true
sudo su - postgres -c "createdb $SMIDB -O $ADMIN" || true
cd /vagrant/SMI_UnB
sudo pip install -r requirements.txt
python manage.py migrate
\ No newline at end of file
......@@ -2,7 +2,7 @@
project = SMI-UnB
version = 0.1.0
has_script = false
pyname = SMI_UnB
pyname = smi_unb
license = mit
author = Brenddon Gontijo
python_version = both
......
#!/bin/bash
# Script to download all necessary cookbooks for Chef and run vagrant up.
mkdir cookbooks && cd cookbooks/
git clone https://github.com/chef-cookbooks/apt.git
git clone https://github.com/chef-cookbooks/build-essential.git
git clone https://github.com/chef-cookbooks/chef_handler.git
git clone https://github.com/chef-cookbooks/compat_resource.git
git clone https://github.com/chef-cookbooks/dmg.git
git clone https://github.com/chef-cookbooks/git.git
git clone https://github.com/chef-cookbooks/mingw.git
git clone https://github.com/chef-cookbooks/openssl.git
git clone https://github.com/chef-cookbooks/vim.git
git clone https://github.com/chef-cookbooks/windows.git
git clone https://github.com/chef-cookbooks/yum-epel.git
git clone https://github.com/chef-cookbooks/yum.git
git clone https://github.com/daptiv/seven_zip.git
git clone https://github.com/poise/python.git
git clone https://github.com/sethvargo/chef-sugar.git
cd .. && vagrant up
vagrant ssh -c "/vagrant/after_installation_script.sh"
vagrant ssh
\ No newline at end of file
0 * * * * export $(cat /root/env | xargs) && python3 /app/manage.py runcrons smi_unb.api.cronjob.MeasurementsSyncCronJob
# Necessary line at end of file to make cron valid
\ No newline at end of file
* * * * * export $(cat /root/env | xargs) && python3 /app/manage.py runcrons smi_unb.data_reader.cronjob.DataCollectCronJob
# Necessary line at end of file to make cron valid
\ No newline at end of file
version: '2'
services:
nginx:
restart: always
build: ./docker/nginx/
ports:
- "80:80"
volumes:
- ./docker/nginx/collect/static/:/var/www/static/
volumes_from:
- web
links:
- web:web
web:
build:
context: .
dockerfile: ./docker/Dockerfile.master
expose:
- "8000"
links:
- postgres:postgres
- redis:redis
env_file: ./docker/env
volumes:
- ./src/:/app/src/
postgres:
restart: always
image: postgres:latest
volumes_from:
- data
volumes:
- ./docker/postgres/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
env_file:
- ./docker/env
expose:
- "5432"
redis:
restart: always
image: redis:latest
expose:
- "6379"
data:
restart: always
image: alpine
volumes:
- /var/lib/postgresql
command: "true"
version: '2'
services:
nginx:
restart: always
build: ./docker/nginx/
ports:
- "80:80"
volumes:
- ./docker/nginx/collect/static/:/var/www/static/
volumes_from:
- web
links:
- web:web
web:
build:
context: .
dockerfile: ./docker/Dockerfile.slave
expose:
- "8000"
links:
- postgres:postgres
- redis:redis
env_file: ./docker/env
volumes:
- ./src/:/app/src/
postgres:
restart: always
image: postgres:latest
volumes_from:
- data
volumes:
- ./docker/postgres/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
env_file:
- ./docker/env
expose:
- "5432"
redis:
restart: always
image: redis:latest
expose:
- "6379"
data:
restart: always
image: alpine
volumes:
- /var/lib/postgresql
command: "true"
FROM python:3.5
RUN apt-get update &&\
apt-get install --no-install-recommends --no-install-suggests -y \
\
# Extra deps
cron \
python3-pip
# Base deps
RUN pip3 install \
requests[security] \
django==1.9.8 \
psycopg2==2.6.2 \
gunicorn \
redis==2.10.3 \
django-redis==4.8.0 \
invoke \
numpy \
pandas \
Sphinx \
django-polymorphic \
manuel \
mpld3 \
six \
unipath \
django_cron \
matplotlib \
djangorestframework
RUN mkdir -p /app
WORKDIR /app
COPY [ \
"setup.py", \
"requirements.txt", \
"boilerplate.ini", \
"manage.py", \
"tasks.py", \
"/app/" \
]
COPY src/ /app/src/
ENV PYTHONPATH=src \
SMI_UNB_PRODUCTION=true
# Setting cron
ADD crons/master_cron /etc/cron.d/smi-cron
RUN chmod 0644 /etc/cron.d/smi-cron
RUN touch /var/log/cron.log
RUN /usr/bin/crontab /etc/cron.d/smi-cron
# Initializing container with script
ADD scripts/start.sh /bin/start.sh
CMD /bin/bash /bin/start.sh
\ No newline at end of file
FROM python:3.5
RUN apt-get update &&\
apt-get install --no-install-recommends --no-install-suggests -y \
\
# Extra deps
cron \
python3-pip
# Base deps
RUN pip3 install \
requests[security] \
django==1.9.8 \
psycopg2==2.6.2 \
gunicorn \
redis==2.10.3 \
django-redis==4.8.0 \
invoke \
numpy \
pandas \
Sphinx \
django-polymorphic \
manuel \
mpld3 \
six \
unipath \
django_cron \
matplotlib \
djangorestframework
RUN mkdir -p /app
WORKDIR /app
COPY [ \
"setup.py", \
"requirements.txt", \
"boilerplate.ini", \
"manage.py", \
"tasks.py", \
"/app/" \
]
COPY src/ /app/src/
ENV PYTHONPATH=src \
SMI_UNB_PRODUCTION=true
# Setting cron
ADD crons/slave_cron /etc/cron.d/smi-cron
RUN chmod 0644 /etc/cron.d/smi-cron
RUN touch /var/log/cron.log
RUN /usr/bin/crontab /etc/cron.d/smi-cron
# Initializing container with script
ADD scripts/start.sh /bin/start.sh
CMD /bin/bash /bin/start.sh
\ No newline at end of file
FROM tutum/nginx
ADD /collect/static/ /var/www/static/
RUN rm /etc/nginx/sites-enabled/default
ADD sites-enabled/ /etc/nginx/sites-enabled
\ No newline at end of file
This diff is collapsed.
/* CHANGELISTS */
#changelist {
position: relative;
width: 100%;
}
#changelist table {
width: 100%;
}
.change-list .hiddenfields { display:none; }
.change-list .filtered table {
border-right: none;
}
.change-list .filtered {
min-height: 400px;
}
.change-list .filtered .results, .change-list .filtered .paginator,
.filtered #toolbar, .filtered div.xfull {
margin-right: 280px;
width: auto;
}
.change-list .filtered table tbody th {
padding-right: 1em;
}
#changelist-form .results {
overflow-x: auto;
}
#changelist .toplinks {
border-bottom: 1px solid #ddd;
}
#changelist .paginator {
color: #666;
border-bottom: 1px solid #eee;
background: #fff;
overflow: hidden;
}
/* CHANGELIST TABLES */
#changelist table thead th {
padding: 0;
white-space: nowrap;
vertical-align: middle;
}