Exemplo n.º 1
0
def main():
    try:
        parser = ArgumentParser()
        parser.add_argument("oauth_keys_file",
                        help="The location of a file containing the application " +
                        "oath consumer key, consumer secret, " +
                        "access token, and access token secret, " +
                        "each on its own line, in that order.  " +
                        "See the tweepy example on oauth to figure " +
                        "out how to get these keys."
                        )
        parser.add_argument("mail_settings_file", help="The automail settings file for sending emails.")
        args = parser.parse_args()
        (consumer_key, consumer_secret, access_token, access_token_secret) = \
            parse_oauth_file(args.oauth_keys_file)
    
        auth = OAuthHandler(consumer_key, consumer_secret)
        auth.set_access_token(access_token, access_token_secret)
    
        pl = PaxListener(args.mail_settings_file, auth)
        
        #open a stream, with ourself as the listener
        stream = Stream(auth, pl)
        #stream.filter(track=["the"])
    
        pax_user_id = '26281970' #follow requires userid, found at mytwitterid.com
        daemon_user_id = '1954653840'
        stream.filter(follow=[pax_user_id]) #track ignores follow, pulls from firehose regardless (this is testing acct)

    except BaseException as e:
        subject = "Exception from paxtix"
        exc_type, exc_value, exc_traceback = sys.exc_info()
        message = '\n'.join(["Pax tix listener has hit an exception!",] + 
                             traceback.format_exception(exc_type, exc_value, exc_traceback),
                             )
        send_email(parse_settings(args.mail_settings_file), subject, message)
        traceback.print_exception(exc_type, exc_value, exc_traceback)
Exemplo n.º 2
0
import clparse
from automail import automail
from datetime import date
import os


listings = clparse.compile_listings(
    "http://boston.craigslist.org/search/aap", bedrooms="5", query="somerville|davis|porter|ball|tufts"
)

listings.sort(key=lambda listing: listing.price)
listings = clparse.sift_by_location(listings, ["somerville", "porter", "davis", "ball", "tufts", "cambridge"])
subject = "Craigslist results for " + str(date.today())
body_text = ""
for listing in listings:
    body_text += listing.print_link() + "<br/>"

body_text += "<br/>Search terms: somerville, davis, porter, ball, tufts"

directory = os.path.dirname(__file__)
if not directory:
    directory = "."
settings_filename = directory + "/mail_settings.txt"

automail.send_email(automail.parse_settings(settings_filename), subject, body_text, "html")
Exemplo n.º 3
0
 def __init__(self, mail_settings_loc, auth):
     StreamListener.__init__(self, API(auth))
     self.mail_settings = parse_settings(mail_settings_loc)
     self.c = 0
     self.hourly_heartbeat()
     self.daily_heartbeat()