diff --git a/celerybeat-schedule b/celerybeat-schedule new file mode 100644 index 000000000..b86dce44e Binary files /dev/null and b/celerybeat-schedule differ diff --git a/dump.rdb b/dump.rdb new file mode 100644 index 000000000..66ed5832c Binary files /dev/null and b/dump.rdb differ diff --git a/sapl/celery.py b/sapl/celery.py new file mode 100644 index 000000000..db23552b6 --- /dev/null +++ b/sapl/celery.py @@ -0,0 +1,17 @@ +import os +from celery import Celery + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sapl.settings') + +app = Celery('sapl') + +app.config_from_object('django.conf:settings', namespace='CELERY') + +app.conf.beat_schedule = { + 'get_cronometro_inst': { + 'task': 'sapl.painel.tasks.get_cronometro', + 'schedule': 10.0 + } +} + +app.autodiscover_tasks() diff --git a/sapl/painel/tasks.py b/sapl/painel/tasks.py new file mode 100644 index 000000000..03946d256 --- /dev/null +++ b/sapl/painel/tasks.py @@ -0,0 +1,19 @@ +import json +import requests +import urllib + +from celery import shared_task + + +@shared_task +def get_cronometro(): + url_dados = 'http://localhost:8000/painel/1272/dados' + # print(requests.get(url_dados).status_code) + #response = requests.get(url_dados) + response = urllib.request.urlopen(url_dados) + dados = json.loads(response.read()) + #cronometro = response['sessao_plenaria']['cronometro_discurso'] + print(dados) + print(response) + print(response.encoding) + return response