Did some ApiThread refactoring, made the refresh button only refresh the current pane, and helped child threads die on exit
This commit is contained in:
@ -17,10 +17,19 @@ class SafeApi(Api):
|
||||
|
||||
|
||||
|
||||
class GetTweets(Thread):
|
||||
def __init__(self, api, list_name, pane, num_entries, username):
|
||||
class ApiThread(Thread):
|
||||
def __init__(self, api):
|
||||
Thread.__init__(self)
|
||||
self.api = api
|
||||
self.setDaemon(True)
|
||||
|
||||
# End class ApiThread
|
||||
|
||||
|
||||
|
||||
class GetTweets(ApiThread):
|
||||
def __init__(self, api, list_name, pane, num_entries, username):
|
||||
ApiThread.__init__(self, api)
|
||||
self.list_name = list_name
|
||||
self.pane = pane
|
||||
self.num_entries = num_entries
|
||||
@ -58,7 +67,7 @@ class GetTweets(Thread):
|
||||
else:
|
||||
statuses = results_to_statuses(self.api.Search(self.list_name, rpp=self.num_entries))
|
||||
|
||||
except HTTPError,URLError:
|
||||
except (HTTPError, URLError):
|
||||
statuses = None
|
||||
|
||||
gtk.gdk.threads_enter()
|
||||
@ -72,10 +81,9 @@ class GetTweets(Thread):
|
||||
|
||||
|
||||
|
||||
class GetSingleTweet(Thread):
|
||||
def __init__(self, api, pane, single_tweet):
|
||||
Thread.__init__(self)
|
||||
self.api = api
|
||||
class GetSingleTweet(ApiThread):
|
||||
def __init__(self, pane, single_tweet):
|
||||
ApiThread.__init__(self, api)
|
||||
self.pane = pane
|
||||
self.single_tweet = single_tweet
|
||||
|
||||
@ -85,7 +93,7 @@ class GetSingleTweet(Thread):
|
||||
with self.api.lock:
|
||||
try:
|
||||
statuses.append(self.api.GetStatus(self.single_tweet))
|
||||
except HTTPError,URLError:
|
||||
except (HTTPError, URLError):
|
||||
statuses = None
|
||||
|
||||
gtk.gdk.threads_enter()
|
||||
@ -99,10 +107,9 @@ class GetSingleTweet(Thread):
|
||||
|
||||
|
||||
|
||||
class GetFollowing(Thread):
|
||||
class GetFollowing(ApiThread):
|
||||
def __init__(self, api, pane, user):
|
||||
Thread.__init__(self)
|
||||
self.api = api
|
||||
ApiThread.__init__(self, api)
|
||||
self.pane = pane
|
||||
self.user = user
|
||||
|
||||
@ -114,7 +121,7 @@ class GetFollowing(Thread):
|
||||
with self.api.lock:
|
||||
relationship = self.api.ShowFriendships(target_screen_name=screen_name)
|
||||
following = relationship.source.following
|
||||
except HTTPError,URLError:
|
||||
except (HTTPError, URLError):
|
||||
following = false
|
||||
|
||||
self.pane.set_following(following)
|
||||
@ -123,10 +130,9 @@ class GetFollowing(Thread):
|
||||
|
||||
|
||||
|
||||
class GetVerified(Thread):
|
||||
class GetVerified(ApiThread):
|
||||
def __init__(self, api, pane, user):
|
||||
Thread.__init__(self)
|
||||
self.api = api
|
||||
ApiThread.__init__(self, api)
|
||||
self.pane = pane
|
||||
self.user = user
|
||||
|
||||
@ -138,12 +144,11 @@ class GetVerified(Thread):
|
||||
with self.api.lock:
|
||||
user = self.api.GetUser(screen_name)
|
||||
verified = user.verified
|
||||
except HTTPError,URLError:
|
||||
except (HTTPError, URLError):
|
||||
verified = false
|
||||
|
||||
self.pane.set_verified(verified)
|
||||
|
||||
|
||||
### End class GetVerified
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user