Esempio n. 1
0
 def from_bytes(bbuff, encoding='ascii'):
     bbuff = bbuff.decode(encoding).strip()
     cmd = POP3DELECmd()
     t, bbuff = read_element(bbuff, toend=True)
     cmd.command = POP3Command[t]
     cmd.msgno, bbuff = read_element(bbuff, toend=True)
     return cmd
Esempio n. 2
0
 def from_bytes(bbuff, encoding='ascii'):
     bbuff = bbuff.decode(encoding).strip()
     cmd = SMTPEHLOCmd()
     t, bbuff = read_element(bbuff, toend=True)
     cmd.command = SMTPCommand[t.upper()]
     cmd.msgno, bbuff = read_element(bbuff, toend=True)
     return cmd
Esempio n. 3
0
 def from_bytes(bbuff, encoding='ascii'):
     bbuff = bbuff.decode(encoding).strip()
     cmd = POP3USERCmd()
     t, bbuff = read_element(bbuff)
     cmd.command = POP3Command[t]
     cmd.username, bbuff = read_element(bbuff, toend=True)
     return cmd
Esempio n. 4
0
 def from_bytes(bbuff, encoding='ascii'):
     bbuff = bbuff.decode(encoding).strip()
     cmd = POP3PASSCmd()
     t, bbuff = read_element(bbuff)
     cmd.command = POP3Command[t]
     cmd.password, bbuff = read_element(bbuff, toend=True)
     return cmd
Esempio n. 5
0
 def from_bytes(bbuff, encoding='utf-7'):
     bbuff = bbuff.decode(encoding).strip()
     cmd = IMAPUNSUBSCRIBECmd()
     cmd.tag, bbuff = read_element(bbuff)
     t, bbuff = read_element(bbuff)
     cmd.command = IMAPCommand[t.upper()]
     cmd.mailboxname = bbuff
     return cmd
Esempio n. 6
0
 def from_bytes(bbuff, encoding='ascii'):
     bbuff = bbuff.decode(encoding).strip()
     cmd = POP3AUTHCmd()
     t, bbuff = read_element(bbuff, toend=True)
     cmd.command = POP3Command[t]
     if bbuff.strip() != '':
         cmd.auth_type, bbuff = read_element(bbuff, toend=True)
     return cmd
Esempio n. 7
0
    def from_bytes(bbuff, encoding='utf-7'):
        bbuff = bbuff.decode(encoding).strip()
        resp = IMAPCAPABILITYResp()
        resp.tag, bbuff = read_element(bbuff)
        t, bbuff = read_element(bbuff)
        resp.command = IMAPCommand[t.upper()]
        resp.capabilities = bbuff.split(' ')

        return resp
Esempio n. 8
0
 def from_bytes(bbuff, encoding='ascii'):
     bbuff = bbuff.decode(encoding).strip()
     cmd = SMTPAUTHCmd()
     t, bbuff = read_element(bbuff)
     cmd.command = SMTPCommand[t.upper()]
     cmd.mechanism, bbuff = read_element(bbuff, toend=True)
     if len(bbuff) > 0:
         cmd.data = bbuff
     return cmd
Esempio n. 9
0
 def from_bytes(bbuff, encoding='utf-7'):
     bbuff = bbuff.decode(encoding).strip()
     cmd = IMAPLOGINCmd()
     cmd.tag, bbuff = read_element(bbuff)
     t, bbuff = read_element(bbuff)
     cmd.command = IMAPCommand[t.upper()]
     cmd.username, bbuff = read_element(bbuff)
     cmd.password = bbuff
     return cmd
Esempio n. 10
0
    def from_bytes(bbuff, encoding='utf-7'):
        bbuff = bbuff.decode(encoding).strip()
        resp = IMAPOKResp()
        resp.tag, bbuff = read_element(bbuff)
        t, bbuff = read_element(bbuff, toend=True)
        resp.status = IMAPResponse[t]
        if bbuff != '':
            resp.args = bbuff.split(' ')

        return resp
Esempio n. 11
0
 def from_bytes(bbuff, encoding='utf-7'):
     try:
         bbuff = bbuff.decode(encoding).strip()
         cmd = IMAPSELECTCmd()
         cmd.tag, bbuff = read_element(bbuff)
         t, bbuff = read_element(bbuff)
         cmd.command = IMAPCommand[t.upper()]
         cmd.mailboxname = bbuff
         return cmd
     except Exception as e:
         print(str(e))
         raise e
