当前位置: 首页>>代码示例>>Python>>正文


Python Utils.writef方法代码示例

本文整理汇总了Python中waflib.Utils.writef方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.writef方法的具体用法?Python Utils.writef怎么用?Python Utils.writef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在waflib.Utils的用法示例。


在下文中一共展示了Utils.writef方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_java_class

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import writef [as 别名]
def check_java_class(self, classname, with_classpath=None):
	"""
	Checks if the specified java class exists

	:param classname: class to check, like java.util.HashMap
	:type classname: string
	:param with_classpath: additional classpath to give
	:type with_classpath: string
	"""
	javatestdir = '.waf-javatest'

	classpath = javatestdir
	if self.env.CLASSPATH:
		classpath += os.pathsep + self.env.CLASSPATH
	if isinstance(with_classpath, str):
		classpath += os.pathsep + with_classpath

	shutil.rmtree(javatestdir, True)
	os.mkdir(javatestdir)

	Utils.writef(os.path.join(javatestdir, 'Test.java'), class_check_source)

	# Compile the source
	self.exec_command(self.env.JAVAC + [os.path.join(javatestdir, 'Test.java')], shell=False)

	# Try to run the app
	cmd = self.env.JAVA + ['-cp', classpath, 'Test', classname]
	self.to_log("%s\n" % str(cmd))
	found = self.exec_command(cmd, shell=False)

	self.msg('Checking for java class %s' % classname, not found)

	shutil.rmtree(javatestdir, True)

	return found
开发者ID:afeldman,项目名称:waf,代码行数:37,代码来源:javaw.py

示例2: store

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import writef [as 别名]
	def store(self, filename):
		"""
		Write the :py:class:`ConfigSet` data into a file. See :py:meth:`ConfigSet.load` for reading such files.

		:param filename: file to use
		:type filename: string
		"""
		try:
			os.makedirs(os.path.split(filename)[0])
		except OSError:
			pass

		buf = []
		merged_table = self.get_merged_dict()
		keys = list(merged_table.keys())
		keys.sort()

		try:
			fun = ascii
		except NameError:
			fun = repr

		for k in keys:
			if k != 'undo_stack':
				buf.append('%s = %s\n' % (k, fun(merged_table[k])))
		Utils.writef(filename, ''.join(buf))
开发者ID:DigitalDan05,项目名称:waf,代码行数:28,代码来源:ConfigSet.py

示例3: store

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import writef [as 别名]
	def store(self):
		"""
		Store data for next runs, set the attributes listed in :py:const:`waflib.Build.SAVED_ATTRS`. Uses a temporary
		file to avoid problems on ctrl+c.
		"""
		data = {}
		for x in SAVED_ATTRS:
			data[x] = getattr(self, x)
		db = os.path.join(self.variant_dir, Context.DBFILE)

		try:
			Node.pickle_lock.acquire()
			Node.Nod3 = self.node_class
			x = cPickle.dumps(data, PROTOCOL)
		finally:
			Node.pickle_lock.release()

		Utils.writef(db + '.tmp', x, m='wb')

		try:
			st = os.stat(db)
			os.remove(db)
			if not Utils.is_win32: # win32 has no chown but we're paranoid
				os.chown(db + '.tmp', st.st_uid, st.st_gid)
		except (AttributeError, OSError):
			pass

		# do not use shutil.move (copy is not thread-safe)
		os.rename(db + '.tmp', db)
开发者ID:blablack,项目名称:ams-lv2,代码行数:31,代码来源:Build.py

示例4: store_pickle

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import writef [as 别名]
 def store_pickle(self, filename):
     dirname, basename = os.path.split(filename)
     if basename == Options.lockfile:
         return store_orig(self, filename)
     Utils.check_dir(dirname)
     table = sorted(
             kv
             for kv in self.get_merged_dict().iteritems()
                 if kv[0] != 'undo_stack'
             )
     Utils.writef(filename, pickle.dumps(table, 2), m='wb')
开发者ID:anthonyrisinger,项目名称:zippy,代码行数:13,代码来源:configset.py

示例5: store

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import writef [as 别名]
	def store(self,filename):
		try:
			os.makedirs(os.path.split(filename)[0])
		except OSError:
			pass
		buf=[]
		merged_table=self.get_merged_dict()
		keys=list(merged_table.keys())
		keys.sort()
		for k in keys:
			if k!='undo_stack':
				buf.append('%s = %r\n'%(k,merged_table[k]))
		Utils.writef(filename,''.join(buf))
