minor fixes; adapt script launcher, g.version for node tools
This commit is contained in:
parent
96cd623196
commit
395fa1c1d3
4 changed files with 19 additions and 12 deletions
|
|
@ -1 +1 @@
|
|||
13.1.dev018
|
||||
13.1.dev19
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ class GlobalContext(Lockable):
|
|||
if name[:11] == 'MMGEN_DEBUG':
|
||||
os.environ[name] = '1'
|
||||
|
||||
def get_mmgen_data_file(self,filename):
|
||||
def get_mmgen_data_file(self,filename,package='mmgen'):
|
||||
"""
|
||||
this is an expensive import, so do only when required
|
||||
"""
|
||||
|
|
@ -326,14 +326,17 @@ class GlobalContext(Lockable):
|
|||
from importlib.resources import files # Python 3.9
|
||||
except ImportError:
|
||||
from importlib_resources import files
|
||||
return files('mmgen').joinpath('data',filename).read_text()
|
||||
return files(package).joinpath('data',filename).read_text()
|
||||
|
||||
@property
|
||||
def version(self):
|
||||
return self.get_mmgen_data_file('version').strip()
|
||||
return self.get_mmgen_data_file(
|
||||
filename = 'version',
|
||||
package = 'mmgen_node_tools' if self.prog_name.startswith('mmnode-') else 'mmgen'
|
||||
).strip()
|
||||
|
||||
@property
|
||||
def release_date(self):
|
||||
return self.get_mmgen_data_file('release_date').strip()
|
||||
return self.get_mmgen_data_file(filename='release_date').strip()
|
||||
|
||||
g = GlobalContext()
|
||||
|
|
|
|||
|
|
@ -17,14 +17,16 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""
|
||||
main.py - Script launcher for the MMGen suite
|
||||
main.py - Script launcher for the MMGen project
|
||||
"""
|
||||
|
||||
def launch(mod):
|
||||
def launch(mod,package='mmgen'):
|
||||
|
||||
if mod in ('walletgen','walletchk','walletconv','passchg','subwalletgen','seedsplit'):
|
||||
mod = 'wallet'
|
||||
if mod == 'keygen': mod = 'addrgen'
|
||||
|
||||
if mod == 'keygen':
|
||||
mod = 'addrgen'
|
||||
|
||||
import sys,os
|
||||
from .globalvars import g
|
||||
|
|
@ -36,7 +38,7 @@ def launch(mod):
|
|||
atexit.register(lambda: termios.tcsetattr(fd,termios.TCSADRAIN,old))
|
||||
|
||||
try:
|
||||
__import__('mmgen.main_' + mod)
|
||||
__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
|
||||
|
|
@ -57,7 +59,7 @@ def launch(mod):
|
|||
|
||||
_o = namedtuple('exit_data',['color','exit_val','fs'])
|
||||
d = {
|
||||
0: _o(nocolor, 1, '{message}'),
|
||||
0: _o(nocolor, 0, '{message}'),
|
||||
1: _o(nocolor, 1, '{message}'),
|
||||
2: _o(yellow, 2, '{message}'),
|
||||
3: _o(yellow, 3, '\nMMGen Error ({name}):\n{message}'),
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ def version():
|
|||
{g.prog_name.upper()} version {g.version}
|
||||
Part of the {g.proj_name} suite, an online/offline cryptocurrency wallet for the
|
||||
command line. Copyright (C){g.Cdates} {g.author} {g.email}
|
||||
""",indent=' ').rstrip())
|
||||
""",indent=' ').rstrip())
|
||||
|
||||
def print_help(po,opts_data,opt_filter):
|
||||
if not 'code' in opts_data:
|
||||
|
|
@ -99,6 +99,7 @@ def opt_preproc_debug(po):
|
|||
('User-selected opts', po.user_opts),
|
||||
('Cmd args', po.cmd_args),
|
||||
)
|
||||
from .util import Msg
|
||||
Msg('\n=== opts.py debug ===')
|
||||
for e in d:
|
||||
Msg(' {:<20}: {}'.format(*e))
|
||||
|
|
@ -106,6 +107,7 @@ def opt_preproc_debug(po):
|
|||
def opt_postproc_debug():
|
||||
a = [k for k in dir(opt) if k[:2] != '__' and getattr(opt,k) != None]
|
||||
b = [k for k in dir(opt) if k[:2] != '__' and getattr(opt,k) == None]
|
||||
from .util import Msg
|
||||
Msg(' Opts after processing:')
|
||||
for k in a:
|
||||
v = getattr(opt,k)
|
||||
|
|
@ -597,7 +599,7 @@ def check_usr_opts(usr_opts): # Raises an exception if any check fails
|
|||
# if len(val) > 20 or not all(s.isalnum() for s in val):
|
||||
# die( 'UserOptError', f'{val!r}: invalid parameter for --token option' )
|
||||
|
||||
from .util import is_int,die
|
||||
from .util import is_int,die,Msg
|
||||
|
||||
cfuncs = { k:v for k,v in locals().items() if k.startswith('chk_') }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue