Skip to content

Commit

Permalink
fix: apply format
Browse files Browse the repository at this point in the history
  • Loading branch information
stfnberat committed Sep 28, 2024
1 parent a7a700c commit 8f8f8c5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/bt_auto_dumper/_v2/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@
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():
if codename_lower in map(str.lower, aliases):
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}")
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -292,5 +298,6 @@ def request_commands_to_server(subnet_identifier: str, subnet_realm: str, wallet
print(response.text)
return []


if __name__ == "__main__":
main()

0 comments on commit 8f8f8c5

Please sign in to comment.