本文整理汇总了Python中waflib.Logs类的典型用法代码示例。如果您正苦于以下问题:Python Logs类的具体用法?Python Logs怎么用?Python Logs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Logs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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))
开发者ID:Anastasia1302,项目名称:code-pile,代码行数:29,代码来源:Build.py
示例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)
开发者ID:OpenDAWN,项目名称:Minaton,代码行数:7,代码来源:lv2.py
示例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)
开发者ID:swidge,项目名称:iPhoneGUITAR,代码行数:7,代码来源:errcheck.py
示例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
开发者ID:jgoppert,项目名称:mavsim,代码行数:25,代码来源:Task.py
示例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, {})
开发者ID:blablack,项目名称:ams-lv2,代码行数:32,代码来源:Build.py
示例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
开发者ID:XNerv,项目名称:waf,代码行数:28,代码来源:Scripting.py
示例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
开发者ID:RunarFreyr,项目名称:waz,代码行数:33,代码来源:Context.py
示例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')
开发者ID:AkiraShirase,项目名称:audacity,代码行数:29,代码来源:Configure.py
示例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
开发者ID:jameslin2014,项目名称:xskit,代码行数:28,代码来源:ccenv.py
示例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
开发者ID:CharString,项目名称:kupfer,代码行数:28,代码来源:Scripting.py
示例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])
开发者ID:asivakum,项目名称:EE563Project,代码行数:27,代码来源:Build.py
示例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
开发者ID:63n,项目名称:ardour,代码行数:32,代码来源:autowaf.py
示例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)
开发者ID:Jajcus,项目名称:jack2,代码行数:29,代码来源:Context.py
示例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)
开发者ID:Anastasia1302,项目名称:code-pile,代码行数:28,代码来源:tex.py
示例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))
开发者ID:afeldman,项目名称:waf,代码行数:25,代码来源:clang_compilation_database.py
示例16: load
def load(self,filename):
tbl=self.table
code=Utils.readf(filename,m='rU')
for m in re_imp.finditer(code):
g=m.group
tbl[g(2)]=eval(g(3))
Logs.debug('env: %s'%str(self.table))
开发者ID:DunamisEric,项目名称:RepSys_Manets_NS-3.17,代码行数:7,代码来源:ConfigSet.py
示例17: execute
def execute(self):
if not Configure.autoconfig:
return execute_method(self)
env = ConfigSet.ConfigSet()
do_config = False
try:
env.load(os.path.join(Context.top_dir, Options.lockfile))
except Exception:
Logs.warn('Configuring the project')
do_config = True
else:
if env.run_dir != Context.run_dir:
do_config = True
else:
h = 0
for f in env['files']:
h = Utils.h_list((h, Utils.readf(f, 'rb')))
do_config = h != env.hash
if do_config:
Options.commands.insert(0, self.cmd)
Options.commands.insert(0, 'configure')
if Configure.autoconfig == 'clobber':
Options.options.__dict__ = env.options
return
return execute_method(self)
开发者ID:XNerv,项目名称:waf,代码行数:28,代码来源:Scripting.py
示例18: start
def start(cwd, version, wafdir):
# simple example, the file main.c is hard-coded
try:
os.stat(cwd + os.sep + 'cbit')
except:
print('call from a folder containing a file named "cbit"')
sys.exit(1)
Logs.init_log()
Context.waf_dir = wafdir
Context.top_dir = Context.run_dir = cwd
Context.out_dir = os.path.join(cwd, 'build')
Context.g_module = imp.new_module('wscript')
Context.g_module.root_path = os.path.join(cwd, 'cbit')
Context.Context.recurse = recurse_rep
# this is a fake module, which looks like a standard wscript file
Context.g_module.options = options
Context.g_module.configure = configure
Context.g_module.build = build
Options.OptionsContext().execute()
do_config = 'configure' in sys.argv
try:
os.stat(cwd + os.sep + 'build')
except:
do_config = True
if do_config:
Context.create_context('configure').execute()
if 'clean' in sys.argv:
Context.create_context('clean').execute()
if 'build' in sys.argv:
Context.create_context('build').execute()
开发者ID:ArduPilot,项目名称:waf,代码行数:35,代码来源:cbdlib.py
示例19: cmd_and_log
def cmd_and_log(self, cmd, **kw):
"""
execute a command, return the stdout
this method should be used whenever possible for proper logging
to obtain stdout+stderr, pass output=BOTH in the arguments (or output=0)
to obtain just stderr, pass output=STDERR in the arguments (or output=-1)
@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)
if 'quiet' in kw:
quiet = kw['quiet']
del kw['quiet']
else:
quiet = None
if 'output' in kw:
to_ret = kw['output']
del kw['output']
else:
to_ret = STDOUT
kw['stdout'] = kw['stderr'] = subprocess.PIPE
if not quiet:
self.to_log(cmd)
try:
p = subprocess.Popen(cmd, **kw)
(out, err) = p.communicate()
except Exception as e:
try:
self.to_log(str(err))
except:
pass
raise Errors.WafError('Execution failure', ex=e)
if not isinstance(out, str):
out = out.decode('utf-8')
if not isinstance(err, str):
err = err.decode('utf-8')
if out and quiet != STDOUT and quiet != BOTH:
self.to_log('out: %s' % out)
if err and quiet != STDERR and quiet != BOTH:
self.to_log('err: %s' % err)
if p.returncode:
e = Errors.WafError('command %r returned %r' % (cmd, p.returncode))
e.returncode = p.returncode
raise e
if to_ret == BOTH:
return (out, err)
elif to_ret == STDERR:
return err
return out
开发者ID:RunarFreyr,项目名称:waz,代码行数:60,代码来源:Context.py
示例20: configure
def configure(conf):
areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
defaultFlags = []
defaultFlags += ['-pedantic', '-Wall', '-Wno-long-long']
if conf.options.debug:
conf.define('_DEBUG', 1)
defaultFlags += ['-O0',
'-Og', # gcc >= 4.8
'-g3',
'-fcolor-diagnostics', # clang
'-fdiagnostics-color', # gcc >= 4.9
'-Werror'
]
if areCustomCxxflagsPresent:
missingFlags = [x for x in defaultFlags if x not in conf.env.CXXFLAGS]
if len(missingFlags) > 0:
Logs.warn("Selected debug mode, but CXXFLAGS is set to a custom value '%s'"
% " ".join(conf.env.CXXFLAGS))
Logs.warn("Default flags '%s' are not activated" % " ".join(missingFlags))
else:
conf.add_supported_cxxflags(defaultFlags)
else:
defaultFlags += ['-O2', '-g']
if not areCustomCxxflagsPresent:
conf.add_supported_cxxflags(defaultFlags)
开发者ID:cawka,项目名称:py-ndn-cpp,代码行数:27,代码来源:default-compiler-flags.py
注:本文中的waflib.Logs类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论