diff --git a/config/main.py b/config/main.py index b25fba6445..2bc9055967 100644 --- a/config/main.py +++ b/config/main.py @@ -2277,11 +2277,14 @@ def get_portchannel_retry_count(ctx, portchannel_name): if is_portchannel_present_in_db(db, portchannel_name) is False: ctx.fail("{} is not present.".format(portchannel_name)) - proc = subprocess.Popen(["teamdctl", portchannel_name, "state", "item", "get", "runner.retry_count"], text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - output, err = proc.communicate() - if proc.returncode != 0: - ctx.fail("Unable to get the retry count: {}".format(err.strip())) - click.echo(output.strip()) + try: + proc = subprocess.Popen(["teamdctl", portchannel_name, "state", "item", "get", "runner.retry_count"], text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + output, err = proc.communicate() + if proc.returncode != 0: + ctx.fail("Unable to get the retry count: {}".format(err.strip())) + click.echo(output.strip()) + except FileNotFoundError: + ctx.fail("Unable to get the retry count: teamdctl could not be run") @portchannel_retry_count.command('set') @click.argument('portchannel_name', metavar='', required=True) @@ -2301,10 +2304,13 @@ def set_portchannel_retry_count(ctx, portchannel_name, retry_count): if is_portchannel_present_in_db(db, portchannel_name) is False: ctx.fail("{} is not present.".format(portchannel_name)) - proc = subprocess.Popen(["teamdctl", portchannel_name, "state", "item", "set", "runner.retry_count", str(retry_count)], text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - output, err = proc.communicate() - if proc.returncode != 0: - ctx.fail("Unable to set the retry count: {}".format(err.strip())) + try: + proc = subprocess.Popen(["teamdctl", portchannel_name, "state", "item", "set", "runner.retry_count", str(retry_count)], text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + output, err = proc.communicate() + if proc.returncode != 0: + ctx.fail("Unable to set the retry count: {}".format(err.strip())) + except FileNotFoundError: + ctx.fail("Unable to set the retry count: teamdctl could not be run") #