mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-11 04:59:51 +00:00
cmdline: read all arguments before parsing
This commit is contained in:
parent
fa9ce51685
commit
89677c47f7
1 changed files with 17 additions and 18 deletions
35
electrum
35
electrum
|
@ -201,20 +201,6 @@ def run_cmdline(config):
|
||||||
# options
|
# options
|
||||||
args += map(lambda x: config.get(x), cmd.options)
|
args += map(lambda x: config.get(x), cmd.options)
|
||||||
|
|
||||||
# pipe data
|
|
||||||
for i, arg in enumerate(args):
|
|
||||||
if arg == '-':
|
|
||||||
if not sys.stdin.isatty():
|
|
||||||
pipe_data = sys.stdin.read()
|
|
||||||
try:
|
|
||||||
pipe_data = json.loads(pipe_data)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
args[i] = pipe_data
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
raise BaseException('Cannot get argument from stdin')
|
|
||||||
|
|
||||||
# instanciate wallet for command-line
|
# instanciate wallet for command-line
|
||||||
storage = WalletStorage(config.get_wallet_path())
|
storage = WalletStorage(config.get_wallet_path())
|
||||||
|
|
||||||
|
@ -383,6 +369,23 @@ if __name__ == '__main__':
|
||||||
sys.argv.remove('help')
|
sys.argv.remove('help')
|
||||||
sys.argv.append('-h')
|
sys.argv.append('-h')
|
||||||
|
|
||||||
|
# read arguments from stdin pipe and prompt
|
||||||
|
for i, arg in enumerate(sys.argv):
|
||||||
|
if arg == '-':
|
||||||
|
if not sys.stdin.isatty():
|
||||||
|
pipe_data = sys.stdin.read()
|
||||||
|
try:
|
||||||
|
pipe_data = json.loads(pipe_data)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
sys.argv[i] = pipe_data
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
raise BaseException('Cannot get argument from stdin')
|
||||||
|
elif arg == '?':
|
||||||
|
sys.argv[i] = prompt_password('Enter argument (will not echo):', False)
|
||||||
|
|
||||||
|
# parse cmd line
|
||||||
parser = get_parser(run_gui, run_daemon, run_cmdline)
|
parser = get_parser(run_gui, run_daemon, run_cmdline)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
@ -404,10 +407,6 @@ if __name__ == '__main__':
|
||||||
if config_options.get('portable'):
|
if config_options.get('portable'):
|
||||||
config_options['electrum_path'] = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'electrum_data')
|
config_options['electrum_path'] = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'electrum_data')
|
||||||
|
|
||||||
# If private key is passed on the command line, '?' triggers prompt.
|
|
||||||
if config_options.get('privkey') and config_options['privkey'] == '?':
|
|
||||||
config_options['privkey'] = prompt_password('Enter PrivateKey (will not echo):', False)
|
|
||||||
|
|
||||||
set_verbosity(config_options.get('verbose'))
|
set_verbosity(config_options.get('verbose'))
|
||||||
config = SimpleConfig(config_options)
|
config = SimpleConfig(config_options)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue