MCPcopy Create free account
hub / github.com/C3ting/ARL / submit_github_task

Function submit_github_task

app/utils/github_task.py:15–47  ·  view source on GitHub ↗
(task_data, action, delay_flag=True)

Source from the content-addressed store, hash-verified

13
14
15def submit_github_task(task_data, action, delay_flag=True):
16 if action not in action_map_collection:
17 return "Not in action_map"
18
19 collection = action_map_collection[action]
20 task_options = {
21 "celery_action": action,
22 "data": task_data
23 }
24 keyword = task_data["keyword"]
25 task_data["celery_id"] = ""
26 utils.conn_db(collection).insert_one(task_data)
27 task_id = str(task_data.pop("_id"))
28 task_data["task_id"] = task_id
29
30 try:
31 if delay_flag:
32 celery_id = celerytask.arl_github.delay(options=task_options)
33 else:
34 celery_id = "fake_celery_id"
35 celerytask.arl_github(options=task_options)
36
37 logger.info("target:{} task_id:{} celery_id:{}".format(keyword, task_id, celery_id))
38 values = {"$set": {"celery_id": str(celery_id)}}
39 task_data["celery_id"] = str(celery_id)
40 utils.conn_db(collection).update_one({"_id": ObjectId(task_id)}, values)
41
42 except Exception as e:
43 utils.conn_db(collection).delete_one({"_id": ObjectId(task_id)})
44 logger.info("Github 任务下发失败 {}".format(keyword))
45 return str(e)
46
47 return task_data
48
49
50# Github 监控任务下发

Callers 4

postMethod · 0.90
github_cron_runFunction · 0.85

Calls

no outgoing calls

Tested by 2