minor fixes

This commit is contained in:
The MMGen Project 2019-03-22 11:32:22 +00:00
commit 281e1f3ffb
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
12 changed files with 28 additions and 19 deletions

View file

@ -75,7 +75,6 @@ class g(object):
debug_addrlist = False
quiet = False
no_license = False
color = (False,True)[sys.stdout.isatty()]
force_256_color = False
testnet = False
regtest = False
@ -99,12 +98,15 @@ class g(object):
traceback = False
test_suite = False
for k in ('win','linux'):
for k in ('linux','win','msys'):
if sys.platform[:len(k)] == k:
platform = k; break
platform = { 'linux':'linux', 'win':'win', 'msys':'win' }[k]
break
else:
die(1,"'{}': platform not supported by {}\n".format(sys.platform,proj_name))
color = sys.stdout.isatty() and platform != 'win'
if os.getenv('HOME'): # Linux or MSYS
home_dir = os.getenv('HOME')
elif platform == 'win': # Windows native:

View file

@ -316,7 +316,7 @@ def setup():
def ev_sleep(secs):
ev.wait(secs)
return (False,True)[ev.isSet()]
return ev.isSet()
def do_led(on,off):
if not on:

View file

@ -78,7 +78,7 @@ def opt_postproc_initializations():
from mmgen.color import init_color
init_color(enable_color=g.color,num_colors=('auto',256)[bool(g.force_256_color)])
if g.platform == 'win': start_mscolor()
if g.color and g.platform == 'win': start_mscolor()
g.coin = g.coin.upper() # allow user to use lowercase
g.dcoin = g.coin

View file

@ -106,7 +106,7 @@ def parse_opts(argv,opts_data,opt_filter=None,skip_help=False):
for l in opts_data[k].strip().splitlines():
m = re.match(pat,l)
if m:
skip = (False,True)[bool(opt_filter) and m.group(1) not in opt_filter]
skip = bool(opt_filter) and m.group(1) not in opt_filter
app = (['',''],[':','='])[m.group(3) == '=']
od.append(list(m.groups()) + app + [skip])
else:

View file

@ -118,7 +118,7 @@ def _get_keypress_mswin(prompt='',immed_chars='',prehold_protect=True,num_chars=
if ord(ch) == 3: raise KeyboardInterrupt
if immed_chars == 'ALL' or ch in immed_chars:
if immed_chars == 'ALL' or ch.decode() in immed_chars:
return ch
if immed_chars == 'ALL_EXCEPT_ENTER' and not ch in '\n\r':
return ch

View file

@ -766,7 +766,7 @@ def keypress_confirm(prompt,default_yes=False,verbose=False,no_nl=False,complete
if opt.accept_defaults:
msg(p)
return (False,True)[default_yes]
return default_yes
while True:
r = get_char(p).strip(b'\n\r')

View file

@ -4,7 +4,7 @@
# file, as all names will be seen by the exec'ed file. To prevent name collisions, all names
# defined here should begin with 'traceback_run_'
import sys
import sys,time
def traceback_run_init():
import os
@ -29,13 +29,14 @@ def traceback_run_process_exception():
exc = l.pop()
if exc[:11] == 'SystemExit:': l.pop()
def red(s): return '{e}[31;1m{}{e}[0m'.format(s,e='\033')
def yellow(s): return '{e}[33;1m{}{e}[0m'.format(s,e='\033')
red = lambda s: '\033[31;1m{}\033[0m'.format(s)
yellow = lambda s: '\033[33;1m{}\033[0m'.format(s)
sys.stdout.write('{}{}'.format(yellow(''.join(l)),red(exc)))
open(traceback_run_outfile,'w').write(''.join(l+[exc]))
traceback_run_outfile = traceback_run_init()
traceback_run_tstart = time.time()
try:
sys.argv.pop(0)
@ -48,6 +49,10 @@ except SystemExit as e:
except Exception as e:
traceback_run_process_exception()
sys.exit(e.mmcode if hasattr(e,'mmcode') else e.code if hasattr(e,'code') else 1)
blue = lambda s: '\033[34;1m{}\033[0m'.format(s)
sys.stdout.write(blue('Runtime: {:0.5f} secs\n'.format(time.time() - traceback_run_tstart)))
# else:
# print('else: '+repr(sys.exc_info()))
# finally:

View file

@ -29,6 +29,7 @@ if ver[0] < min_ver[0] or ver[1] < min_ver[1]:
_gvi = subprocess.check_output(['gcc','--version']).decode().splitlines()[0]
have_mingw64 = 'x86_64' in _gvi and 'MinGW' in _gvi
have_arm = subprocess.check_output(['uname','-m']).strip() == 'aarch64'
have_msys2 = not have_mingw64 and os.getenv('MSYSTEM') == 'MINGW64'
# Zipfile module under Windows (MinGW) can't handle UTF-8 filenames.
# Move it so that distutils will use the 'zip' utility instead.
@ -108,7 +109,7 @@ setup(
platforms = 'Linux, MS Windows, Raspberry Pi/Raspbian, Orange Pi/Armbian',
keywords = g.keywords,
cmdclass = { 'build_ext': my_build_ext, 'install_data': my_install_data },
ext_modules = [module1],
ext_modules = [] if have_msys2 else [module1],
data_files = [('share/mmgen', [
'data_files/mmgen.cfg', # source files must have 0644 mode
'data_files/mn_wordlist.c',

View file

@ -72,7 +72,7 @@ EXAMPLES:
sys.argv = [sys.argv[0]] + ['--skip-cfg-file'] + sys.argv[1:]
cmd_args = opts.init(opts_data,add_opts=['exact_output'])
cmd_args = opts.init(opts_data,add_opts=['exact_output','use_old_ed25519'])
if not 1 <= len(cmd_args) <= 2: opts.usage()

View file

@ -512,7 +512,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
wf,desc='hidden incognito data',out_fmt='hi',add_args=add_args)
def addrgen_seed(self,wf,foo,desc='seed data',in_fmt='seed'):
stdout = (False,True)[desc=='seed data'] #capture output to screen once
stdout = desc == 'seed data' # capture output to screen once
add_args = ([],['-S'])[bool(stdout)] + self.segwit_arg
t = self.spawn('mmgen-addrgen', add_args +
['-i'+in_fmt,'-d',self.tmpdir,wf,self.addr_idx_list])

View file

@ -151,10 +151,11 @@ class TestSuiteRefTX(TestSuiteMain,TestSuiteBase):
)
def __init__(self,trunner,cfgs,spawn):
for n in self.tmpdir_nums:
cfgs[str(n)].update({ 'addr_idx_list': '1-2',
'segwit': n in (33,34),
'dep_generators': { 'addrs':'ref_tx_addrgen'+str(n)[-1] }})
if cfgs:
for n in self.tmpdir_nums:
cfgs[str(n)].update({ 'addr_idx_list': '1-2',
'segwit': n in (33,34),
'dep_generators': { 'addrs':'ref_tx_addrgen'+str(n)[-1] }})
return TestSuiteMain.__init__(self,trunner,cfgs,spawn)
def ref_tx_addrgen(self,atype):

View file

@ -718,7 +718,7 @@ if opt.fork:
d,f = init_coverage()
tool_cmd = ('python3','-m','trace','--count','--coverdir='+d,'--file='+f) + tool_cmd
elif g.platform == 'win':
tool_cmd = ('python3') + tool_cmd
tool_cmd = ('python3',) + tool_cmd
else:
opt.usr_randchars = 0
tc = tool.MMGenToolCmd()