• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.fatal函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中util.fatal函数的典型用法代码示例。如果您正苦于以下问题:Python fatal函数的具体用法?Python fatal怎么用?Python fatal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了fatal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, value):
     try:
         self.value = float(value)
     except:
         fatal("invalid argument: %r" % time)
     warning("'max_time' filter is deprecated, use "
             "'user_time < %.4f' filter expression" % self.value)
开发者ID:efcs,项目名称:zorg,代码行数:7,代码来源:ci.py


示例2: main

def main():
  parser = OptionParser(usage="%prog")
  parser.add_option('-b', '--benchmarks', action='store_true', default=False, dest='benchmarks', help='analyze benchmark applications')
  parser.add_option('-w', '--websites', action='store_true', default=False, dest='websites', help='end-to-end website analysis')
  parser.add_option('-y', '--targetpages', action='store_true', default=False, dest='targetpages', help='prototype target website analysis')
  parser.add_option('-m', '--micro', action='store_true', default=False, dest='micro', help='analyze microbenchmark applications')
  parser.add_option('-x', '--exploit', action='store_true', default=False, dest='exploit', help='analyze exploit applications')
  #parser.add_option('-i', '--interpreter', action='store_true', default=False, dest='interpreter', help='test semantics as an interpreter (currently unsupported)')
  parser.add_option('-e', '--overwrite', action='store_true', default=False, dest='overwrite', help='overwrite expected output')
  #parser.add_option('-s', '--semantics', action='store_true', default=False, dest='semantics', help='test semantics')
  parser.add_option('-g', '--debug', action='store_true', default=False, dest='debug', help='generate debug output')
  parser.add_option('-u', '--url', action='store', default=None, dest='url', help='analyze HTML/JS at given URL')
  parser.add_option('-Y', '--policy', action='store', default=None, dest='policy', help='policy file to apply to URL')
  parser.add_option('-p', '--refine', action='store', default=None, dest='refine', help='maximum of number of predicates to learn')
  parser.add_option('-z', '--syntax-only', action='store_true', default=False, dest='syntaxonly', help='use syntax-only (not semantic) analysis')
  parser.add_option('-d', '--service', action='store_true', default=False, dest='service', help='run JAM as a service')
  parser.add_option('-a', '--apps', action='append', default=None, dest='apps', help='limit to the given app(s)')

  opts, args = parser.parse_args()
    
  if len(args) != 0:
    parser.error("Invalid number of arguments")

  allmods = True
  if opts.benchmarks or opts.micro or opts.exploit or opts.websites or opts.targetpages or opts.url is not None:
    allmods = False

  ref = opts.refine
  if ref is not None:
    try:
      ref = int(ref)
      if ref < -1:
        raise
    except:
      fatal('Invalid refinement limit: %s (should be positive integer, or -1 for unlimited)' % (opts.refine))

  if opts.service:
    start_jam_service(debug=opts.debug)

  #if opts.interpreter:
  #  err('Interpreter tests are currently out-of-order')
  #  run_interpreter_tests(opts.debug)
  if opts.url is not None:
    pol = load_policy(opts.policy)
    run_website(opts.url, pol, debug=opts.debug, overwrite=opts.overwrite, refine=ref, synonly=opts.syntaxonly, service=opts.service)
  if allmods or opts.micro:
    run_microbenchmarks(opts.debug, opts.overwrite, refine=ref, synonly=opts.syntaxonly, service=opts.service, apps=opts.apps)
  if allmods or opts.exploit:
    run_exploits(opts.debug, opts.overwrite, refine=ref, synonly=opts.syntaxonly, service=opts.service, apps=opts.apps)
  if allmods or opts.benchmarks:
    run_benchmarks(opts.debug, opts.overwrite, refine=ref, synonly=opts.syntaxonly, service=opts.service, apps=opts.apps)
  if allmods or opts.websites:
    run_websites(opts.debug, opts.overwrite, refine=ref, synonly=opts.syntaxonly, service=opts.service, apps=opts.apps)
  if allmods or opts.targetpages:
    run_targetpages(opts.debug, opts.overwrite, refine=ref, synonly=opts.syntaxonly, service=opts.service, apps=opts.apps)

  if opts.service:
    close_jam_service()
开发者ID:blackoutjack,项目名称:jamweaver,代码行数:58,代码来源:run.py


示例3: get_netanim

