更新這似乎是未加標籤的響應通過扭曲處理的方式,我發現的唯一示例似乎遍歷所接收的數據並以某種方式收集對他們命令的響應,儘管我是不知道我是怎麼...扭曲的IMAP4客戶端QUOTA命令系列
試圖實現在RFC 2087(http://tools.ietf.org/html/rfc2087)中定義的IMAP4配額命令。
碼 - ImapClient
class SimpleIMAP4Client(imap4.IMAP4Client):
"""
A client with callbacks for greeting messages from an IMAP server.
"""
greetDeferred = None
def serverGreeting(self, caps):
self.serverCapabilities = caps
if self.greetDeferred is not None:
d, self.greetDeferred = self.greetDeferred, None
d.callback(self)
def lineReceived(self, line):
print "<" + str(line)
return imap4.IMAP4Client.lineReceived(self, line)
def sendLine(self, line):
print ">" + str(line)
return imap4.IMAP4Client.sendLine(self, line)
碼 - QUOTAROOT實施
def cbExamineMbox(result, proto):
"""
Callback invoked when examine command completes.
Retrieve the subject header of every message in the mailbox.
"""
print "Fetching storage space"
cmd = "GETQUOTAROOT"
args = _prepareMailboxName("INBOX")
resp = ("QUOTAROOT", "QUOTA")
d = proto.sendCommand(Command(cmd, args, wantResponse=resp))
d.addCallback(cbFetch, proto)
return d
def cbFetch(result, proto):
"""
Finally, display headers.
"""
print "Got Quota"
print result
輸出
Fetching storage space
>0005 GETQUOTAROOT INBOX
<* QUOTAROOT "INBOX" ""
<* QUOTA "" (STORAGE 171609 10584342)
<0005 OK Success
Got Quota
([], 'OK Success')
所以我得到的數據,但結果不包含它,我認爲這是因爲他們沒有標記的反應?
謝謝,從我所看到的解析代碼Command.finish只使用預設組標籤? – Zimm3r
這是正確的。 –
這篇文章有點舊了,但這只是幫助我解決了一個相關的教學扭曲問題,以識別RFC5256'THREAD'命令。 –