On Feb 1, 2012, at 2:34 PM, Chris Rebert wrote: > On Wed, Feb 1, 2012 at 1:00 PM, Russell E. Owen <ro...@uw.edu> wrote: >> I have an odd and very intermittent problem in Python script. >> Occasionally it fails with this error: >> >> Traceback (most recent call last): >> File >> "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas >> eFocusScript.py", line 884, in run >> File >> "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas >> eFocusScript.py", line 1690, in initAll >> TypeError: unbound method initAll() must be called with BaseFocusScript >> instance as first argument (got ScriptClass instance instead) > <snip> >> The code looks like this: >> >> def run(self, sr): >> try: >> self.initAll() > <snip> >> I am puzzled why Python thinks the class type is wrong, given the output >> of inspect.getclasstree. Any ideas on what might be wrong and how to >> track it down (and why it would be so intermittent)? > > What's the offending line of initAll() [#1690 in BaseFocusScript.py] > look like? The lines preceding it would also be helpful for context.
Here you go. The offending line #169 is marked with *** -- Russell class ImagerFocusScript(BaseFocusScript): """...""" def __init__(self, sr, instName, imageViewerTLName = None, defRadius = 5.0, defBinFactor = 1, maxFindAmpl = None, doWindow = False, windowOrigin = 1, windowIsInclusive = True, doZeroOverscan = False, helpURL = None, debug = False, ): ... BaseFocusScript.__init__(self, sr = sr, gcamActor = gcamActor, instName = instName, imageViewerTLName = imageViewerTLName, defRadius = defRadius, defBinFactor = defBinFactor, maxFindAmpl = maxFindAmpl, doWindow = doWindow, windowOrigin = windowOrigin, windowIsInclusive = windowIsInclusive, helpURL = helpURL, debug = debug, ) self.doZeroOverscan = bool(doZeroOverscan) .... def initAll(self): """Override the default initAll to record initial bin factor, if relevant """ *** BaseFocusScript.initAll(self) if self.exposeModel.instInfo.numBin > 0: self.finalBinFactor = self.exposeModel.bin.getInd(0)[0] Also, here is BaseFocusScript: class BaseFocusScript(object): """Basic focus script object. This is a virtual base class. The inheritor must: - Provide widgets - Provide a "run" method """ cmd_Find = "find" cmd_Measure = "measure" cmd_Sweep = "sweep" # constants #DefRadius = 5.0 # centroid radius, in arcsec #NewStarRad = 2.0 # amount of star position change to be considered a new star DefFocusNPos = 5 # number of focus positions DefFocusRange = 200 # default focus range around current focus FocusWaitMS = 1000 # time to wait after every focus adjustment (ms) BacklashComp = 0 # amount of backlash compensation, in microns (0 for none) WinSizeMult = 2.5 # window radius = centroid radius * WinSizeMult FocGraphMargin = 5 # margin on graph for x axis limits, in um MaxFocSigmaFac = 0.5 # maximum allowed sigma of best fit focus as a multiple of focus range MinFocusIncr = 10 # minimum focus increment, in um def __init__(self, sr, gcamActor, instName, tccInstPrefix = None, imageViewerTLName = None, defRadius = 5.0, defBinFactor = 1, finalBinFactor = None, canSetStarPos = True, maxFindAmpl = None, doWindow = True, windowOrigin = 0, windowIsInclusive = True, helpURL = None, debug = False, ): """....""" self.sr = sr self.sr.debug = bool(debug) self.gcamActor = gcamActor .... def initAll(self): """Initialize variables, table and graph. """ # initialize shared variables self.doTakeFinalImage = False self.focDir = None self.currBoreXYDeg = None self.begBoreXYDeg = None self.instScale = None self.arcsecPerPixel = None self.instCtr = None self.instLim = None self.cmdMode = None self.focPosToRestore = None self.expTime = None self.absStarPos = None self.relStarPos = None self.binFactor = None self.window = None # LL pixel is 0, UR pixel is included self.enableCmdBtns(False) -- http://mail.python.org/mailman/listinfo/python-list