def get_netanim(ns3_dir):
    print """
    #
    # Get NetAnim
    #
    """

    if sys.platform in ['cygwin']:
	print "Architecture (%s) does not support NetAnim... skipping" % (sys.platform)
        raise RuntimeError

    # (peek into the ns-3 wscript and extract the required netanim version)
    try:
        # For the recent versions
        netanim_wscript = open(os.path.join(ns3_dir, "src", "netanim", "wscript"), "rt")
    except:
        print "Unable to detect NetAnim required version.Skipping download"
        pass
        return

    required_netanim_version = None
    for line in netanim_wscript:
        if 'NETANIM_RELEASE_NAME' in line:
            required_netanim_version = eval(line.split('=')[1].strip())
            break
    netanim_wscript.close()
    if required_netanim_version is None:
        fatal("Unable to detect NetAnim required version")
    print "Required NetAnim version: ", required_netanim_version


    def netanim_clone():
        print "Retrieving NetAnim from " + constants.NETANIM_REPO
        run_command(['hg', 'clone', constants.NETANIM_REPO, constants.LOCAL_NETANIM_PATH])

    def netanim_update():
        print "Pulling NetAnim updates from " + constants.NETANIM_REPO
        run_command(['hg', '--cwd', constants.LOCAL_NETANIM_PATH, 'pull', '-u', constants.NETANIM_REPO])

    def netanim_download():
        local_file = required_netanim_version + ".tar.bz2"
        remote_file = constants.NETANIM_RELEASE_URL + "/" + local_file
        print "Retrieving NetAnim from " + remote_file
        urllib.urlretrieve(remote_file, local_file)
        print "Uncompressing " + local_file
        run_command(["tar", "-xjf", local_file])
        print "Rename %s as %s" % (required_netanim_version, constants.LOCAL_NETANIM_PATH)
        os.rename(required_netanim_version, constants.LOCAL_NETANIM_PATH)

    if not os.path.exists(os.path.join(ns3_dir, '.hg')):
        netanim_download()
    elif not os.path.exists(constants.LOCAL_NETANIM_PATH):
        netanim_clone()
    else:
        netanim_update()

    return (constants.LOCAL_NETANIM_PATH, required_netanim_version)
开发者ID:GritBear,项目名称:ELEC537-wifi-protocal-simulator,代码行数:57,代码来源:download.py


示例4: get_nsc

def get_nsc(ns3_dir):
    print """
    #
    # Get NSC
    #
    """

    # Skip downloading NSC on OS X due to HFS+ case insensitive issues
    # Skip downloading NSC on Cygwin because of fundamental incompatibilities.
    if sys.platform in ['darwin', 'cygwin']:
        print "Architecture (%s) does not support NSC... skipping" % (sys.platform,)
        raise RuntimeError

    # (peek into the ns-3 wscript and extract the required nsc version)
    try:
        # For the recent versions
        internet_stack_wscript = open(os.path.join(ns3_dir, "src", "internet", "wscript"), "rt")
    except IOError:
        # For the old versions (ns-3.10 and before)
        internet_stack_wscript = open(os.path.join(ns3_dir, "src", "internet-stack", "wscript"), "rt")
    required_nsc_version = None
    for line in internet_stack_wscript:
        if 'NSC_RELEASE_NAME' in line:
            required_nsc_version = eval(line.split('=')[1].strip())
            break
    internet_stack_wscript.close()
    if required_nsc_version is None:
        fatal("Unable to detect NSC required version")
    print "Required NSC version: ", required_nsc_version
    
    def nsc_clone():
        print "Retrieving nsc from " + constants.NSC_REPO
        run_command(['hg', 'clone', constants.NSC_REPO, constants.LOCAL_NSC_PATH])

    def nsc_update():
        print "Pulling nsc updates from " + constants.NSC_REPO
        run_command(['hg', '--cwd', constants.LOCAL_NSC_PATH, 'pull', '-u', constants.NSC_REPO])

    def nsc_download():
        local_file = required_nsc_version + ".tar.bz2"
        remote_file = constants.NSC_RELEASE_URL + "/" + local_file
        print "Retrieving nsc from " + remote_file
        urllib.urlretrieve(remote_file, local_file)
        print "Uncompressing " + local_file
        run_command(["tar", "-xjf", local_file])
        print "Rename %s as %s" % (required_nsc_version, constants.LOCAL_NSC_PATH)
        os.rename(required_nsc_version, constants.LOCAL_NSC_PATH)

    if not os.path.exists(os.path.join(ns3_dir, '.hg')):
        nsc_download()
    elif not os.path.exists(constants.LOCAL_NSC_PATH):
        nsc_clone()
    else:
        nsc_update()

    return (constants.LOCAL_NSC_PATH, required_nsc_version)
