Example #1
0
def login(request):
    """
    Author: @niger
    Check uni and password against oath library and then add user data to User table
    """
    import oauth
    from roary.models import User

    uni = request.POST.get('uni', '')
    password = request.POST.get('password', '')
    import sync
    #sync.google_music("*****@*****.**","naomipurnell")
    data = oauth.login(uni, password)
    if data:
        user = User(uni=data['uni'],
                    department=data['dept'],
                    dorm=data['dorm'])
        user.save()
        request.session['uni'] = uni
        return redirect(
            '/index'
        )  # Generic 200 response, replace with actual response later
    else:
        return redirect('/index?success=fail')
Example #2
0
from tweepy.streaming import StreamListener
from tweepy import Stream
from oauth import login

class StdOutListener(StreamListener):
    """ This listener handles tweets that are received from the stream.
    This is a basic listener that just prints received tweets to stdout."""

    def on_data(self, data):
        print(data['text'])
        return True

    def on_error(self, status):
        print(status)


if __name__ == '__main__':
    l = StdOutListener()
    auth = login()[0]
    set_auth = login()[1]

    stream = Stream(auth, l)
    stream.filter(track=['basketball']).text
Example #3
0
from oauth import login
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
from datetime import date
import csv
import tweepy

analyzer = SentimentIntensityAnalyzer()
api = login()[2]

screen_name = "realDonaldTrump"
today = date.today()

#timeline = api.user_timeline(screen_name=screen_name,count=1000)

count = 1

#TODO: Make this more functional so we can get sentiment analysis by users last few tweets. Turn this into a "what type of tweeter are you website or something like that

fields = [
    'Number', 'Tweet Text', 'Negative Score', 'Positive Score',
    'Retweet Count', 'Like Count'
]

print("Now gathering tweet data for %s..." % screen_name)

with open('%s-%s-sentimentanalysis.csv' % (today, screen_name), 'w') as stats:
    stats_writer = csv.writer(stats)
    stats_writer.writerow(fields)

    page_list = []
    for page in tweepy.Cursor(api.user_timeline, count=200,
Example #4
0
def connect():
#log.debug("Logging in...")
    r = oauth.login() 
    return r