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


Python Utils.to_hex方法代码示例

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


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

示例1: can_retrieve_cache

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import to_hex [as 别名]
 def can_retrieve_cache(self):
     if not getattr(self, "outputs", None):
         return None
     sig = self.signature()
     ssig = Utils.to_hex(self.uid()) + Utils.to_hex(sig)
     dname = os.path.join(self.generator.bld.cache_global, ssig)
     try:
         t1 = os.stat(dname).st_mtime
     except OSError:
         return None
     for node in self.outputs:
         orig = os.path.join(dname, node.name)
         try:
             shutil.copy2(orig, node.abspath())
             os.utime(orig, None)
         except (OSError, IOError):
             Logs.debug("task: failed retrieving file")
             return None
     try:
         t2 = os.stat(dname).st_mtime
     except OSError:
         return None
     if t1 != t2:
         return None
     for node in self.outputs:
         node.sig = sig
         if self.generator.bld.progress_bar < 1:
             self.generator.bld.to_log("restoring from cache %r\n" % node.abspath())
     self.cached = True
     return True
开发者ID:jgoppert,项目名称:mavsim,代码行数:32,代码来源:Task.py

示例2: put_files_cache

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import to_hex [as 别名]
 def put_files_cache(self):
     if getattr(self, "cached", None):
         return None
     sig = self.signature()
     ssig = Utils.to_hex(self.uid()) + Utils.to_hex(sig)
     dname = os.path.join(self.generator.bld.cache_global, ssig)
     tmpdir = tempfile.mkdtemp(prefix=self.generator.bld.cache_global + os.sep + "waf")
     try:
         shutil.rmtree(dname)
     except:
         pass
     try:
         for node in self.outputs:
             dest = os.path.join(tmpdir, node.name)
             shutil.copy2(node.abspath(), dest)
     except (OSError, IOError):
         try:
             shutil.rmtree(tmpdir)
         except:
             pass
     else:
         try:
             os.rename(tmpdir, dname)
         except OSError:
             try:
                 shutil.rmtree(tmpdir)
             except:
                 pass
         else:
             try:
                 os.chmod(dname, Utils.O755)
             except:
                 pass
开发者ID:jgoppert,项目名称:mavsim,代码行数:35,代码来源:Task.py

示例3: can_retrieve_cache

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import to_hex [as 别名]
	def can_retrieve_cache(self):
		"""
		Used by :py:meth:`waflib.Task.cache_outputs`

		Retrieve build nodes from the cache
		update the file timestamps to help cleaning the least used entries from the cache
		additionally, set an attribute 'cached' to avoid re-creating the same cache files

		Suppose there are files in `cache/dir1/file1` and `cache/dir2/file2`:

		#. read the timestamp of dir1
		#. try to copy the files
		#. look at the timestamp again, if it has changed, the data may have been corrupt (cache update by another process)
		#. should an exception occur, ignore the data
		"""

		if not getattr(self, 'outputs', None):
			return None

		sig = self.signature()
		ssig = Utils.to_hex(self.uid()) + Utils.to_hex(sig)

		# first try to access the cache folder for the task
		dname = os.path.join(self.generator.bld.cache_global, ssig)
		try:
			t1 = os.stat(dname).st_mtime
		except OSError:
			return None

		for node in self.outputs:
			orig = os.path.join(dname, node.name)
			try:
				shutil.copy2(orig, node.abspath())
				# mark the cache file as used recently (modified)
				os.utime(orig, None)
			except (OSError, IOError):
				Logs.debug('task: failed retrieving file')
				return None

		# is it the same folder?
		try:
			t2 = os.stat(dname).st_mtime
		except OSError:
			return None

		if t1 != t2:
			return None

		for node in self.outputs:
			node.sig = sig
			if self.generator.bld.progress_bar < 1:
				self.generator.bld.to_log('restoring from cache %r\n' % node.abspath())

		self.cached = True
		return True
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:57,代码来源:Task.py

