def update_nodeinfo(args: argparse.Namespace) -> int:
logger.debug("args[]='%s' - CALLED!", type(args))
- database.cursor.execute("SELECT domain FROM instances WHERE last_nodeinfo < ?", [time.time() - config.get("recheck_block")])
+ if args.domain is not None and args.domain != "":
+ logger.debug("Fetching args.domain='%s'", args.domain)
+ database.cursor.execute("SELECT domain FROM instances WHERE domain = ?", [args.domain])
+ elif args.software is not None and args.software != "":
+ logger.info("Fetching domains for args.software='%s'", args.software)
+ database.cursor.execute("SELECT domain FROM instances WHERE software = ?", [args.software])
+ else:
+ logger.info("Fetching domains for recently updated ...")
+ database.cursor.execute("SELECT domain FROM instances WHERE last_nodeinfo < ? OR last_nodeinfo IS NULL", [time.time() - config.get("recheck_block")])
domains = database.cursor.fetchall()
logger.info("Checking %d domain(s) ...", len(domains))
for row in domains:
- logger.info("Updating nodeinfo for row[domain]='%s' ...", row["domain"])
- federation.fetch_nodeinfo(row["domain"])
+ logger.debug("row[]='%s'", type(row))
+ try:
+ logger.info("Updating nodeinfo for row[domain]='%s' ...", row["domain"])
+ software = federation.determine_software(row["domain"])
+
+ logger.info("Determined software='%s'", software)
+ instances.set_software(row["domain"], software)
+ instances.set_success(row["domain"])
+ except network.exceptions as exception:
+ logger.warning("Exception '%s' during updating nodeinfo for row[domain]='%s'", type(exception), row["domain"])
+ instances.set_last_error(row["domain"], exception)
+
instances.set_last_nodeinfo(row["domain"])
+ instances.update_data(row["domain"])
logger.debug("Success! - EXIT!")
return 0
"last_error_details" : {},
# Wether obfuscation has been used
"has_obfuscation" : {},
+ # Determined software
+ "software" : {},
}
def _set_data(key: str, domain: str, value: any):
# Set timestamp
_set_data("has_obfuscation", domain, status)
logger.debug("EXIT!")
+
+def set_software(domain: str, software: str):
+ logger.debug("domain='%s',software='%s' - CALLED!", domain, software)
+ domain_helper.raise_on(domain)
+
+ if not isinstance(software, str) and software is not None:
+ raise ValueError(f"Parameter software[]='{type(software)}' is not 'str'")
+ elif software == "":
+ raise ValueError("Parameter 'software' is empty")
+
+ # Set timestamp
+ _set_data("software", domain, software)
+ logger.debug("EXIT!")