开发者ID:pablin87,项目名称:sumo-ns3-vanet,代码行数:56,代码来源:download.py


示例5: interp

 def interp(self):
     p = Parser(self.fname, self.text)
     try:
         node = p.parse()
     except ParserError, e:
         ctx = "Traceback: \n"
         for f in callstack:
             ctx = ctx + str(f) + '\n'
         output = ctx + str(e)
         fatal(output)
开发者ID:yuyang0,项目名称:interp-yin,代码行数:10,代码来源:interpreter.py


示例6: split_command_filters

    def split_command_filters(command):
        for i, arg in enumerate(command):
            if arg[:2] != "%%" or arg[-2:] != "%%":
                break
        else:
            fatal("invalid command: %s, only contains filter "
                  "specifications" % ("".join('"%s"' % a for a in command)))

        return ([a[2:-2] for a in command[:i]],
                command[i:])
开发者ID:efcs,项目名称:zorg,代码行数:10,代码来源:ci.py


示例7: instantiate

def instantiate(ckpt_dir=None):
    from m5 import options

    root = objects.Root.getInstance()

    if not root:
        fatal("Need to instantiate Root() before calling instantiate()")

    # we need to fix the global frequency
    ticks.fixGlobalFrequency()

    # Make sure SimObject-valued params are in the configuration
    # hierarchy so we catch them with future descendants() walks
    for obj in root.descendants(): obj.adoptOrphanParams()

    # Unproxy in sorted order for determinism
    for obj in root.descendants(): obj.unproxyParams()

    if options.dump_config:
        ini_file = file(os.path.join(options.outdir, options.dump_config), 'w')
        # Print ini sections in sorted order for easier diffing
        for obj in sorted(root.descendants(), key=lambda o: o.path()):
            obj.print_ini(ini_file)
        ini_file.close()

    # Initialize the global statistics
    stats.initSimStats()

    # Create the C++ sim objects and connect ports
    for obj in root.descendants(): obj.createCCObject()
    for obj in root.descendants(): obj.connectPorts()

    # Do a second pass to finish initializing the sim objects
    for obj in root.descendants(): obj.init()

    # Do a third pass to initialize statistics
    for obj in root.descendants(): obj.regStats()
    for obj in root.descendants(): obj.regFormulas()

    # We're done registering statistics.  Enable the stats package now.
    stats.enable()

    # Restore checkpoint (if any)
    if ckpt_dir:
        ckpt = internal.core.getCheckpoint(ckpt_dir)
        internal.core.unserializeGlobals(ckpt);
        for obj in root.descendants(): obj.loadState(ckpt)
        need_resume.append(root)
    else:
        for obj in root.descendants(): obj.initState()

    # Reset to put the stats in a consistent state.
    stats.reset()
开发者ID:koparasy,项目名称:faultinjection-gem5,代码行数:53,代码来源:simulate.py


示例8: fetch_builds

def fetch_builds(name):
    """
    fetch_builds(name) -> [(path, revision, build), ...]

    Get a list of available builds for the named builder.
    """
    # Handle only_use_cache setting.
    prefs = util.get_prefs()
    if prefs.getboolean("ci", "only_use_cache"):
        cache_path = os.path.join(prefs.path, "ci", "build_cache")
        cache_build_path = os.path.join(cache_path, name)
        items = os.listdir(cache_build_path)
        assert False, "Unimplemented?" + str(items)
    # Otherwise, load the builder map.
    buildermap = load_builder_map()

    # If the builder isn't in the builder map, do a forced load of the builder
    # map.
    if name not in buildermap.builders:
        buildermap = load_builder_map(reload=True)

    # If the builder doesn't exist, report an error.
    builder_artifacts = buildermap.builders.get(name)
    if builder_artifacts is None:
        fatal("unknown builder name: %r" % (name,))

    # Otherwise, load the builder list.
    server_builds = gcs.fetch_builds(builder_artifacts)
    builds = []
    for path in server_builds['items']:
        build = Build.frombasename(path['name'], path['mediaLink'])

        # Ignore any links which don't at least have a revision component.
        if build.revision is not None:
            builds.append(build)

    # If there were no builds, report an error.
    if not builds:
        fatal("builder %r may be misconfigured (no items)" % (name,))

    # Sort the builds, to make sure we return them ordered properly.
    builds.sort()

    return builds
开发者ID:CristinaCristescu,项目名称:zorg,代码行数:44,代码来源:llvmlab.py


示例9: fetch_build_to_path

