コード例 #1
0
ファイル: mailbox.py プロジェクト: ssvlab/esbmc-gpu
    def open(self, mode=0):
        """Open the connection.

        'mode' may be a string, consisting of the characters described
        below, giving the access mode for the mailbox.

        mode   Meaning
        -------------------------------------------------------- 
        r      Open for reading.
        w      Open for writing.
        a      Open for appending to the end of the mailbox.
        c      Create the mailbox if it does not exist.

        """
        if isinstance(mode, types.StringType):
            from mailutils import stream
            flags = 0
            for m in mode:
                if m == 'r':
                    flags = flags | stream.MU_STREAM_READ
                elif m == 'w':
                    flags = flags | stream.MU_STREAM_WRITE
                elif m == 'a':
                    flags = flags | stream.MU_STREAM_APPEND
                elif m == 'c':
                    flags = flags | stream.MU_STREAM_CREAT
            if flags & stream.MU_STREAM_READ and flags & stream.MU_STREAM_WRITE:
                flags = (flags & ~(stream.MU_STREAM_READ | \
                                   stream.MU_STREAM_WRITE)) | \
                                   stream.MU_STREAM_RDWR
            mode = flags
        status = mailbox.open(self.mbox, mode)
        if status:
            raise MailboxError(status)
コード例 #2
0
ファイル: mailbox.py プロジェクト: ssvlab/esbmc-gpu
 def __init__(self, name):
     if isinstance(name, mailbox.MailboxType):
         self.mbox = name
     else:
         self.mbox = mailbox.MailboxType()
         self.__owner = True
         status = mailbox.create(self.mbox, name)
         if status:
             raise MailboxError(status)
コード例 #3
0
ファイル: mailbox.py プロジェクト: ssvlab/esbmc-gpu
    def __init__(self, name=None):
        """MailboxDefault creates a Mailbox object for the supplied
        mailbox 'name'. Before creating, the name is expanded using
        the rules below:

        %           --> system mailbox for the real uid
        %user       --> system mailbox for the given user
        ~/file      --> /home/user/file
        ~user/file  --> /home/user/file
        +file       --> /home/user/Mail/file
        =file       --> /home/user/Mail/file
        """
        self.mbox = mailbox.MailboxType()
        status = mailbox.create_default(self.mbox, name)
        if status:
            raise MailboxError(status)
コード例 #4
0
ファイル: mailbox.py プロジェクト: ssvlab/esbmc-gpu
 def flush(self, expunge=False):
     """Flush the mailbox."""
     status = mailbox.flush(self.mbox, expunge)
     if status:
         raise MailboxError(status)
コード例 #5
0
ファイル: mailbox.py プロジェクト: ssvlab/esbmc-gpu
 def close(self):
     """Close the connection."""
     status = mailbox.close(self.mbox)
     if status:
         raise MailboxError(status)
コード例 #6
0
ファイル: mailbox.py プロジェクト: ssvlab/esbmc-gpu
 def expunge(self):
     """Remove all messages marked for deletion."""
     status = mailbox.expunge(self.mbox)
     if status:
         raise MailboxError(status)
コード例 #7
0
ファイル: mailbox.py プロジェクト: ssvlab/esbmc-gpu
 def get_folder(self):
     """Get the Folder object."""
     status, fld = mailbox.get_folder(self.mbox)
     if status:
         raise MailboxError(status)
     return folder.Folder(fld)
コード例 #8
0
ファイル: mailbox.py プロジェクト: ssvlab/esbmc-gpu
 def message_unseen(self):
     """Return the number of first unseen message in mailbox."""
     status, recent = mailbox.message_unseen(self.mbox)
     if status:
         raise MailboxError(status)
     return unseen
コード例 #9
0
ファイル: mailbox.py プロジェクト: ssvlab/esbmc-gpu
 def unlock(self):
     """Unlock the mailbox."""
     status = mailbox.unlock(self.mbox)
     if status:
         raise MailboxError(status)
コード例 #10
0
ファイル: mailbox.py プロジェクト: ssvlab/esbmc-gpu
 def get_size(self):
     """Return the mailbox size."""
     status, size = mailbox.get_size(self.mbox)
     if status:
         raise MailboxError(status)
     return size
コード例 #11
0
ファイル: mailbox.py プロジェクト: ssvlab/esbmc-gpu
 def lock(self):
     """Lock the mailbox."""
     status = mailbox.lock(self.mbox)
     if status:
         raise MailboxError(status)
コード例 #12
0
ファイル: mailbox.py プロジェクト: ssvlab/esbmc-gpu
 def get_uidls(self):
     """Get UIDL list."""
     status, uidls = mailbox.get_uidls(self.mbox)
     if status:
         raise MailboxError(status)
     return uidls
コード例 #13
0
ファイル: mailbox.py プロジェクト: ssvlab/esbmc-gpu
 def sync(self):
     """Synchronize the mailbox."""
     status = mailbox.sync(self.mbox)
     if status:
         raise MailboxError(status)
コード例 #14
0
ファイル: mailbox.py プロジェクト: ssvlab/esbmc-gpu
 def messages_count(self):
     """Return the number of messages in mailbox."""
     status, total = mailbox.messages_count(self.mbox)
     if status:
         raise MailboxError(status)
     return total
コード例 #15
0
ファイル: mailbox.py プロジェクト: ssvlab/esbmc-gpu
 def get_debug(self):
     """Get the Debug object."""
     status, dbg = mailbox.get_debug(self.mbox)
     if status:
         raise MailboxError(status)
     return debug.Debug(dbg)
コード例 #16
0
ファイル: mailbox.py プロジェクト: ssvlab/esbmc-gpu
 def messages_recent(self):
     """Return the number of recent messages in mailbox."""
     status, recent = mailbox.messages_recent(self.mbox)
     if status:
         raise MailboxError(status)
     return recent
コード例 #17
0
ファイル: mailbox.py プロジェクト: ssvlab/esbmc-gpu
 def get_url(self):
     """Get the Url object."""
     status, u = mailbox.get_url(self.mbox)
     if status:
         raise MailboxError(status)
     return url.Url(u)
コード例 #18
0
ファイル: mailbox.py プロジェクト: ssvlab/esbmc-gpu
 def get_message(self, msgno):
     """Retrieve message number 'msgno'."""
     status, c_msg = mailbox.get_message(self.mbox, msgno)
     if status:
         raise MailboxError(status)
     return message.Message(c_msg)
コード例 #19
0
ファイル: mailbox.py プロジェクト: ssvlab/esbmc-gpu
 def append_message(self, msg):
     """Append 'msg' to the mailbox."""
     status = mailbox.append_message(self.mbox, msg.msg)
     if status:
         raise MailboxError(status)