Skip to content

Commit

Permalink
[KiBot Check][Added] Some tests for broken KiCad Python support
Browse files Browse the repository at this point in the history
From information reported in #606
  • Loading branch information
set-soft committed Apr 10, 2024
1 parent 0500d4d commit fb286fc
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/kibot-check
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,26 @@ try:
kicad_plugins_dirs.append(os.path.join(home, '.kicad', 'scripting', 'plugins'))
except FileNotFoundError:
kicad_ok = False
except ModuleNotFoundError:
kicad_ok = False
if which('kicad'):
error("KiCad installed but the Python support is broken")
res = run_command(['find', '/usr/lib', '-name', 'pcbnew.py'])
if res:
cand = res.split('\n')
if cand:
cand = [x for x in cand if 'pcbnewTransition' not in x]
if cand:
if len(cand) == 1:
dname = os.path.dirname(cand[0])
if dname in sys.path:
error(f"The pcbnew module should be loadable, but fails to load")
else:
error(f"Broken Python support {dname} not in sys.path ({sys.path})")
else:
error(f'Multiple pcbnew modules found: {str(cand)}')
else:
error("KiCad not installed or not available in the path")
kicad_version = (0, 0, 0)
if kicad_ok:
try:
Expand Down
20 changes: 20 additions & 0 deletions src/kibot-check.in
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,26 @@ try:
kicad_plugins_dirs.append(os.path.join(home, '.kicad', 'scripting', 'plugins'))
except FileNotFoundError:
kicad_ok = False
except ModuleNotFoundError:
kicad_ok = False
if which('kicad'):
error("KiCad installed but the Python support is broken")
res = run_command(['find', '/usr/lib', '-name', 'pcbnew.py'])
if res:
cand = res.split('\n')
if cand:
cand = [x for x in cand if 'pcbnewTransition' not in x]
if cand:
if len(cand) == 1:
dname = os.path.dirname(cand[0])
if dname in sys.path:
error(f"The pcbnew module should be loadable, but fails to load")
else:
error(f"Broken Python support {dname} not in sys.path ({sys.path})")
else:
error(f'Multiple pcbnew modules found: {str(cand)}')
else:
error("KiCad not installed or not available in the path")
kicad_version = (0, 0, 0)
if kicad_ok:
try:
Expand Down

0 comments on commit fb286fc

Please sign in to comment.