예제 #1
0
class Agent(object):
    def __init__(self, name, mta):
        self.agent_id = AgentID().generate()
        self.is_active = False
        self.name = name
        self.setupMTA(mta)

    def setupMTA(self, mta, logger=None):
        if mta:
            if logger:
                self.logger = logger
            else:
                self.logger = mta.logger
            self.mta = weakref_ref(mta)
            self.mailbox = Mailbox(self, mta)
        else:
            self.logger = None
            self.mta = None
            self.mailbox = None

    def __cmp__(self, other):
        return cmp(self.agent_id, other.agent_id)

    def __del__(self):
        try:
            self.debug("Destroy")
            self.deactivate()
            if self.mailbox:
                self.mailbox.unregister()
            self.destroy()
        except KeyboardInterrupt:
            self.error("Agent destruction interrupted!")
            self.send('application_interrupt')
        except FUSIL_ERRORS, error:
            writeError(self, error, "Agent destruction error")
예제 #2
0
 def setupMTA(self, mta, logger=None):
     if mta:
         if logger:
             self.logger = logger
         else:
             self.logger = mta.logger
         self.mta = weakref_ref(mta)
         self.mailbox = Mailbox(self, mta)
     else:
         self.logger = None
         self.mta = None
         self.mailbox = None
예제 #3
0
 def setupMTA(self, mta, logger=None):
     """
     Create the mailbox and store a weak reference the message transfert
     agent (MTA).
     """
     if mta:
         if logger:
             self.logger = logger
         else:
             self.logger = mta.logger
         self.mta = weakref_ref(mta)
         self.mailbox = Mailbox(self, mta)
     else:
         self.logger = None
         self.mta = None
         self.mailbox = None
예제 #4
0
class Agent(object):
    def __init__(self, name, mta):
        self.agent_id = AgentID().generate()
        self.is_active = False
        self.name = name
        self.setupMTA(mta)

    def setupMTA(self, mta, logger=None):
        """
        Create the mailbox and store a weak reference the message transfert
        agent (MTA).
        """
        if mta:
            if logger:
                self.logger = logger
            else:
                self.logger = mta.logger
            self.mta = weakref_ref(mta)
            self.mailbox = Mailbox(self, mta)
        else:
            self.logger = None
            self.mta = None
            self.mailbox = None

    def __cmp__(self, other):
        return cmp(self.agent_id, other.agent_id)

    def __del__(self):
        try:
            if hasattr(self, 'is_active'):
                self.deactivate()
            if hasattr(self, "mailbox") and self.mailbox:
                self.mailbox.unregister()
            self.destroy()
        except KeyboardInterrupt:
            self.error("Agent destruction interrupted!")
            self.send('application_interrupt')
        except PTRACE_ERRORS, error:
            writeError(self, error, "Agent destruction error")
        except:
예제 #5
0
파일: agent.py 프로젝트: cherry-wb/segvault
class Agent(object):
    def __init__(self, name, mta):
        self.agent_id = AgentID().generate()
        self.is_active = False
        self.name = name
        self.setupMTA(mta)

    def setupMTA(self, mta, logger=None):
        """
        Create the mailbox and store a weak reference the message transfert
        agent (MTA).
        """
        if mta:
            if logger:
                self.logger = logger
            else:
                self.logger = mta.logger
            self.mta = weakref_ref(mta)
            self.mailbox = Mailbox(self, mta)
        else:
            self.logger = None
            self.mta = None
            self.mailbox = None

    def __cmp__(self, other):
        return cmp(self.agent_id, other.agent_id)

    def __del__(self):
        try:
            if hasattr(self, 'is_active'):
                self.deactivate()
            if hasattr(self, "mailbox") and self.mailbox:
                self.mailbox.unregister()
            self.destroy()
        except KeyboardInterrupt:
            self.error("Agent destruction interrupted!")
            self.send('application_interrupt')
        except PTRACE_ERRORS, error:
            writeError(self, error, "Agent destruction error")
        except:
예제 #6
0
파일: agent.py 프로젝트: cherry-wb/segvault
 def setupMTA(self, mta, logger=None):
     """
     Create the mailbox and store a weak reference the message transfert
     agent (MTA).
     """
     if mta:
         if logger:
             self.logger = logger
         else:
             self.logger = mta.logger
         self.mta = weakref_ref(mta)
         self.mailbox = Mailbox(self, mta)
     else:
         self.logger = None
         self.mta = None
         self.mailbox = None