def fetch_build_to_path(builder, build, root_path, builddir_path):
    path = build.tobasename()

    # Check whether we are using a build cache and get the cached build path if
    # so.
    prefs = util.get_prefs()
    cache_build_path = None
    if prefs.getboolean("ci", "cache_builds"):
        cache_path = os.path.join(prefs.path, "ci", "build_cache")
        cache_build_path = os.path.join(cache_path, builder, path)

    # Copy the build from the cache or download it.
    if cache_build_path and os.path.exists(cache_build_path):
        shutil.copy(cache_build_path, root_path)
    else:
        # Load the builder map.
        buildermap = load_builder_map()

        # If the builder isn't in the builder map, do a forced reload of the
        # builder map.
        if builder not in buildermap.builders:
            buildermap = load_builder_map(reload=True)

        # If the builder doesn't exist, report an error.
        builder_artifacts = buildermap.builders.get(builder)
        if builder_artifacts is None:
            fatal("unknown builder name: %r" % (builder,))

        # Otherwise create the build url.
        gcs.get_compiler(build.url, root_path)

        # Copy the build into the cache, if enabled.
        if cache_build_path is not None:
            shell.mkdir_p(os.path.dirname(cache_build_path))
            shutil.copy(root_path, cache_build_path)

    # Create the directory for the build.
    os.mkdir(builddir_path)

    # Extract the build.
    if shell.execute(['tar', '-xf', root_path, '-C', builddir_path]):
        fatal('unable to extract %r to %r' % (root_path, builddir_path))
开发者ID:CristinaCristescu,项目名称:zorg,代码行数:42,代码来源:llvmlab.py


示例10: create_test_from_file

def create_test_from_file(fl, name, group, policy):
  txt = fl.read()
  fl.close()

  appdir = os.path.join(TESTS_DIR, group, name)
  if os.path.exists(appdir):
    if OVERWRITE:
      if not os.path.isdir(appdir):
        fatal("Unable to overwrite file: %s" % appdir)
      warn("Creating in existing directory: %s" % appdir)
    else:
      fatal("Not overwriting existing directory: %s" % appdir)
  prepare_dir(appdir)

  inputdir = os.path.join(appdir, 'source-input')
  if os.path.exists(inputdir):
    assert OVERWRITE
    if not os.path.isdir(inputdir):
      fatal("Unable to overwrite non-directory: %s" % inputdir)
  else:
    os.makedirs(inputdir)

  tgtfile = "%s.js" % name
  tgtpath = os.path.join(inputdir, tgtfile)
  tgtfl = open(tgtpath, 'w')

  tgtfl.write(txt)
  tgtfl.close()
开发者ID:blackoutjack,项目名称:jamweaver,代码行数:28,代码来源:create_test.py


示例11: main

def main():
  parser = OptionParser(usage="%prog")
  parser.add_option('-n', '--name', action='store', default=None, dest='name', help='name of the new test')
  parser.add_option('-g', '--group', action='store', default=None, dest='group', help='test group to add to')
  parser.add_option('-f', '--file', action='store', default=None, dest='file', help='input source file')
  parser.add_option('-u', '--url', action='store', default=None, dest='url', help='URL for website test case')
  parser.add_option('-F', '--overwrite', action='store_true', default=False, dest='overwrite', help='overwrite existing files')
  parser.add_option('-v', '--verbose', action='store_true', default=False, dest='verbose', help='generate verbose output')
  parser.add_option('-Y', '--policy', action='store', default=None, dest='policy', help='policy file to use for the test case')

  opts, args = parser.parse_args()
    
  if len(args) != 0:
    parser.error("Invalid number of arguments")

  if opts.group not in TEST_GROUPS:
    fatal("Invalid test group: %s" % opts.group)

  global VERBOSE, OVERWRITE
  VERBOSE = opts.verbose
  OVERWRITE = opts.overwrite

  if opts.url is not None:
    group = opts.group
    if group is None:
      group = 'sites'
    if group != 'sites':
      fatal("Invalid group for URL test: %s" % group)
    create_test_for_url(opts.url, opts.name, opts.policy)

  else:
    if opts.file is None:
      if opts.name is None:
        fatal("Name (-n) must be provided for stdin source")
      appname = opts.name
      fl = sys.stdin
    else:
      if not os.path.isfile(opts.file):
        fatal("Unable to access source file: %s" % opts.file)
      filename = os.path.basename(opts.file)
      appname = os.path.splitext(filename)[0]
      fl = open(opts.file, 'r')

    group = opts.group
    if group is None: group = 'bench'

    create_test_from_file(fl, appname, group, opts.policy)
