Browse Source

minor fixes

MMGen 6 years ago
parent
commit
281e1f3ffb

+ 5 - 3
mmgen/globalvars.py

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

+ 1 - 1
mmgen/main_autosign.py

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

+ 1 - 1
mmgen/opts.py

@@ -78,7 +78,7 @@ def opt_postproc_initializations():
 	from mmgen.color import init_color
 	from mmgen.color import init_color
 	init_color(enable_color=g.color,num_colors=('auto',256)[bool(g.force_256_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.coin = g.coin.upper() # allow user to use lowercase
 	g.dcoin = g.coin
 	g.dcoin = g.coin

+ 1 - 1
mmgen/share/Opts.py

@@ -106,7 +106,7 @@ def parse_opts(argv,opts_data,opt_filter=None,skip_help=False):
 		for l in opts_data[k].strip().splitlines():
 		for l in opts_data[k].strip().splitlines():
 			m = re.match(pat,l)
 			m = re.match(pat,l)
 			if m:
 			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) == '=']
 				app = (['',''],[':','='])[m.group(3) == '=']
 				od.append(list(m.groups()) + app + [skip])
 				od.append(list(m.groups()) + app + [skip])
 			else:
 			else:

+ 1 - 1
mmgen/term.py

@@ -118,7 +118,7 @@ def _get_keypress_mswin(prompt='',immed_chars='',prehold_protect=True,num_chars=
 
 
 			if ord(ch) == 3: raise KeyboardInterrupt
 			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
 				return ch
 			if immed_chars == 'ALL_EXCEPT_ENTER' and not ch in '\n\r':
 			if immed_chars == 'ALL_EXCEPT_ENTER' and not ch in '\n\r':
 				return ch
 				return ch

+ 1 - 1
mmgen/util.py

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

+ 8 - 3
scripts/traceback_run.py

@@ -4,7 +4,7 @@
 # file, as all names will be seen by the exec'ed file.  To prevent name collisions, all names
 # 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_'
 # defined here should begin with 'traceback_run_'
 
 
-import sys
+import sys,time
 
 
 def traceback_run_init():
 def traceback_run_init():
 	import os
 	import os
@@ -29,13 +29,14 @@ def traceback_run_process_exception():
 	exc = l.pop()
 	exc = l.pop()
 	if exc[:11] == 'SystemExit:': 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)))
 	sys.stdout.write('{}{}'.format(yellow(''.join(l)),red(exc)))
 
 
 	open(traceback_run_outfile,'w').write(''.join(l+[exc]))
 	open(traceback_run_outfile,'w').write(''.join(l+[exc]))
 
 
 traceback_run_outfile = traceback_run_init()
 traceback_run_outfile = traceback_run_init()
+traceback_run_tstart = time.time()
 
 
 try:
 try:
 	sys.argv.pop(0)
 	sys.argv.pop(0)
@@ -48,6 +49,10 @@ except SystemExit as e:
 except Exception as e:
 except Exception as e:
 	traceback_run_process_exception()
 	traceback_run_process_exception()
 	sys.exit(e.mmcode if hasattr(e,'mmcode') else e.code if hasattr(e,'code') else 1)
 	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:
 # else:
 # 	print('else: '+repr(sys.exc_info()))
 # 	print('else: '+repr(sys.exc_info()))
 # finally:
 # finally:

+ 2 - 1
setup.py

@@ -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]
 _gvi = subprocess.check_output(['gcc','--version']).decode().splitlines()[0]
 have_mingw64 = 'x86_64' in _gvi and 'MinGW' in _gvi
 have_mingw64 = 'x86_64' in _gvi and 'MinGW' in _gvi
 have_arm     = subprocess.check_output(['uname','-m']).strip() == 'aarch64'
 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.
 # Zipfile module under Windows (MinGW) can't handle UTF-8 filenames.
 # Move it so that distutils will use the 'zip' utility instead.
 # 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',
 		platforms    = 'Linux, MS Windows, Raspberry Pi/Raspbian, Orange Pi/Armbian',
 		keywords     = g.keywords,
 		keywords     = g.keywords,
 		cmdclass     = { 'build_ext': my_build_ext, 'install_data': my_install_data },
 		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 = [('share/mmgen', [
 				'data_files/mmgen.cfg',     # source files must have 0644 mode
 				'data_files/mmgen.cfg',     # source files must have 0644 mode
 				'data_files/mn_wordlist.c',
 				'data_files/mn_wordlist.c',

+ 1 - 1
test/gentest.py

@@ -72,7 +72,7 @@ EXAMPLES:
 
 
 sys.argv = [sys.argv[0]] + ['--skip-cfg-file'] + sys.argv[1:]
 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()
 if not 1 <= len(cmd_args) <= 2: opts.usage()
 
 

+ 1 - 1
test/test_py_d/ts_main.py

@@ -512,7 +512,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
 			wf,desc='hidden incognito data',out_fmt='hi',add_args=add_args)
 			wf,desc='hidden incognito data',out_fmt='hi',add_args=add_args)
 
 
 	def addrgen_seed(self,wf,foo,desc='seed data',in_fmt='seed'):
 	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
 		add_args = ([],['-S'])[bool(stdout)] + self.segwit_arg
 		t = self.spawn('mmgen-addrgen', add_args +
 		t = self.spawn('mmgen-addrgen', add_args +
 				['-i'+in_fmt,'-d',self.tmpdir,wf,self.addr_idx_list])
 				['-i'+in_fmt,'-d',self.tmpdir,wf,self.addr_idx_list])

+ 5 - 4
test/test_py_d/ts_misc.py

@@ -151,10 +151,11 @@ class TestSuiteRefTX(TestSuiteMain,TestSuiteBase):
 	)
 	)
 
 
 	def __init__(self,trunner,cfgs,spawn):
 	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)
 		return TestSuiteMain.__init__(self,trunner,cfgs,spawn)
 
 
 	def ref_tx_addrgen(self,atype):
 	def ref_tx_addrgen(self,atype):

+ 1 - 1
test/tooltest2.py

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