def wallet_not_synched_slot(self, wallet): # main thread window = self.wallet_windows.get(wallet, None) if window: if window.question(_("LabelSync detected that this wallet is not synched with the label server.") + "\n\n" + _("Synchronize now?")): WaitingDialog(window, _("Synchronizing..."), partial(self.pull_thread, wallet, True), lambda *args: self._ok_synched(window), lambda exc: self._notok_synch(window, exc))
def _send(self, parent, blob): def sender_thread(): with self._audio_interface() as interface: src = BytesIO(blob) dst = interface.player() amodem.main.send(config=self.modem_config, src=src, dst=dst) print_msg('Sending:', repr(blob)) blob = zlib.compress(blob.encode('ascii')) kbps = self.modem_config.modem_bps / 1e3 msg = 'Sending to Audio MODEM ({0:.1f} kbps)...'.format(kbps) WaitingDialog(parent, msg, sender_thread)
def _recv(self, parent): def receiver_thread(): with self._audio_interface() as interface: src = interface.recorder() dst = BytesIO() amodem.main.recv(config=self.modem_config, src=src, dst=dst) return dst.getvalue() def on_finished(blob): if blob: blob = zlib.decompress(blob).decode('ascii') print_msg('Received:', repr(blob)) parent.setText(blob) kbps = self.modem_config.modem_bps / 1e3 msg = 'Receiving from Audio MODEM ({0:.1f} kbps)...'.format(kbps) WaitingDialog(parent, msg, receiver_thread, on_finished)
def importRecentTipsFromReddit(self): dates = [] for tip in self.tiplist.tips.values(): if hasattr(tip, "chaintip_message_created_utc"): dates.append(int(tip.chaintip_message_created_utc)) if len(dates) > 0: dates = sorted(dates) self.print_error( f"importRecentTipsFromReddit(): latest tip date: {dates[-1]} = {format_time(dates[-1])}, importing..." ) # import... try: dialog = WaitingDialog( self.window, _("importing from Reddit (starting {d})...").format( d=format_time(dates[-1])), lambda: self.reddit.doImport(-3, dates[-1]), auto_exec=True, on_error=self.importError) except Exception as e: traceback.print_exc() traceback.print_stack()
def importTipsFromReddit(self): choice = self.msg_box( icon=QMessageBox.Question, parent=self.window, title=_("Cannot load tips from wallet file"), rich_text=True, text="".join([ "<h3>", _("No valid tip data found in storage"), "</h3>", _("Either there are no tips stored in your wallet file (yet) or the storage version is too old" ), "<br><br>", _("You can 'import' tips (i.e. read inbox items authored by u/chaintip) from reddit... either all available items, 10 days worth of items or only items that are currently marked 'unread'." ), "<br><br>", _("After this initial import, new items coming into your inbox will be automatically read and digested into the list of tips according to their meaning." ), "<br><br>" ]), buttons=(_("Import all available"), _("Import 10 days worth"), _("Import nothing")), defaultButton=_("Import 10 days worth"), escapeButton=_("Import nothing"), ) if choice in (0, 1): # import messages from reddit days = (-2, 10)[choice] #self.reddit.triggerMarkChaintipMessagesUnread(days) #self.reddit.triggerImport(days) # import... try: dialog = WaitingDialog(self.window, "importing from Reddit...", lambda: self.reddit.doImport(days), auto_exec=True, on_error=self.importError) except Exception as e: traceback.print_exc() traceback.print_stack()