Permalink
Browse files

more changes

  • Loading branch information...
1 parent 544ca6c commit 639f1a0ac56a469f38973e1ea931a30e43b7e8ac @drewlesueur committed Jun 8, 2010
Showing with 194 additions and 7 deletions.
  1. +1 −1 app.yaml
  2. +23 −0 capabilities.xml
  3. +9 −6 main.py
  4. +92 −0 wave2.py
  5. +69 −0 wave3.py
View
2 app.yaml
@@ -7,7 +7,7 @@ handlers:
- url: /_wave/verify_token
script: verify.py
- url: /_wave/.*
- script: wave.py
+ script: wave3.py
- url: /assets
static_dir: assets
- url: /.*
View
23 capabilities.xml
@@ -0,0 +1,23 @@
+<w:robot xmlns:w="http://wave.google.com/extensions/robots/1.0">
+<w:version>0xe49de7b</w:version>
+<w:protocolversion>0.21</w:protocolversion>
+<w:capabilities>
+<w:capability name="ANNOTATED_TEXT_CHANGED"/>
+<w:capability name="BLIP_CONTRIBUTORS_CHANGED"/>
+<w:capability name="BLIP_SUBMITTED"/>
+<w:capability name="DOCUMENT_CHANGED"/>
+<!--<w:capability name="EVENT"/>-->
+<w:capability name="FORM_BUTTON_CLICKED"/>
+<w:capability name="GADGET_STATE_CHANGED"/>
+<w:capability name="OPERATION_ERROR"/>
+<w:capability name="WAVELET_BLIP_CREATED"/>
+<w:capability name="WAVELET_BLIP_REMOVED"/>
+<w:capability name="WAVELET_CREATED"/>
+<w:capability name="WAVELET_FETCHED"/>
+<w:capability name="WAVELET_PARTICIPANTS_CHANGED"/>
+<w:capability name="WAVELET_SELF_ADDED"/>
+<w:capability name="WAVELET_SELF_REMOVED"/>
+<w:capability name="WAVELET_TAGS_CHANGED"/>
+<w:capability name="WAVELET_TITLE_CHANGED"/>
+</w:capabilities>
+</w:robot>
View
15 main.py
@@ -42,13 +42,16 @@ def get(self, wave_id):
wavelet = robot.fetch_wavelet(wave_id, 'googlewave.com!conv+root')
# robot.submit(wavelet)
- self.response.out.write(wave_id + "<hr>")
- self.response.out.write(wavelet.creator)
-
if wavelet.creator == "drewalex@googlewave.com":
- for id in wavelet.blips:
- blip = wavelet.blips[id]
- self.response.out.write(blip.text + "<hr />")
+ code = wavelet.root_blip.text
+ code = code.split('\n')
+ code = code[2:] #remove first line
+ code = "\n".join(code)
+ compiled = compile(code, '<string>', 'exec')
+ exec compiled in {'self':self}
+# for id in wavelet.blips:
+# blip = wavelet.blips[id]
+# self.response.out.write(blip.text + "<hr />")
class Gist(webapp.RequestHandler):
View
92 wave2.py
@@ -0,0 +1,92 @@
+from google.appengine.ext import webapp
+from google.appengine.ext.webapp.util import run_wsgi_app
+from google.appengine.api import urlfetch
+import simplejson as json
+import urllib
+
+import sys
+import logging
+#import events #needed?
+
+class Capabilities(webapp.RequestHandler):
+ def get(self):
+ self.response.out.write("""<w:robot xmlns:w="http://wave.google.com/extensions/robots/1.0">
+<w:version>0xe49de7b</w:version>
+<w:protocolversion>0.21</w:protocolversion>
+<w:capabilities>
+<w:capability name="ANNOTATED_TEXT_CHANGED"/>
+<w:capability name="BLIP_CONTRIBUTORS_CHANGED"/>
+<w:capability name="BLIP_SUBMITTED"/>
+<w:capability name="DOCUMENT_CHANGED"/>
+<!--<w:capability name="EVENT"/>-->
+<w:capability name="FORM_BUTTON_CLICKED"/>
+<w:capability name="GADGET_STATE_CHANGED"/>
+<w:capability name="OPERATION_ERROR"/>
+<w:capability name="WAVELET_BLIP_CREATED"/>
+<w:capability name="WAVELET_BLIP_REMOVED"/>
+<w:capability name="WAVELET_CREATED"/>
+<w:capability name="WAVELET_FETCHED"/>
+<w:capability name="WAVELET_PARTICIPANTS_CHANGED"/>
+<w:capability name="WAVELET_SELF_ADDED"/>
+<w:capability name="WAVELET_SELF_REMOVED"/>
+<w:capability name="WAVELET_TAGS_CHANGED"/>
+<w:capability name="WAVELET_TITLE_CHANGED"/>
+</w:capabilities>
+</w:robot>""")
+
+
+
+class MainPage(webapp.RequestHandler):
+ def handle(self, wave_id):
+ from waveapi import events
+ from waveapi import robot
+ from waveapi import ops
+ import passwords
+
+ robot = robot.Robot('gae-run', 'http://a3.twimg.com/profile_images/250985893/twitter_pic_bigger.jpg')
+ robot.setup_oauth(passwords.CONSUMER_KEY, passwords.CONSUMER_SECRET, server_rpc_base='http://www-opensocial.googleusercontent.com/api/rpc')
+ wavelet = robot.fetch_wavelet(wave_id, 'googlewave.com!conv+root')
+ if wavelet.creator == "drewalex@googlewave.com":
+ code = wavelet.root_blip.text
+ toHex = lambda x:"".join(["." + hex(ord(c))[2:].zfill(2) for c in x])
+ logging.info(toHex(code))
+ code = code.split('\n')
+
+ code = code[2:] #remove first line
+ code = "\n".join(code)
+ #logging.info("code is:" + str(code))
+ compiled = compile(code, '<string>', 'exec')
+ exec compiled in {'a':1}
+
+
+ def get(self):
+ wave_id = self.request.get('name')
+ wave_id = urllib.unquote(wave_id)
+ self.handle(wave_id)
+
+ def post(self):
+ json_body = self.request.body
+ json_body = unicode(json_body, 'utf8')
+ body = json.loads(json_body)
+ saved_stdout, sys.stdout = sys.stdout, sys.stderr
+ logging.info('Incoming :): %s', json_body)
+
+ sys.stdout = saved_stdout
+
+ logging.info("test: hello")
+ if 'proxyingFor' in body:
+ wave_id = urllib.unquote(body['proxyingFor'])
+ logging.info("wave_id: %s", wave_id)
+ self.handle(wave_id)
+ else:
+ logging.info("no proxyFor")
+application = webapp.WSGIApplication(
+ [('.*/_wave/capabilities\.xml', Capabilities),
+ ('.*', MainPage)],
+ debug=True)
+
+def main():
+ run_wsgi_app(application)
+
+if __name__ == "__main__":
+ main()
View
69 wave3.py
@@ -0,0 +1,69 @@
+from google.appengine.ext import webapp
+from google.appengine.ext.webapp.util import run_wsgi_app
+from google.appengine.api import urlfetch
+import simplejson as json
+import urllib
+
+import sys
+import logging
+#import events #needed?
+
+class Capabilities(webapp.RequestHandler):
+ def get(self):
+ self.response.out.write("""<w:robot xmlns:w="http://wave.google.com/extensions/robots/1.0">
+<w:version>0xe49de7b</w:version>
+<w:protocolversion>0.21</w:protocolversion>
+<w:capabilities>
+<w:capability name="ANNOTATED_TEXT_CHANGED"/>
+<w:capability name="BLIP_CONTRIBUTORS_CHANGED"/>
+<w:capability name="BLIP_SUBMITTED"/>
+<w:capability name="DOCUMENT_CHANGED"/>
+<!--<w:capability name="EVENT"/>-->
+<w:capability name="FORM_BUTTON_CLICKED"/>
+<w:capability name="GADGET_STATE_CHANGED"/>
+<w:capability name="OPERATION_ERROR"/>
+<w:capability name="WAVELET_BLIP_CREATED"/>
+<w:capability name="WAVELET_BLIP_REMOVED"/>
+<w:capability name="WAVELET_CREATED"/>
+<w:capability name="WAVELET_FETCHED"/>
+<w:capability name="WAVELET_PARTICIPANTS_CHANGED"/>
+<w:capability name="WAVELET_SELF_ADDED"/>
+<w:capability name="WAVELET_SELF_REMOVED"/>
+<w:capability name="WAVELET_TAGS_CHANGED"/>
+<w:capability name="WAVELET_TITLE_CHANGED"/>
+</w:capabilities>
+</w:robot>""")
+
+
+class MainPage(webapp.RequestHandler):
+ def handle(self):
+ from waveapi import events
+ from waveapi import robot
+ from waveapi import ops
+ import passwords
+ robot = robot.Robot('gae-run', 'http://a3.twimg.com/profile_images/250985893/twitter_pic_bigger.jpg')
+ robot.setup_oauth(passwords.CONSUMER_KEY, passwords.CONSUMER_SECRET, server_rpc_base='http://www-opensocial.googleusercontent.com/api/rpc')
+ wavelet = robot.fetch_wavelet('googlewave.com!w+g2tJlP3LB','googlewave.com!conv+root')
+ code = wavelet.root_blip.text
+ code = code.split('\n')
+ code = code[2:] #remove first line
+ code = "\n".join(code)
+ logging.info(code)
+ compiled = compile(code, '<string>', 'exec')
+ exec compiled in {'a':1}
+
+
+ def get(self):
+ self.handle()
+
+ def post(self):
+ self.handle()
+
+application = webapp.WSGIApplication([('.*/_wave/capabilities\.xml', Capabilities),('.*', MainPage)],
+ debug=True)
+
+def main():
+ run_wsgi_app(application)
+
+if __name__ == "__main__":
+ main()

0 comments on commit 639f1a0

Please sign in to comment.