mirror of
https://github.com/simon987/od-database.git
synced 2025-12-13 23:09:01 +00:00
Added crawl logs page
This commit is contained in:
19
task.py
19
task.py
@@ -70,6 +70,16 @@ class CrawlServer:
|
||||
except ConnectionError:
|
||||
return ""
|
||||
|
||||
def fetch_crawl_logs(self):
|
||||
|
||||
try:
|
||||
r = requests.get(self.url + "/task/logs/", headers=CrawlServer.headers)
|
||||
return [
|
||||
TaskResult(r["status_code"], r["file_count"], r["start_time"], r["end_time"], r["website_id"], r["indexed_time"])
|
||||
for r in json.loads(r.text)]
|
||||
except ConnectionError:
|
||||
return []
|
||||
|
||||
|
||||
class TaskDispatcher:
|
||||
|
||||
@@ -119,4 +129,13 @@ class TaskDispatcher:
|
||||
|
||||
return current_tasks
|
||||
|
||||
def get_task_logs_by_server(self) -> dict:
|
||||
|
||||
task_logs = dict()
|
||||
|
||||
for server in self.crawl_servers:
|
||||
task_logs[server.url] = server.fetch_crawl_logs()
|
||||
|
||||
return task_logs
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user