-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathverify_plugin.py
More file actions
105 lines (92 loc) · 3.19 KB
/
verify_plugin.py
File metadata and controls
105 lines (92 loc) · 3.19 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env python3
"""
Verification script to test if the LCSC Manager plugin can be loaded properly
Run this with KiCad's Python: ./kicad_python.sh verify_plugin.py
"""
import sys
import os
print("=== LCSC Manager Plugin Verification ===\n")
# Check plugin installation
plugin_dir = os.path.expanduser("~/Documents/KiCad/9.0/3rdparty/plugins/com_github_hulryung_kicad-lcsc-manager")
print(f"1. Checking plugin directory: {plugin_dir}")
if os.path.exists(plugin_dir):
print(" ✓ Plugin directory exists")
else:
print(" ✗ Plugin directory NOT found")
sys.exit(1)
# Check key files
required_files = [
"__init__.py",
"plugin.py",
"metadata.json",
"lib/requests/__init__.py"
]
print("\n2. Checking required files:")
for file in required_files:
file_path = os.path.join(plugin_dir, file)
if os.path.exists(file_path):
print(f" ✓ {file}")
else:
print(f" ✗ {file} MISSING")
# Check Python path
print(f"\n3. Python path:")
for path in sys.path[:5]:
print(f" - {path}")
# Try importing the plugin
print("\n4. Attempting to import plugin module:")
# Need to import as a package, so add parent directory to path
plugins_dir = os.path.dirname(plugin_dir)
sys.path.insert(0, plugins_dir)
package_name = os.path.basename(plugin_dir)
try:
# Import as package to support relative imports
import importlib
lcsc_module = importlib.import_module(package_name)
print(f" ✓ Package imported successfully")
print(f" Version: {lcsc_module.__version__}")
except Exception as e:
print(f" ✗ Failed to import package: {e}")
import traceback
traceback.print_exc()
sys.exit(1)
try:
LCSCManagerPlugin = getattr(lcsc_module, 'LCSCManagerPlugin', None)
if LCSCManagerPlugin is None:
# Try importing from submodule
plugin_module = importlib.import_module(f"{package_name}.plugin")
LCSCManagerPlugin = plugin_module.LCSCManagerPlugin
print(f" ✓ LCSCManagerPlugin class found")
except Exception as e:
print(f" ✗ Failed to get LCSCManagerPlugin class: {e}")
import traceback
traceback.print_exc()
sys.exit(1)
# Try creating plugin instance
print("\n5. Attempting to create plugin instance:")
try:
plugin = LCSCManagerPlugin()
print(f" ✓ Plugin instance created")
print(f" Name: {plugin.name}")
print(f" Description: {plugin.description}")
print(f" Show toolbar: {plugin.show_toolbar_button}")
# Test GetIconFileName
print("\n6. Testing GetIconFileName:")
icon_light = plugin.GetIconFileName(False)
icon_dark = plugin.GetIconFileName(True)
print(f" Light mode icon: {icon_light}")
print(f" Dark mode icon: {icon_dark}")
if os.path.exists(icon_light):
print(f" ✓ Icon file exists")
else:
print(f" ✗ Icon file NOT found")
except Exception as e:
print(f" ✗ Failed to create plugin instance: {e}")
import traceback
traceback.print_exc()
sys.exit(1)
print("\n=== All checks passed! ===")
print("\nIf toolbar icon still doesn't appear:")
print("1. Make sure KiCad is completely closed")
print("2. Restart KiCad")
print("3. Open PCB Editor")
print("4. Check the toolbar for the LCSC Manager icon")