本文整理汇总了Python中utils.log_info函数的典型用法代码示例。如果您正苦于以下问题:Python log_info函数的具体用法?Python log_info怎么用?Python log_info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log_info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_samples
def parse_samples(process, args, sample_filter_fn):
"""Read samples from record file.
process: Process object
args: arguments
sample_filter_fn: if not None, is used to modify and filter samples.
It returns false for samples should be filtered out.
"""
record_file = args.record_file
symfs_dir = args.symfs
kallsyms_file = args.kallsyms
lib = ReportLib()
lib.ShowIpForUnknownSymbol()
if symfs_dir:
lib.SetSymfs(symfs_dir)
if record_file:
lib.SetRecordFile(record_file)
if kallsyms_file:
lib.SetKallsymsFile(kallsyms_file)
if args.show_art_frames:
lib.ShowArtFrames(True)
process.cmd = lib.GetRecordCmd()
product_props = lib.MetaInfo().get("product_props")
if product_props:
manufacturer, model, name = product_props.split(':')
process.props['ro.product.manufacturer'] = manufacturer
process.props['ro.product.model'] = model
process.props['ro.product.name'] = name
if lib.MetaInfo().get('trace_offcpu') == 'true':
process.props['trace_offcpu'] = True
if args.one_flamegraph:
log_exit("It doesn't make sense to report with --one-flamegraph for perf.data " +
"recorded with --trace-offcpu.""")
else:
process.props['trace_offcpu'] = False
while True:
sample = lib.GetNextSample()
if sample is None:
lib.Close()
break
symbol = lib.GetSymbolOfCurrentSample()
callchain = lib.GetCallChainOfCurrentSample()
if sample_filter_fn and not sample_filter_fn(sample, symbol, callchain):
continue
process.add_sample(sample, symbol, callchain)
if process.pid == 0:
main_threads = [thread for thread in process.threads.values() if thread.tid == thread.pid]
if main_threads:
process.name = main_threads[0].name
process.pid = main_threads[0].pid
for thread in process.threads.values():
min_event_count = thread.num_events * args.min_callchain_percentage * 0.01
thread.flamegraph.trim_callchain(min_event_count)
log_info("Parsed %s callchains." % process.num_samples)
示例2: check_full
def check_full(self):
"""
This is the default that verify will use, this will
do the entire stack of checks.
"""
try:
self.decoded = self.decode()
self.check_type('purchase-receipt')
self.check_db()
self.check_url()
except InvalidReceipt:
return self.invalid()
if self.premium != ADDON_PREMIUM:
log_info('Valid receipt, not premium')
return self.ok_or_expired()
try:
self.check_purchase()
except InvalidReceipt:
return self.invalid()
except RefundedReceipt:
return self.refund()
return self.ok_or_expired()
示例3: application
def application(environ, start_response):
status = '200 OK'
with statsd.timer('services.verify'):
data = environ['wsgi.input'].read()
try:
addon_id = id_re.search(environ['PATH_INFO']).group('addon_id')
except AttributeError:
output = ''
log_info({'receipt': '%s...' % data[:10], 'addon': 'empty'},
'Wrong url %s' % environ['PATH_INFO'][:20])
start_response('500 Internal Server Error', [])
return [output]
try:
verify = Verify(addon_id, data, environ)
output = verify()
start_response(status, verify.get_headers(len(output)))
receipt_cef.log(environ, addon_id, 'verify',
'Receipt verification')
except:
output = ''
log_exception({'receipt': '%s...' % data[:10], 'addon': addon_id})
receipt_cef.log(environ, addon_id, 'verify',
'Receipt verification error')
start_response('500 Internal Server Error', [])
return [output]
示例4: application
def application(environ, start_response):
status = "200 OK"
with statsd.timer("services.verify"):
data = environ["wsgi.input"].read()
try:
addon_id = id_re.search(environ["PATH_INFO"]).group("addon_id")
except AttributeError:
output = ""
log_info({"receipt": "%s..." % data[:10], "addon": "empty"}, "Wrong url %s" % environ["PATH_INFO"][:20])
start_response("500 Internal Server Error", [])
return [output]
try:
verify = Verify(addon_id, data, environ)
output = verify()
start_response(status, verify.get_headers(len(output)))
receipt_cef.log(environ, addon_id, "verify", "Receipt verification")
except:
output = ""
log_exception({"receipt": "%s..." % data[:10], "addon": addon_id})
receipt_cef.log(environ, addon_id, "verify", "Receipt verification error")
start_response("500 Internal Server Error", [])
return [output]
示例5: check_type
def check_type(self, *types):
"""
Verifies that the type of receipt is what we expect.
"""
if self.decoded.get('typ', '') not in types:
log_info('Receipt type not in %s' % ','.join(types))
raise InvalidReceipt('WRONG_TYPE')
示例6: collect_data
def collect_data(args):
""" Run app_profiler.py to generate record file. """
app_profiler_args = [sys.executable, os.path.join(scripts_path, "app_profiler.py"), "-nb"]
if args.app:
app_profiler_args += ["-p", args.app]
elif args.native_program:
app_profiler_args += ["-np", args.native_program]
else:
log_exit("Please set profiling target with -p or -np option.")
if args.compile_java_code:
app_profiler_args.append("--compile_java_code")
if args.disable_adb_root:
app_profiler_args.append("--disable_adb_root")
record_arg_str = ""
if args.dwarf_unwinding:
record_arg_str += "-g "
else:
record_arg_str += "--call-graph fp "
if args.events:
tokens = args.events.split()
if len(tokens) == 2:
num_events = tokens[0]
event_name = tokens[1]
record_arg_str += "-c %s -e %s " % (num_events, event_name)
else:
log_exit("Event format string of -e option cann't be recognized.")
log_info("Using event sampling (-c %s -e %s)." % (num_events, event_name))
else:
record_arg_str += "-f %d " % args.sample_frequency
log_info("Using frequency sampling (-f %d)." % args.sample_frequency)
record_arg_str += "--duration %d " % args.capture_duration
app_profiler_args += ["-r", record_arg_str]
returncode = subprocess.call(app_profiler_args)
return returncode == 0
示例7: main
def main():
parser = argparse.ArgumentParser(description="""
Annotate source files based on profiling data. It reads line information from binary_cache
generated by app_profiler.py or binary_cache_builder.py, and generate annotated source
files in annotated_files directory.""")
parser.add_argument('-i', '--perf_data_list', nargs='+', action='append', help="""
The paths of profiling data. Default is perf.data.""")
parser.add_argument('-s', '--source_dirs', type=extant_dir, nargs='+', action='append', help="""
Directories to find source files.""")
parser.add_argument('--comm', nargs='+', action='append', help="""
Use samples only in threads with selected names.""")
parser.add_argument('--pid', nargs='+', action='append', help="""
Use samples only in processes with selected process ids.""")
parser.add_argument('--tid', nargs='+', action='append', help="""
Use samples only in threads with selected thread ids.""")
parser.add_argument('--dso', nargs='+', action='append', help="""
Use samples only in selected binaries.""")
parser.add_argument('--ndk_path', type=extant_dir, help='Set the path of a ndk release.')
args = parser.parse_args()
config = {}
config['perf_data_list'] = flatten_arg_list(args.perf_data_list)
if not config['perf_data_list']:
config['perf_data_list'].append('perf.data')
config['source_dirs'] = flatten_arg_list(args.source_dirs)
config['comm_filters'] = flatten_arg_list(args.comm)
config['pid_filters'] = flatten_arg_list(args.pid)
config['tid_filters'] = flatten_arg_list(args.tid)
config['dso_filters'] = flatten_arg_list(args.dso)
config['ndk_path'] = args.ndk_path
annotator = SourceFileAnnotator(config)
annotator.annotate()
log_info('annotate finish successfully, please check result in annotated_files/.')
示例8: check_db
def check_db(self):
"""
Verifies the decoded receipt against the database.
Requires that decode is run first.
"""
if not self.decoded:
raise ValueError('decode not run')
self.setup_db()
# Get the addon and user information from the installed table.
try:
self.uuid = self.decoded['user']['value']
except KeyError:
# If somehow we got a valid receipt without a uuid
# that's a problem. Log here.
log_info('No user in receipt')
raise InvalidReceipt('NO_USER')
try:
storedata = self.decoded['product']['storedata']
self.addon_id = int(dict(parse_qsl(storedata)).get('id', ''))
except:
# There was some value for storedata but it was invalid.
log_info('Invalid store data')
raise InvalidReceipt('WRONG_STOREDATA')
示例9: add_disassembly
def add_disassembly(self, filter_lib):
""" Collect disassembly information:
1. Use objdump to collect disassembly for each function in FunctionSet.
2. Set flag to dump addr_hit_map when generating record info.
"""
objdump = Objdump(self.ndk_path, self.binary_cache_path)
cur_lib_name = None
dso_info = None
for function in sorted(self.functions.id_to_func.values(), key=lambda a: a.lib_id):
if function.func_name == 'unknown':
continue
lib_name = self.libs.get_lib_name(function.lib_id)
if lib_name != cur_lib_name:
cur_lib_name = lib_name
if filter_lib(lib_name):
dso_info = objdump.get_dso_info(lib_name)
else:
dso_info = None
if dso_info:
log_info('Disassemble %s' % dso_info[0])
if dso_info:
code = objdump.disassemble_code(dso_info, function.start_addr, function.addr_len)
function.disassembly = code
self.gen_addr_hit_map_in_record_info = True
示例10: gen_source_lines
def gen_source_lines(self):
# 1. Create Addr2line instance
if not self.config.get('binary_cache_dir'):
log_info("Can't generate line information because binary_cache is missing.")
return
if not find_tool_path('addr2line', self.config['ndk_path']):
log_info("Can't generate line information because can't find addr2line.")
return
addr2line = Addr2Nearestline(self.config['ndk_path'], self.config['binary_cache_dir'], True)
# 2. Put all needed addresses to it.
for location in self.location_list:
mapping = self.get_mapping(location.mapping_id)
dso_name = self.get_string(mapping.filename_id)
if location.lines:
function = self.get_function(location.lines[0].function_id)
addr2line.add_addr(dso_name, function.vaddr_in_dso, location.vaddr_in_dso)
for function in self.function_list:
dso_name = self.get_string(function.dso_name_id)
addr2line.add_addr(dso_name, function.vaddr_in_dso, function.vaddr_in_dso)
# 3. Generate source lines.
addr2line.convert_addrs_to_lines()
# 4. Annotate locations and functions.
for location in self.location_list:
if not location.lines:
continue
mapping = self.get_mapping(location.mapping_id)
dso_name = self.get_string(mapping.filename_id)
dso = addr2line.get_dso(dso_name)
if not dso:
continue
sources = addr2line.get_addr_source(dso, location.vaddr_in_dso)
if not sources:
continue
for (source_id, source) in enumerate(sources):
source_file, source_line, function_name = source
function_id = self.get_function_id(function_name, dso_name, 0)
if function_id == 0:
continue
if source_id == 0:
# Clear default line info
location.lines = []
location.lines.append(self.add_line(source_file, source_line, function_id))
for function in self.function_list:
dso_name = self.get_string(function.dso_name_id)
if function.vaddr_in_dso:
dso = addr2line.get_dso(dso_name)
if not dso:
continue
sources = addr2line.get_addr_source(dso, function.vaddr_in_dso)
if sources:
source_file, source_line, _ = sources[0]
function.source_filename_id = self.get_string_id(source_file)
function.start_line = source_line
示例11: unzip_recording_data
def unzip_recording_data(args):
zip_file_path = os.path.join(args.out_dir, 'simpleperf_data.zip')
with zipfile.ZipFile(zip_file_path, 'r') as zip_fh:
names = zip_fh.namelist()
log_info('There are %d recording data files.' % len(names))
for name in names:
log_info('recording file: %s' % os.path.join(args.out_dir, name))
zip_fh.extract(name, args.out_dir)
remove(zip_file_path)
示例12: get_storedata
def get_storedata(self):
"""
Attempt to retrieve the storedata information from the receipt.
"""
try:
storedata = self.decoded['product']['storedata']
return dict(parse_qsl(storedata))
except Exception, e:
log_info('Invalid store data: {err}'.format(err=e))
raise InvalidReceipt('WRONG_STOREDATA')
示例13: get_user
def get_user(self):
"""
Attempt to retrieve the user information from the receipt.
"""
try:
return self.decoded['user']['value']
except KeyError:
# If somehow we got a valid receipt without a uuid
# that's a problem. Log here.
log_info('No user in receipt')
raise InvalidReceipt('NO_USER')
示例14: get_inapp_id
def get_inapp_id(self):
"""
Attempt to retrieve the inapp id
from the storedata in the receipt.
"""
try:
return int(self.get_storedata()['inapp_id'])
except Exception, e:
# There was some value for storedata but it was invalid.
log_info('Invalid store data for inapp id: {err}'.format(
err=e))
raise InvalidReceipt('WRONG_STOREDATA')
示例15: _copy_to_binary_cache
def _copy_to_binary_cache(self, from_path, expected_build_id, target_file):
if target_file[0] == '/':
target_file = target_file[1:]
target_file = target_file.replace('/', os.sep)
target_file = os.path.join(self.binary_cache_dir, target_file)
if not self._need_to_copy(from_path, target_file, expected_build_id):
# The existing file in binary_cache can provide more information, so no need to copy.
return
target_dir = os.path.dirname(target_file)
if not os.path.isdir(target_dir):
os.makedirs(target_dir)
log_info('copy to binary_cache: %s to %s' % (from_path, target_file))
shutil.copy(from_path, target_file)