Merge lp:~paul-stanley/endroid/assorted_bug_fixes into lp:endroid

Proposed by Paul Stanley
Status: Merged
Approved by: Phil Connell
Approved revision: 100
Merged at revision: 103
Proposed branch: lp:~paul-stanley/endroid/assorted_bug_fixes
Merge into: lp:endroid
Diff against target: 106 lines (+22/-8)
5 files modified
src/endroid/database.py (+5/-1)
src/endroid/pluginmanager.py (+3/-3)
src/endroid/plugins/command.py (+4/-1)
src/endroid/plugins/correct.py (+5/-2)
src/endroid/plugins/whosonline.py (+5/-1)
To merge this branch: bzr merge lp:~paul-stanley/endroid/assorted_bug_fixes
Reviewer Review Type Date Requested Status
Phil Connell Approve
Review via email: mp+282024@code.launchpad.net

This proposal supersedes a proposal from 2016-01-08.

Commit message

1. Fix bug in database update function when more than 1 field is being updated
2. Make sure exceptions when loading plugins are logged fully in order to aide locating the source of the exception
3. Make sure that listrooms only shows rooms that the user is allowed in
4. Fix couple of bugs in plugins

Description of the change

Assorted endroid fixes:
1. Fix bug in database update function when more than 1 field is being updated
2. Make sure exceptions when loading plugins are logged fully in order to aide locating the source of the exception
3. Make sure that listrooms only shows rooms that the user is allowed in
4. Fix couple of bugs in plugins

To post a comment you must log in.
Revision history for this message
Phil Connell (pconnell) wrote : Posted in a previous version of this proposal

Minor thing to fix inline; don't forget to hit 'set commit message' after re-proposing (otherwise it won't be auto-merged when approved).

review: Needs Fixing
Revision history for this message
Phil Connell (pconnell) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/endroid/database.py'
2--- src/endroid/database.py 2014-07-28 15:50:00 +0000
3+++ src/endroid/database.py 2016-01-08 16:01:14 +0000
4@@ -75,6 +75,10 @@
5 @staticmethod
6 def _buildConditions(conditions):
7 return " and ".join(Database._sanitize(c) + "=?" for c in conditions) or "1"
8+
9+ @staticmethod
10+ def _buildSetConditions(fields):
11+ return ", ".join(Database._sanitize(c) + "=?" for c in fields)
12
13 def create_table(self, name, fields):
14 """
15@@ -160,7 +164,7 @@
16
17 """
18 n = Database._sanitize(self._tName(name))
19- query = "UPDATE {0} SET {1} WHERE ({2});".format(n, Database._buildConditions(fields), Database._buildConditions(conditions))
20+ query = "UPDATE {0} SET {1} WHERE ({2});".format(n, Database._buildSetConditions(fields), Database._buildConditions(conditions))
21 tup = Database._tupleFromFieldValues(fields)
22 tup = tup + Database._tupleFromFieldValues(conditions)
23 Database.raw(query, tup)
24
25=== modified file 'src/endroid/pluginmanager.py'
26--- src/endroid/pluginmanager.py 2014-09-15 16:37:31 +0000
27+++ src/endroid/pluginmanager.py 2016-01-08 16:01:14 +0000
28@@ -309,7 +309,7 @@
29 + "\". Check that it exists in your PYTHONPATH.")
30 return
31 except Exception as e:
32- logging.error(e)
33+ logging.exception(e)
34 logging.error("**Failed to import plugin {}".format(modname))
35 return
36 else:
37@@ -325,7 +325,7 @@
38 else:
39 plugin = PluginMeta.registry[modname]()
40 except Exception as k:
41- logging.error(k)
42+ logging.exception(k)
43 logging.error("**Could not import plugin {}. Module doesn't seem to"
44 "define a Plugin".format(modname))
45 return
46@@ -399,7 +399,7 @@
47 # replaced by a proxy
48 self._loaded[modname] = plugin
49 except Exception as e:
50- logging.error(e)
51+ logging.exception(e)
52 logging.error('\t**Error initializing "{}". See log for '
53 'details.'.format(modname))
54 return False
55
56=== modified file 'src/endroid/plugins/command.py'
57--- src/endroid/plugins/command.py 2014-08-20 11:57:49 +0000
58+++ src/endroid/plugins/command.py 2016-01-08 16:01:14 +0000
59@@ -264,7 +264,10 @@
60 msg.dec_handlers()
61
62 def _command_muc(self, msg):
63- self._command(self._muc_handlers, msg.body, msg)
64+ # Some clients seem to send an empty message when joining a chat room
65+ # - Ignore it
66+ if msg.body is not None:
67+ self._command(self._muc_handlers, msg.body, msg)
68
69 def _command_chat(self, msg):
70 self._command(self._chat_handlers, msg.body, msg)
71
72=== modified file 'src/endroid/plugins/correct.py'
73--- src/endroid/plugins/correct.py 2013-08-19 14:52:48 +0000
74+++ src/endroid/plugins/correct.py 2016-01-08 16:01:14 +0000
75@@ -31,9 +31,12 @@
76 sender. Checks whether the phrase matches the substitution regex, and
77 if so, attempts to correct using the correct() method.
78 """
79- match = REOBJ.match(msg.body)
80+ try:
81+ match = REOBJ.match(msg.body)
82+ except re.error:
83+ match = None
84
85- if match:
86+ if match and msg.sender in self.lastmsg:
87 self.correct(msg, self.lastmsg[msg.sender], match)
88 else:
89 msg.unhandled()
90
91=== modified file 'src/endroid/plugins/whosonline.py'
92--- src/endroid/plugins/whosonline.py 2014-08-14 10:01:44 +0000
93+++ src/endroid/plugins/whosonline.py 2016-01-08 16:01:14 +0000
94@@ -24,7 +24,11 @@
95
96 @command
97 def listrooms(self, msg, arg):
98- rooms = self.usermanagement.get_available_rooms() or ["I'm not in any rooms!"]
99+ # Only list rooms that the user is allowed in
100+ rooms = [room
101+ for room in self.usermanagement.get_available_rooms()
102+ if msg.sender in self.usermanagement.get_users(room)] or [
103+ "I'm not in any rooms!"]
104 msg.reply('\n'.join(rooms))
105
106 @command(synonyms=('isonline',), helphint='{user}')

Subscribers

People subscribed via source and target branches