def getDevice(self, device=None): """Starting with stdgraph, drill until a device is found in the graphcap or isn't""" if not device: device = iraf.envget("stdgraph","") graphcap = getGraphcap() # protect against circular definitions devstr = device tried = {devstr: None} while not graphcap.has_key(devstr): pdevstr = devstr devstr = iraf.envget(pdevstr,"") if not devstr: raise iraf.IrafError( "No entry found for specified stdgraph device `%s'" % device) elif tried.has_key(devstr): # track back through circular definition s = [devstr] next = pdevstr while next and (next != devstr): s.append(next) next = tried[next] if next: s.append(next) s.reverse() raise iraf.IrafError( "Circular definition in graphcap for device\n%s" % (string.join(s,' -> '),)) else: tried[devstr] = pdevstr return devstr
def printPlot(window=None): """Print contents of window (default active window) to stdplot window must be a GkiKernel object (with a gkibuffer attribute.) """ if window is None: window = gwm.getActiveGraphicsWindow() if window is None: return gkibuff = window.gkibuffer.get() if gkibuff: graphcap = getGraphcap() stdplot = iraf.envget('stdplot','') if not stdplot: msg = "No hardcopy device defined in stdplot" elif not graphcap.has_key(stdplot): msg = "Unknown hardcopy device stdplot=`%s'" % stdplot else: printer = gkiiraf.GkiIrafKernel(stdplot) printer.append(gkibuff) printer.flush() msg = "snap completed" stdout = kernel.getStdout(default=sys.stdout) stdout.write("%s\n" % msg)