From 132899fe8919c4e42729ae13325de8069fa2063f Mon Sep 17 00:00:00 2001 From: Gustavo274 Date: Fri, 10 Sep 2021 11:13:12 -0300 Subject: [PATCH] Att celery --- celerybeat-schedule | Bin 0 -> 16384 bytes dump.rdb | Bin 0 -> 294 bytes sapl/celery.py | 17 +++++++++++++++++ sapl/painel/tasks.py | 19 +++++++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 celerybeat-schedule create mode 100644 dump.rdb create mode 100644 sapl/celery.py create mode 100644 sapl/painel/tasks.py diff --git a/celerybeat-schedule b/celerybeat-schedule new file mode 100644 index 0000000000000000000000000000000000000000..b86dce44e0f1821d10dc9ac2b3e19f183b5c4a0a GIT binary patch literal 16384 zcmeI2&rcIU6vwCCV%vf8t3W}1*n$Z^5;q`V)Oa8vULG4{k}yPepEvhC|mjgU0f z3rPGAyr?lT9t~%sUOafxyIwqa^=M*ZqBGsCEx|T~AOU@y?7p4t?(Eyoo9{Q0yqzF9^gDc9iR`O512f zDQEvnw|{xo>C^I`1_=3f;m>`!*C&>r;^Q2#dyV@Y9>@VX)G7n#!_mx#kMBN@>iTUK za{aDZT((Ut$p2{gBWL975I_#dp_YKN-M_LkRN$t5uEwA7d9un0{nKHA91h08*!~)3 z7SG?EcFy;Uup@rsAiU&e409a)O4dBh?2=LhqRI#0yq(Tkx?WP^ z^3}ksI;EZ$-|&r+vZP7_W|oo2uw+TOuhyPB77vTVZ!xZ$`K*;)V?3YL)0WM_W11|( z^6P4X8Ju1>Q!H7?u&d&_>lD0WDNj5q&a{nOM$H*%i)B=9*sHd>dn{1Qq`?_auQB?2 z1AOz;|0NiVOsU?96=*VZ>wJUiHZ`qd{bW?9E7W<3@r)?^s;ET$zNva-4zFwACV%MWwbv8njAn zwQ0~UW^+doIyrkP?l< zpaw%iR#IEhBE)uSYuM4&hz4g1>LID?Z%l+3(z zz2wxK)S^m80SL_|#wG?~G09+6s8^7gl9XS;sDV)F;NlwW9pWFL>*?VUWNB;;H4>_l zNgS&=sb!3o<@rU~sYQCq2%}QV^niXgH#Ih~&^5F$Pt`RsH%-*FGzI#~!rUm?FxfIW S*}}l`|K;rqVvl}a=>z}@LS_U2 literal 0 HcmV?d00001 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