本文整理汇总了Python中util.fatal函数的典型用法代码示例。如果您正苦于以下问题:Python fatal函数的具体用法?Python fatal怎么用?Python fatal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fatal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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()
示例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)
示例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)
示例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)
示例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:])
示例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()
示例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
示例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))
示例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()
示例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)
示例12: check_tracing
def check_tracing():
if defines.TRACING_ON:
return
fatal("Tracing is not enabled. Compile with TRACING_ON")
示例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()
示例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)
示例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)