Merge lp:~slimey/endroid/plugin-freshening into lp:endroid

Proposed by Simon C
Status: Merged
Merged at revision: 32
Proposed branch: lp:~slimey/endroid/plugin-freshening
Merge into: lp:endroid
Prerequisite: lp:~ben-hutchings/endroid/roomowner
Diff against target: 140 lines (+36/-12)
6 files modified
bin/endroid_echo (+7/-4)
debian/endroid.install (+1/-0)
etc/endroid.conf (+18/-0)
src/endroid/plugins/compute/__init__.py (+2/-2)
src/endroid/plugins/httpinterface.py (+7/-4)
src/endroid/plugins/remote.py (+1/-2)
To merge this branch: bzr merge lp:~slimey/endroid/plugin-freshening
Reviewer Review Type Date Requested Status
Martin Morrison Approve
Review via email: mp+179420@code.launchpad.net

Commit message

Freshening up remote notification and wolfram alpha plugins

Description of the change

Freshening up some of the plugins that have decayed: remote notifications and wolfram alpha

To post a comment you must log in.
Revision history for this message
Martin Morrison (isoschiz) :
review: Approve
Revision history for this message
Martin Morrison (isoschiz) wrote :

The prerequisite lp:~ben-hutchings/endroid/roomowner has not yet been merged into lp:endroid.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/endroid_echo'
2--- bin/endroid_echo 2013-08-09 12:01:49 +0000
3+++ bin/endroid_echo 2013-08-09 12:01:50 +0000
4@@ -4,9 +4,9 @@
5 import sys
6 import urllib
7
8-KEY_ENV_VAR = 'ENDROID_REMOTE_KEY'
9-JID_ENV_VAR = 'ENDROID_REMOTE_USER'
10-REMOTE_URL = 'http://127.0.0.1:8880/remote/'
11+KEY_ENV_VAR = 'ENDROID_REMOTE_KEY' # eg XACKJAASKJDAHD
12+JID_ENV_VAR = 'ENDROID_REMOTE_USER' # eg frodo@shire.org
13+URL_ENV_VAR = 'ENDROID_REMOTE_URL' # eg http://127.0.0.1:8880/remote/
14
15 class UserError(Exception):
16 pass
17@@ -21,11 +21,14 @@
18 if KEY_ENV_VAR not in os.environ:
19 raise UserError("Message key env var (%s) not set" % KEY_ENV_VAR)
20
21+ if URL_ENV_VAR not in os.environ:
22+ raise UserError("Endroid URL env var (%s) not set" % URL_ENV_VAR)
23+
24 params = {'user': os.environ[JID_ENV_VAR],
25 'key': os.environ[KEY_ENV_VAR],
26 'message': ' '.join(sys.argv[1:])}
27
28- f = urllib.urlopen(REMOTE_URL, urllib.urlencode(params))
29+ f = urllib.urlopen(os.environ[URL_ENV_VAR], urllib.urlencode(params))
30 for line in f.readlines():
31 line = line.strip()
32 if "Error:" in line:
33
34=== modified file 'debian/endroid.install'
35--- debian/endroid.install 2012-09-02 20:45:27 +0000
36+++ debian/endroid.install 2013-08-09 12:01:50 +0000
37@@ -1,4 +1,5 @@
38 etc/endroid.conf etc/endroid/
39 etc/init/endroid.conf etc/init/
40 bin/endroid usr/bin/
41+bin/endroid_echo usr/bin/
42 lib/wokkel-0.7.0-py2.7.egg usr/lib/endroid/dependencies
43
44=== modified file 'etc/endroid.conf'
45--- etc/endroid.conf 2013-08-09 12:01:49 +0000
46+++ etc/endroid.conf 2013-08-09 12:01:50 +0000
47@@ -31,3 +31,21 @@
48 [group:*]
49
50 [room:*]
51+
52+# HTTP remote messaging feature (via 'httpinterface' and 'remote' plugins)
53+#
54+# port is the port (defaults to 8880)
55+# interface is the interface (defaults to 127.0.0.1, ie accessible only
56+# from the local host. Set to 0.0.0.0 to enable access from anywhere).
57+
58+[ group | room : * : pconfig : endroid.plugins.httpinterface ]
59+#port = 8881
60+#interface = 0.0.0.0
61+
62+
63+# Wolfram Alpha compute plugin. Get an API key for free at
64+# https://developer.wolframalpha.com/portal/apisignup.html
65+# and then put it below - good for 2000 free queries/month.
66+
67+[ group | room : * : pconfig : endroid.plugins.compute ]
68+#api_key = 123ABC-DE45FGJIJK
69
70=== modified file 'src/endroid/plugins/compute/__init__.py'
71--- src/endroid/plugins/compute/__init__.py 2012-08-09 12:39:52 +0000
72+++ src/endroid/plugins/compute/__init__.py 2013-08-09 12:01:50 +0000
73@@ -16,7 +16,7 @@
74 import wap
75
76 # Constants for the DB values we use
77-WOLFRAM_API_SERVER_DEFAULT = "http://api.wolframalpha.com/v1/query.jsp"
78+WOLFRAM_API_SERVER_DEFAULT = "http://api.wolframalpha.com/v2/query"
79
80 MESSAGES = {
81 'help' : """
82@@ -44,7 +44,7 @@
83 self.waeo = wap.WolframAlphaEngine(self.api_key, self.server)
84 except KeyError:
85 logging.error("ERROR: Compute: There is no API key set in config! Set 'api_key' variable"
86- "in section '[Plugin:endroid.plugins.compute]'. Aborting plugin load.")
87+ " in section '[Plugin:endroid.plugins.compute]'. Aborting plugin load.")
88 raise PluginInitError("Aborted plugin initialization")
89
90 def help(self):
91
92=== modified file 'src/endroid/plugins/httpinterface.py'
93--- src/endroid/plugins/httpinterface.py 2013-08-09 12:01:49 +0000
94+++ src/endroid/plugins/httpinterface.py 2013-08-09 12:01:50 +0000
95@@ -11,7 +11,8 @@
96 from twisted.web.resource import Resource
97 from twisted.web.server import Site
98
99-HTTP_PORT = 8880
100+DEFAULT_HTTP_PORT = 8880
101+DEFAULT_HTTP_INTERFACE = '127.0.0.1'
102
103 NOT_FOUND_TEMPLATE = """
104 <html>
105@@ -111,10 +112,10 @@
106 re_src = re.escape(path_prefix) + r"(/.*)?"
107 self.register_regex_path(plugin, callback, re_src)
108
109- def endroid_init(self):
110+ def endroid_init(self, port, interface):
111 self.root = IndexPage(self)
112 factory = Site(self.root)
113- reactor.listenTCP(HTTP_PORT, factory)
114+ reactor.listenTCP(port, factory, interface=interface)
115
116 class HTTPInterface(Plugin):
117 """
118@@ -158,5 +159,7 @@
119
120 def endroid_init(self):
121 if not HTTPInterface.enInited:
122- HTTPInterface.object.endroid_init()
123+ port = self.vars.get("port", DEFAULT_HTTP_PORT)
124+ interface = self.vars.get("interface", DEFAULT_HTTP_INTERFACE)
125+ HTTPInterface.object.endroid_init(port, interface)
126 HTTPInterface.enInited = True
127
128=== modified file 'src/endroid/plugins/remote.py'
129--- src/endroid/plugins/remote.py 2013-08-09 12:01:49 +0000
130+++ src/endroid/plugins/remote.py 2013-08-09 12:01:50 +0000
131@@ -191,8 +191,7 @@
132 self._validate_args(request.args)
133
134 self.messagehandler.send_chat(request.args['user'][0],
135- "Remote notification received: %s" % request.args['message'][0],
136- self)
137+ "Remote notification received: %s" % request.args['message'][0])
138 header_msg = \
139 "<strong>Message delivered to %s</strong> <br />" % \
140 request.args['user'][0]

Subscribers

People subscribed via source and target branches