當前位置: 首頁>>代碼示例>>Python>>正文


Python DnstestConfig.sleep方法代碼示例

本文整理匯總了Python中pydnstest.config.DnstestConfig.sleep方法的典型用法代碼示例。如果您正苦於以下問題:Python DnstestConfig.sleep方法的具體用法?Python DnstestConfig.sleep怎麽用?Python DnstestConfig.sleep使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pydnstest.config.DnstestConfig的用法示例。


在下文中一共展示了DnstestConfig.sleep方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_example_config_to_string

# 需要導入模塊: from pydnstest.config import DnstestConfig [as 別名]
# 或者: from pydnstest.config.DnstestConfig import sleep [as 別名]
 def test_example_config_to_string(self):
     """ test converting the example config to a string """
     fpath = os.path.abspath("dnstest.ini.example")
     with open(fpath, 'r') as fh:
         expected = fh.read()
     dc = DnstestConfig()
     dc.server_prod = '1.2.3.4'
     dc.server_test = '1.2.3.5'
     dc.default_domain = '.example.com'
     dc.have_reverse_dns = True
     dc.ignore_ttl = False
     dc.sleep = 0.0
     result = dc.to_string()
     assert result == expected
開發者ID:,項目名稱:,代碼行數:16,代碼來源:

示例2: main

# 需要導入模塊: from pydnstest.config import DnstestConfig [as 別名]
# 或者: from pydnstest.config.DnstestConfig import sleep [as 別名]
def main(options):
    """
    main function - does everything...

    split this out this way for testing...p
    """
    # read in config, set variable
    config = DnstestConfig()
    if options.exampleconf:
        config.set_example_values()
        print(config.to_string())
        raise SystemExit(0)

    if options.promptconfig:
        # interactively build a configuration file
        config.prompt_config()
        raise SystemExit(0)

    if options.config_file:
        conf_file = options.config_file
    else:
        conf_file = config.find_config_file()
    if conf_file is None:
        print("ERROR: no configuration file found. Run with --promptconfig to build one interactively, or --example-config for an example.")
        raise SystemExit(1)
    config.load_config(conf_file)

    if options.ignorettl:
        config.ignore_ttl = True

    if options.configprint:
        print("# {fname}".format(fname=config.conf_file))
        print(config.to_string())
        raise SystemExit(0)

    parser = DnstestParser()
    chk = DNStestChecks(config)

    if options.sleep:
        config.sleep = options.sleep
        print("Note - will sleep %g seconds between lines" % options.sleep)

    # if no other options, read from stdin
    if options.testfile:
        if not os.path.exists(options.testfile):
            print("ERROR: test file '%s' does not exist." % options.testfile)
            raise SystemExit(1)
        fh = open(options.testfile, 'r')
    else:
        # read from stdin
        sys.stderr.write("WARNING: reading from STDIN. Run with '-f filename' to read tests from a file.\n")
        fh = sys.stdin

    # read input line by line, handle each line as we're given it
    passed = 0
    failed = 0
    for line in fh:
        line = line.strip()
        if not line:
            continue
        if line[:1] == "#":
            continue
        if options.verify:
            r = run_verify_line(line, parser, chk)
        else:
            r = run_check_line(line, parser, chk)
        if r is False:
            continue
        elif r['result']:
            passed = passed + 1
        else:
            failed = failed + 1
        format_test_output(r)
        if config.sleep is not None and config.sleep > 0.0:
            sleep(config.sleep)

    msg = ""
    if failed == 0:
        msg = "All %d tests passed. (pydnstest %s)" % (passed, VERSION)
    else:
        msg = "%d passed / %d FAILED. (pydnstest %s)" % (passed, failed, VERSION)
    print("++++ %s" % msg)

    if options.testfile:
        # we were reading a file, close it
        fh.close()
開發者ID:jantman,項目名稱:pydnstest,代碼行數:88,代碼來源:main.py


注:本文中的pydnstest.config.DnstestConfig.sleep方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。