Report amount of imported users after scan

This commit is contained in:
Manuel Cortez 2022-08-03 09:39:45 -05:00
parent 9afd6774f2
commit 03f59064d5
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790
2 changed files with 7 additions and 6 deletions

View File

@ -36,7 +36,7 @@ class autocompletionScan(object):
return confirmation return confirmation
def prepare_progress_dialog(self): def prepare_progress_dialog(self):
self.progress_dialog = wx_scan.get_progress_dialog(parent=self.dialog) self.progress_dialog = wx_scan.autocompletionScanProgressDialog()
# 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")
self.progress_dialog.Show() self.progress_dialog.Show()
@ -44,7 +44,7 @@ class autocompletionScan(object):
def on_update_progress(self, percent): def on_update_progress(self, percent):
if percent > 100: if percent > 100:
percent = 100 percent = 100
wx.CallAfter(self.progress_dialog.Update, percent) wx.CallAfter(self.progress_dialog.update, percent)
def scan(self): def scan(self):
""" Attempts to add all users selected by current user to the autocomplete database. """ """ Attempts to add all users selected by current user to the autocomplete database. """
@ -76,8 +76,8 @@ class autocompletionScan(object):
if len(z) == 0: if len(z) == 0:
continue continue
try: try:
results = selff.buffer.session.twitter.lookup_users(user_id=z) results = self.buffer.session.twitter.lookup_users(user_id=z)
except NameError: except TweepyException:
wx.CallAfter(wx_scan.show_error) wx.CallAfter(wx_scan.show_error)
return self.done() return self.done()
users.extend(results) users.extend(results)
@ -86,6 +86,7 @@ class autocompletionScan(object):
pub.sendMessage("on-update-progress", percent=percent) pub.sendMessage("on-update-progress", percent=percent)
for user in users: for user in users:
database.set_user(user.screen_name, user.name, 1) database.set_user(user.screen_name, user.name, 1)
wx.CallAfter(wx_scan.show_success, len(users))
self.done() self.done()
def done(self): def done(self):

View File

@ -39,8 +39,8 @@ def confirm():
return True return True
return False return False
def show_success(): def show_success(users):
with wx.MessageDialog(None, _("TWBlue has imported {} users successfully."), _("Done")) as dlg: with wx.MessageDialog(None, _("TWBlue has imported {} users successfully.").format(users), _("Done")) as dlg:
dlg.ShowModal() dlg.ShowModal()
def show_error(): def show_error():