From c8815a9230c1d335fa1c06b8d337d3fc612a32cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Sun, 7 Apr 2019 18:40:32 +0200 Subject: [PATCH] Fix no-else-raise pylint errors --- gajim/common/jingle_ft.py | 3 +- gajim/common/jingle_session.py | 6 +-- gajim/common/modules/adhoc_commands.py | 70 +++++++++++++------------- gajim/common/protocol/bytestream.py | 7 ++- 4 files changed, 42 insertions(+), 44 deletions(-) diff --git a/gajim/common/jingle_ft.py b/gajim/common/jingle_ft.py index ab618ca25..6c6ba7c3a 100644 --- a/gajim/common/jingle_ft.py +++ b/gajim/common/jingle_ft.py @@ -307,8 +307,7 @@ class JingleFileTransfer(JingleContent): self.__state_changed(State.CAND_SENT_AND_RECEIVED, args) self.__state_changed(State.TRANSFERING) raise nbxmpp.NodeProcessed - else: - self.__state_changed(State.CAND_RECEIVED, args) + self.__state_changed(State.CAND_RECEIVED, args) def __on_iq_result(self, stanza, content, error, action): log.info("__on_iq_result") diff --git a/gajim/common/jingle_session.py b/gajim/common/jingle_session.py index 5f36b925b..9fe000043 100644 --- a/gajim/common/jingle_session.py +++ b/gajim/common/jingle_session.py @@ -593,9 +593,9 @@ class JingleSession: text = 'Content %s (created by %s) does not exist' % (name, creator) self.__send_error(stanza, 'bad-request', text=text, type_='_modify') raise nbxmpp.NodeProcessed - else: - cn = self.contents[(creator, name)] - cn.on_stanza(stanza, content, error, action) + + cn = self.contents[(creator, name)] + cn.on_stanza(stanza, content, error, action) def __on_session_terminate(self, stanza, jingle, error, action): self.connection.delete_jingle_session(self.sid) diff --git a/gajim/common/modules/adhoc_commands.py b/gajim/common/modules/adhoc_commands.py index 2650f4549..5c34c67e1 100644 --- a/gajim/common/modules/adhoc_commands.py +++ b/gajim/common/modules/adhoc_commands.py @@ -438,44 +438,44 @@ class AdHocCommands(BaseModule): self._sessions[(jid, sessionid, node)] = obj self._log.info('Comand %s executed: %s', node, jid) raise nbxmpp.NodeProcessed - else: - # the command is already running, check for it - magictuple = (jid, sessionid, node) - if magictuple not in self._sessions: - # we don't have this session... ha! - self._log.warning('Invalid session %s', magictuple) - raise nbxmpp.NodeProcessed - - action = cmd.getAttr('action') - obj = self._sessions[magictuple] - - try: - if action == 'cancel': - rc = obj.cancel(stanza) - elif action == 'prev': - rc = obj.prev(stanza) - elif action == 'next': - rc = obj.next(stanza) - elif action == 'execute' or action is None: - rc = obj.execute(stanza) - elif action == 'complete': - rc = obj.complete(stanza) - else: - # action is wrong. stop the session, send error - raise AttributeError - except AttributeError: - # the command probably doesn't handle invoked action... - # stop the session, return error - del self._sessions[magictuple] - self._log.warning('Wrong action %s %s', node, jid) - raise nbxmpp.NodeProcessed - - # delete the session if rc is False - if not rc: - del self._sessions[magictuple] + # the command is already running, check for it + magictuple = (jid, sessionid, node) + if magictuple not in self._sessions: + # we don't have this session... ha! + self._log.warning('Invalid session %s', magictuple) raise nbxmpp.NodeProcessed + action = cmd.getAttr('action') + obj = self._sessions[magictuple] + + try: + if action == 'cancel': + rc = obj.cancel(stanza) + elif action == 'prev': + rc = obj.prev(stanza) + elif action == 'next': + rc = obj.next(stanza) + elif action == 'execute' or action is None: + rc = obj.execute(stanza) + elif action == 'complete': + rc = obj.complete(stanza) + else: + # action is wrong. stop the session, send error + raise AttributeError + except AttributeError: + # the command probably doesn't handle invoked action... + # stop the session, return error + del self._sessions[magictuple] + self._log.warning('Wrong action %s %s', node, jid) + raise nbxmpp.NodeProcessed + + # delete the session if rc is False + if not rc: + del self._sessions[magictuple] + + raise nbxmpp.NodeProcessed + def send_command(self, jid, node, session_id, form, action='execute'): """ diff --git a/gajim/common/protocol/bytestream.py b/gajim/common/protocol/bytestream.py index 6b9cdf272..1d77cd39d 100644 --- a/gajim/common/protocol/bytestream.py +++ b/gajim/common/protocol/bytestream.py @@ -757,11 +757,10 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): app.socks5queue.on_success[file_props.sid] = self._proxy_auth_ok raise nbxmpp.NodeProcessed + if file_props.stopped: + self.remove_transfer(file_props) else: - if file_props.stopped: - self.remove_transfer(file_props) - else: - app.socks5queue.send_file(file_props, self.name, 'server') + app.socks5queue.send_file(file_props, self.name, 'server') raise nbxmpp.NodeProcessed