def wprs(filepath=None, daemon=False): """Generate JSON file database summary""" db = WPWatcherDataBase(filepath, daemon=daemon) sys.stdout.buffer.write( WPWatcher.results_summary(db._data).encode("utf8")) sys.stdout.flush() exit(0)
def show(urlpart, filepath=None, daemon=False): """Inspect a report in database""" db = WPWatcherDataBase(filepath, daemon=daemon) matching_reports = [r for r in db._data if urlpart in r["site"]] eq_reports = [r for r in db._data if urlpart == r["site"]] if len(eq_reports): sys.stdout.buffer.write( format_results(eq_reports[0], format="cli").encode("utf8")) elif len(matching_reports) == 1: sys.stdout.buffer.write( format_results(matching_reports[0], format="cli").encode("utf8")) elif len(matching_reports) > 1: sys.stdout.buffer.write( "The following sites match your search: \n".encode("utf8")) sys.stdout.buffer.write( WPWatcher.results_summary(matching_reports).encode("utf8")) sys.stdout.buffer.write( "\nPlease be more specific. \n".encode("utf8")) else: sys.stdout.buffer.write("No report found".encode("utf8")) exit(1) exit(0)