开发者ID:blackoutjack,项目名称:jamweaver,代码行数:47,代码来源:create_test.py


示例12: check_tracing

    def check_tracing():
        if defines.TRACING_ON:
            return

        fatal("Tracing is not enabled.  Compile with TRACING_ON")
开发者ID:sdzahed,项目名称:624-Project,代码行数:5,代码来源:main.py


示例13: instantiate

def instantiate(ckpt_dir=None):
    from m5 import options

    root = objects.Root.getInstance()

    if not root:
        fatal("Need to instantiate Root() before calling instantiate()")

    # we need to fix the global frequency
    ticks.fixGlobalFrequency()

    # Make sure SimObject-valued params are in the configuration
    # hierarchy so we catch them with future descendants() walks
    for obj in root.descendants(): obj.adoptOrphanParams()

    # Unproxy in sorted order for determinism
    for obj in root.descendants(): obj.unproxyParams()

    if options.dump_config:
        ini_file = file(os.path.join(options.outdir, options.dump_config), 'w')
        # Print ini sections in sorted order for easier diffing
        for obj in sorted(root.descendants(), key=lambda o: o.path()):
            obj.print_ini(ini_file)
        ini_file.close()

    if options.json_config:
        try:
            import json
            json_file = file(os.path.join(options.outdir, options.json_config), 'w')
            d = root.get_config_as_dict()
            json.dump(d, json_file, indent=4)
            json_file.close()
        except ImportError:
            pass

    do_dot(root, options.outdir, options.dot_config)

    # Initialize the global statistics
    stats.initSimStats()

    # Create the C++ sim objects and connect ports
    for obj in root.descendants(): obj.createCCObject()
    for obj in root.descendants(): obj.connectPorts()

    # Do a second pass to finish initializing the sim objects
    for obj in root.descendants(): obj.init()

    # Do a third pass to initialize statistics
    for obj in root.descendants(): obj.regStats()

    # Do a fourth pass to initialize probe points
    for obj in root.descendants(): obj.regProbePoints()

    # Do a fifth pass to connect probe listeners
    for obj in root.descendants(): obj.regProbeListeners()

    # We're done registering statistics.  Enable the stats package now.
    stats.enable()

    # Restore checkpoint (if any)
    if ckpt_dir:
        _drain_manager.preCheckpointRestore()
        ckpt = internal.core.getCheckpoint(ckpt_dir)
        internal.core.unserializeGlobals(ckpt);
        for obj in root.descendants(): obj.loadState(ckpt)
    else:
        for obj in root.descendants(): obj.initState()

    # Check to see if any of the stat events are in the past after resuming from
    # a checkpoint, If so, this call will shift them to be at a valid time.
    updateStatEvents()
开发者ID:clementcole,项目名称:gem5,代码行数:71,代码来源:simulate.py


示例14: action_exec

def action_exec(name, args):
    """execute a command against a published root"""

    parser = OptionParser("""\
usage: %%prog %(name)s [options] ... test command args ...

Executes the given command against the latest published build. The syntax for
commands (and exit code) is exactly the same as for the 'bisect' tool, so this
command is useful for testing bisect test commands.

See 'bisect' for more notermation on the exact test syntax.\
""" % locals())

    parser.add_option("-b", "--build", dest="build_name", metavar="STR",
                      help="name of build to fetch",
                      action="store", default=DEFAULT_BUILDER)
    parser.add_option("-s", "--sandbox", dest="sandbox",
                      help="directory to use as a sandbox",
                      action="store", default=None)
    parser.add_option("", "--min-rev", dest="min_rev",
                      help="minimum revision to test",
                      type="int", action="store", default=None)
    parser.add_option("", "--max-rev", dest="max_rev",
                      help="maximum revision to test",
                      type="int", action="store", default=None)
    parser.add_option("", "--near", dest="near_build",
                      help="use a build near NAME",
                      type="str", action="store", metavar="NAME", default=None)

    parser.disable_interspersed_args()

    (opts, args) = parser.parse_args(args)

    if opts.build_name is None:
        parser.error("no build name given (see --build)")

    available_builds = list(llvmlab.fetch_builds(opts.build_name))
    available_builds.sort()
    available_builds.reverse()

    if opts.min_rev is not None:
        available_builds = [b for b in available_builds
                            if b.revision >= opts.min_rev]
    if opts.max_rev is not None:
        available_builds = [b for b in available_builds
                            if b.revision <= opts.max_rev]

    if len(available_builds) == 0:
        fatal("No builds available for builder name: %s" % opts.build_name)

    # Find the best match, if requested.
    if opts.near_build:
        build = get_best_match(available_builds, opts.near_build)
        if not build:
            parser.error("no match for build %r" % opts.near_build)
    else:
        # Otherwise, take the latest build.
        build = available_builds[0]

    test_result, _ = execute_sandboxed_test(
        opts.sandbox, opts.build_name, build, args, verbose=True,
        show_command_output=True)

    print '%s: %s' % (('FAIL', 'PASS')[test_result],
                      build.tobasename(include_suffix=False))

    raise SystemExit(test_result != True)
开发者ID:efcs,项目名称:zorg,代码行数:67,代码来源:ci.py


示例15: action_bisect


#.........这里部分代码省略.........
path to the build under test.

The stdout and stderr of the command are logged to files inside the sandbox
directory. Use an explicit sandbox directory if you would like to look at
them.

It is possible to run multiple distinct commands for each test by separating
them in the command line arguments by '----'. The failure of any command causes
the entire test to fail.\
""" % locals())

    parser.add_option("-b", "--build", dest="build_name", metavar="STR",
                      help="name of build to fetch",
                      action="store", default=DEFAULT_BUILDER)
    parser.add_option("-s", "--sandbox", dest="sandbox",
                      help="directory to use as a sandbox",
                      action="store", default=None)
    parser.add_option("-v", "--verbose", dest="verbose",
                      help="output more test notermation",
                      action="store_true", default=False)
    parser.add_option("-V", "--very-verbose", dest="very_verbose",
                      help="output even more test notermation",
                      action="store_true", default=False)
    parser.add_option("", "--show-output", dest="show_command_output",
                      help="display command output",
                      action="store_true", default=False)
    parser.add_option("", "--single-step", dest="single_step",
                      help="single step instead of binary stepping",
                      action="store_true", default=False)
    parser.add_option("", "--min-rev", dest="min_rev",
                      help="minimum revision to test",
                      type="int", action="store", default=None)
    parser.add_option("", "--max-rev", dest="max_rev",
                      help="maximum revision to test",
                      type="int", action="store", default=None)

    parser.disable_interspersed_args()

    (opts, args) = parser.parse_args(args)

    if opts.build_name is None:
        parser.error("no build name given (see --build)")

    # Very verbose implies verbose.
    opts.verbose |= opts.very_verbose

    start_time = time.time()
    available_builds = list(llvmlab.fetch_builds(opts.build_name))
    available_builds.sort()
    available_builds.reverse()
    if opts.very_verbose:
        note("fetched builds in %.2fs" % (time.time() - start_time,))

    if opts.min_rev is not None:
        available_builds = [b for b in available_builds
                            if b.revision >= opts.min_rev]
    if opts.max_rev is not None:
        available_builds = [b for b in available_builds
                            if b.revision <= opts.max_rev]

    def predicate(item):
        # Run the sandboxed test.
        test_result, _ = execute_sandboxed_test(
            opts.sandbox, opts.build_name, item, args, verbose=opts.verbose,
            very_verbose=opts.very_verbose,
            show_command_output=opts.show_command_output or opts.very_verbose)

        # Print status.
        print '%s: %s' % (('FAIL', 'PASS')[test_result],
                          item.tobasename(include_suffix=False))

        return test_result

    if opts.single_step:
        for item in available_builds:
            if predicate(item):
                break
        else:
            item = None
    else:
        if opts.min_rev is None or opts.max_rev is None:
            # Gallop to find initial search range, under the assumption that we
            # are most likely looking for something at the head of this list.
            search_space = algorithm.gallop(predicate, available_builds)
        else:
            # If both min and max revisions are specified,
            # don't gallop - bisect the given range.
            search_space = available_builds
        item = algorithm.bisect(predicate, search_space)

    if item is None:
        fatal('unable to find any passing build!')

    print '%s: first working build' % item.tobasename(include_suffix=False)
    index = available_builds.index(item)
    if index == 0:
        print 'no failing builds!?'
    else:
        print '%s: next failing build' % available_builds[index-1].tobasename(
            include_suffix=False)
开发者ID:efcs,项目名称:zorg,代码行数:101,代码来源:ci.py


示例16: action_fetch

def action_fetch(name, args):
    """fetch a build from the server"""

    parser = OptionParser("""\
usage: %%prog %(name)s [options] builder [build-name]

Fetch the build from the named builder which matchs build-name. If no match is
found, get the first build before the given name. If no build name is given,
the most recent build is fetched.

The available builders can be listed using:

  %%prog ls

