本文整理汇总了Python中logging.warn方法的典型用法代码示例。如果您正苦于以下问题:Python logging.warn方法的具体用法?Python logging.warn怎么用?Python logging.warn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logging
的用法示例。
在下文中一共展示了logging.warn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: saveState
# 需要导入模块: import logging [as 别名]
# 或者: from logging import warn [as 别名]
def saveState(dataHub):
import pickle as pickle
import gzip
pickle.dump(dataHub, gzip.open(dataHub.args.save_state, "wb"))
logging.warn("^"*20 + " saving state to pickle and exiting " + "^"*20)
示例2: getExportFormat
# 需要导入模块: import logging [as 别名]
# 或者: from logging import warn [as 别名]
def getExportFormat(args):
formats = [None, "png", "pdf", "svg"]
if args.type == "batch" or args.format is not None:
exportFormat = args.format
if exportFormat is None:
exportFormat = "pdf"
else:
exportFormat = args.export.partition(".")
if len(exportFormat[2]) > 0:
exportFormat = exportFormat[2]
if exportFormat not in formats:
logging.warn("= File suffix {} not recognized; exporting as .svg =".format(exportFormat))
exportFormat = "svg"
else:
exportFormat = "svg"
exportFormat = exportFormat.lower()
return exportFormat
示例3: get_symbol_train
# 需要导入模块: import logging [as 别名]
# 或者: from logging import warn [as 别名]
def get_symbol_train(network, data_shape, **kwargs):
"""Wrapper for get symbol for train
Parameters
----------
network : str
name for the base network symbol
data_shape : int
input shape
kwargs : dict
see symbol_builder.get_symbol_train for more details
"""
if network.startswith('legacy'):
logging.warn('Using legacy model.')
return symbol_builder.import_module(network).get_symbol_train(**kwargs)
config = get_config(network, data_shape, **kwargs).copy()
config.update(kwargs)
return symbol_builder.get_symbol_train(**config)
示例4: get_symbol
# 需要导入模块: import logging [as 别名]
# 或者: from logging import warn [as 别名]
def get_symbol(network, data_shape, **kwargs):
"""Wrapper for get symbol for test
Parameters
----------
network : str
name for the base network symbol
data_shape : int
input shape
kwargs : dict
see symbol_builder.get_symbol for more details
"""
if network.startswith('legacy'):
logging.warn('Using legacy model.')
return symbol_builder.import_module(network).get_symbol(**kwargs)
config = get_config(network, data_shape, **kwargs).copy()
config.update(kwargs)
return symbol_builder.get_symbol(**config)
示例5: get_remote_info_json
# 需要导入模块: import logging [as 别名]
# 或者: from logging import warn [as 别名]
def get_remote_info_json(jfname):
try:
logging.info('loading example '+jfname)
rfo = urllib.urlopen(jfname)
di = json.loads(rfo.read())
nat, glbs = 0, 0
for k,v in di.items():
if k != 'dimensions' or k != 'variables':
glbs +=1
for k,v in di['variables'].items():
for a in v: nat += 1
dims = [ l for k, v in di['dimensions'].items() for d, l in v.items() if d == 'length' ]
return { 'num global attr' : glbs, 'num vars' : len(di['variables'].keys()), 'num dims' : \
len(di['dimensions'].keys()), 'ave attrs per var' : nat / len(di['variables'].keys()), \
'dims sizes' : dims }
except Exception, e:
logging.warn("WARN get_remote_info_json on %s : %s, update S3 bucket" % (jfname, str(e)))
return {}
#---------------------------------------------------------------------------------
示例6: bootstrap_chrome_ous
# 需要导入模块: import logging [as 别名]
# 或者: from logging import warn [as 别名]
def bootstrap_chrome_ous(**kwargs):
"""Bootstraps Chrome device OUs.
Args:
**kwargs: keyword args including a user_email with which to run the
Directory API client methods (required for BigQuery streaming).
"""
logging.info('Requesting delegated admin for bootstrap')
client = directory.DirectoryApiClient(user_email=kwargs['user_email'])
for org_unit_name, org_unit_path in constants.ORG_UNIT_DICT.iteritems():
logging.info(
'Creating org unit %s at path %s ...', org_unit_name, org_unit_path)
if client.get_org_unit(org_unit_path):
logging.warn(_ORG_UNIT_EXISTS_MSG, org_unit_name)
else:
client.insert_org_unit(org_unit_path)
示例7: proc_cornell_movie_dialogs
# 需要导入模块: import logging [as 别名]
# 或者: from logging import warn [as 别名]
def proc_cornell_movie_dialogs(corpus_path, tokenize):
num_sentences = 0
with codecs.open('%s/movie_lines.txt' % corpus_path, 'r',
'latin1') as inf:
for line in inf:
parts = line.split('+++$+++')
if not len(parts) == 5:
logging.warn('movie dialogs: skipping line %s' % line)
continue
sentence = u' '.join(tokenize(parts[4], lang='en'))
if not sentence:
logging.warn('movie dialogs: skipping null sentence %s' % line)
continue
yield u'%s' % sentence
num_sentences += 1
if num_sentences % SENTENCES_STATS == 0:
logging.info('movie dialogs: %8d sentences.' % num_sentences)
if DEBUG_LIMIT and num_sentences >= DEBUG_LIMIT:
logging.warn('movie dialogs: debug limit reached, stopping.')
break
示例8: proc_corpus_with_one_sentence_perline
# 需要导入模块: import logging [as 别名]
# 或者: from logging import warn [as 别名]
def proc_corpus_with_one_sentence_perline(corpus_path, tokenize, lang):
logging.info("adding sentences from %s..." % corpus_path)
num_sentences = 0
with codecs.open(corpus_path, 'r', 'utf8') as inf:
for line in inf:
sentence = u' '.join(tokenize(line, lang=lang))
if not sentence:
logging.warn('%s: skipping null sentence.' % corpus_path)
continue
yield u'%s' % sentence
num_sentences += 1
if num_sentences % SENTENCES_STATS == 0:
logging.info('%s: %8d sentences.' % (corpus_path, num_sentences))
if DEBUG_LIMIT and num_sentences >= DEBUG_LIMIT:
logging.warn('%s: debug limit reached, stopping.' % corpus_path)
break
示例9: make_extra_conf
# 需要导入模块: import logging [as 别名]
# 或者: from logging import warn [as 别名]
def make_extra_conf(self, extra_conf_template, add_overwrite_keys=None):
for k in extra_conf_template:
value = self._generate_value_from_template_key(k, extra_conf_template[k])
if value:
extra_conf_template[k] = value
else:
logging.warn('Value for key %s is None removing from config' % k)
extra_conf_template.pop(k)
# Useful to build storage config - keep it after first template transformation
if add_overwrite_keys:
for k in add_overwrite_keys:
new_value = add_overwrite_keys[k]
if extra_conf_template.get(k):
logging.warn('Overriding key:{} value: {} with new_value {}'.format(k,extra_conf_template[k], new_value))
else:
logging.info('Adding new key:{} with value: {}'.format(k, new_value))
extra_conf_template[k] = new_value
return self._make_extra_conf_as_kv_list(extra_conf_template)
示例10: report_status_to_hbs
# 需要导入模块: import logging [as 别名]
# 或者: from logging import warn [as 别名]
def report_status_to_hbs(data):
"""
send formated data to transfer via rpc
Args:
data (dict): {}
"""
addr = g.HEARTBEAT['addr']
rpc = get_hbs_rpc_client(addr)
for i in range(3):
try:
res = rpc.call('Agent.ReportStatus', data)
except Exception as e:
logging.warn("call (%s) Agent.ReportStatus failure, times: %s -> msg: %s" %
(addr, i, e))
continue
return res
logging.error("report_status_to_hbs %s to hbs (%s) failure" % (data, addr))
示例11: send_data_to_transfer
# 需要导入模块: import logging [as 别名]
# 或者: from logging import warn [as 别名]
def send_data_to_transfer(data):
"""
send formated data to transfer via rpc, select transfer randomly and every
transfer will retry 3 times if failure
Args:
data (list of dict): [{}, {}, ...]
"""
addrs = g.TRANSFER['addrs']
logging.debug(addrs)
random.shuffle(addrs)
for addr in addrs:
call_success = False
rpc = get_transfer_rpc_client(addr)
for i in range(3):
try:
res = rpc.call('Transfer.Update', data)
except Exception as e:
logging.warn("call (%s) Transfer.update failure, times: %s -> msg: %s" %
(addr, i, e))
continue
call_success = True
return res
if not call_success:
logging.error("send data %s to transfer (%s) failure" %
(data, addr))
示例12: _HttpUrlLoggingWrapper
# 需要导入模块: import logging [as 别名]
# 或者: from logging import warn [as 别名]
def _HttpUrlLoggingWrapper(func):
"""Decorates func, logging when 'url' params do not start with https://."""
@functools.wraps(func)
def _CheckAndLog(*args, **kwargs):
try:
arg_index = FindArgumentIndex(func, 'url')
except ValueError:
return func(*args, **kwargs)
if arg_index < len(args):
arg_value = args[arg_index]
elif 'url' in kwargs:
arg_value = kwargs['url']
elif 'url' not in kwargs:
arg_value = GetDefaultArgument(func, 'url')
if arg_value and not arg_value.startswith('https://'):
logging.warn('SECURITY : fetching non-HTTPS url %s' % (arg_value))
return func(*args, **kwargs)
return _CheckAndLog
示例13: CheckTests
# 需要导入模块: import logging [as 别名]
# 或者: from logging import warn [as 别名]
def CheckTests(db):
cursor = db.cursor()
cursor.execute('''
SELECT category, test, count(*)
FROM scores
WHERE category IS NOT NULL
GROUP BY category, test
ORDER BY category, test
;''')
for category, test_key, num_scores in cursor.fetchall():
test_set = all_test_sets.GetTestSet(category)
if not test_set:
logging.warn('No test_set for category: %s (num_scores=%s)',
category, num_scores)
continue
test = test_set.GetTest(test_key)
if not test:
logging.warn('No test: %s, %s (num_scores=%s)',
category, test_key, num_scores)
示例14: http_token_secure
# 需要导入模块: import logging [as 别名]
# 或者: from logging import warn [as 别名]
def http_token_secure(func):
def secure_check(arg):
logging.info("Rest_API_Plugin.http_token_secure() called")
# Check if the airflow_expected_http_token variable is not none from configurations. This means authentication is enabled.
if airflow_expected_http_token:
logging.info("Performing Token Authentication")
if request.headers.get(airflow_rest_api_plugin_http_token_header_name, None) != airflow_expected_http_token:
warning_message = "Token Authentication Failed"
logging.warn(warning_message)
base_response = REST_API_Response_Util.get_base_response(include_arguments=False)
return REST_API_Response_Util.get_403_error_response(base_response=base_response, output=warning_message)
return func(arg)
return secure_check
# Function used to validate the JWT Token
示例15: do_realign
# 需要导入模块: import logging [as 别名]
# 或者: from logging import warn [as 别名]
def do_realign(dataHub, sample):
processes = dataHub.args.processes
if processes is None or processes == 0:
# we don't really gain from using virtual cores, so try to figure out how many physical
# cores we have
processes = misc.cpu_count_physical()
variant = dataHub.variant
reads = sample.reads
name = "{}:{{}}".format(sample.name[:15])
t0 = time.time()
refalignments, badReadsRef = do1remap(variant.chromParts("ref"), reads, processes,
jobName=name.format("ref"), tryExact=dataHub.args.fast)
altalignments, badReadsAlt = do1remap(variant.chromParts("alt"), reads, processes,
jobName=name.format("alt"), tryExact=dataHub.args.fast)
t1 = time.time()
logging.debug(" Time to realign: {:.1f}s".format(t1-t0))
badReads = badReadsRef.union(badReadsAlt)
if len(badReads) > 0:
logging.warn(" Alignment failed with {} reads (this is a known issue)".format(badReads))
for badRead in badReads:
refalignments.pop(badRead, None)
altalignments.pop(badRead, None)
assert set(refalignments.keys()) == set(altalignments.keys()), \
set(refalignments.keys()) ^ set(altalignments.keys())
alnCollections = []
for key in refalignments:
alnCollection = AlignmentSetCollection(key)
alnCollection.addSet(refalignments[key], "ref")
alnCollection.addSet(altalignments[key], "alt")
alnCollections.append(alnCollection)
return alnCollections