Exemplo n.º 1
0
def getCities(api):
    try:
        results = api.trends_available()
        return results
    except Exception as e:
        Utils.emitException([str(datetime.utcnow()),"Thrown when making API call to trends_available.",type(e),e.args,e])
        return None
    return None
Exemplo n.º 2
0
def getTrends(woeid, api):
    try:
        results = api.trends_place(woeid)
        trends = results[0]["trends"]
        return trends
    except Exception as e:
        Utils.emitException([str(datetime.utcnow()),"Thrown when making API call to trends_place. WOEID: " + str(woeid),type(e),e.args,e])
        return None
    return None
Exemplo n.º 3
0
                        if city['name'] != None and city['countryCode'] != None and city['woeid'] != None and dateObj != None and api != None:
                            trends = TwitterAPI.getTrends(city['woeid'], api)
                            if trends != None:
                                #Saving Trends
                                woeid = str(city['woeid'])
                                if (woeid != ""):
                                    TrendingHistoryDB.updateTrendsCollection(trends, dateObj, woeid, city['name'], city['countryCode'])
                            else:
                                Utils.emitWarning([str(datetime.utcnow()),"Returned trends object was None Type."])
                            Utils.goToSleep(65)
                        else:
                            Utils.emitWarning([str(datetime.utcnow()),"Params were not as epectied before trying to get trends in given city."])
            else:
                Utils.emitWarning([str(datetime.utcnow()),"Cities list was None Type."])
                break
        else:
            Utils.emitWarning([str(datetime.utcnow()),"DateObj in TrendingController is None Type."])
            break
    Utils.emitWarning([str(datetime.utcnow()),"Left the main loop, program terminating..."])


'''
Starts the main function.
'''
if __name__ == '__main__':
    while(True):
        try:
            main()
        except Exception as e:
            Utils.emitException([str(datetime.utcnow()),"Fatal Error.",type(e),e.args,e])
        continue