Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def set_os_info(self, result, jid):
if self.xml.get_object('information_notebook').get_n_pages() < 5:
return
error = is_error_result(result)
i = 0
client = ''
os_info = ''
while i in self.os_info:
if self.os_info[i]['resource'] == JID(jid).getResource():
if not error:
self.os_info[i]['client'] = '%s %s' % (result.name,
result.version)
else:
self.os_info[i]['client'] = Q_('?Client:Unknown')
if not error and result.os is not None:
self.os_info[i]['os'] = result.os
else:
self.os_info[i]['os'] = Q_('?OS:Unknown')
if i > 0:
client += '\n'
os_info += '\n'
client += self.os_info[i]['client']
os_info += self.os_info[i]['os']
def validate_jid(jid, type_=None):
try:
jid = JID(str(jid))
except InvalidJid as error:
raise ValueError(error)
if type_ is None:
return jid
if type_ == 'bare' and jid.isBare:
return jid
if type_ == 'full' and jid.isFull:
return jid
if type_ == 'domain' and jid.isDomain:
return jid
raise ValueError('Not a %s JID' % type_)
def _test_credentials(self, ignore_all_errors=False):
self._show_progress_page(_('Connecting...'),
_('Connecting to server...'))
address, password = self.get_page('login').get_credentials()
jid = JID(address)
advanced = self.get_page('login').is_advanced()
self._client = self._get_base_client(
jid.getDomain(),
jid.getNode(),
Mode.LOGIN_TEST,
advanced,
ignore_all_errors)
self._client.set_password(password)
self._client.subscribe('login-successful', self._on_login_successful)
self._client.connect()
def validate_jid(jid):
try:
return JID(str(jid))
except InvalidJid as error:
raise ValueError(error)
def _jid_converter(jid):
return JID(jid.decode())
def _add_bookmark(self, account, nickname, password):
con = app.connections[account]
add_bookmark = self.bookmark_switch.get_active()
if not add_bookmark:
return
autojoin = self.autojoin_switch.get_active()
# Add as bookmark, with autojoin and not minimized
name = app.get_nick_from_jid(self.room_jid)
con.get_module('Bookmarks').add_bookmark(name,
JID(self.room_jid),
autojoin,
password,
nickname)