help="Fetches instances (aka. \"domains\") from an initial instance.",
)
parser.add_argument("--domain", required=True, help="Instance name (aka. domain) to fetch further instances from. Start with a large instance, e.g. mastodon.social .")
+ parser.add_argument("--single", action="store_true", help="Only fetch given instance.")
parser.set_defaults(command=commands.fetch_instances)
# DEBUG: print("DEBUG: init_parser(): EXIT!")
# DEBUG: print("DEBUG: run_command(): CALLED!")
args = _PARSER.parse_args()
print(f"DEBUG: args[{type(args)}]={args}")
- status = int(args.command(args))
+ status = args.command(args)
# DEBUG: print("DEBUG: status={status} - EXIT!")
- return status
+ return status if type(status) == int else 0
def shutdown():
print("DEBUG: Closing database connection ...")
# Initial fetch
fba.fetch_instances(args.domain, None, None, sys.argv[0])
+ if args.single:
+ print(f"DEBUG: Not fetching more instances - EXIT!")
+ return
+
# Loop through some instances
fba.cursor.execute(
"SELECT domain, origin, software, nodeinfo_url FROM instances WHERE software IN ('pleroma', 'mastodon', 'friendica', 'misskey', 'gotosocial', 'bookwyrm', 'takahe', 'lemmy') AND (last_instance_fetch IS NULL OR last_instance_fetch < ?) ORDER BY rowid DESC", [time.time() - config.get("recheck_instance")]