mirror of
				https://github.com/MCV-Software/TWBlue.git
				synced 2025-10-31 12:12:01 +00:00 
			
		
		
		
	Return on exception
This commit is contained in:
		| @@ -1,13 +1,13 @@ | |||||||
| # -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||||||
| """ Scanning code for autocompletion feature on TWBlue. This module can retrieve user objects from the selected Twitter account automatically. """ | """ Scanning code for autocompletion feature on TWBlue. This module can retrieve user objects from the selected Twitter account automatically. """ | ||||||
| import time | import time | ||||||
|  | import threading | ||||||
| import wx | import wx | ||||||
| import widgetUtils | import widgetUtils | ||||||
| import output | import output | ||||||
| from tweepy.cursor import Cursor | from tweepy.cursor import Cursor | ||||||
| from tweepy.errors import TweepyException | from tweepy.errors import TweepyException | ||||||
| from pubsub import pub | from pubsub import pub | ||||||
| from mysc.thread_utils import call_threaded |  | ||||||
| from . import wx_scan | from . import wx_scan | ||||||
| from . import manage | from . import manage | ||||||
| from . import storage | from . import storage | ||||||
| @@ -36,7 +36,8 @@ class autocompletionScan(object): | |||||||
|                 self.progress_dialog = wx_scan.get_progress_dialog(parent=self.dialog) |                 self.progress_dialog = wx_scan.get_progress_dialog(parent=self.dialog) | ||||||
|                 # connect method to update progress dialog |                 # connect method to update progress dialog | ||||||
|                 pub.subscribe(self.on_update_progress, "on-update-progress") |                 pub.subscribe(self.on_update_progress, "on-update-progress") | ||||||
|                 scanner = call_threaded(self.scan) |                 scanner = threading.Thread(target=self.scan) | ||||||
|  |                 scanner.start() | ||||||
|  |  | ||||||
|     def on_update_progress(self, percent): |     def on_update_progress(self, percent): | ||||||
|         if percent > 100: |         if percent > 100: | ||||||
| @@ -64,7 +65,7 @@ class autocompletionScan(object): | |||||||
|                         ids.append(str(i)) |                         ids.append(str(i)) | ||||||
|             except TweepyException: |             except TweepyException: | ||||||
|                 wx.CallAfter(wx_scan.show_error) |                 wx.CallAfter(wx_scan.show_error) | ||||||
|                 self.done() |                 return self.done() | ||||||
|         # As next step requires batches of 100s users, let's split our user Ids so we won't break the param rules. |         # As next step requires batches of 100s users, let's split our user Ids so we won't break the param rules. | ||||||
|         split_users = [ids[i:i + 100] for i in range(0, len(ids), 100)] |         split_users = [ids[i:i + 100] for i in range(0, len(ids), 100)] | ||||||
|         # store returned users in this list. |         # store returned users in this list. | ||||||
| @@ -74,9 +75,10 @@ class autocompletionScan(object): | |||||||
|                 continue |                 continue | ||||||
|             try: |             try: | ||||||
|                 results = selff.buffer.session.twitter.lookup_users(user_id=z) |                 results = selff.buffer.session.twitter.lookup_users(user_id=z) | ||||||
|             except TweepyException: |             except NameError: | ||||||
|                 wx.CallAfter(wx_scan.show_error) |                 wx.CallAfter(wx_scan.show_error) | ||||||
|                 self.done() |                 wx.CallAfter(self.dialog.SetFocus) | ||||||
|  |                 return self.done() | ||||||
|             users.extend(results) |             users.extend(results) | ||||||
|             time.sleep(1) |             time.sleep(1) | ||||||
|             percent = percent + (100/len(split_users)) |             percent = percent + (100/len(split_users)) | ||||||
|   | |||||||
| @@ -31,6 +31,5 @@ def get_progress_dialog(parent=None): | |||||||
|     return wx.ProgressDialog(_("Retrieving Twitter users from account..."), _("working..."),  parent=parent, maximum=100, style=wx.PD_APP_MODAL) |     return wx.ProgressDialog(_("Retrieving Twitter users from account..."), _("working..."),  parent=parent, maximum=100, style=wx.PD_APP_MODAL) | ||||||
|  |  | ||||||
| def show_error(): | def show_error(): | ||||||
|     dlg = wx.MessageDialog(None, _("Error adding users from Twitter. Please try again in about 15 minutes."), _("Error"), style=wx.ICON_ERROR) |     with wx.MessageDialog(None, _("Error adding users from Twitter. Please try again in about 15 minutes."), _("Error"), style=wx.ICON_ERROR) as dlg: | ||||||
|         dlg.ShowModal() |         dlg.ShowModal() | ||||||
|     dlg.Destroy() |  | ||||||
		Reference in New Issue
	
	Block a user