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