示例4: put_files_cache

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import to_hex [as 别名]
def put_files_cache(self):
	if not Task.push_addr:
		return
	if not self.outputs:
		return
	if getattr(self, 'cached', None):
		return

	#print "called put_files_cache", id(self)
	bld = self.generator.bld
	sig = self.signature()
	ssig = Utils.to_hex(self.uid() + sig)

	conn = None
	cnt = 0
	try:
		for node in self.outputs:
			# We could re-create the signature of the task with the signature of the outputs
			# in practice, this means hashing the output files
			# this is unnecessary
			try:
				if not conn:
					conn = get_connection(push=True)
				sock_send(conn, ssig, cnt, node.abspath())
			except Exception as e:
				Logs.debug("netcache: could not push the files %r" % e)

				# broken connection? remove this one
				close_connection(conn)
				conn = None
			cnt += 1
	finally:
		release_connection(conn, push=True)

	bld.task_sigs[self.uid()] = self.cache_sig
开发者ID:DigitalDan05,项目名称:waf,代码行数:37,代码来源:netcache_client.py

示例5: rsync_and_ssh

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import to_hex [as 别名]
def rsync_and_ssh(task):

	# remove a warning
	task.uid_ = id(task)

	bld = task.generator.bld

	task.env.user, _, _ = task.env.login.partition('@')
	task.env.hdir = Utils.to_hex(Utils.h_list((task.generator.path.abspath(), task.env.variant)))
	task.env.remote_dir = '~%s/wafremote/%s' % (task.env.user, task.env.hdir)
	task.env.local_dir = bld.srcnode.abspath() + '/'

	task.env.remote_dir_variant = '%s/%s/%s' % (task.env.remote_dir, Context.g_module.out, task.env.variant)
	task.env.build_dir = bld.bldnode.abspath()

	ret = task.exec_command(bld.make_mkdir_command(task))
	if ret:
		return ret
	ret = task.exec_command(bld.make_send_command(task))
	if ret:
		return ret
	ret = task.exec_command(bld.make_exec_command(task))
	if ret:
		return ret
	ret = task.exec_command(bld.make_save_command(task))
	if ret:
		return ret
开发者ID:JodyGoldberg,项目名称:waf,代码行数:29,代码来源:remote.py

示例6: hash_env_vars

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import to_hex [as 别名]
	def hash_env_vars(self, env, vars_lst):
		"""
		Hashes configuration set variables::

			def build(bld):
				bld.hash_env_vars(bld.env, ['CXX', 'CC'])

		This method uses an internal cache.

		:param env: Configuration Set
		:type env: :py:class:`waflib.ConfigSet.ConfigSet`
		:param vars_lst: list of variables
		:type vars_list: list of string
		"""

		if not env.table:
			env = env.parent
			if not env:
				return Utils.SIG_NIL

		idx = str(id(env)) + str(vars_lst)
		try:
			cache = self.cache_env
		except AttributeError:
			cache = self.cache_env = {}
		else:
			try:
				return self.cache_env[idx]
			except KeyError:
				pass

		lst = [env[a] for a in vars_lst]
		cache[idx] = ret = Utils.h_list(lst)
		Logs.debug('envhash: %s %r', Utils.to_hex(ret), lst)
		return ret
开发者ID:blablack,项目名称:ams-lv2,代码行数:37,代码来源:Build.py

示例7: put_files_cache

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import to_hex [as 别名]
	def put_files_cache(self):
		"""
		Used by :py:func:`waflib.Task.cache_outputs` to store the build files in the cache
		"""

		# file caching, if possible
		# try to avoid data corruption as much as possible
		if getattr(self, 'cached', None):
			return None
		if not getattr(self, 'outputs', None):
			return None

		sig = self.signature()
		ssig = Utils.to_hex(self.uid()) + Utils.to_hex(sig)
		dname = os.path.join(self.generator.bld.cache_global, ssig)
		tmpdir = tempfile.mkdtemp(prefix=self.generator.bld.cache_global + os.sep + 'waf')

		try:
			shutil.rmtree(dname)
		except Exception:
			pass

		try:
			for node in self.outputs:
				dest = os.path.join(tmpdir, node.name)
				shutil.copy2(node.abspath(), dest)
		except (OSError, IOError):
			try:
				shutil.rmtree(tmpdir)
			except Exception:
				pass
		else:
			try:
				os.rename(tmpdir, dname)
			except OSError:
				try:
					shutil.rmtree(tmpdir)
				except Exception:
					pass
			else:
				try:
					os.chmod(dname, Utils.O755)
				except Exception:
					pass
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:46,代码来源:Task.py

