def getTEM(): classes = registry.getClasses() for i in classes: name, c = i if issubclass(c, tem.TEM): t = c() break return t
def handler(self): classes = registry.getClasses() tems = [] ccdcameras = [] fastccdcameras = [] for i in classes: name, c = i if issubclass(c, tem.TEM): tems.append(i) elif issubclass(c, ccdcamera.FastCCDCamera): fastccdcameras.append(i) elif issubclass(c, ccdcamera.CCDCamera): ccdcameras.append(i) for name, c in tems + ccdcameras + fastccdcameras: if issubclass(c, tem.TEM): instrumentclass = instrument.TEM wxaddmethod = self.panel.addTEM elif issubclass(c, ccdcamera.FastCCDCamera): instrumentclass = instrument.FastCCDCamera wxaddmethod = self.panel.addCCDCamera elif issubclass(c, ccdcamera.CCDCamera): instrumentclass = instrument.CCDCamera wxaddmethod = self.panel.addCCDCamera class ObjectClass(c, instrumentclass): def __init__(self): self._hostname = socket.gethostname().lower() c.__init__(self) instrumentclass.__init__(self) def getHostname(self): return self._hostname tries = 3 instance = None for i in range(1,tries+1): try: instance = ObjectClass() self.instruments[name] = instance self.objectservice._addObject(name, instance) self.logger.info('Added interface for %s' % name) break except Exception, e: self.logger.debug('Initialization of %s failed: %s' % (name, e)) continue if instance is None: continue if self.hasMagnifications(name): self.initializeMagnifications(name) wxaddmethod(name)
def handler(self): classes = registry.getClasses() tems = [] ccdcameras = [] for i in classes: name, c = i if issubclass(c, tem.TEM): tems.append(i) elif issubclass(c, ccdcamera.CCDCamera): ccdcameras.append(i) for name, c in tems + ccdcameras: if issubclass(c, tem.TEM): instrumentclass = instrument.TEM wxaddmethod = self.panel.addTEM elif issubclass(c, ccdcamera.CCDCamera): instrumentclass = instrument.CCDCamera wxaddmethod = self.panel.addCCDCamera class ObjectClass(c, instrumentclass): def __init__(self): self._hostname = socket.gethostname().lower() c.__init__(self) instrumentclass.__init__(self) def getHostname(self): return self._hostname def getCs(self): return self.cs tries = 3 instance = None for i in range(1, tries + 1): try: instance = ObjectClass() self.instruments[name] = instance self.objectservice._addObject(name, instance) self.logger.info('Added interface for %s' % name) break except Exception, e: self.logger.debug('Initialization of %s failed: %s' % (name, e)) continue if instance is None: continue if self.hasMagnifications(name): self.initializeMagnifications(name) wxaddmethod(name)