本文整理汇总了Python中offlineimap.ui.UIBase.getglobalui方法的典型用法代码示例。如果您正苦于以下问题:Python UIBase.getglobalui方法的具体用法?Python UIBase.getglobalui怎么用?Python UIBase.getglobalui使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类offlineimap.ui.UIBase
的用法示例。
在下文中一共展示了UIBase.getglobalui方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: syncfoldersto
# 需要导入模块: from offlineimap.ui import UIBase [as 别名]
# 或者: from offlineimap.ui.UIBase import getglobalui [as 别名]
def syncfoldersto(self, dest, copyfolders):
"""Syncs the folders in this repository to those in dest.
It does NOT sync the contents of those folders.
For every time dest.makefolder() is called, also call makefolder()
on each folder in copyfolders."""
src = self
srcfolders = src.getfolders()
destfolders = dest.getfolders()
# Create hashes with the names, but convert the source folders
# to the dest folder's sep.
srchash = {}
for folder in srcfolders:
srchash[folder.getvisiblename().replace(src.getsep(), dest.getsep())] = \
folder
desthash = {}
for folder in destfolders:
desthash[folder.getvisiblename()] = folder
#
# Find new folders.
#
for key in srchash.keys():
if not key in desthash:
try:
dest.makefolder(key)
for copyfolder in copyfolders:
copyfolder.makefolder(key.replace(dest.getsep(), copyfolder.getsep()))
except:
UIBase.getglobalui().warn("ERROR Attempting to make folder " \
+ key + ":" +str(sys.exc_info()[1]))
示例2: syncmessagesto_neguid_msg
# 需要导入模块: from offlineimap.ui import UIBase [as 别名]
# 或者: from offlineimap.ui.UIBase import getglobalui [as 别名]
def syncmessagesto_neguid_msg(self, uid, dest, applyto, register = 1):
if register:
UIBase.getglobalui().registerthread(self.getaccountname())
UIBase.getglobalui().copyingmessage(uid, self, applyto)
successobject = None
successuid = None
message = self.getmessage(uid)
flags = self.getmessageflags(uid)
rtime = self.getmessagetime(uid)
for tryappend in applyto:
successuid = tryappend.savemessage(uid, message, flags, rtime)
if successuid >= 0:
successobject = tryappend
break
# Did we succeed?
if successobject != None:
if successuid: # Only if IMAP actually assigned a UID
# Copy the message to the other remote servers.
for appendserver in \
[x for x in applyto if x != successobject]:
appendserver.savemessage(successuid, message, flags, rtime)
# Copy to its new name on the local server and delete
# the one without a UID.
self.savemessage(successuid, message, flags, rtime)
self.deletemessage(uid) # It'll be re-downloaded.
else:
# Did not find any server to take this message. Ignore.
pass
示例3: copymessageto
# 需要导入模块: from offlineimap.ui import UIBase [as 别名]
# 或者: from offlineimap.ui.UIBase import getglobalui [as 别名]
def copymessageto(self, uid, applyto, register = 1):
# Sometimes, it could be the case that if a sync takes awhile,
# a message might be deleted from the maildir before it can be
# synced to the status cache. This is only a problem with
# self.getmessage(). So, don't call self.getmessage unless
# really needed.
if register:
UIBase.getglobalui().registerthread(self.getaccountname())
UIBase.getglobalui().copyingmessage(uid, self, applyto)
message = ''
# If any of the destinations actually stores the message body,
# load it up.
for object in applyto:
if object.storesmessages():
message = self.getmessage(uid)
break
flags = self.getmessageflags(uid)
rtime = self.getmessagetime(uid)
for object in applyto:
newuid = object.savemessage(uid, message, flags, rtime)
if newuid > 0 and newuid != uid:
# Change the local uid.
self.savemessage(newuid, message, flags, rtime)
self.deletemessage(uid)
uid = newuid
示例4: processmessagesflags
# 需要导入模块: from offlineimap.ui import UIBase [as 别名]
# 或者: from offlineimap.ui.UIBase import getglobalui [as 别名]
def processmessagesflags(self, operation, uidlist, flags):
if len(uidlist) > 101:
# Hack for those IMAP ervers with a limited line length
self.processmessagesflags(operation, uidlist[:100], flags)
self.processmessagesflags(operation, uidlist[100:], flags)
return
imapobj = self.imapserver.acquireconnection()
try:
try:
imapobj.select(self.getfullname())
except imapobj.readonly:
UIBase.getglobalui().flagstoreadonly(self, uidlist, flags)
return
r = imapobj.uid('store',
imaputil.listjoin(uidlist),
operation + 'FLAGS',
imaputil.flagsmaildir2imap(flags))
assert r[0] == 'OK', 'Error with store: ' + '. '.join(r[1])
r = r[1]
finally:
self.imapserver.releaseconnection(imapobj)
# Some IMAP servers do not always return a result. Therefore,
# only update the ones that it talks about, and manually fix
# the others.
needupdate = copy(uidlist)
for result in r:
if result == None:
# Compensate for servers that don't return anything from
# STORE.
continue
attributehash = imaputil.flags2hash(imaputil.imapsplit(result)[1])
if not ('UID' in attributehash and 'FLAGS' in attributehash):
# Compensate for servers that don't return a UID attribute.
continue
lflags = attributehash['FLAGS']
uid = long(attributehash['UID'])
self.messagelist[uid]['flags'] = imaputil.flagsimap2maildir(lflags)
try:
needupdate.remove(uid)
except ValueError: # Let it slide if it's not in the list
pass
for uid in needupdate:
if operation == '+':
for flag in flags:
if not flag in self.messagelist[uid]['flags']:
self.messagelist[uid]['flags'].append(flag)
self.messagelist[uid]['flags'].sort()
elif operation == '-':
for flag in flags:
if flag in self.messagelist[uid]['flags']:
self.messagelist[uid]['flags'].remove(flag)
示例5: syncmessagesto_delete
# 需要导入模块: from offlineimap.ui import UIBase [as 别名]
# 或者: from offlineimap.ui.UIBase import getglobalui [as 别名]
def syncmessagesto_delete(self, dest, applyto):
"""Pass 3 of folder synchronization.
Look for message present in dest but not in self.
If any, delete them."""
deletelist = []
for uid in dest.getmessageuidlist():
if uid < 0:
continue
if not self.uidexists(uid):
deletelist.append(uid)
if len(deletelist):
UIBase.getglobalui().deletingmessages(deletelist, applyto)
for object in applyto:
object.deletemessages(deletelist)
示例6: savemessage
# 需要导入模块: from offlineimap.ui import UIBase [as 别名]
# 或者: from offlineimap.ui.UIBase import getglobalui [as 别名]
def savemessage(self, uid, content, flags, rtime):
# This function only ever saves to tmp/,
# but it calls savemessageflags() to actually save to cur/ or new/.
ui = UIBase.getglobalui()
ui.debug('perscon', 'savemessage: called to write with flags %s and content %s' % \
(repr(flags), "<?>"))
if uid < 0:
# We cannot assign a new uid.
return uid
if uid in self.messagelist:
# We already have it.
self.savemessageflags(uid, flags)
return uid
msguid = "IMAP.%s.%s.%s" % (self.accountname, self.name, uid)
atts = {}
flags.sort ()
msg = EmailJSON.convert_mail_to_dict(content, self.name, msguid, flags, rtime, atts)
msg = EmailJSON.tojson(msg)
try:
r = self.repository.rpc("doc/%s" % msguid, data=msg)
except urllib2.HTTPError as e:
print e.read ()
print msg
os._exit(1)
self.messagelist[uid] = {'uid': uid, 'flags': flags }
ui.debug('perscon', 'savemessage: returning uid %d' % uid)
return uid
示例7: syncitall
# 需要导入模块: from offlineimap.ui import UIBase [as 别名]
# 或者: from offlineimap.ui.UIBase import getglobalui [as 别名]
def syncitall(accounts, config):
currentThread().setExitMessage('SYNC_WITH_TIMER_TERMINATE')
ui = UIBase.getglobalui()
threads = threadutil.threadlist()
mbnames.init(config, accounts)
for accountname in accounts:
syncaccount(threads, config, accountname)
# Wait for the threads to finish.
threads.reset()
示例8: md5handler
# 需要导入模块: from offlineimap.ui import UIBase [as 别名]
# 或者: from offlineimap.ui.UIBase import getglobalui [as 别名]
def md5handler(self, response):
ui = UIBase.getglobalui()
challenge = response.strip()
ui.debug('imap', 'md5handler: got challenge %s' % challenge)
passwd = self.getpassword()
retval = self.username + ' ' + hmac.new(passwd, challenge).hexdigest()
ui.debug('imap', 'md5handler: returning %s' % retval)
return retval
示例9: savemessageflags
# 需要导入模块: from offlineimap.ui import UIBase [as 别名]
# 或者: from offlineimap.ui.UIBase import getglobalui [as 别名]
def savemessageflags(self, uid, flags):
imapobj = self.imapserver.acquireconnection()
try:
try:
imapobj.select(self.getfullname())
except imapobj.readonly:
UIBase.getglobalui().flagstoreadonly(self, [uid], flags)
return
result = imapobj.uid("store", "%d" % uid, "FLAGS", imaputil.flagsmaildir2imap(flags))
assert result[0] == "OK", "Error with store: " + ". ".join(r[1])
finally:
self.imapserver.releaseconnection(imapobj)
result = result[1][0]
if not result:
self.messagelist[uid]["flags"] = flags
else:
flags = imaputil.flags2hash(imaputil.imapsplit(result)[1])["FLAGS"]
self.messagelist[uid]["flags"] = imaputil.flagsimap2maildir(flags)
示例10: __init__
# 需要导入模块: from offlineimap.ui import UIBase [as 别名]
# 或者: from offlineimap.ui.UIBase import getglobalui [as 别名]
def __init__(self, name, sep, repository, accountname, config):
self.name = name
self.config = config
self.sep = sep
self.messagelist = None
self.repository = repository
self.accountname = accountname
self.ui = UIBase.getglobalui()
self.debug("name=%s sep=%s acct=%s" % (name, sep, accountname))
BaseFolder.__init__(self)
示例11: __init__
# 需要导入模块: from offlineimap.ui import UIBase [as 别名]
# 或者: from offlineimap.ui.UIBase import getglobalui [as 别名]
def __init__(self, config, name):
self.config = config
self.name = name
self.metadatadir = config.getmetadatadir()
self.localeval = config.getlocaleval()
self.ui = UIBase.getglobalui()
self.refreshperiod = self.getconffloat('autorefresh', 0.0)
self.quicknum = 0
if self.refreshperiod == 0.0:
self.refreshperiod = None
示例12: savemessageflags
# 需要导入模块: from offlineimap.ui import UIBase [as 别名]
# 或者: from offlineimap.ui.UIBase import getglobalui [as 别名]
def savemessageflags(self, uid, flags):
imapobj = self.imapserver.acquireconnection()
try:
try:
imapobj.select(self.getfullname())
except imapobj.readonly:
UIBase.getglobalui().flagstoreadonly(self, [uid], flags)
return
result = imapobj.uid('store', '%d' % uid, 'FLAGS',
imaputil.flagsmaildir2imap(flags))
assert result[0] == 'OK', 'Error with store: ' + '. '.join(r[1])
finally:
self.imapserver.releaseconnection(imapobj)
result = result[1][0]
if not result:
self.messagelist[uid]['flags'] = flags
else:
flags = imaputil.flags2hash(imaputil.imapsplit(result)[1])['FLAGS']
self.messagelist[uid]['flags'] = imaputil.flagsimap2maildir(flags)
示例13: syncmessagesto_flags
# 需要导入模块: from offlineimap.ui import UIBase [as 别名]
# 或者: from offlineimap.ui.UIBase import getglobalui [as 别名]
def syncmessagesto_flags(self, dest, applyto):
"""Pass 4 of folder synchronization.
Look for any flag matching issues -- set dest message to have the
same flags that we have."""
# As an optimization over previous versions, we store up which flags
# are being used for an add or a delete. For each flag, we store
# a list of uids to which it should be added. Then, we can call
# addmessagesflags() to apply them in bulk, rather than one
# call per message as before. This should result in some significant
# performance improvements.
addflaglist = {}
delflaglist = {}
for uid in self.getmessagelist().keys():
if uid < 0: # Ignore messages missed by pass 1
continue
selfflags = self.getmessageflags(uid)
destflags = dest.getmessageflags(uid)
addflags = [x for x in selfflags if x not in destflags]
for flag in addflags:
if not flag in addflaglist:
addflaglist[flag] = []
addflaglist[flag].append(uid)
delflags = [x for x in destflags if x not in selfflags]
for flag in delflags:
if not flag in delflaglist:
delflaglist[flag] = []
delflaglist[flag].append(uid)
for object in applyto:
for flag in addflaglist.keys():
UIBase.getglobalui().addingflags(addflaglist[flag], flag, [object])
object.addmessagesflags(addflaglist[flag], [flag])
for flag in delflaglist.keys():
UIBase.getglobalui().deletingflags(delflaglist[flag], flag, [object])
object.deletemessagesflags(delflaglist[flag], [flag])
示例14: __init__
# 需要导入模块: from offlineimap.ui import UIBase [as 别名]
# 或者: from offlineimap.ui.UIBase import getglobalui [as 别名]
def __init__(self, root, name, sep, repository, accountname, config):
self.name = name
self.config = config
self.dofsync = config.getdefaultboolean("general", "fsync", True)
self.root = root
self.sep = sep
self.ui = UIBase.getglobalui()
self.messagelist = None
self.repository = repository
self.accountname = accountname
BaseFolder.__init__(self)
示例15: deletemessages_noconvert
# 需要导入模块: from offlineimap.ui import UIBase [as 别名]
# 或者: from offlineimap.ui.UIBase import getglobalui [as 别名]
def deletemessages_noconvert(self, uidlist):
# Weed out ones not in self.messagelist
uidlist = [uid for uid in uidlist if uid in self.messagelist]
if not len(uidlist):
return
self.addmessagesflags_noconvert(uidlist, ['T'])
imapobj = self.imapserver.acquireconnection()
try:
try:
imapobj.select(self.getfullname())
except imapobj.readonly:
UIBase.getglobalui().deletereadonly(self, uidlist)
return
if self.expunge:
assert(imapobj.expunge()[0] == 'OK')
finally:
self.imapserver.releaseconnection(imapobj)
for uid in uidlist:
del self.messagelist[uid]