-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_status.py
More file actions
executable file
·75 lines (60 loc) · 2.87 KB
/
Copy pathcheck_status.py
File metadata and controls
executable file
·75 lines (60 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/./.venv/bin/python
"""
Check scraper status and progress
"""
import json
import os
import csv
from datetime import datetime
from collections import defaultdict
def check_status():
"""Check and display scraper status"""
# Check status file
if os.path.exists('scraper_status.json'):
with open('scraper_status.json', 'r') as f:
status = json.load(f)
print("=== SCRAPER STATUS ===")
print(f"Start time: {status.get('start_time', 'Not started')}")
print(f"Last completed: {status.get('last_completed_date', 'None')} COA{status.get('last_completed_court', 0):02d}")
print(f"Total requests: {status.get('total_requests', 0)}")
print(f"Total files downloaded: {status.get('total_files_downloaded', 0)}")
print(f"Completed combinations: {len(status.get('completed_combinations', []))}")
else:
print("No status file found - scraper hasn't started yet")
# Check log file for patterns
if os.path.exists('scrape_log.csv'):
print("\n=== LOG ANALYSIS ===")
court_stats = defaultdict(lambda: {'total': 0, 'with_cases': 0, 'files': 0})
date_stats = defaultdict(lambda: {'total': 0, 'with_cases': 0, 'files': 0})
with open('scrape_log.csv', 'r') as f:
reader = csv.DictReader(f)
for row in reader:
court = row['court']
date = row['date']
cases = int(row['criminal_cases_found'])
files = int(row['files_downloaded'])
court_stats[court]['total'] += 1
court_stats[court]['files'] += files
if cases > 0:
court_stats[court]['with_cases'] += 1
date_stats[date]['total'] += 1
date_stats[date]['files'] += files
if cases > 0:
date_stats[date]['with_cases'] += 1
print(f"Courts processed: {len(court_stats)}")
print(f"Dates processed: {len(date_stats)}")
# Show court summary
print("\n=== BY COURT ===")
for court in sorted(court_stats.keys()):
stats = court_stats[court]
print(f"{court}: {stats['with_cases']}/{stats['total']} dates with cases, {stats['files']} files")
# Show recent dates with opinions
print("\n=== RECENT DATES WITH CRIMINAL OPINIONS ===")
dates_with_cases = [(date, stats) for date, stats in date_stats.items() if stats['with_cases'] > 0]
dates_with_cases.sort(key=lambda x: x[0], reverse=True)
for date, stats in dates_with_cases[:10]: # Last 10 dates with cases
print(f"{date}: {stats['with_cases']}/{stats['total']} courts had cases, {stats['files']} files")
else:
print("No log file found")
if __name__ == "__main__":
check_status()