问题Pybossa webhooks,如何执行它 [英] Issue in Pybossa webhooks, how to execute it
问题描述
目前,我正在执行它,如下所示:
python app.py test_project
其中test_project是我的project_short_name。但是,它正在将我恢复到此存储库的index.html页面。
我找到了!看看 pybossa.model.event_listeners
你会发现 push_webhook
函数,它将webhook推入队列。它被同一个文件中的 on_taskrun_submit,on_auditrun_submit
函数调用。如果你真的想手动执行webhook,看看 pybossa.jobs
,你会发现 webhook
函数,这是webhook执行的地方。您可以像这样手动调用它:
def trigger_webhook(short_name,task_id = 0,result_id = 0):
来自pybossa.jobs import webhook
from datetime import datetime $ b $ from pybossa.core import project_repo
$ b with app.app_context():
project = project_repo.get_by_shortname(short_name )
$ b $ payload = dict(event =task_completed,
project_short_name = project.short_name,
project_id = project.id,
task_id = task_id,
result_id = result_id,
fired_at = datetime.utcnow()。strftime(%Y-%m-%d%H:%M:%S))
webhook(project.webhook,payload )
我把这个函数放在cli.py中,所以我可以直接调用它。 b $ b
I am working with the Pybossa webhooks, and found this plugin to analyse the Pybossa results in real-time. I forked it but not getting how it is to be executed.
Currently, I am executing it as follows:
python app.py test_project
where test_project is my project_short_name. But, it is reverting me to index.html page of this repository.
I found it ! Look into pybossa.model.event_listeners
you will find push_webhook
function, it push webhook into queue. And it's called by on_taskrun_submit, on_auditrun_submit
function in the same file.
If you really want to execute webhook manually, look into pybossa.jobs
, you will find webhook
function, it's where the webhook execute. You can call it manually like this:
def trigger_webhook(short_name, task_id=0, result_id=0):
from pybossa.jobs import webhook
from datetime import datetime
from pybossa.core import project_repo
with app.app_context():
project = project_repo.get_by_shortname(short_name)
payload = dict(event="task_completed",
project_short_name=project.short_name,
project_id=project.id,
task_id=task_id,
result_id=result_id,
fired_at=datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S"))
webhook(project.webhook, payload)
I put this function in cli.py so I can call it handily.
这篇关于问题Pybossa webhooks,如何执行它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!