def execute(self):
     if "english" not in self.agent.blackboard:
         english = English()
         self.agent.stash("english",english)
     english = self.agent.fetch("english")
     tweets = self.agent.tweet_cache
     self.agent.tweet_cache = []
     if self.filename != None:
         f = open(self.filename, "a") 
     dayFiles = {}
     
     for tweet in tweets:
         if english.is_english(tweet["text"]):
             if self.filename != None:
                 fOut = f
             else:
                 dateName = "tweets-%i-%i-%i" % (tweet.created_at.year, tweet.created_at.month, tweet.created_at.day)
                 if dateName not in dayFiles:
                     dayFiles[dateName] = open(dateName, "a")
                 fOut = dayFiles[dateName]
             self.write_tweet(fOut,tweet)
     
     if self.filename != None:
         f.close()
     for ff in dayFiles:
         ff.close()
Exemple #2
0
    def get(self):
        # self.response.write
        a = American()
        print a.print_out()

        e = English()
        print e.print_out()

        content = a.print_out() + e.print_out()

        self.response.write(a.print_out())
        self.response.write(e.print_out())
 def execute(self):
     if "english" not in self.agent.blackboard:
         english = English()
         self.agent.stash("english", english)
     english = self.agent.fetch("english")
     tweets = self.agent.tweet_cache
     self.agent.tweet_cache = []
     for tweet in tweets:
         # Only dump English tweets. 
         # XXX - Rest of world: remove this if statement
         if english.is_english(tweet["text"]):
             print tweet["text"]
Exemple #4
0
import requests, random
from english import English
from twitter import Twitter

url = 'http://earthquake.usgs.gov/earthquakes/feed' \
		'/v1.0/summary/significant_hour.geojson'

test_url = 'http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/significant_month.geojson'

r = requests.get(url)
if r.status_code == 200:
	if len(r.json()['features']) > 0:
		s = English(r.json())
		t = Twitter()
		t.tweet(s.sentence())
else:
	print "Error: Status code {}".format(r.status_code)