-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDetectionScript.py
More file actions
44 lines (39 loc) · 1.6 KB
/
DetectionScript.py
File metadata and controls
44 lines (39 loc) · 1.6 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
import json
from pathlib import Path
# Deprecated types and markers
DEPRECATED_TYPES = {"singlestat", "graph"}
TEXT_PANEL_WITH_HTML = ("text", "html")
def check_dashboard(file_path):
with open(file_path, "r", encoding="utf-8") as f:
data = json.load(f)
deprecated_panels = []
for panel in data.get("panels", []):
panel_type = panel.get("type", "")
title = panel.get("title", "Untitled")
# Check for deprecated panel types
if panel_type in DEPRECATED_TYPES:
deprecated_panels.append((title, f"Deprecated panel type: {panel_type}"))
# Check for old HTML text mode
elif panel_type == TEXT_PANEL_WITH_HTML[0]:
mode = panel.get("mode") or panel.get("options", {}).get("mode")
if mode == TEXT_PANEL_WITH_HTML[1]:
deprecated_panels.append((title, "Text panel using HTML (AngularJS)"))
return deprecated_panels
def scan_dashboards(folder_path):
folder = Path(folder_path)
json_files = list(folder.glob("*.json"))
if not json_files:
print("No JSON files found in the folder.")
return
for json_file in json_files:
findings = check_dashboard(json_file)
if findings:
print(f"\nDashboard: {json_file.name}")
for title, issue in findings:
print(f" - Panel: '{title}' → {issue}")
else:
print(f"\nDashboard: {json_file.name}")
print(" No deprecated AngularJS components found.")
if __name__ == "__main__":
dashboards_folder = "/content/drive/MyDrive/v11"
scan_dashboards(dashboards_folder)