The available builds can be listed using:

  %%prog ls builder""" % locals())
    parser.add_option("-f", "--force", dest="force",
                      help=("always download and extract, overwriting any"
                            "existing files"),
                      action="store_true", default=False)
    parser.add_option("", "--update-link", dest="update_link", metavar="PATH",
                      help=("update a symbolic link at PATH to point to the "
                            "fetched build (on success)"),
                      action="store", default=None)
    parser.add_option("-d", "--dry-run", dest='dry_run',
                      help=("Perform all operations except the actual "
                            "downloading and extracting of any files"),
                      action="store_true", default=False)

    (opts, args) = parser.parse_args(args)

    if len(args) == 0:
        parser.error("please specify a builder name")
    elif len(args) == 1:
        builder, = args
        build_name = None
    elif len(args) == 2:
        builder, build_name = args
    else:
        parser.error("invalid number of arguments")

    builds = list(llvmlab.fetch_builds(builder))
    if not builds:
        parser.error("no builds for builder: %r" % builder)

    build = get_best_match(builds, build_name)
    if not build:
        parser.error("no match for build %r" % build_name)

    path = build.tobasename()
    if build_name is not None and not path.startswith(build_name):
        note('no exact match, fetching %r' % path)

    # Get the paths to extract to.
    root_path = path
    builddir_path = build.tobasename(include_suffix=False)

    if not opts.dry_run:
        # Check that the download and extract paths are clean.
        for p in (root_path, builddir_path):
            if os.path.exists(p):
                # If we are using --force, then clean the path.
                if opts.force:
                    shutil.rmtree(p, ignore_errors=True)
                    continue
                fatal('current directory is not clean, %r exists' % p)
        llvmlab.fetch_build_to_path(builder, build, root_path, builddir_path)

    print 'downloaded root: %s' % root_path
    print 'extracted path : %s' % builddir_path

    # Update the symbolic link, if requested.
    if not opts.dry_run and opts.update_link:
        # Remove the existing path.
        try:
            os.unlink(opts.update_link)
        except OSError as e:
            if e.errno != errno.ENOENT:
                fatal('unable to update symbolic link at %r, cannot unlink' % (
                        opts.update_link))

        # Create the symbolic link.
        os.symlink(os.path.abspath(builddir_path), opts.update_link)
        print 'updated link at: %s' % opts.update_link
    return os.path.abspath(builddir_path)
开发者ID:efcs,项目名称:zorg,代码行数:86,代码来源:ci.py


示例17: create_test_for_url

def create_test_for_url(url, name, policy):
  fatal("URL test case creation not yet implemented")
开发者ID:blackoutjack,项目名称:jamweaver,代码行数:2,代码来源:create_test.py


示例18: execute_sandboxed_test

def execute_sandboxed_test(sandbox, builder, build, args,
                           verbose=False, very_verbose=False,
                           add_path_variables=True,
                           show_command_output=False,
                           reuse_sandbox=False):

    def split_command_filters(command):
        for i, arg in enumerate(command):
            if arg[:2] != "%%" or arg[-2:] != "%%":
                break
        else:
            fatal("invalid command: %s, only contains filter "
                  "specifications" % ("".join('"%s"' % a for a in command)))

        return ([a[2:-2] for a in command[:i]],
                command[i:])

    path = build.tobasename(include_suffix=False)
    fullpath = build.tobasename()

    if verbose:
        note('testing %r' % path)

    # Create the sandbox directory, if it doesn't exist.
    is_temp = False
    if sandbox is None:
        sandbox = tempfile.mkdtemp()
        is_temp = True
    else:
        # Make absolute.
        sandbox = os.path.abspath(sandbox)
        if not os.path.exists(sandbox):
            os.mkdir(sandbox)

    # Compute paths and make sure sandbox is clean.
    root_path = os.path.join(sandbox, fullpath)
    builddir_path = os.path.join(sandbox, path)
    need_build = True
    if reuse_sandbox and (os.path.exists(root_path) and
                          os.path.exists(builddir_path)):
        need_build = False
    else:
        for p in (root_path, builddir_path):
            if os.path.exists(p):
                fatal('sandbox is not clean, %r exists' % p)

    # Fetch and extract the build.
    if need_build:
        start_time = time.time()
        llvmlab.fetch_build_to_path(builder, build, root_path, builddir_path)
        if very_verbose:
            note("extracted build in %.2fs" % (time.time() - start_time,))

    # Attempt to find clang/clang++ in the downloaded build.
    def find_binary(name):
        x = subprocess.check_output(['find', builddir_path, '-name', name])\
                    .strip().split("\n")[0]
        if x == '':
            x = None
        return x

    clang_path = find_binary('clang')
    clangpp_path = find_binary('clang++')
    liblto_path = find_binary('libLTO.dylib')
    if liblto_path is not None:
        liblto_dir = os.path.dirname(liblto_path)
    else:
        liblto_dir = None

    # Construct the interpolation variables.
    options = {'sandbox': sandbox,
               'path': builddir_path,
               'revision': build.revision,
               'build': build.build,
               'clang': clang_path,
               'clang++': clangpp_path,
               'libltodir': liblto_dir}

    # Inject environment variables.
    env = os.environ.copy()
    for key, value in options.items():
        env['TEST_%s' % key.upper()] = str(value)

    # Extend the environment to include the path to the extracted build.
    #
    # FIXME: Ideally, we would be able to read some kind of configuration
    # notermation about a builder so that we could just set this up, it doesn't
    # necessarily here as hard-coded notermation.
    if add_path_variables:
        path_extensions = []
        dyld_library_path_extensions = []
        toolchains_dir = os.path.join(builddir_path,
                                      ('Applications/Xcode.app/Contents/'
                                       'Developer/Toolchains'))
        toolchain_paths = []
        if os.path.exists(toolchains_dir):
            toolchain_paths = [os.path.join(toolchains_dir, name, 'usr')
                               for name in os.listdir(toolchains_dir)]
        for package_root in ['', 'Developer/usr/'] + toolchain_paths:
            p = os.path.join(builddir_path, package_root, 'bin')
#.........这里部分代码省略.........
开发者ID:efcs,项目名称:zorg,代码行数:101,代码来源:ci.py


示例19: get_pybindgen

def get_pybindgen(ns3_dir):
    print """
    #
    # Get PyBindGen
    #
    """

    if sys.platform in ['cygwin']:
        print "Architecture (%s) does not support PyBindGen ... skipping" % (sys.platform,)
        raise RuntimeError

    # (peek into the ns-3 wscript and extract the required pybindgen version)
    ns3_python_wscript = open(os.path.join(ns3_dir, "bindings", "python", "wscript"), "rt")
    required_pybindgen_version = None
    for line in ns3_python_wscript:
        if 'REQUIRED_PYBINDGEN_VERSION' in line:
            required_pybindgen_version = eval(line.split('=')[1].strip())
            ns3_python_wscript.close()
            break
    if required_pybindgen_version is None:
        fatal("Unable to detect pybindgen required version")
    print "Required pybindgen version: ", '.'.join([str(x) for x in required_pybindgen_version])

    # work around http_proxy handling bug in bzr
    if 'http_proxy' in os.environ and 'https_proxy' not in os.environ:
        os.environ['https_proxy'] = os.environ['http_proxy']
 
    if len(required_pybindgen_version) == 4:
        rev = "-rrevno:%i" % required_pybindgen_version[3]
    else:
        rev = "-rtag:%s" % '.'.join([str(x) for x in required_pybindgen_version])
        
    if os.path.exists(constants.LOCAL_PYBINDGEN_PATH):
        print "Trying to update pybindgen; this will fail if no network connection is available.  Hit Ctrl-C to skip."

        try:
            run_command(["bzr", "pull", rev, "-d", constants.LOCAL_PYBINDGEN_PATH, constants.PYBINDGEN_BRANCH])
        except KeyboardInterrupt:
            print "Interrupted; Python bindings will be disabled."
        else:
            print "Update was successful."
    else:
        print "Trying to fetch pybindgen; this will fail if no network connection is available.  Hit Ctrl-C to skip."
        try:
            run_command(["bzr", "checkout", rev, constants.PYBINDGEN_BRANCH, constants.LOCAL_PYBINDGEN_PATH])
        except KeyboardInterrupt:
            print "Interrupted; Python bindings will be disabled."
            shutil.rmtree(constants.LOCAL_PYBINDGEN_PATH, True)
            return False
        print "Fetch was successful."

    ## generate a fake version.py file in pybindgen it's safer this
    ## way, since the normal version generation process requires
    ## bazaar python bindings, which may not be available.
    vfile = open(os.path.join(constants.LOCAL_PYBINDGEN_PATH, "pybindgen", "version.py"), "wt")
    vfile.write("""
# (fake version generated by ns-3)
__version__ = %r
""" % list(required_pybindgen_versi 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.filechunkiter函数代码示例发布时间:2022-05-27
下一篇:
Python util.fail函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap