From d4c4cc1b69d11034753b953d401bb95ff37251b4 Mon Sep 17 00:00:00 2001 From: scgbckbone Date: Tue, 13 May 2025 16:12:06 +0200 Subject: [PATCH] remove exception dumping to console --- shared/actions.py | 6 ++---- shared/auth.py | 6 +++--- shared/backups.py | 12 +++++------- shared/bbqr.py | 2 +- shared/hsm.py | 6 +++--- shared/hsm_ux.py | 4 ++-- shared/imptask.py | 2 +- shared/main.py | 4 +--- shared/mk4.py | 3 +-- shared/msgsign.py | 2 +- shared/multisig.py | 2 +- shared/notes.py | 4 +--- shared/ownership.py | 2 +- shared/psbt.py | 2 +- shared/serializations.py | 2 +- shared/trick_pins.py | 10 ++++------ shared/usb.py | 2 +- shared/ux_q1.py | 2 +- shared/vdisk.py | 4 ++-- 19 files changed, 33 insertions(+), 44 deletions(-) diff --git a/shared/actions.py b/shared/actions.py index 520e55fb..342eba6a 100644 --- a/shared/actions.py +++ b/shared/actions.py @@ -833,7 +833,7 @@ async def start_login_sequence(): # safe to do so. Remember the bootrom checks PIN on every access to # the secret, so "letting" them past this point is harmless if they don't know # the true pin. - sys.print_exception(exc) + # sys.print_exception(exc) if not pa.is_successful(): raise @@ -854,9 +854,7 @@ async def start_login_sequence(): try: from pwsave import MicroSD2FA MicroSD2FA.enforce_policy() - except BaseException as exc: - # robustness: keep going! - sys.print_exception(exc) + except: pass # robustness: keep going! # implement idle timeout now that we are logged-in IMPT.start_task('idle', idle_logout()) diff --git a/shared/auth.py b/shared/auth.py index 70c24c8c..5fe4729d 100644 --- a/shared/auth.py +++ b/shared/auth.py @@ -1148,7 +1148,7 @@ class NewPassphrase(UserAuthorizedAction): except BaseException as exc: self.failed = "Exception" - sys.print_exception(exc) + # sys.print_exception(exc) finally: self.done() @@ -1345,7 +1345,7 @@ class NewEnrollRequest(UserAuthorizedAction): return await self.failure('No space left') except BaseException as exc: self.failed = "Exception" - sys.print_exception(exc) + # sys.print_exception(exc) finally: UserAuthorizedAction.cleanup() # because no results to store self.pop_menu() @@ -1454,7 +1454,7 @@ Binary checksum and signature will be further verified before any changes are ma except BaseException as exc: self.failed = "Exception" - sys.print_exception(exc) + # sys.print_exception(exc) finally: UserAuthorizedAction.cleanup() # because no results to store self.pop_menu() diff --git a/shared/backups.py b/shared/backups.py index 361c4315..3a4ef4ea 100644 --- a/shared/backups.py +++ b/shared/backups.py @@ -146,9 +146,10 @@ def extract_long_secret(vals): if ('long_secret' in vals) and version.has_608: try: ls = a2b_hex(vals.pop('long_secret')) - except Exception as exc: - sys.print_exception(exc) + except: + # sys.print_exception(exc) # but keep going. + pass return ls def restore_from_dict_ll(vals): @@ -186,9 +187,7 @@ def restore_from_dict_ll(vals): if ls is not None: try: pa.ls_change(ls) - except Exception as exc: - sys.print_exception(exc) - # but keep going + except: pass # but keep going pb = .70 dis.progress_bar_show(pb) @@ -222,8 +221,7 @@ def restore_from_dict_ll(vals): from trick_pins import tp try: tp.restore_backup(vals[key]) - except Exception as exc: - sys.print_exception(exc) + except: pass # continue as `tp.restore_backup` handles # saving into settings diff --git a/shared/bbqr.py b/shared/bbqr.py index c0ae8664..c684e0b8 100644 --- a/shared/bbqr.py +++ b/shared/bbqr.py @@ -214,7 +214,7 @@ class BBQrState: # can happen if QR got corrupted between scanner and us (overlap) # or back BBQr implementation #print("corrupt QR: %s" % scan) - import sys; sys.print_exception(exc) + # import sys; sys.print_exception(exc) dis.draw_bbqr_progress(hdr, self.parts, corrupt=True) return True diff --git a/shared/hsm.py b/shared/hsm.py index 69f389ed..b786602b 100644 --- a/shared/hsm.py +++ b/shared/hsm.py @@ -71,9 +71,9 @@ def restore_backup(s): with open(POLICY_FNAME, 'wt') as f: f.write(s) - except BaseException as exc: + except: # keep going, we don't want to brick - sys.print_exception(exc) + # sys.print_exception(exc) pass def pop_list(j, fld_name, cleanup_fcn=None): @@ -936,7 +936,7 @@ class HSMPolicy: return 'y' except BaseException as exc: - sys.print_exception(exc) + # sys.print_exception(exc) err = "Rejected: " + (str(exc) or problem_file_line(exc)) self.refuse(log, err) diff --git a/shared/hsm_ux.py b/shared/hsm_ux.py index 5cc4fb91..2a8b4a4f 100644 --- a/shared/hsm_ux.py +++ b/shared/hsm_ux.py @@ -67,7 +67,7 @@ Press %s to save policy and enable HSM mode.''' % (self.policy.hash(), confirm_c except BaseException as exc: self.failed = "Exception" - sys.print_exception(exc) + # sys.print_exception(exc) self.refused = True self.ux_done = True @@ -354,7 +354,7 @@ class hsmUxInteraction: await sleep_ms(100) except BaseException as exc: # just in case, keep going - sys.print_exception(exc) + # sys.print_exception(exc) continue # do the interactions, but don't let user actually press anything diff --git a/shared/imptask.py b/shared/imptask.py index 6979854c..5a96e0a8 100644 --- a/shared/imptask.py +++ b/shared/imptask.py @@ -58,7 +58,7 @@ class ImportantTask: else: # uncaught exception in an unnamed (and unimportant) task print("UNNAMED: " + context["message"]) - sys.print_exception(context["exception"]) + # sys.print_exception(context["exception"]) print("... future: %r" % context.get("future", '?')) def start_task(self, name, awaitable): diff --git a/shared/main.py b/shared/main.py index 870bd7e1..25008382 100644 --- a/shared/main.py +++ b/shared/main.py @@ -61,9 +61,7 @@ try: from psram import PSRAMWrapper glob.PSRAM = PSRAMWrapper() -except BaseException as exc: - sys.print_exception(exc) - # continue tho +except: pass # continue tho # Setup keypad/keyboard if version.has_qwerty: diff --git a/shared/mk4.py b/shared/mk4.py index eab4b6e6..297b33aa 100644 --- a/shared/mk4.py +++ b/shared/mk4.py @@ -57,8 +57,7 @@ def init0(): try: make_psram_fs() - except BaseException as exc: - sys.print_exception(exc) + except: pass if version.is_devmode: try: diff --git a/shared/msgsign.py b/shared/msgsign.py index 43bcbaf8..144dc651 100644 --- a/shared/msgsign.py +++ b/shared/msgsign.py @@ -493,7 +493,7 @@ async def sd_sign_msg_done(signature, address, text, base=None, orig_path=None, except OSError as exc: prob = 'Failed to write!\n\n%s\n\n' % exc - sys.print_exception(exc) + # sys.print_exception(exc) # fall through to try again # prompt them to input another card? diff --git a/shared/multisig.py b/shared/multisig.py index d8254f3c..af95f800 100644 --- a/shared/multisig.py +++ b/shared/multisig.py @@ -1746,7 +1746,7 @@ async def ms_coordinator_file(af_str, my_xfp, chain, slot_b=None): except Exception as exc: # show something for coders, but no user feedback - sys.print_exception(exc) + # sys.print_exception(exc) continue except CardMissingError: diff --git a/shared/notes.py b/shared/notes.py index fa4d8e5f..a97111b1 100644 --- a/shared/notes.py +++ b/shared/notes.py @@ -607,9 +607,7 @@ async def import_from_other(menu, *a): obj = json.load(open(fname, 'rt')) assert 'coldcard_notes' in obj return True - except Exception as exc: - import sys; sys.print_exception(exc) - pass + except: pass fn = await file_picker(min_size=8, max_size=100000, taster=contains_json, **choice) if not fn: return diff --git a/shared/ownership.py b/shared/ownership.py index a52bec65..94a2ef9b 100644 --- a/shared/ownership.py +++ b/shared/ownership.py @@ -81,7 +81,7 @@ class AddressCacheFile: except OSError: return except Exception as exc: - sys.print_exception(exc) + # sys.print_exception(exc) self.count = 0 self.hdr = None return diff --git a/shared/psbt.py b/shared/psbt.py index 8e46ba01..0ff2806d 100644 --- a/shared/psbt.py +++ b/shared/psbt.py @@ -859,7 +859,7 @@ class psbtInputProxy(psbtProxy): try: psbt.active_multisig.validate_script(redeem_script, subpaths=self.subpaths) except BaseException as exc: - sys.print_exception(exc) + # sys.print_exception(exc) raise FatalPSBTIssue('Input #%d: %s' % (my_idx, exc)) if not which_key and DEBUG: diff --git a/shared/serializations.py b/shared/serializations.py index ef5a87ae..e0caf051 100755 --- a/shared/serializations.py +++ b/shared/serializations.py @@ -230,7 +230,7 @@ def disassemble(script): #print('dis %d: opcode=%d' % (offset, c)) yield (None, c) except Exception as e: - import sys;sys.print_exception(e) + # import sys;sys.print_exception(e) raise ValueError("bad script") diff --git a/shared/trick_pins.py b/shared/trick_pins.py index 4d094e1e..f3cda398 100644 --- a/shared/trick_pins.py +++ b/shared/trick_pins.py @@ -374,8 +374,7 @@ class TrickPinMgmt: b, slot = tp.update_slot(pin.encode(), new=True, tc_flags=flags, tc_arg=arg, secret=new_secret) - except Exception as exc: - sys.print_exception(exc) # not visible + except: pass tp = TrickPinMgmt() @@ -492,7 +491,7 @@ class TrickPinMenu(MenuSystem): tc_arg=tc_arg, secret=new_secret) await ux_dramatic_pause("Saved.", 1) except BaseException as exc: - sys.print_exception(exc) + # sys.print_exception(exc) await ux_show_story("Failed: %s" % exc) self.update_contents() @@ -712,7 +711,7 @@ You can restore it by trying to re-add the same PIN (%s) again later.''' % pin self.pop_submenu() # too lazy to get redraw right except BaseException as exc: - sys.print_exception(exc) + # sys.print_exception(exc) await ux_show_story("Failed: %s" % exc) async def delete_pin(self, m,l, item): @@ -813,8 +812,7 @@ normal operation.''') # save it try: b, slot = tp.update_slot(pin.encode(), tc_flags=flags, tc_arg=new_val) - except BaseException as exc: - sys.print_exception(exc) + except: pass return va.index(cd_val), lgto_ch[1:], set_it diff --git a/shared/usb.py b/shared/usb.py index 0e9777cb..413592d4 100644 --- a/shared/usb.py +++ b/shared/usb.py @@ -240,7 +240,7 @@ class USBHandler: # catch bugs and fuzzing too if is_simulator() or is_devmode: print("USB request caused this: ", end='') - sys.print_exception(exc) + # sys.print_exception(exc) resp = b'err_Confused ' + problem_file_line(exc) if not success: diff --git a/shared/ux_q1.py b/shared/ux_q1.py index 91a696c6..09ef73fa 100644 --- a/shared/ux_q1.py +++ b/shared/ux_q1.py @@ -1059,7 +1059,7 @@ async def ux_visualize_txn(bin_txn): msg += '\n\nTxid:\n' + b2a_hex(txid).decode() except Exception as exc: - sys.print_exception(exc) + # sys.print_exception(exc) msg = "Unable to deserialize" await ux_show_story(msg, title="Signed Transaction") diff --git a/shared/vdisk.py b/shared/vdisk.py index 47b31e2b..1ac66f98 100644 --- a/shared/vdisk.py +++ b/shared/vdisk.py @@ -79,7 +79,7 @@ class VirtDisk: # corrupt or unformated? # XXX incomplete error handling here; needs work VBLKDEV.set_inserted(True) - sys.print_exception(exc) + # sys.print_exception(exc) return None @@ -93,7 +93,7 @@ class VirtDisk: return list(sorted(('/vdisk/'+fn, sz) for (fn,ty,_,sz) in os.ilistdir('/vdisk') if ty == 0x8000)) except BaseException as exc: - sys.print_exception(exc) + # sys.print_exception(exc) return [] finally: