From c4a1a70afe55ae3d6a14bf3c745217ca07fef218 Mon Sep 17 00:00:00 2001 From: Michael Schmoock Date: Wed, 1 Sep 2021 14:44:03 +0200 Subject: [PATCH] autopilot: return error messages on run-once --- autopilot/autopilot.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/autopilot/autopilot.py b/autopilot/autopilot.py index 00a8158..a9e9902 100755 --- a/autopilot/autopilot.py +++ b/autopilot/autopilot.py @@ -163,12 +163,14 @@ def run_once(plugin, dryrun=False): # to open if available_funds < plugin.min_capacity_sat: - plugin.log(f"Too low available funds: {available_funds} < {plugin.min_capacity_sat}") - return False + message = f"Too low available funds: {available_funds} < {plugin.min_capacity_sat}" + plugin.log(message) + return message if len(channels) >= plugin.num_channels: - plugin.log(f"Already have {len(channels)} channels. Aim is for {plugin.num_channels}.") - return False + message = f"Already have {len(channels)} channels. Aim is for {plugin.num_channels}." + plugin.log(message) + return message num_channels = min( int(available_funds / plugin.min_capacity_sat), @@ -182,7 +184,9 @@ def run_once(plugin, dryrun=False): plugin.initialized.wait() if plugin.initerror: - return f"Error: autopilot had initialization errors: {str(plugin.initerror)}" + message = f"Error: autopilot had initialization errors: {str(plugin.initerror)}" + plugin.log(message, 'error') + return message candidates = plugin.autopilot.find_candidates( num_channels,