Skip to content

Commit

Permalink
Add debug switch to the fab command
Browse files Browse the repository at this point in the history
  • Loading branch information
yaqwsx committed Oct 31, 2022
1 parent bb13d00 commit 90cded9
Showing 1 changed file with 19 additions and 26 deletions.
45 changes: 19 additions & 26 deletions kikit/fab_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,24 @@ def fabCommand(f):
help="Run DRC check before building the output.")(f)
f = click.option("--nametemplate", default="{}",
help="Template for naming the output files.")(f)
f = click.option("--debug", is_flag=True, default=False,
help="Print extra debugging information")(f)
return f

def execute(fab, kwargs):
debug = kwargs["debug"]
del kwargs["debug"]

try:
return fab(**kwargs)
except Exception as e:
import sys
sys.stderr.write(f"An error occurred: {e}\n")
sys.stderr.write("No output files produced\n")
if debug:
raise e from None
sys.exit(1)

@click.command()
@fabCommand
@click.option("--assembly/--no-assembly", help="Generate files for SMT assembly (schematics is required)")
Expand All @@ -32,15 +48,7 @@ def jlcpcb(**kwargs):
from kikit.fab import jlcpcb
from kikit.common import fakeKiCADGui
app = fakeKiCADGui()

try:
return jlcpcb.exportJlcpcb(**kwargs)
except Exception as e:
import sys
sys.stderr.write("An error occurred: " + str(e) + "\n")
sys.stderr.write("No output files produced\n")
sys.exit(1)

return execute(jlcpcb.exportJlcpcb, kwargs)

@click.command()
@fabCommand
Expand Down Expand Up @@ -72,14 +80,7 @@ def pcbway(**kwargs):
from kikit.fab import pcbway
from kikit.common import fakeKiCADGui
app = fakeKiCADGui()

try:
return pcbway.exportPcbway(**kwargs)
except Exception as e:
import sys
sys.stderr.write("An error occurred: " + str(e) + "\n")
sys.stderr.write("No output files produced\n")
sys.exit(1)
return execute(pcbway.exportPcbway, kwargs)


@click.command()
Expand All @@ -91,15 +92,7 @@ def oshpark(**kwargs):
from kikit.fab import oshpark
from kikit.common import fakeKiCADGui
app = fakeKiCADGui()

try:
return oshpark.exportOSHPark(**kwargs)
except Exception as e:
import sys
sys.stderr.write("An error occurred: " + str(e) + "\n")
sys.stderr.write("No output files produced\n")
sys.exit(1)

return execute(oshpark.exportOSHPark, kwargs)

@click.group()
def fab():
Expand Down

0 comments on commit 90cded9

Please sign in to comment.