示例8: run_c_code

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import to_hex [as 别名]
def run_c_code(self,*k,**kw):
	lst=[str(v)for(p,v)in kw.items()if p!='env']
	h=Utils.h_list(lst)
	dir=self.bldnode.abspath()+os.sep+(not Utils.is_win32 and'.'or'')+'conf_check_'+Utils.to_hex(h)
	try:
		os.makedirs(dir)
	except OSError:
		pass
	try:
		os.stat(dir)
	except OSError:
		self.fatal('cannot use the configuration test folder %r'%dir)
	cachemode=getattr(Options.options,'confcache',None)
	if cachemode==CACHE_RESULTS:
		try:
			proj=ConfigSet.ConfigSet(os.path.join(dir,'cache_run_c_code'))
		except OSError:
			pass
		else:
			ret=proj['cache_run_c_code']
			if isinstance(ret,str)and ret.startswith('Test does not build'):
				self.fatal(ret)
			return ret
	bdir=os.path.join(dir,'testbuild')
	if not os.path.exists(bdir):
		os.makedirs(bdir)
	self.test_bld=bld=Build.BuildContext(top_dir=dir,out_dir=bdir)
	bld.init_dirs()
	bld.progress_bar=0
	bld.targets='*'
	if kw['compile_filename']:
		node=bld.srcnode.make_node(kw['compile_filename'])
		node.write(kw['code'])
	bld.logger=self.logger
	bld.all_envs.update(self.all_envs)
	bld.env=kw['env']
	o=bld(features=kw['features'],source=kw['compile_filename'],target='testprog')
	for k,v in kw.items():
		setattr(o,k,v)
	if not kw.get('quiet',None):
		self.to_log("==>\n%s\n<=="%kw['code'])
	bld.targets='*'
	ret=-1
	try:
		try:
			bld.compile()
		except Errors.WafError:
			ret='Test does not build: %s'%Utils.ex_stack()
			self.fatal(ret)
		else:
			ret=getattr(bld,'retval',0)
	finally:
		proj=ConfigSet.ConfigSet()
		proj['cache_run_c_code']=ret
		proj.store(os.path.join(dir,'cache_run_c_code'))
	return ret
开发者ID:WU-ARL,项目名称:ndn-ops,代码行数:58,代码来源:c_config.py

示例9: run_build

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import to_hex [as 别名]
def run_build(self,*k,**kw):
	lst=[str(v)for(p,v)in kw.items()if p!='env']
	h=Utils.h_list(lst)
	dir=self.bldnode.abspath()+os.sep+(not Utils.is_win32 and'.'or'')+'conf_check_'+Utils.to_hex(h)
	try:
		os.makedirs(dir)
	except OSError:
		pass
	try:
		os.stat(dir)
	except OSError:
		self.fatal('cannot use the configuration test folder %r'%dir)
	cachemode=getattr(Options.options,'confcache',None)
	if cachemode==1:
		try:
			proj=ConfigSet.ConfigSet(os.path.join(dir,'cache_run_build'))
		except OSError:
			pass
		except IOError:
			pass
		else:
			ret=proj['cache_run_build']
			if isinstance(ret,str)and ret.startswith('Test does not build'):
				self.fatal(ret)
			return ret
	bdir=os.path.join(dir,'testbuild')
	if not os.path.exists(bdir):
		os.makedirs(bdir)
	self.test_bld=bld=Build.BuildContext(top_dir=dir,out_dir=bdir)
	bld.init_dirs()
	bld.progress_bar=0
	bld.targets='*'
	bld.logger=self.logger
	bld.all_envs.update(self.all_envs)
	bld.env=kw['env']
	bld.kw=kw
	bld.conf=self
	kw['build_fun'](bld)
	ret=-1
	try:
		try:
			bld.compile()
		except Errors.WafError:
			ret='Test does not build: %s'%Utils.ex_stack()
			self.fatal(ret)
		else:
			ret=getattr(bld,'retval',0)
	finally:
		if cachemode==1:
			proj=ConfigSet.ConfigSet()
			proj['cache_run_build']=ret
			proj.store(os.path.join(dir,'cache_run_build'))
		else:
			shutil.rmtree(dir)
	return ret