开发者ID:DunamisEric,项目名称:RepSys_Manets_NS-3.17,代码行数:15,代码来源:ConfigSet.py

示例6: write

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import writef [as 别名]
	def write(self, data, flags='w', encoding='ISO8859-1'):
		"""
		Writes data to the file represented by this node, see :py:func:`waflib.Utils.writef`::

			def build(bld):
				bld.path.make_node('foo.txt').write('Hello, world!')

		:param data: data to write
		:type  data: string
		:param flags: Write mode
		:type  flags: string
		:param encoding: encoding value for Python3
		:type encoding: string
		"""
		Utils.writef(self.abspath(), data, flags, encoding)
开发者ID:Tiksagol,项目名称:waf,代码行数:17,代码来源:Node.py

示例7: check_java_class

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import writef [as 别名]
def check_java_class(self,classname,with_classpath=None):
	javatestdir='.waf-javatest'
	classpath=javatestdir
	if self.env['CLASSPATH']:
		classpath+=os.pathsep+self.env['CLASSPATH']
	if isinstance(with_classpath,str):
		classpath+=os.pathsep+with_classpath
	shutil.rmtree(javatestdir,True)
	os.mkdir(javatestdir)
	Utils.writef(os.path.join(javatestdir,'Test.java'),class_check_source)
	self.exec_command(self.env['JAVAC']+[os.path.join(javatestdir,'Test.java')],shell=False)
	cmd=self.env['JAVA']+['-cp',classpath,'Test',classname]
	self.to_log("%s\n"%str(cmd))
	found=self.exec_command(cmd,shell=False)
	self.msg('Checking for java class %s'%classname,not found)
	shutil.rmtree(javatestdir,True)
	return found
开发者ID:PseudoSky,项目名称:voodoo,代码行数:19,代码来源:javaw.py

示例8: check_java_class

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import writef [as 别名]
def check_java_class(self, classname, with_classpath=None):
    javatestdir = ".waf-javatest"
    classpath = javatestdir
    if self.env["CLASSPATH"]:
        classpath += os.pathsep + self.env["CLASSPATH"]
    if isinstance(with_classpath, str):
        classpath += os.pathsep + with_classpath
    shutil.rmtree(javatestdir, True)
    os.mkdir(javatestdir)
    Utils.writef(os.path.join(javatestdir, "Test.java"), class_check_source)
    self.exec_command(self.env["JAVAC"] + [os.path.join(javatestdir, "Test.java")], shell=False)
    cmd = self.env["JAVA"] + ["-cp", classpath, "Test", classname]
    self.to_log("%s\n" % str(cmd))
    found = self.exec_command(cmd, shell=False)
    self.msg("Checking for java class %s" % classname, not found)
    shutil.rmtree(javatestdir, True)
    return found
开发者ID:raahilshah,项目名称:MSMPTCP,代码行数:19,代码来源:javaw.py

示例9: store

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import writef [as 别名]
 def store(self, filename):
     try:
         os.makedirs(os.path.split(filename)[0])
     except OSError:
         pass
     buf = []
     merged_table = self.get_merged_dict()
     keys = list(merged_table.keys())
     keys.sort()
     try:
         fun = ascii
     except NameError:
         fun = repr
     for k in keys:
         if k != "undo_stack":
             buf.append("%s = %s\n" % (k, fun(merged_table[k])))
     Utils.writef(filename, "".join(buf))
开发者ID:hlyes,项目名称:ns-3-dev,代码行数:19,代码来源:ConfigSet.py

示例10: store

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import writef [as 别名]
	def store(self):
		data={}
		for x in SAVED_ATTRS:
			data[x]=getattr(self,x)
		db=os.path.join(self.variant_dir,Context.DBFILE)
		try:
			Node.pickle_lock.acquire()
			Node.Nod3=self.node_class
			x=cPickle.dumps(data,PROTOCOL)
		finally:
			Node.pickle_lock.release()
		Utils.writef(db+'.tmp',x,m='wb')
		try:
			st=os.stat(db)
			os.remove(db)
			if not Utils.is_win32:
				os.chown(db+'.tmp',st.st_uid,st.st_gid)
		except(AttributeError,OSError):
			pass
		os.rename(db+'.tmp',db)
开发者ID:Gnurou,项目名称:glmark2,代码行数:22,代码来源:Build.py

