Exemple #1
0
def _shutdown():
    global _start_time, _monitor, _has_shutdown

    if _has_shutdown:
        return

    _has_shutdown = True
    output.debug("Shutting down...")

    elapsed = datetime.now() - _start_time
    mem_res = "{0:cM}".format(Size(_monitor.peak_mem_res))
    reporter.register_info("peak_memory", _monitor.peak_mem_res)

    output.empty()

    if _monitor.peak_mem_res > 0:
        output.norm(
            f"Completed (Elapsed: {str(elapsed)} - Peak Memory: {mem_res})")
    else:
        # if we don't have memory info - likely not running in a terminal, don't print junk
        output.norm(f"Completed (Elapsed: {str(elapsed)})")

    if reporter.get_output_file() != "":
        with Spinner() as spinner:
            reporter.save_output(spinner)
Exemple #2
0
def check_ipv6_connection() -> str:
    prefix = "IPv6 -> Internet:"
    url = "https://ipv6.icanhazip.com/"

    res = _check_connection(url)

    reporter.register_info("ipv6", res)

    return f"{prefix} {res}"
Exemple #3
0
def check_ipv6_connection() -> str:
    prefix = "IPv6 -> Internet:"
    url = "https://ipv6.icanhazip.com/"

    try:
        res = _check_connection(url)

        if not checkers.is_ipv6(res):
            res = "(Unavailable)"
    except Exception:
        res = "(Unavailable)"

    reporter.register_info("ipv6", res)

    return f"{prefix} {res}"
Exemple #4
0
def _set_basic_info():
    reporter.register_info("start_time", int(time.time()))
    reporter.register_info("yawast_version", get_version())
    reporter.register_info(
        "python_version",
        f"{''.join(sys.version.splitlines())} ({platform.python_implementation()})",
    )
    reporter.register_info("openssl_version", ssl.OPENSSL_VERSION)
    reporter.register_info("platform", platform.platform())
    reporter.register_info("options", str(sys.argv))
    reporter.register_info("encoding", _get_locale())