From a1a9d700c8d9ca7d43a59d2f031a65958f905d5e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 2 Jun 2024 16:53:24 +0200 Subject: [PATCH] Continued: - show run-mode of nodeinfo.sh - fetch_instances can now (again) fetch new instances (not registered) --- fba/commands.py | 11 +++++++++-- nodeinfo.sh | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/fba/commands.py b/fba/commands.py index 59c97f1..eed2813 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -277,7 +277,7 @@ def fetch_blocks(args: argparse.Namespace) -> int: logger.warning("args.domain='%s' is blacklisted, won't check it!", args.domain) return 101 elif not instances.is_registered(args.domain): - logger.warning("args.domain='%s' is not registered, please run ./utils.py fetch_instances '%s' first.", args.domain, args.domain) + logger.warning("args.domain='%s' is not registered, please run ./fba.py fetch_instances --domain=%s first.", args.domain, args.domain) return 102 logger.debug("Invoking locking.acquire() ...") @@ -984,6 +984,13 @@ def fetch_instances(args: argparse.Namespace) -> int: # Fetch record database.cursor.execute("SELECT domain, origin, software FROM instances WHERE domain = ? LIMIT 1", [domain]) rows = database.cursor.fetchall() + + if len(rows) == 0: + rows.append({ + "domain" : args.domain, + "origin" : None, + "software": None, + }) elif args.software not in [None, ""]: logger.debug("args.software='%s' - BEFORE!", args.software) software = software_helper.alias(args.software) @@ -999,7 +1006,7 @@ def fetch_instances(args: argparse.Namespace) -> int: if row["software"] is None and instances.is_registered(row["domain"]) : logger.warning("row[domain]='%s' has no software detected. You can try to run ./fba.py update_nodeinfo --domain=%s --force to get it updated - SKIPPED!", row["domain"], row["domain"]) continue - elif software_helper.is_relay(row["software"]) and instances.is_registered(row["domain"]): + elif row["software"] is not None and software_helper.is_relay(row["software"]) and instances.is_registered(row["domain"]): logger.warning("row[domain]='%s' is of software type '%s' which is not supported by this command. Please invoke fetch_relays instead - SKIPPED!", row["domain"], row["software"]) continue elif not args.force and not args.software in [None, ""]and instances.is_recent(row["domain"]): diff --git a/nodeinfo.sh b/nodeinfo.sh index 2ba2944..adfc385 100755 --- a/nodeinfo.sh +++ b/nodeinfo.sh @@ -30,6 +30,7 @@ then MODE="generator" else DOMAIN_LIST=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE software IS NULL AND nodeinfo_url IS NOT NULL ORDER BY last_updated ASC;") + MODE="nodeinfo_null" fi if [ -z "${DOMAIN_LIST}" -a -z "${SOFTWARE_LIST}" ] @@ -38,6 +39,8 @@ then exit 255 fi +echo "$0: Run-mode is: '${MODE}'" + if [ -n "${DOMAIN_LIST}" ] then for DOMAIN in ${DOMAIN_LIST}; -- 2.39.5