Add get_api function
This commit is contained in:
parent
d5c3283ce8
commit
e32209bf2b
|
@ -8,6 +8,10 @@ from oauthtwitter import OAuthApi
|
|||
from urllib2 import HTTPError,URLError
|
||||
import avcache
|
||||
|
||||
# These are the global constants for the twitter oauth entry for our app
|
||||
CONSUMER_KEY = jGu64TPCUtyLZKyWyMJldQ
|
||||
CONSUMER_SECRET = lTRrTyvzRfJab5HsAe16zkV8tqFVRp0k0cTfHL0l4GE
|
||||
|
||||
|
||||
class CustomApi(OAuthApi):
|
||||
'''
|
||||
|
@ -16,13 +20,11 @@ class CustomApi(OAuthApi):
|
|||
instantiated
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
OAuthApi.__init__(self, username, password)
|
||||
def __init__(self, access_token):
|
||||
OAuthApi.__init__(self, CONSUMER_KEY, CONSUMER_SECRET, access_token)
|
||||
self.lock = RLock()
|
||||
self.sig_proxy = SigProxy()
|
||||
|
||||
self.username = username
|
||||
|
||||
thread = GetUserLists(api=self)
|
||||
thread.sig_proxy.connect('lists-ready', self.on_lists_ready)
|
||||
thread.start()
|
||||
|
@ -459,3 +461,7 @@ def dms_to_statuses(direct_messages):
|
|||
status.text = dm.text
|
||||
statuses.append(status)
|
||||
return statuses
|
||||
|
||||
|
||||
def get_api(username, password):
|
||||
|
||||
|
|
2
hrafn.py
2
hrafn.py
|
@ -70,7 +70,7 @@ class Hrafn():
|
|||
for item in config.sections():
|
||||
if (re.match(r'account', item)):
|
||||
username = config.get(item, 'username')
|
||||
self.accounts[username] = apithreads.CustomApi(username=username, password=config.get(item, 'password'))
|
||||
self.accounts[username] = apithreads.get_api(username=username, password=config.get(item, 'password'))
|
||||
self.accounts[username].sig_proxy.connect('lists-ready', self.on_lists_ready)
|
||||
|
||||
if not self.db.has_key('active_user'):
|
||||
|
|
Reference in New Issue
Block a user