From 8f8f8c5dfeb89625d89e493dd3fbae1482526ee8 Mon Sep 17 00:00:00 2001 From: drunest Date: Sat, 28 Sep 2024 12:07:38 -0500 Subject: [PATCH] fix: apply format --- src/bt_auto_dumper/_v2/__main__.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/bt_auto_dumper/_v2/__main__.py b/src/bt_auto_dumper/_v2/__main__.py index b5fc114..8398139 100644 --- a/src/bt_auto_dumper/_v2/__main__.py +++ b/src/bt_auto_dumper/_v2/__main__.py @@ -18,9 +18,10 @@ CODENAME_MAP = { "computehorde": ["sn12", "12", "computehorde"], "omron": ["sn13", "13", "omron", "Omron"], - "textprompting": ["sn14", "14", "textprompting"] + "textprompting": ["sn14", "14", "textprompting"], } + def normalize_codename(codename: str) -> str: codename_lower = codename.lower() for normalized, aliases in CODENAME_MAP.items(): @@ -28,6 +29,7 @@ def normalize_codename(codename: str) -> str: return normalized return codename + def main(apiver: str | None = None): apiver = apiver or pathlib.Path(__file__).parent.name parser = argparse.ArgumentParser(description=f"BT Auto Dumper CLI {apiver}") @@ -75,7 +77,9 @@ def main(apiver: str | None = None): dump_and_upload(normalized_subnet_identifier, args.subnet_realm, wallet, autovalidator_address, args.note) -def dump_and_upload(subnet_identifier: str, subnet_realm: str, wallet: bt.wallet, autovalidator_address: str, note: str): +def dump_and_upload( + subnet_identifier: str, subnet_realm: str, wallet: bt.wallet, autovalidator_address: str, note: str +): """ Dump and upload the output of the commands to the AutoValidator Args: @@ -92,7 +96,6 @@ def dump_and_upload(subnet_identifier: str, subnet_realm: str, wallet: bt.wallet "omron": ["echo 'Mainnet Command 1'", "echo 'Mainnet Command 2'"], } - commands = request_commands_to_server(subnet_identifier, subnet_realm, wallet, autovalidator_address) if not commands: @@ -143,7 +146,7 @@ def make_signed_request( if file_path: files = {"file": open(file_path, "rb")} file = files.get("file") - + if isinstance(file, BufferedReader): file_content = file.read() file.seek(0) @@ -263,7 +266,10 @@ def update_confg(config_path: str, new_autovalidator_address: str, new_codename: except Exception as e: raise RuntimeError(f"Failed to write to the configuration file: {config_path}.\n Error: {e}") -def request_commands_to_server(subnet_identifier: str, subnet_realm: str, wallet: bt.wallet, autovalidator_address: str) -> list: + +def request_commands_to_server( + subnet_identifier: str, subnet_realm: str, wallet: bt.wallet, autovalidator_address: str +) -> list: """ Request commands to the server Args: @@ -292,5 +298,6 @@ def request_commands_to_server(subnet_identifier: str, subnet_realm: str, wallet print(response.text) return [] + if __name__ == "__main__": main()