daemon.py: new method: get_exec_version_str()
This commit is contained in:
parent
54f436c25a
commit
074e2b2b74
2 changed files with 21 additions and 1 deletions
|
|
@ -284,6 +284,22 @@ class CoinDaemon(Daemon):
|
|||
yield CoinProtocol.Base.create_network_id(coin,network)
|
||||
return list(gen())
|
||||
|
||||
@classmethod
|
||||
def get_exec_version_str(cls):
|
||||
try:
|
||||
cp = run([cls.exec_fn,'--version'],stdout=PIPE,stderr=PIPE,check=True)
|
||||
except:
|
||||
try:
|
||||
cp = run([cls.exec_fn,'version'],stdout=PIPE,stderr=PIPE,check=True)
|
||||
except:
|
||||
die(2,f'Unable to execute {cls.exec_fn}')
|
||||
|
||||
if cp.returncode:
|
||||
die(2,f'Unable to execute {cls.exec_fn}')
|
||||
else:
|
||||
res = cp.stdout.decode().splitlines()
|
||||
return ( res[0] if len(res) == 1 else [s for s in res if 'ersion' in s][0] ).strip()
|
||||
|
||||
def __new__(cls,
|
||||
network_id = None,
|
||||
proto = None,
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ opts_data = {
|
|||
-q, --quiet Produce quieter output
|
||||
-u, --usermode Run the daemon in user (non test-suite) mode
|
||||
-v, --verbose Produce more verbose output
|
||||
-V, --print-version Print version strings from exec’ed daemons (not RPC)
|
||||
-W, --no-wait Don't wait for daemons to change state before exiting
|
||||
""",
|
||||
'notes': """
|
||||
|
|
@ -50,7 +51,10 @@ def run(network_id=None,proto=None,daemon_id=None):
|
|||
daemon_id = daemon_id )
|
||||
d.debug = d.debug or opt.debug
|
||||
d.wait = not opt.no_wait
|
||||
if opt.get_state:
|
||||
|
||||
if opt.print_version:
|
||||
msg('{:16} {}'.format( d.exec_fn+':', d.get_exec_version_str() ))
|
||||
elif opt.get_state:
|
||||
print(d.state_msg())
|
||||
elif opt.testing:
|
||||
for cmd in d.start_cmds if action == 'start' else [d.stop_cmd]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue