code style reformatting using black

This commit is contained in:
Goffi 2018-06-27 20:14:46 +02:00
commit 744cb0c503

View file

@ -19,6 +19,7 @@
from sat.core.i18n import _, D_
from sat.core.log import getLogger
log = getLogger(__name__)
from sat.core import exceptions
from sat.tools import xml_tools
@ -31,7 +32,7 @@ from twisted.python.failure import Failure
from twisted.words.protocols.jabber import jid
from sat.tools import email as sat_email
# FIXME: this plugin code is old and need a cleaning
#  FIXME: this plugin code is old and need a cleaning
# TODO: account deletion/password change need testing
@ -41,10 +42,10 @@ PLUGIN_INFO = {
C.PI_TYPE: "MISC",
C.PI_PROTOCOLS: [],
C.PI_DEPENDENCIES: ["XEP-0077"],
C.PI_RECOMMENDATIONS: ['GROUPBLOG'],
C.PI_RECOMMENDATIONS: ["GROUPBLOG"],
C.PI_MAIN: "MiscAccount",
C.PI_HANDLER: "no",
C.PI_DESCRIPTION: _(u"""SàT account creation""")
C.PI_DESCRIPTION: _(u"""SàT account creation"""),
}
CONFIG_SECTION = "plugin account"
@ -53,22 +54,24 @@ CONFIG_SECTION = "plugin account"
# all theses values (key=option name, value=default) can (and should) be overriden in sat.conf
# in section CONFIG_SECTION
default_conf = {"email_from": "NOREPLY@example.net",
"email_server": "localhost",
"email_sender_domain": "",
"email_port": 25,
"email_username": "",
"email_password": "",
"email_starttls": "false",
"email_auth": "false",
"email_admins_list": [],
"admin_email": "",
"new_account_server": "localhost",
"new_account_domain": "", # use xmpp_domain if not found
"reserved_list": ['libervia'] # profiles which can't be used
}
default_conf = {
"email_from": "NOREPLY@example.net",
"email_server": "localhost",
"email_sender_domain": "",
"email_port": 25,
"email_username": "",
"email_password": "",
"email_starttls": "false",
"email_auth": "false",
"email_admins_list": [],
"admin_email": "",
"new_account_server": "localhost",
"new_account_domain": "", #  use xmpp_domain if not found
"reserved_list": ["libervia"], # profiles which can't be used
}
WELCOME_MSG = D_(u"""Welcome to Libervia, the web interface of Salut à Toi.
WELCOME_MSG = D_(
u"""Welcome to Libervia, the web interface of Salut à Toi.
Your account on {domain} has been successfully created.
This is a demonstration version to show you the current status of the project.
@ -88,55 +91,101 @@ Any feedback welcome. Thank you!
Salut à Toi association
https://www.salut-a-toi.org
""")
"""
)
DEFAULT_DOMAIN = u"example.net"
class MiscAccount(object):
"""Account plugin: create a SàT + XMPP account, used by Libervia"""
# XXX: This plugin was initialy a Q&D one used for the demo.
# TODO: cleaning, separate email handling, more configuration/tests, fixes
def __init__(self, host):
log.info(_(u"Plugin Account initialization"))
self.host = host
host.bridge.addMethod("registerSatAccount", ".plugin", in_sign='sss', out_sign='', method=self._registerAccount, async=True)
host.bridge.addMethod("getNewAccountDomain", ".plugin", in_sign='', out_sign='s', method=self.getNewAccountDomain, async=False)
host.bridge.addMethod("getAccountDialogUI", ".plugin", in_sign='s', out_sign='s', method=self._getAccountDialogUI, async=False)
host.bridge.addMethod("asyncConnectWithXMPPCredentials", ".plugin", in_sign='ss', out_sign='b', method=self.asyncConnectWithXMPPCredentials, async=True)
host.bridge.addMethod(
"registerSatAccount",
".plugin",
in_sign="sss",
out_sign="",
method=self._registerAccount,
async=True,
)
host.bridge.addMethod(
"getNewAccountDomain",
".plugin",
in_sign="",
out_sign="s",
method=self.getNewAccountDomain,
async=False,
)
host.bridge.addMethod(
"getAccountDialogUI",
".plugin",
in_sign="s",
out_sign="s",
method=self._getAccountDialogUI,
async=False,
)
host.bridge.addMethod(
"asyncConnectWithXMPPCredentials",
".plugin",
in_sign="ss",
out_sign="b",
method=self.asyncConnectWithXMPPCredentials,
async=True,
)
self.fixEmailAdmins()
self._sessions = Sessions()
self.__account_cb_id = host.registerCallback(self._accountDialogCb, with_data=True)
self.__change_password_id = host.registerCallback(self.__changePasswordCb, with_data=True)
self.__account_cb_id = host.registerCallback(
self._accountDialogCb, with_data=True
)
self.__change_password_id = host.registerCallback(
self.__changePasswordCb, with_data=True
)
def deleteBlogCallback(posts, comments):
return lambda data, profile: self.__deleteBlogPostsCb(posts, comments, data, profile)
return lambda data, profile: self.__deleteBlogPostsCb(
posts, comments, data, profile
)
self.__delete_posts_id = host.registerCallback(deleteBlogCallback(True, False), with_data=True)
self.__delete_comments_id = host.registerCallback(deleteBlogCallback(False, True), with_data=True)
self.__delete_posts_comments_id = host.registerCallback(deleteBlogCallback(True, True), with_data=True)
self.__delete_account_id = host.registerCallback(self.__deleteAccountCb, with_data=True)
self.__delete_posts_id = host.registerCallback(
deleteBlogCallback(True, False), with_data=True
)
self.__delete_comments_id = host.registerCallback(
deleteBlogCallback(False, True), with_data=True
)
self.__delete_posts_comments_id = host.registerCallback(
deleteBlogCallback(True, True), with_data=True
)
self.__delete_account_id = host.registerCallback(
self.__deleteAccountCb, with_data=True
)
# FIXME: remove this after some time, when the deprecated parameter is really abandoned
def fixEmailAdmins(self):
"""Handle deprecated config option "admin_email" to fix the admin emails list"""
admin_email = self.getConfig('admin_email')
admin_email = self.getConfig("admin_email")
if not admin_email:
return
log.warning(u"admin_email parameter is deprecated, please use email_admins_list instead")
log.warning(
u"admin_email parameter is deprecated, please use email_admins_list instead"
)
param_name = "email_admins_list"
try:
section = ""
value = self.host.memory.getConfig(section, param_name, Exception)
except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
section = CONFIG_SECTION
value = self.host.memory.getConfig(section, param_name, default_conf[param_name])
value = self.host.memory.getConfig(
section, param_name, default_conf[param_name]
)
value = set(value)
value.add(admin_email)
@ -193,7 +242,7 @@ class MiscAccount(object):
if not password or not profile:
raise exceptions.DataError
if profile.lower() in self.getConfig('reserved_list'):
if profile.lower() in self.getConfig("reserved_list"):
return defer.fail(Failure(exceptions.ConflictError))
d = self.host.memory.createProfile(profile, password)
@ -216,11 +265,15 @@ class MiscAccount(object):
else:
jid_s = profile + u"@" + self.getNewAccountDomain()
jid_ = jid.JID(jid_s)
d = self.host.plugins['XEP-0077'].registerNewAccount(jid_, password)
d = self.host.plugins["XEP-0077"].registerNewAccount(jid_, password)
def setParams(dummy):
self.host.memory.setParam("JabberID", jid_s, "Connection", profile_key=profile)
d = self.host.memory.setParam("Password", password, "Connection", profile_key=profile)
self.host.memory.setParam(
"JabberID", jid_s, "Connection", profile_key=profile
)
d = self.host.memory.setParam(
"Password", password, "Connection", profile_key=profile
)
return d
def removeProfile(failure):
@ -235,9 +288,11 @@ class MiscAccount(object):
def _sendEmailEb(self, failure_, email):
# TODO: return error code to user
log.error(_(u"Failed to send account creation confirmation to {email}: {msg}").format(
email = email,
msg = failure_))
log.error(
_(u"Failed to send account creation confirmation to {email}: {msg}").format(
email=email, msg=failure_
)
)
def sendEmails(self, email, profile):
# time to send the email
@ -245,43 +300,68 @@ class MiscAccount(object):
domain = self.getNewAccountDomain()
# email to the administrators
admins_emails = self.getConfig('email_admins_list')
admins_emails = self.getConfig("email_admins_list")
if not admins_emails:
log.warning(u"No known admin email, we can't send email to administrator(s).\nPlease fill email_admins_list parameter")
log.warning(
u"No known admin email, we can't send email to administrator(s).\nPlease fill email_admins_list parameter"
)
d_admin = defer.fail(exceptions.DataError("no admin email"))
else:
subject = _(u'New Libervia account created')
body = (u"""New account created: {profile} [{email}]""".format(
profile = profile,
subject = _(u"New Libervia account created")
body = u"""New account created: {profile} [{email}]""".format(
profile=profile,
# there is no email when an existing XMPP account is used
email = email or u"<no email>"))
email=email or u"<no email>",
)
d_admin = sat_email.sendEmail(self.host, admins_emails, subject, body)
admins_emails_txt = u', '.join([u'<' + addr + u'>' for addr in admins_emails])
d_admin.addCallbacks(lambda dummy: log.debug(u"Account creation notification sent to admin(s) {}".format(admins_emails_txt)),
lambda dummy: log.error(u"Failed to send account creation notification to admin {}".format(admins_emails_txt)))
admins_emails_txt = u", ".join([u"<" + addr + u">" for addr in admins_emails])
d_admin.addCallbacks(
lambda dummy: log.debug(
u"Account creation notification sent to admin(s) {}".format(
admins_emails_txt
)
),
lambda dummy: log.error(
u"Failed to send account creation notification to admin {}".format(
admins_emails_txt
)
),
)
if not email:
# TODO: if use register with an existing account, an XMPP message should be sent
return d_admin
jid_s = self.host.memory.getParamA(u"JabberID", u"Connection", profile_key=profile)
subject = _(u'Your Libervia account has been created')
body = (_(WELCOME_MSG).format(profile=profile, jid=jid_s, domain=domain))
jid_s = self.host.memory.getParamA(
u"JabberID", u"Connection", profile_key=profile
)
subject = _(u"Your Libervia account has been created")
body = _(WELCOME_MSG).format(profile=profile, jid=jid_s, domain=domain)
# XXX: this will not fail when the email address doesn't exist
# FIXME: check email reception to validate email given by the user
# FIXME: delete the profile if the email could not been sent?
d_user = sat_email.sendEmail(self.host, [email], subject, body)
d_user.addCallbacks(lambda dummy: log.debug(u"Account creation confirmation sent to <{}>".format(email)),
self._sendEmailEb)
d_user.addCallbacks(
lambda dummy: log.debug(
u"Account creation confirmation sent to <{}>".format(email)
),
self._sendEmailEb,
)
return defer.DeferredList([d_user, d_admin])
def getNewAccountDomain(self):
"""get the domain that will be set to new account"""
domain = self.getConfig('new_account_domain') or self.getConfig('xmpp_domain', None)
domain = self.getConfig("new_account_domain") or self.getConfig(
"xmpp_domain", None
)
if not domain:
log.warning(_(u'xmpp_domain needs to be set in sat.conf. Using "{default}" meanwhile').format(default=DEFAULT_DOMAIN))
log.warning(
_(
u'xmpp_domain needs to be set in sat.conf. Using "{default}" meanwhile'
).format(default=DEFAULT_DOMAIN)
)
return DEFAULT_DOMAIN
return domain
@ -291,10 +371,17 @@ class MiscAccount(object):
@param profile: %(doc_profile)s
@return: XML of the dialog
"""
form_ui = xml_tools.XMLUI("form", "tabs", title=D_("Manage your account"), submit_id=self.__account_cb_id)
form_ui = xml_tools.XMLUI(
"form",
"tabs",
title=D_("Manage your account"),
submit_id=self.__account_cb_id,
)
tab_container = form_ui.current_container
tab_container.addTab("update", D_("Change your password"), container=xml_tools.PairsContainer)
tab_container.addTab(
"update", D_("Change your password"), container=xml_tools.PairsContainer
)
form_ui.addLabel(D_("Current profile password"))
form_ui.addPassword("current_passwd", value="")
form_ui.addLabel(D_("New password"))
@ -328,7 +415,9 @@ class MiscAccount(object):
@param data
@param profile
"""
sat_cipher = yield self.host.memory.asyncGetParamA(C.PROFILE_PASS_PATH[1], C.PROFILE_PASS_PATH[0], profile_key=profile)
sat_cipher = yield self.host.memory.asyncGetParamA(
C.PROFILE_PASS_PATH[1], C.PROFILE_PASS_PATH[0], profile_key=profile
)
@defer.inlineCallbacks
def verify(attempt):
@ -340,7 +429,7 @@ class MiscAccount(object):
message = D_("The provided profile password doesn't match.")
error_ui = xml_tools.XMLUI("popup", title=D_("Attempt failure"))
error_ui.addText(message)
return {'xmlui': error_ui.toXml()}
return {"xmlui": error_ui.toXml()}
# check for account deletion
# FIXME: uncomment and fix these features
@ -370,9 +459,9 @@ class MiscAccount(object):
"""
# check for password modification
current_passwd = data[xml_tools.SAT_FORM_PREFIX + 'current_passwd']
new_passwd1 = data[xml_tools.SAT_FORM_PREFIX + 'new_passwd1']
new_passwd2 = data[xml_tools.SAT_FORM_PREFIX + 'new_passwd2']
current_passwd = data[xml_tools.SAT_FORM_PREFIX + "current_passwd"]
new_passwd1 = data[xml_tools.SAT_FORM_PREFIX + "new_passwd1"]
new_passwd2 = data[xml_tools.SAT_FORM_PREFIX + "new_passwd2"]
if new_passwd1 or new_passwd2:
verified = yield verify(current_passwd)
assert isinstance(verified, bool)
@ -381,7 +470,11 @@ class MiscAccount(object):
data = yield self.__changePassword(new_passwd1, profile=profile)
defer.returnValue(data)
else:
defer.returnValue(error_ui(D_("The values entered for the new password are not equal.")))
defer.returnValue(
error_ui(
D_("The values entered for the new password are not equal.")
)
)
defer.returnValue(error_ui())
defer.returnValue({})
@ -392,11 +485,22 @@ class MiscAccount(object):
@param password (str): the new password
@param profile (str): %(doc_profile)s
"""
session_id, dummy = self._sessions.newSession({'new_password': password}, profile=profile)
form_ui = xml_tools.XMLUI("form", title=D_("Change your password?"), submit_id=self.__change_password_id, session_id=session_id)
form_ui.addText(D_("Note for advanced users: this will actually change both your SàT profile password AND your XMPP account password."))
session_id, dummy = self._sessions.newSession(
{"new_password": password}, profile=profile
)
form_ui = xml_tools.XMLUI(
"form",
title=D_("Change your password?"),
submit_id=self.__change_password_id,
session_id=session_id,
)
form_ui.addText(
D_(
"Note for advanced users: this will actually change both your SàT profile password AND your XMPP account password."
)
)
form_ui.addText(D_("Continue with changing the password?"))
return {'xmlui': form_ui.toXml()}
return {"xmlui": form_ui.toXml()}
def __changePasswordCb(self, data, profile):
"""Actually change the user XMPP account and SàT profile password
@ -404,22 +508,33 @@ class MiscAccount(object):
@profile (str): %(doc_profile)s
"""
client = self.host.getClient(profile)
password = self._sessions.profileGet(data['session_id'], profile)['new_password']
del self._sessions[data['session_id']]
password = self._sessions.profileGet(data["session_id"], profile)["new_password"]
del self._sessions[data["session_id"]]
def passwordChanged(dummy):
d = self.host.memory.setParam(C.PROFILE_PASS_PATH[1], password, C.PROFILE_PASS_PATH[0], profile_key=profile)
d.addCallback(lambda dummy: self.host.memory.setParam("Password", password, "Connection", profile_key=profile))
d = self.host.memory.setParam(
C.PROFILE_PASS_PATH[1],
password,
C.PROFILE_PASS_PATH[0],
profile_key=profile,
)
d.addCallback(
lambda dummy: self.host.memory.setParam(
"Password", password, "Connection", profile_key=profile
)
)
confirm_ui = xml_tools.XMLUI("popup", title=D_("Confirmation"))
confirm_ui.addText(D_("Your password has been changed."))
return defer.succeed({'xmlui': confirm_ui.toXml()})
return defer.succeed({"xmlui": confirm_ui.toXml()})
def errback(failure):
error_ui = xml_tools.XMLUI("popup", title=D_("Error"))
error_ui.addText(D_("Your password could not be changed: %s") % failure.getErrorMessage())
return defer.succeed({'xmlui': error_ui.toXml()})
error_ui.addText(
D_("Your password could not be changed: %s") % failure.getErrorMessage()
)
return defer.succeed({"xmlui": error_ui.toXml()})
d = self.host.plugins['XEP-0077'].changePassword(client, password)
d = self.host.plugins["XEP-0077"].changePassword(client, password)
d.addCallbacks(passwordChanged, errback)
return d
@ -427,12 +542,31 @@ class MiscAccount(object):
"""Ask for a confirmation before deleting the XMPP account and SàT profile
@param profile
"""
form_ui = xml_tools.XMLUI("form", title=D_("Delete your account?"), submit_id=self.__delete_account_id)
form_ui.addText(D_("If you confirm this dialog, you will be disconnected and then your XMPP account AND your SàT profile will both be DELETED."))
target = D_('contact list, messages history, blog posts and comments' if 'GROUPBLOG' in self.host.plugins else D_('contact list and messages history'))
form_ui.addText(D_("All your data stored on %(server)s, including your %(target)s will be erased.") % {'server': self.getNewAccountDomain(), 'target': target})
form_ui.addText(D_("There is no other confirmation dialog, this is the very last one! Are you sure?"))
return {'xmlui': form_ui.toXml()}
form_ui = xml_tools.XMLUI(
"form", title=D_("Delete your account?"), submit_id=self.__delete_account_id
)
form_ui.addText(
D_(
"If you confirm this dialog, you will be disconnected and then your XMPP account AND your SàT profile will both be DELETED."
)
)
target = D_(
"contact list, messages history, blog posts and comments"
if "GROUPBLOG" in self.host.plugins
else D_("contact list and messages history")
)
form_ui.addText(
D_(
"All your data stored on %(server)s, including your %(target)s will be erased."
)
% {"server": self.getNewAccountDomain(), "target": target}
)
form_ui.addText(
D_(
"There is no other confirmation dialog, this is the very last one! Are you sure?"
)
)
return {"xmlui": form_ui.toXml()}
def __deleteAccountCb(self, data, profile):
"""Actually delete the XMPP account and SàT profile
@ -441,18 +575,25 @@ class MiscAccount(object):
@param profile
"""
client = self.host.getClient(profile)
def userDeleted(dummy):
# FIXME: client should be disconnected at this point, so 2 next loop should be removed (to be confirmed)
for jid_ in client.roster._jids: # empty roster
client.presence.unsubscribe(jid_)
for jid_ in self.host.memory.getWaitingSub(profile): # delete waiting subscriptions
for jid_ in self.host.memory.getWaitingSub(
profile
): # delete waiting subscriptions
self.host.memory.delWaitingSub(jid_)
delete_profile = lambda: self.host.memory.asyncDeleteProfile(profile, force=True)
if 'GROUPBLOG' in self.host.plugins:
d = self.host.plugins['GROUPBLOG'].deleteAllGroupBlogsAndComments(profile_key=profile)
delete_profile = lambda: self.host.memory.asyncDeleteProfile(
profile, force=True
)
if "GROUPBLOG" in self.host.plugins:
d = self.host.plugins["GROUPBLOG"].deleteAllGroupBlogsAndComments(
profile_key=profile
)
d.addCallback(lambda dummy: delete_profile())
else:
delete_profile()
@ -461,10 +602,13 @@ class MiscAccount(object):
def errback(failure):
error_ui = xml_tools.XMLUI("popup", title=D_("Error"))
error_ui.addText(D_("Your XMPP account could not be deleted: %s") % failure.getErrorMessage())
return defer.succeed({'xmlui': error_ui.toXml()})
error_ui.addText(
D_("Your XMPP account could not be deleted: %s")
% failure.getErrorMessage()
)
return defer.succeed({"xmlui": error_ui.toXml()})
d = self.host.plugins['XEP-0077'].unregister(client, jid.JID(client.jid.host))
d = self.host.plugins["XEP-0077"].unregister(client, jid.JID(client.jid.host))
d.addCallbacks(userDeleted, errback)
return d
@ -477,20 +621,60 @@ class MiscAccount(object):
"""
if posts:
if comments: # delete everything
form_ui = xml_tools.XMLUI("form", title=D_("Delete all your (micro-)blog posts and comments?"), submit_id=self.__delete_posts_comments_id)
form_ui.addText(D_("If you confirm this dialog, all the (micro-)blog data you submitted will be erased."))
form_ui.addText(D_("These are the public and private posts and comments you sent to any group."))
form_ui.addText(D_("There is no other confirmation dialog, this is the very last one! Are you sure?"))
form_ui = xml_tools.XMLUI(
"form",
title=D_("Delete all your (micro-)blog posts and comments?"),
submit_id=self.__delete_posts_comments_id,
)
form_ui.addText(
D_(
"If you confirm this dialog, all the (micro-)blog data you submitted will be erased."
)
)
form_ui.addText(
D_(
"These are the public and private posts and comments you sent to any group."
)
)
form_ui.addText(
D_(
"There is no other confirmation dialog, this is the very last one! Are you sure?"
)
)
else: # delete only the posts
form_ui = xml_tools.XMLUI("form", title=D_("Delete all your (micro-)blog posts?"), submit_id=self.__delete_posts_id)
form_ui.addText(D_("If you confirm this dialog, all the public and private posts you sent to any group will be erased."))
form_ui.addText(D_("There is no other confirmation dialog, this is the very last one! Are you sure?"))
form_ui = xml_tools.XMLUI(
"form",
title=D_("Delete all your (micro-)blog posts?"),
submit_id=self.__delete_posts_id,
)
form_ui.addText(
D_(
"If you confirm this dialog, all the public and private posts you sent to any group will be erased."
)
)
form_ui.addText(
D_(
"There is no other confirmation dialog, this is the very last one! Are you sure?"
)
)
elif comments: # delete only the comments
form_ui = xml_tools.XMLUI("form", title=D_("Delete all your (micro-)blog comments?"), submit_id=self.__delete_comments_id)
form_ui.addText(D_("If you confirm this dialog, all the public and private comments you made on other people's posts will be erased."))
form_ui.addText(D_("There is no other confirmation dialog, this is the very last one! Are you sure?"))
form_ui = xml_tools.XMLUI(
"form",
title=D_("Delete all your (micro-)blog comments?"),
submit_id=self.__delete_comments_id,
)
form_ui.addText(
D_(
"If you confirm this dialog, all the public and private comments you made on other people's posts will be erased."
)
)
form_ui.addText(
D_(
"There is no other confirmation dialog, this is the very last one! Are you sure?"
)
)
return {'xmlui': form_ui.toXml()}
return {"xmlui": form_ui.toXml()}
def __deleteBlogPostsCb(self, posts, comments, data, profile):
"""Actually delete the XMPP account and SàT profile
@ -500,26 +684,39 @@ class MiscAccount(object):
"""
if posts:
if comments:
target = D_('blog posts and comments')
d = self.host.plugins['GROUPBLOG'].deleteAllGroupBlogsAndComments(profile_key=profile)
target = D_("blog posts and comments")
d = self.host.plugins["GROUPBLOG"].deleteAllGroupBlogsAndComments(
profile_key=profile
)
else:
target = D_('blog posts')
d = self.host.plugins['GROUPBLOG'].deleteAllGroupBlogs(profile_key=profile)
target = D_("blog posts")
d = self.host.plugins["GROUPBLOG"].deleteAllGroupBlogs(
profile_key=profile
)
elif comments:
target = D_('comments')
d = self.host.plugins['GROUPBLOG'].deleteAllGroupBlogsComments(profile_key=profile)
target = D_("comments")
d = self.host.plugins["GROUPBLOG"].deleteAllGroupBlogsComments(
profile_key=profile
)
def deleted(result):
ui = xml_tools.XMLUI("popup", title=D_("Deletion confirmation"))
# TODO: change the message when delete/retract notifications are done with XEP-0060
ui.addText(D_("Your %(target)s have been deleted.") % {'target': target})
ui.addText(D_("Known issue of the demo version: you need to refresh the page to make the deleted posts actually disappear."))
return defer.succeed({'xmlui': ui.toXml()})
ui.addText(D_("Your %(target)s have been deleted.") % {"target": target})
ui.addText(
D_(
"Known issue of the demo version: you need to refresh the page to make the deleted posts actually disappear."
)
)
return defer.succeed({"xmlui": ui.toXml()})
def errback(failure):
error_ui = xml_tools.XMLUI("popup", title=D_("Error"))
error_ui.addText(D_("Your %(target)s could not be deleted: %(message)s") % {'target': target, 'message': failure.getErrorMessage()})
return defer.succeed({'xmlui': error_ui.toXml()})
error_ui.addText(
D_("Your %(target)s could not be deleted: %(message)s")
% {"target": target, "message": failure.getErrorMessage()}
)
return defer.succeed({"xmlui": error_ui.toXml()})
d.addCallbacks(deleted, errback)
return d
@ -541,16 +738,21 @@ class MiscAccount(object):
raise exceptions.ConflictError
d = self.createProfile(password, jid_s, jid_s)
d.addCallback(lambda dummy: self.host.memory.getProfileName(jid_s)) # checks if the profile has been successfuly created
d.addCallback(
lambda dummy: self.host.memory.getProfileName(jid_s)
) # checks if the profile has been successfuly created
d.addCallback(self.host.connect, password, {}, 0)
def connected(result):
self.sendEmails(None, profile=jid_s)
return result
def removeProfile(failure): # profile has been successfully created but the XMPP credentials are wrong!
log.debug("Removing previously auto-created profile: %s" % failure.getErrorMessage())
def removeProfile(
failure
): # profile has been successfully created but the XMPP credentials are wrong!
log.debug(
"Removing previously auto-created profile: %s" % failure.getErrorMessage()
)
self.host.memory.asyncDeleteProfile(jid_s)
raise failure