From ed4cac5fb52f514851ce90cdb3b95c8998f6c863 Mon Sep 17 00:00:00 2001 From: smk762 Date: Mon, 13 Jan 2025 15:55:22 +0800 Subject: [PATCH] add scan results as obj param --- utils/.gitignore | 1 + utils/generate_app_configs.py | 23 ++++++++++++----------- utils/scan_electrums.py | 7 ++----- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/utils/.gitignore b/utils/.gitignore index c61f6af07..2f194327c 100644 --- a/utils/.gitignore +++ b/utils/.gitignore @@ -1,2 +1,3 @@ __pycache__/ .env +.venv \ No newline at end of file diff --git a/utils/generate_app_configs.py b/utils/generate_app_configs.py index 7d5742e72..33c9faaf3 100755 --- a/utils/generate_app_configs.py +++ b/utils/generate_app_configs.py @@ -91,11 +91,6 @@ "UAH", ] - - -with open(f"{script_path}/electrum_scan_report.json", "r") as f: - electrum_scan_report = json.load(f) - with open(f"{repo_path}/explorers/explorer_paths.json", "r") as f: explorer_paths = json.load(f) @@ -133,8 +128,9 @@ def colorize(string, color): class CoinConfig: - def __init__(self, coin_data: dict): + def __init__(self, coin_data: dict, electrum_scan_report: dict): self.coin_data = coin_data + self.electrum_scan_report = electrum_scan_report self.data = {} self.is_testnet = self.is_testnet_network() self.ticker = self.coin_data["coin"].replace("-TEST", "") @@ -528,7 +524,8 @@ def get_explorers(self): self.data[self.ticker].update({i[0]: i[1]}) -def parse_coins_repo(): +def parse_coins_repo(electrum_scan_report): + ensure_chainids() errors = [] coins_config = {} with open(f"{repo_path}/coins", "r") as f: @@ -536,7 +533,7 @@ def parse_coins_repo(): for item in coins_data: if item["mm2"] == 1: - config = CoinConfig(item) + config = CoinConfig(item, electrum_scan_report) config.get_generics() config.get_protocol_info() config.clean_name() @@ -770,9 +767,13 @@ def sort_dicts_list(data, sort_key): if sys.argv[1] == "no-scan": skip_scan = True if skip_scan is False: - get_electrums_report() - ensure_chainids() - coins_config, nodata = parse_coins_repo() + electrum_scan_report = get_electrums_report() + else: + # Use existing scan data + with open(f"{script_path}/electrum_scan_report.json", "r") as f: + electrum_scan_report = json.load(f) + + coins_config, nodata = parse_coins_repo(electrum_scan_report) # Includes failing servers with open(f"{script_path}/coins_config_unfiltered.json", "w+") as f: json.dump(coins_config, f, indent=4) diff --git a/utils/scan_electrums.py b/utils/scan_electrums.py index 6c6598e92..a922b37a5 100755 --- a/utils/scan_electrums.py +++ b/utils/scan_electrums.py @@ -389,10 +389,6 @@ def get_repo_electrums(): return repo_electrums - - - - def get_existing_report(): if os.path.exists("electrum_scan_report.json"): with open(f"{script_path}/electrum_scan_report.json", "r") as f: @@ -549,8 +545,9 @@ def get_electrums_report(): with open(f"{script_path}/electrum_scan_report.json", "w+") as f: f.write(json.dumps(results, indent=4)) - + # print(json.dumps(results, indent=4)) + return results if __name__ == '__main__': get_electrums_report()