Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Commit

Permalink
seperate run and run_with_exit
Browse files Browse the repository at this point in the history
  • Loading branch information
BlinkyStitt committed Nov 21, 2016
1 parent b86302f commit 3f4b476
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions docker/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,17 @@ def run(*args):

log.info("Running %s...", command_list[1])
log.debug("Full command: %s", command_list)

return subprocess.check_call(command_list, env=os.environ)


def run_or_exit(*args):
"""Run a python command inside the joinmarket virtualenv.
Logs and exits if the command fails.
"""
try:
return subprocess.check_call(command_list, env=os.environ)
return run(*args)
except subprocess.CalledProcessError as e:
log.error("%s", e)
sys.exit(e.returncode)
Expand All @@ -60,6 +69,7 @@ def wait_for_config(*args):
try:
run('check-config.py')
except subprocess.CalledProcessError as e:
# TODO: this is too verbose
log.error("Unable to load config: %s. Sleeping..." % e)
time.sleep(60)
else:
Expand Down Expand Up @@ -129,7 +139,7 @@ def maker(args):
# wait for bitcoind to respond
wait_for_config()

run('yg-pe.py', wallet_filename, *args)
run_or_exit('yg-pe.py', wallet_filename, *args)


def ob_watcher(args):
Expand All @@ -138,7 +148,7 @@ def ob_watcher(args):
# todo: although, why does the orderbook need bitcoind?
wait_for_config()

run('ob-watcher.py', *args)
run_or_exit('ob-watcher.py', *args)


def sendpayment(args):
Expand All @@ -153,7 +163,7 @@ def sendpayment(args):
# wait for bitcoind to respond
wait_for_config()

run('sendpayment.py', *args)
run_or_exit('sendpayment.py', *args)


def tumbler(args):
Expand All @@ -164,12 +174,12 @@ def tumbler(args):
# wait for bitcoind to respond
wait_for_config()

run('tumbler.py', *args)
run_or_exit('tumbler.py', *args)


def wallet_tool(args):
"""Inspect and manage your Bitcoin wallet."""
run('wallet-tool.py', *args)
run_or_exit('wallet-tool.py', *args)


def main():
Expand Down

0 comments on commit 3f4b476

Please sign in to comment.