Skip to content

Commit 7172a10

Browse files
committed
feat: process log file using python script
1 parent 2b4ec6a commit 7172a10

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ public/manifest.json
2222
# benchmarking
2323
/results
2424
tasks_test.jsonl
25-
webwand_test_log.txt
25+
webwand_test_log.txt
26+
tasks_status.txt

benchmark.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def click_extensions_icon(driver):
174174
top = window_position['y']
175175
right = window_position['x'] + window_position['width']
176176
# click Extensions icon
177-
pyautogui.click(right - 150, top + 50)
177+
pyautogui.click(right - 165, top + 50)
178178
# click webwand
179179
pyautogui.click(right - 300, top + 210)
180180

@@ -196,10 +196,10 @@ def main():
196196
result = run_webwand_task(driver, task_id, task['ques'])
197197
logging.info(f'Task {task_id} status: {result}')
198198
# Optional: if the previous task timed out, reset the driver after each task to ensure proper state for the next task
199-
# if result == "js-script-timeout":
200-
# driver.quit()
201-
# driver = setup_driver()
202-
# initial_load = True
199+
if result == "js-script-timeout":
200+
driver.quit()
201+
driver = setup_driver()
202+
initial_load = True
203203
driver.quit()
204204

205205
if __name__ == "__main__":

process_log.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import re
2+
3+
def process_log_file(log_file_path):
4+
with open(log_file_path, 'r') as file:
5+
log_data = file.readlines()
6+
7+
task_status_pattern = re.compile(r"Task ([\w\s-]+--\d+) status: (script-error|success|fail|doc-unload-max-retry|js-script-timeout|webdriver-error|python-script-error)")
8+
tasks = []
9+
10+
for line in log_data:
11+
match = task_status_pattern.search(line)
12+
if match:
13+
task_id = match.group(1)
14+
status = match.group(2)
15+
tasks.append((task_id, status))
16+
17+
return tasks
18+
19+
def write_task_status(tasks):
20+
header = "Task_id\tTask_status"
21+
rows = [f"{task_id}\t{status}" for task_id, status in tasks]
22+
return header + "\n" + "\n".join(rows)
23+
24+
log_file_path = 'webwand_test_log.txt'
25+
tasks = process_log_file(log_file_path)
26+
formatted_output = write_task_status(tasks)
27+
28+
output_file_path = 'tasks_status.txt'
29+
with open(output_file_path, 'w') as output_file:
30+
output_file.write(formatted_output)
31+
32+
print(f"Tasks results are saved to {output_file_path}")

0 commit comments

Comments
 (0)