Skip to content

Commit

Permalink
v.0.86 - More verbose error report, some cleanups.
Browse files Browse the repository at this point in the history
  • Loading branch information
LordBlick committed Oct 10, 2014
1 parent 355c348 commit 13cead6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 20 deletions.
43 changes: 27 additions & 16 deletions pcbPanelize
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class panelizePCB:
ui.buttonProceed.connect("clicked", lambda xargs: self.appPanelize())
ui.buttonExit.connect("clicked", lambda xargs: self.Exit())

def errReport(self, txt):
ui = self.ui
ui.logView.insert_end(("Script Version: v.%0.2f. Error report:\n"+txt) % ui.version)

def brdBounds(self, pcb):
outPoints = []
for Draw in pcb.GetDrawings():
Expand Down Expand Up @@ -56,15 +60,19 @@ class panelizePCB:

def brdItemize(self, pcb):
self.lsItems = []
nullType = type(None)
for ItemStr in ('Drawings', 'Tracks', 'Modules'):
if ItemStr:
for Item in (getattr(pcb, 'Get'+ItemStr)()):
Item.remove = False
self.lsItems.append(Item)
for idx, Item in enumerate(getattr(pcb, 'Get'+ItemStr)()):
if type(Item)==nullType:
raise TypeError, "Null Object Error#%i, expected %s Type…" % (idx+1, ItemStr[:-1])
Item.remove = False
self.lsItems.append(Item)
nZones = pcb.GetAreaCount()
if nZones:
for idx in range(nZones):
Zone = pcb.GetArea(idx)
if type(Zone)==nullType:
raise TypeError, "Null Object Error#%i, expected Zone/Area Type…" % (idx+1,)
Zone.remove = False
self.lsItems.append(Zone)

Expand All @@ -86,7 +94,7 @@ class panelizePCB:

def brdPanel(self, pcb, nx, ny, spaceX=0, spaceY=0, margin=0, SolMsk=0, angle=0, debug=False):
if nx<1 or(ny<1):
return False
raise ValueError, "Collumns(%i) or Rows(%i) cannot be less than 1…" % (nx, ny)
if SolMsk:
for Module in pcb.GetModules():
Module.SetLocalSolderMaskMargin(SolMsk)
Expand Down Expand Up @@ -158,7 +166,7 @@ class panelizePCB:
pcb.Delete(Item)
pcb.SetAuxOrigin(wxBase)
pcb.SetGridOrigin(wxBase)
return True
return

def appUpdateFilename(self, bUpEmptyTxt=True):
ui = self.ui
Expand All @@ -181,23 +189,26 @@ class panelizePCB:
try:
pcb = LoadBoard(fileNamePCB)
except Exception as err:
ui.logView.insert_end("Unrecognized data found. Checkout that file:\n\t'%s'\nError message:\n\t%s\n"% (uiFileName, err))
self.errReport(("Unrecognized data found. Checkout that file:\n"+\
"\t'%s'\nError message:\n\t%s\n") % (uiFileName, err))
self.appDropFilename()
return
ui.logView.insert_end("Reading file:\n\t'%s'\n"% uiFileName)
Margin = ui.Margin.get_value() if ui.Margin.get_checked() else 0
SpaceX = ui.SpaceX.get_value() if ui.SpaceX.get_checked() else 0
SpaceY = ui.SpaceY.get_value() if ui.SpaceY.get_checked() else 0
bDone = self.brdPanel(pcb, int(ui.Cols.get_value()), int(ui.Rows.get_value()),
spaceX=SpaceX, spaceY=SpaceY, margin=Margin,
SolMsk=FromMils(4), angle=ui.rfAngle.get_value())
if bDone:
pcb.Save(fileNameSave)
ui.logView.insert_end("Saved in file:\n\t'%s'\n"% fileNameSave.replace(pt.expanduser('~'), '~'))
else:
ui.logView.insert_end("Something went wrong. Contact developers.\n"+\
"Provide info about current configuration and processed file:\n\t'%s'\n"% uiFileName)
try:
self.brdPanel(pcb, int(ui.Cols.get_value()), int(ui.Rows.get_value()),
spaceX=SpaceX, spaceY=SpaceY, margin=Margin,
SolMsk=FromMils(4), angle=ui.rfAngle.get_value())
except Exception as err:
self.errReport("Something went wrong. Contact developers.\n"+\
"Provide info about current configuration and processed file:\n"+\
"\t'%s'\nError message:\n\t%s\n" % (uiFileName, err))
self.appDropFilename()
return
pcb.Save(fileNameSave)
ui.logView.insert_end("Saved in file:\n\t'%s'\n"% fileNameSave.replace(pt.expanduser('~'), '~'))

def appFileName(self):
ui = self.ui
Expand Down
8 changes: 4 additions & 4 deletions uiPanelize.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ def __init__(frame, txtLabel, parentFixed, lsVal, x, y, row_height, active=0, wr
super(gtk.Frame, frame).__init__(label=txtLabel)
items = len(lsVal)
frame.fixed = gtk.Fixed()
frame.lsRet = map(lambda row: row[1], lsVal)
if type(wrap) is not int or(wrap<0):
wrap = 0
frameW = 5
Expand Down Expand Up @@ -322,7 +321,6 @@ def set_checked(fixed, bCheck):

class panelizeUI:
def __init__(ui):
from sys import path as ptSys
ui.apw = apw()
ui.gtk = gtk
ui.fontDesc = pango.FontDescription('Univers,Sans Condensed 8')
Expand All @@ -335,6 +333,8 @@ def __init__(ui):
ui.buttonProceed.connect("clicked",
lambda w: ui.logView.insert_end("Angle: %0.1f°\n" % (ui.rfAngle.get_value()/10)))
ui.logView.insert_end("User Interface Test...\nSo long… So long… So long… So long… long… Sooooo long…\n")
for kAttr in('Margin', 'SpaceX', 'SpaceY'):
setattr(getattr(ui,kAttr), 'logView',ui.logView)
ui.uiEnter()

uiEnter = lambda ui: gtk.main()
Expand All @@ -344,9 +344,9 @@ def uiInit(ui):
from gobject import TYPE_STRING as goStr, TYPE_INT as goInt
apw = ui.apw
ui.callDir = pt.dirname(pt.abspath(__file__))
version =.85
cd(ui.callDir)
ui.title = "PCBnew python module based Panelizator v.%0.2f. For BZR>5161" % version
ui.version = .86
ui.title = "PCBnew python module based Panelizator v.%0.2f. For BZR>5161" % ui.version
ui.mainWindow = gtk.Window(gtk.WINDOW_TOPLEVEL)
ui.wdhMain, ui.hgtMain = (580, 300)
ui.mainWindow.set_geometry_hints(min_width=ui.wdhMain, min_height=ui.hgtMain)
Expand Down

0 comments on commit 13cead6

Please sign in to comment.