def return_collection_list(self): client = pymongo.MongoClient() db = client.topics if db.names_and_keywords.count() < 1: db.names_and_keywords.insert_one(json.dumps({"Name": "antibiotics", "Topic":"antibiotics"})) collection_list = [] for data in db.names_and_keywords.find(): collection_list.append(grabber.twitter_data_grabber(data['Topic'], data['Name'])) return collection_list
def post_new_dataset(): collection_name = request.form['new_keyword_name'] keyword = request.form['new_keyword'] client = pymongo.MongoClient() db = client.topics for db_post in db.names_and_keywords.find(): if db_post['Name'] == collection_name: return send_from_directory('.', 'create_dataset_fail.html') new_grabber = twitter_data_grabber(keyword, collection_name) grabber_list.append(new_grabber) try: new_grabber.start() db.names_and_keywords.insert_one( { "Topic": keyword, "Name": collection_name }) return send_from_directory('.', 'create_dataset_success.html') except Exception, e: print e return send_from_directory('.', 'create_dataset_fail.html')