Exemplo n.º 1
0
(options, args) = twitstream.parser.parse_args()

if len(args) < 1:
    twitstream.parser.error("requires one method argument")
else:
    method = args[0]
    if method not in twitstream.GETMETHODS and method not in twitstream.POSTPARAMS:
        raise NotImplementedError("Unknown method: %s" % method)

twitstream.ensure_credentials(options)

stream = twitstream.twitstream(method,
                               options.username,
                               options.password,
                               twitstream.DEFAULTACTION,
                               defaultdata=args[1:],
                               debug=options.debug,
                               engine=options.engine)

stream.run()

########NEW FILE########
__FILENAME__ = warehouse
#!/usr/bin/env python

import sys
import twitstream
from urlparse import urlunsplit, urlsplit
from binascii import unhexlify, hexlify
Exemplo n.º 2
0
                access_token=accessToken,
                callback=self.async_callback(self._on_post)
            )

        res = json.dumps({"code": 200, "response": "success"})
        self.finish(res)

    def _on_post(self, new_entry):
        if not new_entry:
            self.authorize_redirect()
            return


if __name__ == "__main__":
    # Stream
    stream = twitstream.twitstream(
        'track', tweet_callback, defaultdata=['lonely'])

    # Tornado
    settings = dict(
        twitter_consumer_key=settings['CONSUMER_KEY'],
        twitter_consumer_secret=settings['CONSUMER_SECRET'],
        cookie_secret=settings['COOKIE_SECRET'],
        template_path=os.path.join(os.path.dirname(__file__), 'templates'),
        static_path=os.path.join(os.path.dirname(__file__), "static")
    )
    app = tornado.web.Application(
    	handlers = [
            (r"/", IndexHandler),
            (r"/planet", MainHandler),
            (r"/login", TwitterHandler),
            (r"/logout", LogoutHandler),
Exemplo n.º 3
0
                                 post_args={"status": "Testing 128 thousamn"},
                                 access_token=accessToken,
                                 callback=self.async_callback(self._on_post))

    def _on_post(self, new_entry):
        if not new_entry:
            # Call failed; perhaps missing permission?
            self.authorize_redirect()
            return
        self.finish("Posted a message!")


stream = twitstream.twitstream(method,
                               options.username,
                               options.password,
                               testFunction,
                               defaultdata=args[1:],
                               debug=options.debug,
                               engine=options.engine)

settings = dict(
    twitter_consumer_key='EGLC7uXFL0wNMygeZoZOTw',
    twitter_consumer_secret='pnvNerZKSBSw1kri5wjaM255CluYwd3OdaovUeyCsI',
    cookie_secret='NTliOTY5NzJkYTVlMTU0OTAwMTdlNjgzMTA5M2U3OGQ5NDIxZmU3Mg==',
    template_path=os.path.join(os.path.dirname(__file__), 'templates'),
)

if __name__ == "__main__":

    app = tornado.web.Application(handlers=[
        (r"/", IndexHandler),
Exemplo n.º 4
0
    def open(self):
        GLOBALS['sockets'].append(self)
        print "WebSocket opened"

    def on_close(self):
        print "WebSocket closed"
        GLOBALS['sockets'].remove(self)

class Announcer(tornado.web.RequestHandler):
    def get(self, *args, **kwargs):
        data = self.get_argument('data')
        for socket in GLOBALS['sockets']:
            socket.write_message(data)
        self.write('Posted')


stream = twitstream.twitstream(method, options.username, options.password, testCallback, 
            defaultdata=args[1:], debug=options.debug, engine=options.engine)

if __name__ == "__main__":
	app = tornado.web.Application(
		handlers = [
            (r"/", MainHandler),
            (r"/socket", ClientSocket),
            (r"/push", Announcer), 
        ] 
	)
	http_server = tornado.httpserver.HTTPServer(app)
	http_server.listen(8000)
	stream.run(tweetVelocity)
Exemplo n.º 5
0
#!/usr/bin/env python

import twitstream

(options, args) = twitstream.parser.parse_args()
    
if len(args) < 1:
    twitstream.parser.error("requires one method argument")
else:
    method = args[0]
    if method not in twitstream.GETMETHODS and method not in twitstream.POSTPARAMS:
        raise NotImplementedError("Unknown method: %s" % method)

twitstream.ensure_credentials(options)

stream = twitstream.twitstream(method, options.username, options.password, twitstream.DEFAULTACTION, 
            defaultdata=args[1:], debug=options.debug, engine=options.engine)

stream.run()

########NEW FILE########
__FILENAME__ = warehouse
#!/usr/bin/env python

import sys
import twitstream
from urlparse import urlunsplit, urlsplit
from binascii import unhexlify, hexlify


# Provide documentation:
USAGE = """%prog [options] [dburl]