示例11: setup_private_ssh_key

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import writef [as 别名]
	def setup_private_ssh_key(self):
		"""
		When WAF_SSH_KEY points to a private key, a .ssh directory will be created in the build directory
		Make sure that the ssh key does not prompt for a password
		"""
		key = os.environ.get('WAF_SSH_KEY', '')
		if not key:
			return
		if not os.path.isfile(key):
			self.fatal('Key in WAF_SSH_KEY must point to a valid file')
		self.ssh_dir = os.path.join(self.path.abspath(), 'build', '.ssh')
		self.ssh_hosts = os.path.join(self.ssh_dir, 'known_hosts')
		self.ssh_key = os.path.join(self.ssh_dir, os.path.basename(key))
		self.ssh_config = os.path.join(self.ssh_dir, 'config')
		for x in self.ssh_hosts, self.ssh_key, self.ssh_config:
			if not os.path.isfile(x):
				if not os.path.isdir(self.ssh_dir):
					os.makedirs(self.ssh_dir)
				Utils.writef(self.ssh_key, Utils.readf(key), 'wb')
				os.chmod(self.ssh_key, 448)

				Utils.writef(self.ssh_hosts, '\n'.join(self.get_ssh_hosts()))
				os.chmod(self.ssh_key, 448)

				Utils.writef(self.ssh_config, 'UserKnownHostsFile %s' % self.ssh_hosts, 'wb')
				os.chmod(self.ssh_config, 448)
		self.env.SSH_OPTS = ['-F', self.ssh_config, '-i', self.ssh_key]
		self.env.append_value('RSYNC_SEND_OPTS', '--exclude=build/.ssh')
开发者ID:JodyGoldberg,项目名称:waf,代码行数:30,代码来源:remote.py

示例12: store

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import writef [as 别名]
	def store(self):
		data = {}
		for x in Build.SAVED_ATTRS:
			data[x] = getattr(self, x)
		db = os.path.join(self.variant_dir, Context.DBFILE + self.store_key)

		try:
			waflib.Node.pickle_lock.acquire()
			waflib.Node.Nod3 = self.node_class
			x = Build.cPickle.dumps(data, Build.PROTOCOL)
		finally:
			waflib.Node.pickle_lock.release()

		Logs.debug('rev_use: storing %s', db)
		Utils.writef(db + '.tmp', x, m='wb')
		try:
			st = os.stat(db)
			os.remove(db)
			if not Utils.is_win32:
				os.chown(db + '.tmp', st.st_uid, st.st_gid)
		except (AttributeError, OSError):
			pass
		os.rename(db + '.tmp', db)
开发者ID:ventosus,项目名称:lv2,代码行数:25,代码来源:fast_partial.py

示例13: exec_command

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import writef [as 别名]
	def exec_command(self, cmd, **kw):
		Logs.debug('runner: %r', cmd)
		if getattr(Options.options, 'dump_test_scripts', False):
			script_code = SCRIPT_TEMPLATE % {
				'python': sys.executable,
				'env': self.get_test_env(),
				'cwd': self.get_cwd().abspath(),
				'cmd': cmd
			}
			script_file = self.inputs[0].abspath() + '_run.py'
			Utils.writef(script_file, script_code)
			os.chmod(script_file, Utils.O755)
			if Logs.verbose > 1:
				Logs.info('Test debug file written as %r' % script_file)

		proc = Utils.subprocess.Popen(cmd, cwd=self.get_cwd().abspath(), env=self.get_test_env(),
			stderr=Utils.subprocess.PIPE, stdout=Utils.subprocess.PIPE, shell=isinstance(cmd,str))
		(stdout, stderr) = proc.communicate()
		self.waf_unit_test_results = tup = (self.inputs[0].abspath(), proc.returncode, stdout, stderr)
		testlock.acquire()
		try:
			return self.generator.add_test_results(tup)
		finally:
			testlock.release()
开发者ID:blablack,项目名称:ams-lv2,代码行数:26,代码来源:waf_unit_test.py

示例14: write

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import writef [as 别名]
	def write(self,data,flags='w',encoding='ISO8859-1'):
		Utils.writef(self.abspath(),data,flags,encoding)
开发者ID:DunamisEric,项目名称:RepSys_Manets_NS-3.17,代码行数:4,代码来源:Node.py

示例15: write

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import writef [as 别名]
 def write(self, data, flags="w", encoding="ISO8859-1"):
     Utils.writef(self.abspath(), data, flags, encoding)
开发者ID:utctao,项目名称:reliable-slam,代码行数:4,代码来源:Node.py


注:本文中的waflib.Utils.writef方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。