diff --git a/chat/chat_server/db/db.py b/chat/chat_server/db/db.py index ee564a1..83353b3 100644 --- a/chat/chat_server/db/db.py +++ b/chat/chat_server/db/db.py @@ -85,9 +85,8 @@ def password_correct(self, nick, password): log.err('DB: password_correct CALL SUCCESSFUL') if correct_password: return correct_password[0][0] == password - else: - log.err('DB: password_correct CALL FAILURE: no such user in database') - raise failure.Failure(sqlite3.IntegrityError()) + log.err('DB: password_correct CALL FAILURE: no such user in database') + raise failure.Failure(sqlite3.IntegrityError()) except failure.Failure as f: log.err(f'DB: password_correct FAILURE: {f.getErrorMessage()}') raise @@ -174,8 +173,7 @@ def add_notification(self, author, target, notification): @log_operation @defer.inlineCallbacks def get_notifications(self, user): - results = yield self._dbpool.runQuery(query.select_notifications, (user,)) - return results + return (yield self._dbpool.runQuery(query.select_notifications, (user,))) @log_operation def delete_notifications(self, user): diff --git a/chat/chat_server/dispatch/dispatcher.py b/chat/chat_server/dispatch/dispatcher.py index b7b0177..0b11e82 100644 --- a/chat/chat_server/dispatch/dispatcher.py +++ b/chat/chat_server/dispatch/dispatcher.py @@ -45,10 +45,7 @@ def remove_peer(self, peer, nick=None): for c in self.channels.values(): c.unregister_user(nick) elif isinstance(peer, ChatServer): - nicks = [] - for k, v in self.user2peer.items(): - if v == peer: - nicks.append(k) + nicks = [k for k, v in self.user2peer.items() if v == peer] self.server_peers.remove(peer) for n in nicks: self.user2peer.pop(n, None) diff --git a/chat/chat_server/peer/chat_client.py b/chat/chat_server/peer/chat_client.py index 35706ff..28a09e8 100644 --- a/chat/chat_server/peer/chat_client.py +++ b/chat/chat_server/peer/chat_client.py @@ -490,7 +490,6 @@ def msg_JOIN(self, message): else: if self.connected: self.endpoint.no_channel(channel_name) - pass except failure.Failure: self.endpoint.internal_error('DB error, please try again.') diff --git a/chat/client/gui_qt.py b/chat/client/gui_qt.py index f24ebaf..219fc84 100644 --- a/chat/client/gui_qt.py +++ b/chat/client/gui_qt.py @@ -94,9 +94,8 @@ def __init__(self, app, parent=None): def send_message(self): message = self.ui.plainTextEdit.toPlainText() self.ui.textBrowser.append(message) - if message.strip(" ") != "": - if self.client: - self.client.handle_input(message.strip(" ")) + if message.strip(" ") != "" and self.client: + self.client.handle_input(message.strip(" ")) self.ui.plainTextEdit.clear() def quit_channel(self): diff --git a/monitor/db.py b/monitor/db.py index 0510a1a..b8422c4 100644 --- a/monitor/db.py +++ b/monitor/db.py @@ -6,8 +6,7 @@ def connect_db(): """Connects to the specific database.""" - conn = sqlite3.connect(app.config['DATABASE']) - return conn + return sqlite3.connect(app.config['DATABASE']) def init_db(): diff --git a/monitor/monitor.py b/monitor/monitor.py index af5c3a5..6950aeb 100644 --- a/monitor/monitor.py +++ b/monitor/monitor.py @@ -19,7 +19,7 @@ def extract_ratings(rows): # extracts all channels from records and returns list def extract_channels(rows): - return list(set([row[1] for row in rows])) + return list({row[1] for row in rows}) @app.route('/', methods=['GET', 'POST']) @@ -69,8 +69,8 @@ def history(): ratings_list = extract_ratings(rows) channels_list = extract_channels(rows) - for i in range(0, len(ratings_list)): - for j in range(0, 6): + for i in range(len(ratings_list)): + for j in range(6): if ratings_list[i][j] < 0.5: ratings_list[i][j] = 0 @@ -95,8 +95,8 @@ def channel(name): ratings_list = extract_ratings(rows) channels_list = [name] - for i in range(0, len(ratings_list)): - for j in range(0, 6): + for i in range(len(ratings_list)): + for j in range(6): if ratings_list[i][j] < 0.5: ratings_list[i][j] = 0