本文整理汇总了Python中waflib.Logs类的典型用法代码示例。如果您正苦于以下问题:Python Logs类的具体用法?Python Logs怎么用?Python Logs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Logs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_link
def do_link(self, src, tgt):
"""
Create a symlink from tgt to src.
This method is overridden in :py:meth:`waflib.Build.UninstallContext.do_link` to remove the symlink.
:param src: file name as absolute path
:type src: string
:param tgt: file destination, as absolute path
:type tgt: string
"""
d, _ = os.path.split(tgt)
Utils.check_dir(d)
link = False
if not os.path.islink(tgt):
link = True
elif os.readlink(tgt) != src:
link = True
if link:
try: os.remove(tgt)
except OSError: pass
if not self.progress_bar:
Logs.info('+ symlink %s (to %s)' % (tgt, src))
os.symlink(src, tgt)
else:
if not self.progress_bar:
Logs.info('- symlink %s (to %s)' % (tgt, src))
示例2: env_path
def env_path(parent_dir_var,name):
parent=os.getenv(parent_dir_var)
if parent:
return os.path.join(parent,name)
else:
Logs.warn('Environment variable %s unset, using LIBDIR\n'%parent_dir_var)
return os.path.join(conf.env['LIBDIR'],name)
示例3: ant_glob
def ant_glob(self,*k,**kw):
if k:
lst=Utils.to_list(k[0])
for pat in lst:
if'..'in pat.split('/'):
Logs.error("In ant_glob pattern %r: '..' means 'two dots', not 'parent directory'"%k[0])
return old_ant_glob(self,*k,**kw)
示例4: runnable_status
def runnable_status(self):
for t in self.run_after:
if not t.hasrun:
return ASK_LATER
bld = self.generator.bld
try:
new_sig = self.signature()
except Errors.TaskNotReady:
return ASK_LATER
key = self.uid()
try:
prev_sig = bld.task_sigs[key]
except KeyError:
Logs.debug("task: task %r must run as it was never run before or the task code changed" % self)
return RUN_ME
for node in self.outputs:
try:
if node.sig != new_sig:
return RUN_ME
except AttributeError:
Logs.debug("task: task %r must run as the output nodes do not exist" % self)
return RUN_ME
if new_sig != prev_sig:
return RUN_ME
return SKIP_ME
示例5: clean
def clean(self):
"""
Remove most files from the build directory, and reset all caches.
Custom lists of files to clean can be declared as `bld.clean_files`.
For example, exclude `build/program/myprogram` from getting removed::
def build(bld):
bld.clean_files = bld.bldnode.ant_glob('**',
excl='.lock* config.log c4che/* config.h program/myprogram',
quiet=True, generator=True)
"""
Logs.debug('build: clean called')
if hasattr(self, 'clean_files'):
for n in self.clean_files:
n.delete()
elif self.bldnode != self.srcnode:
# would lead to a disaster if top == out
lst = []
for env in self.all_envs.values():
lst.extend(self.root.find_or_declare(f) for f in env[CFG_FILES])
for n in self.bldnode.ant_glob('**/*', excl='.lock* *conf_check_*/** config.log c4che/*', quiet=True):
if n in lst:
continue
n.delete()
self.root.children = {}
for v in SAVED_ATTRS:
if v == 'root':
continue
setattr(self, v, {})
示例6: distclean_dir
def distclean_dir(dirname):
"""
Distclean function called in the particular case when::
top == out
:param dirname: absolute path of the folder to clean
:type dirname: string
"""
for (root, dirs, files) in os.walk(dirname):
for f in files:
if _can_distclean(f):
fname = os.path.join(root, f)
try:
os.remove(fname)
except OSError:
Logs.warn('Could not remove %r' % fname)
for x in (Context.DBFILE, 'config.log'):
try:
os.remove(x)
except OSError:
pass
try:
shutil.rmtree('c4che')
except OSError:
pass
示例7: exec_command
def exec_command(self, cmd, **kw):
"""
execute a command, return the exit status
if the context has the attribute 'log', capture and log the process stderr/stdout
this method should be used whenever possible for proper logging
@param cmd: args for subprocess.Popen
@param kw: keyword arguments for subprocess.Popen
"""
subprocess = Utils.subprocess
kw['shell'] = isinstance(cmd, str)
Logs.debug('runner: %r' % cmd)
try:
if self.logger:
# warning: may deadlock with a lot of output (subprocess limitation)
self.logger.info(cmd)
kw['stdout'] = kw['stderr'] = subprocess.PIPE
p = subprocess.Popen(cmd, **kw)
(out, err) = p.communicate()
if out:
self.logger.debug('out: %s' % out.decode('utf-8'))
if err:
self.logger.error('err: %s' % err.decode('utf-8'))
return p.returncode
else:
p = subprocess.Popen(cmd, **kw)
return p.wait()
except OSError:
return -1
示例8: download_tool
def download_tool(tool,force=False,ctx=None):
for x in Utils.to_list(Context.remote_repo):
for sub in Utils.to_list(Context.remote_locs):
url='/'.join((x,sub,tool+'.py'))
try:
web=urlopen(url)
try:
if web.getcode()!=200:
continue
except AttributeError:
pass
except Exception:
continue
else:
tmp=ctx.root.make_node(os.sep.join((Context.waf_dir,'waflib','extras',tool+'.py')))
tmp.write(web.read(),'wb')
Logs.warn('Downloaded %s from %s'%(tool,url))
download_check(tmp)
try:
module=Context.load_tool(tool)
except Exception:
Logs.warn('The tool %s from %s is unusable'%(tool,url))
try:
tmp.delete()
except Exception:
pass
continue
return module
raise Errors.WafError('Could not load the Waf tool')
示例9: get_ccenv
def get_ccenv(fname):
'''Returns dictionary of variant C/C++ build environments. In which the keys
are the name of the actual variant C/C++ build environments and its values the
settings for that variant build environment.
:param fname: Complete path to the configuration file.
:type fname: str
'''
if not os.path.exists(fname):
Logs.warn("CCENV: ini file '%s' not found!" % fname)
ccenv = {}
c = configparser.ConfigParser()
c.read(fname)
for s in c.sections():
ccenv[s] = {'prefix' : None, 'shlib' : [], 'env' : [], 'c': ['gcc'], 'cxx': ['g++', 'cpp']}
if c.has_option(s, 'c'):
ccenv[s]['c'] = c.get(s,'c').split(',')
if c.has_option(s, 'cxx'):
ccenv[s]['cxx'] = c.get(s,'cxx').split(',')
if c.has_option(s, 'prefix'):
ccenv[s]['prefix'] = c.get(s,'prefix')
if c.has_option(s, 'shlib'):
ccenv[s]['shlib'] = [l for l in str(c.get(s,'shlib')).split(',') if len(l)]
if c.has_option(s, 'env'):
ccenv[s]['env'] = [l.split('\t') for l in c.get(s,'env').splitlines() if len(l)]
if c.has_option(s, 'host'):
ccenv[s]['host'] = c.get(s,'host')
return ccenv
示例10: distclean_dir
def distclean_dir(dirname):
"""
Distclean function called in the particular case when::
top == out
:param dirname: absolute path of the folder to clean
:type dirname: string
"""
for (root, dirs, files) in os.walk(dirname):
for f in files:
if _can_distclean(f):
fname = root + os.sep + f
try:
os.unlink(fname)
except:
Logs.warn('could not remove %r' % fname)
for x in [Context.DBFILE, 'config.log']:
try:
os.unlink(x)
except:
pass
try:
shutil.rmtree('c4che')
except:
pass
示例11: restore
def restore(self):
try:
env = ConfigSet.ConfigSet(os.path.join(self.cache_dir, "build.config.py"))
except (IOError, OSError):
pass
else:
if env["version"] < Context.HEXVERSION:
raise Errors.WafError("Version mismatch! reconfigure the project")
for t in env["tools"]:
self.setup(**t)
f = None
try:
try:
f = open(os.path.join(self.variant_dir, Context.DBFILE), "rb")
except (IOError, EOFError):
Logs.debug("build: could not load the build cache (missing)")
else:
try:
waflib.Node.pickle_lock.acquire()
waflib.Node.Nod3 = self.node_class
try:
data = cPickle.load(f)
except Exception, e:
Logs.debug("build: could not load the build cache %r" % e)
else:
for x in SAVED_ATTRS:
setattr(self, x, data[x])
示例12: build_version_files
def build_version_files(header_path, source_path, domain, major, minor, micro, exportname, visheader):
header_path = os.path.abspath(header_path)
source_path = os.path.abspath(source_path)
text = "int " + domain + "_major_version = " + str(major) + ";\n"
text += "int " + domain + "_minor_version = " + str(minor) + ";\n"
text += "int " + domain + "_micro_version = " + str(micro) + ";\n"
try:
o = open(source_path, 'w')
o.write(text)
o.close()
except IOError:
Logs.error('Failed to open %s for writing\n' % source_path)
sys.exit(-1)
text = "#ifndef __" + domain + "_version_h__\n"
text += "#define __" + domain + "_version_h__\n"
if visheader != '':
text += "#include \"" + visheader + "\"\n"
text += exportname + " extern const char* " + domain + "_revision;\n"
text += exportname + " extern int " + domain + "_major_version;\n"
text += exportname + " extern int " + domain + "_minor_version;\n"
text += exportname + " extern int " + domain + "_micro_version;\n"
text += "#endif /* __" + domain + "_version_h__ */\n"
try:
o = open(header_path, 'w')
o.write(text)
o.close()
except IOError:
Logs.warn('Failed to open %s for writing\n' % header_path)
sys.exit(-1)
return None
示例13: end_msg
def end_msg(self, *k, **kw):
"""Print the end of a 'Checking for' message. See :py:meth:`waflib.Context.Context.msg`"""
if kw.get('quiet', None):
return
self.in_msg -= 1
if self.in_msg:
return
result = kw.get('result', None) or k[0]
defcolor = 'GREEN'
if result == True:
msg = 'ok'
elif result == False:
msg = 'not found'
defcolor = 'YELLOW'
else:
msg = str(result)
self.to_log(msg)
try:
color = kw['color']
except KeyError:
if len(k) > 1 and k[1] in Logs.colors_lst:
# compatibility waf 1.7
color = k[1]
else:
color = defcolor
Logs.pprint(color, msg)
示例14: parse_node
def parse_node(node):
if node in seen:
return
seen.append(node)
code = node.read()
global re_tex
for match in re_tex.finditer(code):
for path in match.group('file').split(','):
if path:
add_name = True
found = None
for k in exts_deps_tex:
Logs.debug('tex: trying %s%s' % (path, k))
found = node.parent.find_resource(path + k)
for tsk in self.generator.tasks:
if not found or found in tsk.outputs:
break
else:
nodes.append(found)
add_name = False
for ext in exts_tex:
if found.name.endswith(ext):
parse_node(found)
break
# no break, people are crazy
if add_name:
names.append(path)
示例15: write_compilation_database
def write_compilation_database(ctx):
"Write the clang compilation database as JSON"
database_file = ctx.bldnode.make_node('compile_commands.json')
Logs.info('Build commands will be stored in %s', database_file.path_from(ctx.path))
try:
root = json.load(database_file)
except IOError:
root = []
clang_db = dict((x['file'], x) for x in root)
for task in getattr(ctx, 'clang_compilation_database_tasks', []):
try:
cmd = task.last_cmd
except AttributeError:
continue
directory = getattr(task, 'cwd', ctx.variant_dir)
f_node = task.inputs[0]
filename = os.path.relpath(f_node.abspath(), directory)
entry = {
"directory": directory,
"arguments": cmd,
"file": filename,
}
clang_db[filename] = entry
root = list(clang_db.values())
database_file.write(json.dumps(root, indent=2))