Python 3 port:
/!\ this is a huge commit /!\ starting from this commit, SàT is needs Python 3.6+ /!\ SàT maybe be instable or some feature may not work anymore, this will improve with time This patch port backend, bridge and frontends to Python 3. Roughly this has been done this way: - 2to3 tools has been applied (with python 3.7) - all references to python2 have been replaced with python3 (notably shebangs) - fixed files not handled by 2to3 (notably the shell script) - several manual fixes - fixed issues reported by Python 3 that where not handled in Python 2 - replaced "async" with "async_" when needed (it's a reserved word from Python 3.7) - replaced zope's "implements" with @implementer decorator - temporary hack to handle data pickled in database, as str or bytes may be returned, to be checked later - fixed hash comparison for password - removed some code which is not needed anymore with Python 3 - deactivated some code which needs to be checked (notably certificate validation) - tested with jp, fixed reported issues until some basic commands worked - ported Primitivus (after porting dependencies like urwid satext) - more manual fixes
This commit is contained in:
parent
d21a6a660f
commit
fbfe96c505
1 changed files with 6336 additions and 6398 deletions
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# SàT plugin for managing Maildir type mail boxes
|
||||
|
|
@ -139,7 +139,7 @@ class MaildirBox(object):
|
|||
@param mailboxUser: MailboxUser instance"""
|
||||
if boxname not in self.__mailboxes:
|
||||
err_msg = _("Trying to remove an mailboxUser not referenced")
|
||||
log.error(_(u"INTERNAL ERROR: ") + err_msg)
|
||||
log.error(_("INTERNAL ERROR: ") + err_msg)
|
||||
raise MaildirError(err_msg)
|
||||
assert self.__mailboxes[profile][boxname] == mailboxUser
|
||||
del self.__mailboxes[profile][boxname]
|
||||
|
|
@ -158,7 +158,7 @@ class MaildirBox(object):
|
|||
return self.data[profile][boxname] # the boxname MUST exist in the data
|
||||
except KeyError:
|
||||
err_msg = _("Boxname doesn't exist in internal data")
|
||||
log.error(_(u"INTERNAL ERROR: ") + err_msg)
|
||||
log.error(_("INTERNAL ERROR: ") + err_msg)
|
||||
raise MaildirError(err_msg)
|
||||
|
||||
def getUid(self, boxname, message_id, profile):
|
||||
|
|
@ -211,7 +211,7 @@ class MaildirBox(object):
|
|||
@param message_uid: unique integer identifier
|
||||
@return: unique id of the message as given by MaildirMailbox or None if not found"""
|
||||
box_data = self.__getBoxData(boxname, profile)
|
||||
for message_id in box_data.keys(): # TODO: this is highly inefficient on big mailbox, must be replaced in the future
|
||||
for message_id in list(box_data.keys()): # TODO: this is highly inefficient on big mailbox, must be replaced in the future
|
||||
if message_id == 'cur_idx':
|
||||
continue
|
||||
if box_data[message_id][0] == message_uid:
|
||||
|
|
@ -248,7 +248,7 @@ class MaildirBox(object):
|
|||
@param flag: flag to check
|
||||
@return: list of id (as given by MaildirMailbox)"""
|
||||
box_data = self.__getBoxData(boxname, profile)
|
||||
assert(isinstance(flag, basestring))
|
||||
assert(isinstance(flag, str))
|
||||
flag = flag.upper()
|
||||
result = []
|
||||
for key in box_data:
|
||||
|
|
@ -296,22 +296,22 @@ class MaildirBox(object):
|
|||
@param boxname: name of the box which was observed
|
||||
@param signal: which signal was observed by the caller"""
|
||||
if (profile, boxname) not in self.__observed:
|
||||
err_msg = _(u"Trying to remove an observer for an inexistant mailbox")
|
||||
log.error(_(u"INTERNAL ERROR: ") + err_msg)
|
||||
err_msg = _("Trying to remove an observer for an inexistant mailbox")
|
||||
log.error(_("INTERNAL ERROR: ") + err_msg)
|
||||
raise MaildirError(err_msg)
|
||||
if signal not in self.__observed[(profile, boxname)]:
|
||||
err_msg = _(u"Trying to remove an inexistant observer, no observer for this signal")
|
||||
log.error(_(u"INTERNAL ERROR: ") + err_msg)
|
||||
err_msg = _("Trying to remove an inexistant observer, no observer for this signal")
|
||||
log.error(_("INTERNAL ERROR: ") + err_msg)
|
||||
raise MaildirError(err_msg)
|
||||
if not callback in self.__observed[(profile, boxname)][signal]:
|
||||
err_msg = _(u"Trying to remove an inexistant observer")
|
||||
log.error(_(u"INTERNAL ERROR: ") + err_msg)
|
||||
err_msg = _("Trying to remove an inexistant observer")
|
||||
log.error(_("INTERNAL ERROR: ") + err_msg)
|
||||
raise MaildirError(err_msg)
|
||||
self.__observed[(profile, boxname)][signal].remove(callback)
|
||||
|
||||
def emitSignal(self, profile, boxname, signal_name):
|
||||
"""Emit the signal to observer"""
|
||||
log.debug(u'emitSignal %s %s %s' % (profile, boxname, signal_name))
|
||||
log.debug('emitSignal %s %s %s' % (profile, boxname, signal_name))
|
||||
try:
|
||||
for observer_cb in self.__observed[(profile, boxname)][signal_name]:
|
||||
observer_cb()
|
||||
|
|
@ -347,7 +347,7 @@ class MailboxUser(object):
|
|||
@param profile: real profile (ie not a profile_key)
|
||||
THIS OBJECT MUST NOT BE USED DIRECTLY: use MaildirBox.accessMessageBox instead"""
|
||||
if _maildir._checkBoxReference(name, profile):
|
||||
log.error(u"INTERNAL ERROR: MailboxUser MUST NOT be instancied directly")
|
||||
log.error("INTERNAL ERROR: MailboxUser MUST NOT be instancied directly")
|
||||
raise MaildirError('double MailboxUser instanciation')
|
||||
if name != "INBOX":
|
||||
raise NotImplementedError
|
||||
|
|
@ -357,7 +357,7 @@ class MailboxUser(object):
|
|||
profile_path = self.maildir._getProfilePath(profile)
|
||||
full_profile_path = os.path.join(self.maildir.host.memory.getConfig('', 'local_dir'), 'maildir', profile_path)
|
||||
if not os.path.exists(full_profile_path):
|
||||
os.makedirs(full_profile_path, 0700)
|
||||
os.makedirs(full_profile_path, 0o700)
|
||||
mailbox_path = os.path.join(full_profile_path, MAILDIR_PATH)
|
||||
self.mailbox_path = mailbox_path
|
||||
self.mailbox = maildir.MaildirMailbox(mailbox_path)
|
||||
|
|
@ -365,7 +365,7 @@ class MailboxUser(object):
|
|||
self.__uid_table_update()
|
||||
|
||||
if observer:
|
||||
log.debug(u"adding observer for %s (%s)" % (name, profile))
|
||||
log.debug("adding observer for %s (%s)" % (name, profile))
|
||||
self.maildir.addObserver(observer, profile, name, "NEW_MESSAGE")
|
||||
|
||||
def __uid_table_update(self):
|
||||
|
|
@ -378,7 +378,7 @@ class MailboxUser(object):
|
|||
|
||||
def __del__(self):
|
||||
if self.observer:
|
||||
log.debug(u"removing observer for %s" % self.name)
|
||||
log.debug("removing observer for %s" % self.name)
|
||||
self._maildir.removeObserver(self.observer, self.name, "NEW_MESSAGE")
|
||||
self.maildir._removeBoxAccess(self.name, self, profile=self.profile)
|
||||
|
||||
|
|
@ -490,7 +490,7 @@ class MailboxUser(object):
|
|||
Also purge the internal data of these messages
|
||||
"""
|
||||
for mess_id in self.getMessageIdsWithFlag("\\Deleted"):
|
||||
print ("Deleting %s" % mess_id)
|
||||
print(("Deleting %s" % mess_id))
|
||||
self.mailbox.deleteMessage(self.getIdxFromId(mess_id))
|
||||
self.mailbox = maildir.MaildirMailbox(self.mailbox_path) # We need to reparse the dir to have coherent indexing
|
||||
self.maildir.purgeDeleted(self.name, profile=self.profile)
|
||||
|
|
|
|||
Loading…
Reference in a new issue