本文整理汇总了Python中mod.log.error函数的典型用法代码示例。如果您正苦于以下问题:Python error函数的具体用法?Python error怎么用?Python error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_include_path
def get_include_path() :
"""return the global shader header search path"""
include_path = '{}/bgfx/src'.format(proj_path)
include_path = os.path.normpath(include_path)
if not os.path.isdir(include_path) :
log.error("could not find bgfx shader include search path at '{}'".format(include_path))
return include_path
示例2: ensure_valid_project_dir
def ensure_valid_project_dir(proj_dir):
"""test if project dir is valid, if not, dump error and abort
:param proj_dir: absolute project directory to check
"""
if not is_valid_project_dir(proj_dir):
log.error("'{}' is not a valid project directory".format(proj_dir))
示例3: gather_and_write_imports
def gather_and_write_imports(fips_dir, proj_dir) :
"""first does and gather_imports, then a write_imports with the result"""
imports = gather_imports(fips_dir, proj_dir)
if imports is not None :
write_imports(fips_dir, proj_dir, imports)
else :
log.error("project imports are incomplete, please run 'fips fetch'")
示例4: copy_template_file
def copy_template_file(fips_dir, proj_dir, filename, values, silent=False) :
"""copy a template file from fips/templates to the project
directory and replace template values (e.g. the project name),
ask for user permission if files exist
:param fips_dir: absolute fips directory
:param proj_dir: absolute project directory
:param filename: filename to copy from fips/templates
:param values: template key/value dictionary
:param silent: if True, overwrite existing file and don't print status
:returns: True file overwritten, False on not overwritten
"""
src_path = fips_dir + '/templates/' + filename
dst_path = proj_dir + '/' + filename
if not os.path.isfile(src_path) :
log.error("template src file '{}' doesn't exist".format(src_path))
if not silent :
if os.path.isfile(dst_path) :
if not util.confirm("overwrite '{}'?".format(dst_path)) :
log.info("skipping '{}'".format(dst_path))
return False
content = None
with open(src_path, 'r') as f :
content = f.read()
content = Template(content).substitute(values)
with open(dst_path, 'w') as f :
f.write(content)
if not silent :
log.info("wrote '{}'".format(dst_path))
return True
示例5: run
def run(fips_dir, proj_dir, args) :
"""run the init verb"""
if len(args) > 0 :
proj_name = args[0]
project.init(fips_dir, proj_name)
else :
log.error("expected one arg [project]")
示例6: load
def load(fips_dir, proj_dir, pattern) :
"""load one or more matching configs from fips and current project dir
:param fips_dir: absolute fips directory
:param proj_dir: absolute project directory
:param pattern: config name pattern (e.g. 'linux-make-*')
:returns: an array of loaded config objects
"""
dirs = get_config_dirs(fips_dir, proj_dir)
configs = []
for curDir in dirs :
paths = glob.glob('{}/{}.yml'.format(curDir, pattern))
for path in paths :
try :
with open(path, 'r') as f :
cfg = yaml.load(f)
folder, fname = os.path.split(path)
# patch path, folder, and name
cfg['path'] = path
cfg['folder'] = folder
cfg['name'] = os.path.splitext(fname)[0]
if 'generator' not in cfg :
cfg['generator'] = 'Default'
if 'generator-platform' not in cfg :
cfg['generator-platform'] = None
if 'generator-toolset' not in cfg :
cfg['generator-toolset'] = None
if 'defines' not in cfg :
cfg['defines'] = None
configs.append(cfg)
except yaml.error.YAMLError, e:
log.error('YML parse error: {}', e.message)
示例7: run
def run(fips_dir, proj_dir, args) :
"""run diagnostics
:param fips_dir: absolute path to fips directory
:param proj_dir: absolute path to current project
:args: command line args
"""
noun = 'all'
ok = False
if len(args) > 0 :
noun = args[0]
if noun in ['all', 'configs'] :
check_configs(fips_dir, proj_dir)
ok = True
if noun in ['all', 'imports'] :
check_imports(fips_dir, proj_dir)
ok = True
if noun in ['all', 'tools'] :
check_tools(fips_dir)
ok = True
if noun in ['all', 'fips'] :
check_fips(fips_dir)
ok = True
if not ok :
log.error("invalid noun '{}'".format(noun))
示例8: run
def run(fips_dir, proj_dir, args) :
if not util.is_valid_project_dir(proj_dir) :
log.error('must be run in a project directory')
if len(args) > 0:
if args[0] == 'clean':
vscode.cleanup(fips_dir, proj_dir)
else:
log.error("invalid noun '{}' (expected: clean)".format(noun))
示例9: check_config_valid
def check_config_valid(fips_dir, cfg, print_errors=False) :
"""check if provided config is valid, and print errors if not
:param cfg: a loaded config object
:returns: (True, [ errors ]) tuple with result and error messages
"""
errors = []
valid = True
# check whether all required fields are present
# (NOTE: name and folder should always be present since they are appended
# during loading)
required_fields = ['name', 'folder', 'platform', 'generator', 'build_tool', 'build_type']
for field in required_fields :
if field not in cfg :
errors.append("missing field '{}' in '{}'".format(field, cfg['path']))
valid = False
# check if the platform string is valid
if not valid_platform(cfg['platform']) :
errors.append("invalid platform name '{}' in '{}'".format(cfg['platform'], cfg['path']))
valid = False
# check if the platform can be built on current host platform
if cfg['platform'] not in target_platforms[util.get_host_platform()] :
errors.append("'{}' is not a valid target platform for host '{}'".format(cfg['platform'], util.get_host_platform()))
valid = False
# check if the target platform SDK is installed
if not check_sdk(fips_dir, cfg['platform']) :
errors.append("platform sdk for '{}' not installed (see './fips help setup')".format(cfg['platform']))
valid = False
# check if the generator name is valid
if not valid_generator(cfg['generator']) :
errors.append("invalid generator name '{}' in '{}'".format(cfg['generator'], cfg['path']))
valid = False
# check if build tool is valid
if not valid_build_tool(cfg['build_tool']) :
errors.append("invalid build_tool name '{}' in '{}'".format(cfg['build_tool'], cfg['path']))
valid = False
# check if the build tool can be found
if not check_build_tool(fips_dir, cfg['build_tool']) :
errors.append("build tool '{}' not found".format(cfg['build_tool']))
valid = False
# check if build type is valid (Debug, Release, Profiling)
if not valid_build_type(cfg['build_type']) :
errors.append("invalid build_type '{}' in '{}'".format(cfg['build_type'], cfg['path']))
valid = False
if print_errors :
for error in errors :
log.error(error, False)
return (valid, errors)
示例10: build
def build(fips_dir, proj_dir, cfg_name, target=None) :
"""perform a build of config(s) in project
:param fips_dir: absolute path of fips
:param proj_dir: absolute path of project dir
:param cfg_name: config name or pattern
:param target: optional target name (build all if None)
:returns: True if build was successful
"""
# prepare
dep.fetch_imports(fips_dir, proj_dir)
proj_name = util.get_project_name_from_dir(proj_dir)
util.ensure_valid_project_dir(proj_dir)
dep.gather_and_write_imports(fips_dir, proj_dir)
# load the config(s)
configs = config.load(fips_dir, proj_dir, cfg_name)
num_valid_configs = 0
if configs :
for cfg in configs :
# check if config is valid
config_valid, _ = config.check_config_valid(fips_dir, cfg, print_errors=True)
if config_valid :
log.colored(log.YELLOW, "=== building: {}".format(cfg['name']))
if not gen_project(fips_dir, proj_dir, cfg, False) :
log.error("Failed to generate '{}' of project '{}'".format(cfg['name'], proj_name))
# select and run build tool
build_dir = util.get_build_dir(fips_dir, proj_name, cfg)
num_jobs = settings.get(proj_dir, 'jobs')
result = False
if cfg['build_tool'] == make.name :
result = make.run_build(fips_dir, target, build_dir, num_jobs)
elif cfg['build_tool'] == ninja.name :
result = ninja.run_build(fips_dir, target, build_dir, num_jobs)
elif cfg['build_tool'] == xcodebuild.name :
result = xcodebuild.run_build(fips_dir, target, cfg['build_type'], build_dir, num_jobs)
else :
result = cmake.run_build(fips_dir, target, cfg['build_type'], build_dir)
if result :
num_valid_configs += 1
else :
log.error("Failed to build config '{}' of project '{}'".format(cfg['name'], proj_name))
else :
log.error("Config '{}' not valid in this environment".format(cfg['name']))
else :
log.error("No valid configs found for '{}'".format(cfg_name))
if num_valid_configs != len(configs) :
log.error('{} out of {} configs failed!'.format(len(configs) - num_valid_configs, len(configs)))
return False
else :
log.colored(log.GREEN, '{} configs built'.format(num_valid_configs))
return True
示例11: push
def push(proj_dir):
"""runs a 'git push' in the provided git repo
:param proj_dir: path to git repo
"""
check_exists_with_error()
try:
res = subprocess.check_call('git push', cwd=proj_dir, shell=True)
except subprocess.CalledProcessError as e:
log.error("'git push' failed with '{}'".format(e.returncode))
示例12: commit
def commit(proj_dir, msg):
"""runs a 'git commit -m msg' in the provided git repo
:param proj_dir: path to a git repo
"""
check_exists_with_error()
try:
subprocess.check_call('git commit -m "{}"'.format(msg), cwd=proj_dir, shell=True)
except subprocess.CalledProcessError as e:
log.error("'git commit' failed with '{}'".format(e.returncode))
示例13: run
def run(fips_dir, proj_dir, args) :
if len(args) > 0 :
if args[0] == 'build' :
build_deploy_webpage(fips_dir, proj_dir)
elif args[0] == 'serve' :
serve_webpage(fips_dir, proj_dir)
else :
log.error("Invalid param '{}', expected 'build' or 'serve'".format(args[0]))
else :
log.error("Param 'build' or 'serve' expected")
示例14: run
def run(fips_dir, proj_dir, args) :
"""build fips project"""
if not util.is_valid_project_dir(proj_dir) :
log.error('must be run in a project directory')
cfg_name = None
if len(args) > 0 :
cfg_name = args[0]
if not cfg_name :
cfg_name = settings.get(proj_dir, 'config')
project.build(fips_dir, proj_dir, cfg_name)
示例15: check_config_valid
def check_config_valid(fips_dir, proj_dir, cfg, print_errors=False) :
"""check if provided config is valid, and print errors if not
:param cfg: a loaded config object
:returns: (True, [ messages ]) tuple with result and error messages
"""
messages = []
valid = True
# check whether all required fields are present
# (NOTE: name and folder should always be present since they are appended
# during loading)
required_fields = ['name', 'folder', 'platform', 'generator', 'build_tool', 'build_type']
for field in required_fields :
if field not in cfg :
messages.append("missing field '{}' in '{}'".format(field, cfg['path']))
valid = False
# check if the target platform SDK is installed
if not check_sdk(fips_dir, cfg['platform']) :
messages.append("platform sdk for '{}' not installed (see './fips help setup')".format(cfg['platform']))
valid = False
# check if the generator name is valid
if not valid_generator(cfg['generator']) :
messages.append("invalid generator name '{}' in '{}'".format(cfg['generator'], cfg['path']))
valid = False
# check if build tool is valid
if not valid_build_tool(cfg['build_tool']) :
messages.append("invalid build_tool name '{}' in '{}'".format(cfg['build_tool'], cfg['path']))
valid = False
# check if the build tool can be found
if not check_build_tool(fips_dir, cfg['build_tool']) :
messages.append("build tool '{}' not found".format(cfg['build_tool']))
valid = False
# check if build type is valid (Debug, Release, Profiling)
if not valid_build_type(cfg['build_type']) :
messages.append("invalid build_type '{}' in '{}'".format(cfg['build_type'], cfg['path']))
valid = False
# check if the toolchain file can be found (if this is a crosscompiling toolchain)
if cfg['platform'] not in native_platforms :
toolchain_path = get_toolchain(fips_dir, proj_dir, cfg)
if not toolchain_path :
messages.append("toolchain file not found for config '{}'!".format(cfg['name']))
valid = False
if print_errors :
for msg in messages :
log.error(msg, False)
return (valid, messages)