minor cleanups

This commit is contained in:
The MMGen Project 2023-12-12 10:19:49 +00:00
commit 7140b76100
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
5 changed files with 15 additions and 12 deletions

View file

@ -9,7 +9,7 @@
# https://gitlab.com/mmgen/mmgen-wallet
"""
devinit: Developer tools init/launch code for the MMGen suite
devinit: Developer tools initialization for the MMGen suite
"""
devtools_funcs = {

View file

@ -26,7 +26,7 @@ color_funcs = {
def pfmt(*args,color=None):
import pprint
ret = pprint.PrettyPrinter(indent=4).pformat(
ret = pprint.PrettyPrinter(indent=4,width=116).pformat(
args if len(args) > 1 else '' if not args else args[0] )
return color_funcs[color](ret) if color else ret
@ -47,7 +47,7 @@ def Pmsg(*args,color=None):
sys.stdout.write(pfmt(*args,color=color) + '\n')
def Pdie(*args,exit_val=1):
Pmsg(*args,color='red')
Pmsg(*args,color=('yellow' if exit_val == 1 else 'red' if exit_val else None))
sys.exit(exit_val)
def Pexit(*args):

View file

@ -17,9 +17,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
main: Script launcher for the MMGen project
main: Script launcher for the MMGen Project
"""
import sys,os
def launch(mod,package='mmgen'):
if mod in ('walletgen','walletchk','walletconv','passchg','subwalletgen','seedsplit'):
@ -28,8 +30,6 @@ def launch(mod,package='mmgen'):
if mod == 'keygen':
mod = 'addrgen'
import sys,os
if sys.platform == 'linux' and sys.stdin.isatty():
import termios,atexit
fd = sys.stdin.fileno()
@ -40,9 +40,10 @@ def launch(mod,package='mmgen'):
__import__(f'{package}.main_{mod}')
except KeyboardInterrupt:
sys.stderr.write('\nUser interrupt\n')
sys.exit(1) # must exit normally so exit handlers will be called
sys.exit(1)
except EOFError:
sys.stderr.write('\nEnd of file\n')
sys.exit(1)
except Exception as e:
if os.getenv('MMGEN_EXEC_WRAPPER'):

View file

@ -57,7 +57,9 @@ opts_data = {
-c, --check-solc-version Check the installed solc version
""",
'notes': """
The owner address must be in checksummed format
The owner address must be in checksummed format.
Use mmgen-tool eth_checksummed_addr to create it if necessary.
"""
}
}

View file

@ -34,7 +34,7 @@ if not os.getenv('MMGEN_DEVTOOLS'):
init_dev()
from mmgen.cfg import Config,gc
from mmgen.color import green,gray,brown
from mmgen.color import green,gray,brown,orange
from mmgen.util import msg,gmsg,ymsg,Msg,async_run
from test.include.common import set_globals,end_msg
@ -117,7 +117,7 @@ class UnitTestHelpers:
def skip_msg(self,desc):
cfg._util.qmsg(gray(f'Skipping subtest {self.subtest_name.replace("_","-")!r} for {desc}'))
def process_bad_data(self,data):
def process_bad_data(self,data,pfx='bad '):
if os.getenv('PYTHONOPTIMIZE'):
ymsg('PYTHONOPTIMIZE set, skipping error handling tests')
return
@ -129,7 +129,7 @@ class UnitTestHelpers:
m_noraise = "\nillegal action 'bad {}' failed to raise an exception (expected {!r})"
for (desc,exc_chk,emsg_chk,func) in data:
try:
cfg._util.vmsg_r(' bad {:{w}}'.format( desc+':', w=desc_w+1 ))
cfg._util.vmsg_r(' {}{:{w}}'.format(pfx, desc+':', w=desc_w+1))
func()
except Exception as e:
exc = type(e).__name__
@ -147,7 +147,7 @@ def run_test(test,subtest=None):
def run_subtest(t,subtest):
subtest_disp = subtest.replace('_','-')
msg(brown(f'Running unit subtest {test}.{subtest_disp}'))
msg(brown('Running unit subtest ') + orange(f'{test}.{subtest_disp}'))
if getattr(t,'silence_output',False):
t._silence()