开发者ID:raystubbs,项目名称:NMSU-BigData-REU-NDN-Access-Control-Simulation,代码行数:57,代码来源:Configure.py

示例10: run

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import to_hex [as 别名]
	def run(self):
		for x in self.inputs:
			cmd = Utils.to_list(self.env.AR) + ["x", x.abspath() ]

			ar_dir_basename = x.name.replace(".a", "_a")
			ar_dir = self.generator.path.get_bld().make_node(ar_dir_basename)
			print(ar_dir.abspath())
			try:
				ar_dir.delete()
			except:
				pass
			ar_dir.mkdir()
			d = ar_dir.abspath()

			self.exec_command(cmd, cwd=d)

			bdir = self.generator.path.get_bld()

			nodes = []
			for _cwd, _dirs, _files in Node.os.walk(d):
				for f in _files:
					dirname = Node.os.path.basename(_cwd)
					filename = Node.os.path.join(_cwd, f)
					h = Utils.h_file(filename)
					new_filename = Node.os.path.join(
					 _cwd,
					 "%s-%s-%s" % (dirname, Utils.to_hex(h), f))

					rd = Node.os.path.relpath(new_filename, bdir.abspath())
					Node.os.rename(filename, new_filename)
					n = bdir.find_node(rd)
					n.sig = h

					# cache outputs for future runs
					try:
						self.generator.bld.pouet[self.uid()].append(n.bldpath())
					except:
						self.generator.bld.pouet[self.uid()] = [n.bldpath()]

					self.generator.add_those_o_files(n)
					nodes.append(n)

			try:
				link = self.generator.link_task
				link.inputs += nodes
				link.inputs.sort(key=lambda x: x.abspath())
			except:
				pass
开发者ID:waf-extras,项目名称:waf-extras,代码行数:50,代码来源:unpack_a.py

示例11: run_c_code

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import to_hex [as 别名]
def run_c_code(self, *k, **kw):
	lst = [str(v) for (p, v) in kw.items() if p != 'env']
	h = Utils.h_list(lst)
	dir = self.bldnode.abspath() + os.sep + '.conf_check_' + Utils.to_hex(h)

	try:
		os.makedirs(dir)
	except:
		pass

	try:
		os.stat(dir)
	except:
		self.fatal('cannot use the configuration test folder %r' % dir)

	bdir = os.path.join(dir, 'testbuild')

	if not os.path.exists(bdir):
		os.makedirs(bdir)

	self.test_bld = bld = Build.BuildContext(top_dir=dir, out_dir=bdir) # keep the temporary build context on an attribute for debugging
	bld.load() # configuration test cache
	bld.targets = '*'

	if kw['compile_filename']:
		node = bld.srcnode.make_node(kw['compile_filename'])
		node.write(kw['code'])

	bld.logger = self.logger
	bld.all_envs.update(self.all_envs)
	bld.all_envs['default'] = kw['env']

	o = bld(features=kw['features'], source=kw['compile_filename'], target='testprog')

	for k, v in kw.items():
		setattr(o, k, v)

	self.to_log("==>\n%s\n<==" % kw['code'])

	# compile the program
	bld.targets = '*'
	try:
		bld.compile()
	except Errors.WafError:
		self.fatal('Test does not build: %s' % Utils.ex_stack())

	return getattr(bld, 'retval', 0)
