def __init__(self, original): self.process = NullProcess() #make an attempt to update the original caller if hasattr(original, 'pid'): try: original.pid = self.process.pid except: pass if hasattr(original, 'inode'): try: original.inode = self.process.inode except: pass
class AdaptToNullProcess(object): """I can adapt a L{IDroneModelAppProcess} provider or a L{IDroneModelAppInstance} provider to a L{IKittNullProcess} provider. I hold no references to the Original Object after Instantiation. """ implements(IKittNullProcess) def __init__(self, original): self.process = NullProcess() #make an attempt to update the original caller if hasattr(original, 'pid'): try: original.pid = self.process.pid except: pass if hasattr(original, 'inode'): try: original.inode = self.process.inode except: pass def __getattribute__(self, name): try: return object.__getattribute__(self, name) except: return self.process.__getattribute__(name)
def __init__(self, original): self.process = NullProcess() #assume the process is dead if original.server.hostname == config.HOSTNAME: #delay scanning the process, for as long as possible try: self.process = ProcessSnapshot(original.pid) except InvalidProcess: pass #raise all others else: self.process = RemoteProcess(original.pid) #make an attempt to update the original caller if hasattr(original, 'pid'): try: original.pid = self.process.pid except: pass if hasattr(original, 'inode'): try: original.inode = self.process.inode except: pass