-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
27 lines (22 loc) · 917 Bytes
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import tweepy
import logging
from decouple import config
from datetime import datetime
logging.basicConfig(level=logging.INFO, filename='logs/logs.log', filemode='a', format='%(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger()
def create_api():
consumer_key = config('API_KEY')
consumer_secret = config('API_SECRET_KEY')
access_token = config('ACCESS_TOKEN')
access_token_secret = config('ACCESS_TOKEN_SECRET')
auth = tweepy.OAuthHandler(consumer_key,consumer_secret)
auth.set_access_token(access_token,access_token_secret)
api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)
try:
api.verify_credentials()
except Exception:
logger.exception('Error Creating Api')
now = datetime.now()
current_time = now.strftime('%m/%d/%y, %H:%M:%S')
logger.info('Api Created on {}'.format(current_time))
return api