Esempio n. 12
0
 def from_bytes(bbuff, encoding='utf-7'):
     print('Here!')
     try:
         bbuff = bbuff.decode(encoding).strip()
         cmd = IMAPAUTHENTICATECmd()
         cmd.tag, bbuff = read_element(bbuff)
         t, bbuff = read_element(bbuff)
         cmd.command = IMAPCommand[t.upper()]
         cmd.auth_type = IMAPAuthMethod[bbuff.upper()]
         return cmd
     except Exception as e:
         print(str(e))
         raise e
Esempio n. 13
0
 def from_bytes(bbuff, encoding='ascii'):
     bbuff = bbuff.decode(encoding).strip()
     cmd = SMTPHELPCmd()
     t, bbuff = read_element(bbuff, toend=True)
     cmd.command = SMTPCommand[t.upper()]
     if len(bbuff) > 0:
         cmd.data = bbuff.split(' ')
     return cmd
Esempio n. 14
0
    def from_bytes(bbuff, encoding='ascii'):
        bbuff = bbuff.decode(encoding).strip().split('\r\n')
        resp = POP3OKResp()
        status, resp.params = read_element(bbuff[0], toend=True)
        resp.status = POP3ResponseStatus(status)
        if len(bbuff) > 1:
            resp.data = bbuff[1:]

        return resp
Esempio n. 15
0
    def from_bytes(bbuff, encoding='ascii'):
        bbuff = bbuff.decode(encoding).strip()
        cmd = SMTPRCPTCmd()
        t, bbuff = read_element(bbuff)
        cmd.command = SMTPCommand[t.upper()]
        t, bbuff = read_element(bbuff, marker=':')
        temp_email = bbuff.strip()
        if temp_email[0] == '<':
            temp_email = temp_email[1:]
            cmd.emailaddress, bbuff = read_element(temp_email,
                                                   marker='>',
                                                   toend=True)

        else:
            # this case means the email address was defined in an old format, using spaces
            cmd.emailaddress, bbuff = read_element(temp_email, toend=True)

        if bbuff != '':
            cmd.params = bbuff.split(' ')

        return cmd
Esempio n. 16
0
 def from_bytes(bbuff, encoding='ascii'):
     if bbuff is None:
         # we return an empty instance, as this command is muliline
         return SMTPDATACmd()
     bbuff = bbuff.decode(encoding).strip()
     cmd = SMTPDATACmd()
     t, bbuff = read_element(bbuff, marker='\n')
     cmd.command = SMTPCommand[t.strip().upper()]
     cmd.emaildata = ''
     for line in bbuff.split('\n'):
         if line.strip() == '.':
             break
         cmd.emaildata += line + '\n'
     return cmd
Esempio n. 17
0
 def from_bytes(bbuff, encoding='utf-7'):
     bbuff = bbuff.decode(encoding).strip()
     cmd = IMAPSTARTTLSCmd()
     cmd.tag, bbuff = read_element(bbuff)
     cmd.command = IMAPCommand[bbuff.upper()]
     return cmd
Esempio n. 18
0
def read_list(line):
    temp = read_element(line, marker='(', marker_end=')')
    return temp[1:-1].split(' ')
Esempio n. 19
0
 def from_bytes(bbuff, encoding='utf-7'):
     bbuff = bbuff.decode(encoding).strip()
     cmd = IMAPCAPABILITYCmd()
     cmd.tag, bbuff = read_element(bbuff, toend=True)
     cmd.command = IMAPCommand[bbuff.upper()]
     return cmd
Esempio n. 20
0
 def from_bytes(bbuff, encoding='ascii'):
     bbuff = bbuff.decode(encoding).strip()
     resp = POP3ERRResp()
     status, resp.params = read_element(bbuff, toend=True)
     resp.status = POP3ResponseStatus(status)
     return resp
Esempio n. 21
0
 def from_bytes(bbuff, encoding='utf-7'):
     bbuff = bbuff.decode(encoding).strip()
     cmd = IMAPLOGOUTCmd()
     cmd.tag, bbuff = read_element(bbuff)
     cmd.command = IMAPCommand[bbuff]
     return cmd