本文整理汇总了Python中mx.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parseVmArgs
def parseVmArgs(self, args, addDefaultArgs=True):
args = mx.expand_project_in_args(args, insitu=False)
jacocoArgs = mx_gate.get_jacoco_agent_args()
if jacocoArgs:
args = jacocoArgs + args
args = ['-Xbootclasspath/p:' + dep.classpath_repr() for dep in _jvmci_bootclasspath_prepends] + args
jvmciModeArgs = _jvmciModes[_vm.jvmciMode]
if jvmciModeArgs:
bcpDeps = [jdkDist.dist() for jdkDist in jdkDeployedDists]
if bcpDeps:
args = ['-Xbootclasspath/p:' + os.pathsep.join([d.classpath_repr() for d in bcpDeps])] + args
# Set the default JVMCI compiler
for jdkDist in reversed(jdkDeployedDists):
assert isinstance(jdkDist, JvmciJDKDeployedDist), jdkDist
if jdkDist._compilers:
jvmciCompiler = jdkDist._compilers[-1]
args = ['-Djvmci.compiler=' + jvmciCompiler] + args
break
if '-version' in args:
ignoredArgs = args[args.index('-version') + 1:]
if len(ignoredArgs) > 0:
mx.log("Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs))
return self.processArgs(args, addDefaultArgs=addDefaultArgs)
示例2: _create_jdk_bundle
def _create_jdk_bundle(jdkBuildDir, debugLevel, jdkImageDir):
"""
Creates a tar.gz JDK archive, an accompanying tar.gz.sha1 file with its
SHA1 signature plus symlinks to the archive for non-canonical architecture names.
"""
arches = _get_jdk_bundle_arches()
jdkTgzPath = join(_suite.get_output_root(), 'jdk-bundles', 'jdk9-{}-{}-{}.tar.gz'.format(debugLevel, _get_openjdk_os(), arches[0]))
with mx.Archiver(jdkTgzPath, kind='tgz') as arc:
mx.log('Creating ' + jdkTgzPath)
for root, _, filenames in os.walk(jdkImageDir):
for name in filenames:
f = join(root, name)
arcname = 'jdk1.9.0/' + os.path.relpath(f, jdkImageDir)
arc.zf.add(name=f, arcname=arcname, recursive=False)
with open(jdkTgzPath + '.sha1', 'w') as fp:
mx.log('Creating ' + jdkTgzPath + '.sha1')
fp.write(mx.sha1OfFile(jdkTgzPath))
def _create_link(source, link_name):
if exists(link_name):
os.remove(link_name)
mx.log('Creating ' + link_name + ' -> ' + source)
os.symlink(source, link_name)
for arch in arches[1:]:
link_name = join(_suite.get_output_root(), 'jdk-bundles', 'jdk9-{}-{}-{}.tar.gz'.format(debugLevel, _get_openjdk_os(), arch))
jdkTgzName = os.path.basename(jdkTgzPath)
_create_link(jdkTgzName, link_name)
_create_link(jdkTgzName + '.sha1', link_name + '.sha1')
示例3: checkheaders
def checkheaders(args):
"""check Java source headers against any required pattern"""
failures = {}
for p in mx.projects():
if not p.isJavaProject():
continue
csConfig = join(mx.project(p.checkstyleProj).dir, ".checkstyle_checks.xml")
if not exists(csConfig):
mx.log("Cannot check headers for " + p.name + " - " + csConfig + " does not exist")
continue
dom = xml.dom.minidom.parse(csConfig)
for module in dom.getElementsByTagName("module"):
if module.getAttribute("name") == "RegexpHeader":
for prop in module.getElementsByTagName("property"):
if prop.getAttribute("name") == "header":
value = prop.getAttribute("value")
matcher = re.compile(value, re.MULTILINE)
for sourceDir in p.source_dirs():
for root, _, files in os.walk(sourceDir):
for name in files:
if name.endswith(".java") and name != "package-info.java":
f = join(root, name)
with open(f) as fp:
content = fp.read()
if not matcher.match(content):
failures[f] = csConfig
for n, v in failures.iteritems():
mx.log("{0}: header does not match RegexpHeader defined in {1}".format(n, v))
return len(failures)
示例4: __init__
def __init__(self, title, tasks=None, disableJacoco=False):
self.tasks = tasks
self.title = title
self.skipped = False
if tasks is not None:
for t in tasks:
if t.title == title:
mx.abort('Gate task with title "' + title + '" is already defined')
if Task.startAtFilter:
assert not Task.filters
if Task.startAtFilter in title:
self.skipped = False
Task.startAtFilter = None
else:
self.skipped = True
elif Task.filters:
if Task.filtersExclude:
self.skipped = any([f in title for f in Task.filters])
else:
self.skipped = not any([f in title for f in Task.filters])
if not self.skipped:
self.start = time.time()
self.end = None
self.duration = None
self.disableJacoco = disableJacoco
mx.log(time.strftime('gate: %d %b %Y %H:%M:%S: BEGIN: ') + title)
示例5: verify_jvmci_ci_versions
def verify_jvmci_ci_versions(args=None, extraVMarguments=None):
version_pattern = re.compile(r'^(?!\s*#).*jvmci-(?P<version>\d*\.\d*)')
def _grep_version(files, msg):
version = None
last = None
linenr = 0
for filename in files:
for line in open(filename):
m = version_pattern.search(line)
if m:
new_version = m.group('version')
if version and version != new_version:
mx.abort(
os.linesep.join([
"Multiple JVMCI versions found in {0} files:".format(msg),
" {0} in {1}:{2}: {3}".format(version, *last),
" {0} in {1}:{2}: {3}".format(new_version, filename, linenr, line),
]))
last = (filename, linenr, line.rstrip())
version = new_version
linenr = linenr + 1
if not version:
mx.abort("No JVMCI version found in {0} files!".format(msg))
return version
hocon_version = _grep_version(glob.glob(join(mx.primary_suite().dir, 'ci*.hocon')) + glob.glob(join(mx.primary_suite().dir, 'ci*/*.hocon')), 'ci.hocon')
travis_version = _grep_version(glob.glob('.travis.yml'), 'TravisCI')
if hocon_version != travis_version:
mx.abort("Travis and ci.hocon JVMCI versions do not match: {0} vs. {1}".format(travis_version, hocon_version))
mx.log('JVMCI versions are ok!')
示例6: parseVmArgs
def parseVmArgs(self, args, addDefaultArgs=True):
args = mx.expand_project_in_args(args, insitu=False)
jacocoArgs = mx_gate.get_jacoco_agent_args()
if jacocoArgs:
args = jacocoArgs + args
args = ['-Xbootclasspath/p:' + dep.classpath_repr() for dep in _jvmci_bootclasspath_prepends] + args
# Remove JVMCI jars from class path. They are only necessary when
# compiling with a javac from JDK8 or earlier.
cpIndex, cp = mx.find_classpath_arg(args)
if cp:
excluded = frozenset([dist.path for dist in _suite.dists])
cp = os.pathsep.join([e for e in cp.split(os.pathsep) if e not in excluded])
args[cpIndex] = cp
jvmciModeArgs = _jvmciModes[_vm.jvmciMode]
if jvmciModeArgs:
bcpDeps = [jdkDist.dist() for jdkDist in jdkDeployedDists]
if bcpDeps:
args = ['-Xbootclasspath/p:' + os.pathsep.join([d.classpath_repr() for d in bcpDeps])] + args
# Set the default JVMCI compiler
for jdkDist in reversed(jdkDeployedDists):
assert isinstance(jdkDist, JvmciJDKDeployedDist), jdkDist
if jdkDist._compilers:
jvmciCompiler = jdkDist._compilers[-1]
args = ['-Djvmci.compiler=' + jvmciCompiler] + args
break
if '-version' in args:
ignoredArgs = args[args.index('-version') + 1:]
if len(ignoredArgs) > 0:
mx.log("Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs))
return self.processArgs(args, addDefaultArgs=addDefaultArgs)
示例7: c1visualizer
def c1visualizer(args):
"""run the Cl Compiler Visualizer"""
libpath = join(_suite.dir, 'lib')
if mx.get_os() == 'windows':
executable = join(libpath, 'c1visualizer', 'bin', 'c1visualizer.exe')
else:
executable = join(libpath, 'c1visualizer', 'bin', 'c1visualizer')
# Check whether the current C1Visualizer installation is the up-to-date
if exists(executable) and not exists(mx.library('C1VISUALIZER_DIST').get_path(resolve=False)):
mx.log('Updating C1Visualizer')
shutil.rmtree(join(libpath, 'c1visualizer'))
archive = mx.library('C1VISUALIZER_DIST').get_path(resolve=True)
if not exists(executable):
zf = zipfile.ZipFile(archive, 'r')
zf.extractall(libpath)
if not exists(executable):
mx.abort('C1Visualizer binary does not exist: ' + executable)
if mx.get_os() != 'windows':
# Make sure that execution is allowed. The zip file does not always specfiy that correctly
os.chmod(executable, 0777)
mx.run([executable])
示例8: js_image_test
def js_image_test(binary, bench_location, name, warmup_iterations, iterations, timeout=None, bin_args=None):
bin_args = bin_args if bin_args is not None else []
jsruncmd = [binary] + bin_args + [join(bench_location, 'harness.js'), '--', join(bench_location, name + '.js'),
'--', '--warmup-iterations=' + str(warmup_iterations),
'--iterations=' + str(iterations)]
mx.log(' '.join(jsruncmd))
passing = []
stdoutdata = []
def stdout_collector(x):
stdoutdata.append(x)
mx.log(x.rstrip())
stderrdata = []
def stderr_collector(x):
stderrdata.append(x)
mx.warn(x.rstrip())
returncode = mx.run(jsruncmd, cwd=bench_location, out=stdout_collector, err=stderr_collector, nonZeroIsFatal=False, timeout=timeout)
if returncode == mx.ERROR_TIMEOUT:
print('INFO: TIMEOUT (> %d): %s' % (timeout, name))
elif returncode >= 0:
matches = 0
for line in stdoutdata:
if re.match(r'^\S+: *\d+(\.\d+)?\s*$', line):
matches += 1
if matches > 0:
passing = stdoutdata
if not passing:
mx.abort('JS benchmark ' + name + ' failed')
示例9: jaotc_test
def jaotc_test(args):
"""run (acceptance) tests for the AOT compiler (jaotc)"""
all_tests = ['HelloWorld', 'java.base', 'javac']
parser = ArgumentParser(prog='mx jaotc-test')
parser.add_argument("--list", default=None, action="store_true", help="Print the list of available jaotc tests.")
parser.add_argument('tests', help='tests to run (omit to run all tests)', nargs=ZERO_OR_MORE)
args = parser.parse_args(args)
if args.list:
print "The following jaotc tests are available:\n"
for name in all_tests:
print " " + name
return
tests = args.tests or all_tests
for test in tests:
mx.log('Testing `{}`'.format(test))
if test == 'HelloWorld':
test_class(
classpath=mx.classpath('JAOTC_TEST'),
main_class='jdk.tools.jaotc.test.HelloWorld'
)
elif test == 'javac':
test_javac('jdk.tools.jaotc')
elif test == 'java.base':
test_modules(
classpath=mx.project('jdk.tools.jaotc.test').output_dir(),
main_class='jdk.tools.jaotc.test.HelloWorld',
modules=['java.base']
)
else:
mx.abort('Unknown jaotc test: {}'.format(test))
示例10: _run_netbeans_app
def _run_netbeans_app(app_name, env=None, args=None):
args = [] if args is None else args
dist = app_name.upper() + '_DIST'
name = app_name.lower()
extractPath = join(_suite.get_output_root())
if mx.get_os() == 'windows':
executable = join(extractPath, name, 'bin', name + '.exe')
else:
executable = join(extractPath, name, 'bin', name)
# Check whether the current installation is up-to-date
if exists(executable) and not exists(mx.library(dist).get_path(resolve=False)):
mx.log('Updating ' + app_name)
shutil.rmtree(join(extractPath, name))
archive = mx.library(dist).get_path(resolve=True)
if not exists(executable):
zf = zipfile.ZipFile(archive, 'r')
zf.extractall(extractPath)
if not exists(executable):
mx.abort(app_name + ' binary does not exist: ' + executable)
if mx.get_os() != 'windows':
# Make sure that execution is allowed. The zip file does not always specfiy that correctly
os.chmod(executable, 0777)
mx.run([executable]+args, env=env)
示例11: testgen
def testgen(args):
'''generate the expected output for unit tests, and All/Failing test classes'''
parser = ArgumentParser(prog='r testgen')
parser.add_argument('--tests', action='store', default=_all_unit_tests(), help='pattern to match test classes')
args = parser.parse_args(args)
# check we are in the home directory
if os.getcwd() != _fastr_suite.dir:
mx.abort('must run rtestgen from FastR home directory')
# check the version of GnuR against FastR
try:
fastr_version = subprocess.check_output([mx.get_jdk().java, '-cp', mx.classpath('com.oracle.truffle.r.runtime'), 'com.oracle.truffle.r.runtime.RVersionNumber'])
gnur_version = subprocess.check_output(['R', '--version'])
if not gnur_version.startswith(fastr_version):
mx.abort('R version is incompatible with FastR, please update to ' + fastr_version)
except subprocess.CalledProcessError:
mx.abort('RVersionNumber.main failed')
# clean the test project to invoke the test analyzer AP
testOnly = ['--projects', 'com.oracle.truffle.r.test']
mx.clean(['--no-dist', ] + testOnly)
mx.build(testOnly)
# now just invoke junit with the appropriate options
mx.log("generating expected output for packages: ")
for pkg in args.tests.split(','):
mx.log(" " + str(pkg))
junit(['--tests', args.tests, '--gen-expected-output', '--gen-expected-quiet'])
示例12: benchmark
def benchmark(self, mxBenchmarkArgs, bmSuiteArgs):
"""Run a benchmark suite."""
parser = ArgumentParser(prog="mx benchmark", description=benchmark.__doc__)
parser.add_argument("benchmark", help="Benchmark to run, format: <suite>:<benchmark>.")
parser.add_argument(
"--results-file", default="bench-results.json", help="Path to JSON output file with benchmark results."
)
parser.add_argument("--machine-name", default=None, help="Abstract name of the target machine.")
mxBenchmarkArgs = parser.parse_args(mxBenchmarkArgs)
self.checkEnvironmentVars()
suite, benchNamesList = self.getSuiteAndBenchNames(mxBenchmarkArgs)
results = []
failures_seen = False
suite.before(bmSuiteArgs)
for benchnames in benchNamesList:
suite.validateEnvironment()
try:
partialResults = self.execute(suite, benchnames, mxBenchmarkArgs, bmSuiteArgs)
results.extend(partialResults)
except RuntimeError:
failures_seen = True
mx.log(traceback.format_exc())
topLevelJson = {"queries": results}
dump = json.dumps(topLevelJson)
with open(mxBenchmarkArgs.results_file, "w") as txtfile:
txtfile.write(dump)
if failures_seen:
return 1
return 0
示例13: native_image_layout
def native_image_layout(dists, subdir, native_image_root, debug_gr_8964=False):
if not dists:
return
dest_path = join(native_image_root, subdir)
# Cleanup leftovers from previous call
if exists(dest_path):
if debug_gr_8964:
mx.log('[mx_substratevm.native_image_layout: remove_tree: ' + dest_path + ']')
remove_tree(dest_path)
mkpath(dest_path)
# Create symlinks to conform with native-image directory layout scheme
def symlink_jar(jar_path):
if debug_gr_8964:
def log_stat(prefix, file_name):
file_stat = os.stat(file_name)
mx.log(' ' + prefix + '.st_mode: ' + oct(file_stat.st_mode))
mx.log(' ' + prefix + '.st_mtime: ' + time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(file_stat.st_mtime)))
dest_jar = join(dest_path, basename(jar_path))
mx.log('[mx_substratevm.native_image_layout.symlink_jar: symlink_or_copy')
mx.log(' src: ' + jar_path)
log_stat('src', jar_path)
mx.log(' dst: ' + dest_jar)
symlink_or_copy(jar_path, dest_jar, debug_gr_8964)
log_stat('dst', dest_jar)
mx.log(']')
else:
symlink_or_copy(jar_path, join(dest_path, basename(jar_path)), debug_gr_8964)
for dist in dists:
mx.logv('Add ' + type(dist).__name__ + ' ' + str(dist) + ' to ' + dest_path)
symlink_jar(dist.path)
if not dist.isBaseLibrary() and dist.sourcesPath:
symlink_jar(dist.sourcesPath)
示例14: run
def run(self, cwd, args):
out = mx.TeeOutputCapture(mx.OutputCapture())
args = self.post_process_command_line_args(args)
mx.log("Running JVM with args: {0}".format(args))
code = self.run_java(args, out=out, err=out, cwd=cwd, nonZeroIsFatal=False)
out = out.underlying.data
dims = self.dimensions(cwd, args, code, out)
return code, out, dims
示例15: deploy_binary_if_truffle_head
def deploy_binary_if_truffle_head(args):
"""If the active branch is 'truffle-head', deploy binaries for the primary suite to remote maven repository."""
primary_branch = 'truffle-head'
active_branch = mx.VC.get_vc(_suite.dir).active_branch(_suite.dir)
if active_branch == primary_branch:
return mx.command_function('deploy-binary')(args)
else:
mx.log('The active branch is "%s". Binaries are deployed only if the active branch is "%s".' % (active_branch, primary_branch))
return 0