开发者ID:zsx,项目名称:waf,代码行数:49,代码来源:c_config.py

示例12: hash_env_vars

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import to_hex [as 别名]
	def hash_env_vars(self,env,vars_lst):
		if not env.table:
			env=env.parent
			if not env:
				return Utils.SIG_NIL
		idx=str(id(env))+str(vars_lst)
		try:
			cache=self.cache_env
		except AttributeError:
			cache=self.cache_env={}
		else:
			try:
				return self.cache_env[idx]
			except KeyError:
				pass
		lst=[env[a]for a in vars_lst]
		cache[idx]=ret=Utils.h_list(lst)
		Logs.debug('envhash: %s %r',Utils.to_hex(ret),lst)
		return ret
开发者ID:Gnurou,项目名称:glmark2,代码行数:21,代码来源:Build.py

示例13: can_retrieve_cache

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import to_hex [as 别名]
def can_retrieve_cache(self):
	if not Task.pull_addr:
		return False
	if not self.outputs:
		return False
	self.cached = False

	cnt = 0
	sig = self.signature()
	ssig = Utils.to_hex(self.uid() + sig)

	conn = None
	err = False
	try:
		try:
			conn = get_connection()
			for node in self.outputs:
				p = node.abspath()
				recv_file(conn, ssig, cnt, p)
				cnt += 1
		except MissingFile as e:
			Logs.debug('netcache: file is not in the cache %r' % e)
			err = True

		except Exception as e:
			Logs.debug('netcache: could not get the files %r' % e)
			err = True

			# broken connection? remove this one
			close_connection(conn)
			conn = None
	finally:
		release_connection(conn)
	if err:
		return False

	for node in self.outputs:
		node.sig = sig
		#if self.generator.bld.progress_bar < 1:
		#	self.generator.bld.to_log('restoring from cache %r\n' % node.abspath())

	self.cached = True
	return True
开发者ID:DigitalDan05,项目名称:waf,代码行数:45,代码来源:netcache_client.py

示例14: can_retrieve_cache

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import to_hex [as 别名]
def can_retrieve_cache(self):
    if not Task.pull_addr:
        return False
    if not self.outputs:
        return False
    self.cached = False

    cnt = 0
    sig = self.signature()
    ssig = Utils.to_hex(self.uid() + sig)

    conn = None
    err = False
    try:
        try:
            conn = get_connection()
            for node in self.outputs:
                p = node.abspath()
                recv_file(conn, ssig, cnt, p)
                cnt += 1
            else:
                Logs.debug("netcache: obtained %r from cache", self.outputs)
        except MissingFile as e:
            Logs.debug("netcache: file is not in the cache %r", e)
            err = True

        except Exception as e:
            Logs.debug("netcache: could not get the files %r", self.outputs)
            if Logs.verbose > 1:
                Logs.debug("netcache: exception %r", e)
            err = True

            # broken connection? remove this one
            close_connection(conn)
            conn = None
    finally:
        release_connection(conn)
    if err:
        return False

    self.cached = True
    return True
开发者ID:thmo,项目名称:waf,代码行数:44,代码来源:netcache_client.py

示例15: scan

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import to_hex [as 别名]
    def scan(self):
        env = self.env
        gen = self.generator
        bld = gen.bld
        zpy = bld.zpy
        out = self.outputs[0].parent
        sig = Utils.to_hex(
            (self.inputs and getattr(self.inputs[0], 'sig', None))
            or getattr(out, 'sig', None)
            or Utils.md5(self.dist.name_and_version).digest()
            )

        deps = ([], [])

        #self.signode = out.make_node(sig)
        self.signode = bld.bldnode.make_node(
            str('.%s.%s' % (out.name, sig)),
            )
        self.signode.mkdir()
        #deps[0].append(self.signode)

        return deps
开发者ID:anthonyrisinger,项目名称:zippy,代码行数:24,代码来源:task.py


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