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


Python Utils.check_dir方法代码示例

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


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

示例1: configure_paths

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import check_dir [as 别名]
def configure_paths(ctx):
    """Setup blender paths"""
    # Get the username
    user = getuser()
    _platform = Utils.unversioned_sys_platform()
    config_path = {"user": "", "system": ""}
    if _platform.startswith("linux"):
        config_path["user"] = "/home/%s/.config/blender/" % user
        config_path["system"] = "/usr/share/blender/"
    elif _platform == "darwin":
        # MAC OS X
        config_path["user"] = "/Users/%s/Library/Application Support/Blender/" % user
        config_path["system"] = "/Library/Application Support/Blender/"
    elif Utils.is_win32:
        # Windows
        appdata_path = ctx.getenv("APPDATA").replace("\\", "/")
        homedrive = ctx.getenv("HOMEDRIVE").replace("\\", "/")

        config_path["user"] = "%s/Blender Foundation/Blender/" % appdata_path
        config_path["system"] = "%sAll Users/AppData/Roaming/Blender Foundation/Blender/" % homedrive
    else:
        ctx.fatal("Unsupported platform. " "Available platforms: Linux, OSX, MS-Windows.")

    blender_version = ctx.env["BLENDER_VERSION"]

    config_path["user"] += blender_version + "/"
    config_path["system"] += blender_version + "/"

    ctx.env["BLENDER_CONFIG_DIR"] = os.path.abspath(config_path["user"])
    if ctx.options.directory_system:
        ctx.env["BLENDER_CONFIG_DIR"] = config_path["system"]

    ctx.env["BLENDER_ADDONS_DIR"] = os.path.join(ctx.env["BLENDER_CONFIG_DIR"], "scripts/addons")
    Utils.check_dir(ctx.env["BLENDER_ADDONS_DIR"])
开发者ID:eriser,项目名称:alta,代码行数:36,代码来源:blender.py

示例2: do_install

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import check_dir [as 别名]
	def do_install(self,src,tgt,chmod=Utils.O644):
		d,_=os.path.split(tgt)
		Utils.check_dir(d)
		srclbl=src.replace(self.srcnode.abspath()+os.sep,'')
		if not Options.options.force:
			try:
				st1=os.stat(tgt)
				st2=os.stat(src)
			except OSError:
				pass
			else:
				if st1.st_mtime>=st2.st_mtime and st1.st_size==st2.st_size:
					Logs.info('- install %s (from %s)'%(tgt,srclbl))
					return False
		Logs.info('+ install %s (from %s)'%(tgt,srclbl))
		try:
			os.remove(tgt)
		except OSError:
			pass
		try:
			shutil.copy2(src,tgt)
			os.chmod(tgt,chmod)
		except IOError:
			try:
				os.stat(src)
			except(OSError,IOError):
				Logs.error('File %r does not exist'%src)
			raise Errors.WafError('Could not install the file %r'%tgt)
开发者ID:RunarFreyr,项目名称:waz,代码行数:30,代码来源:Build.py

示例3: do_install

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import check_dir [as 别名]
	def do_install(self,src,tgt,**kw):
		d,_=os.path.split(tgt)
		if not d:
			raise Errors.WafError('Invalid installation given %r->%r'%(src,tgt))
		Utils.check_dir(d)
		srclbl=src.replace(self.srcnode.abspath()+os.sep,'')
		if not Options.options.force:
			try:
				st1=os.stat(tgt)
				st2=os.stat(src)
			except OSError:
				pass
			else:
				if st1.st_mtime+2>=st2.st_mtime and st1.st_size==st2.st_size:
					if not self.progress_bar:
						Logs.info('- install %s (from %s)'%(tgt,srclbl))
					return False
		if not self.progress_bar:
			Logs.info('+ install %s (from %s)'%(tgt,srclbl))
		try:
			os.chmod(tgt,Utils.O644|stat.S_IMODE(os.stat(tgt).st_mode))
		except EnvironmentError:
			pass
		try:
			os.remove(tgt)
		except OSError:
			pass
		try:
			self.copy_fun(src,tgt,**kw)
		except IOError:
			try:
				os.stat(src)
			except EnvironmentError:
				Logs.error('File %r does not exist'%src)
			raise Errors.WafError('Could not install the file %r'%tgt)
开发者ID:guysherman,项目名称:basic-cpp-template,代码行数:37,代码来源:Build.py

示例4: do_link

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import check_dir [as 别名]
	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,代码行数:31,代码来源:Build.py

示例5: do_install

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import check_dir [as 别名]
 def do_install(self, src, tgt, chmod=Utils.O644):
     d, _ = os.path.split(tgt)
     if not d:
         raise Errors.WafError("Invalid installation given %r->%r" % (src, tgt))
     Utils.check_dir(d)
     srclbl = src.replace(self.srcnode.abspath() + os.sep, "")
     if not Options.options.force:
         try:
             st1 = os.stat(tgt)
             st2 = os.stat(src)
         except OSError:
             pass
         else:
             if st1.st_mtime >= st2.st_mtime and st1.st_size == st2.st_size:
                 if not self.progress_bar:
                     Logs.info("- install %s (from %s)" % (tgt, srclbl))
                 return False
     if not self.progress_bar:
         Logs.info("+ install %s (from %s)" % (tgt, srclbl))
     try:
         os.remove(tgt)
     except OSError:
         pass
     try:
         shutil.copy2(src, tgt)
         os.chmod(tgt, chmod)
     except IOError:
         try:
             os.stat(src)
         except (OSError, IOError):
             Logs.error("File %r does not exist" % src)
         raise Errors.WafError("Could not install the file %r" % tgt)
开发者ID:asivakum,项目名称:EE563Project,代码行数:34,代码来源:Build.py

示例6: do_install

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import check_dir [as 别名]
	def do_install(self, src, tgt, **kw):
		"""
		Copy a file from src to tgt with given file permissions. The actual copy is not performed
		if the source and target file have the same size and the same timestamps. When the copy occurs,
		the file is first removed and then copied (prevent stale inodes).

		This method is overridden in :py:meth:`waflib.Build.UninstallContext.do_install` to remove the file.

		:param src: file name as absolute path
		:type src: string
		:param tgt: file destination, as absolute path
		:type tgt: string
		:param chmod: installation mode
		:type chmod: int
		"""
		d, _ = os.path.split(tgt)
		if not d:
			raise Errors.WafError('Invalid installation given %r->%r' % (src, tgt))
		Utils.check_dir(d)

		srclbl = src.replace(self.srcnode.abspath() + os.sep, '')
		if not Options.options.force:
			# check if the file is already there to avoid a copy
			try:
				st1 = os.stat(tgt)
				st2 = os.stat(src)
			except OSError:
				pass
			else:
				# same size and identical timestamps -> make no copy
				if st1.st_mtime + 2 >= st2.st_mtime and st1.st_size == st2.st_size:
					if not self.progress_bar:
						Logs.info('- install %s (from %s)' % (tgt, srclbl))
					return False

		if not self.progress_bar:
			Logs.info('+ install %s (from %s)' % (tgt, srclbl))

		# Give best attempt at making destination overwritable,
		# like the 'install' utility used by 'make install' does.
		try:
			os.chmod(tgt, Utils.O644 | stat.S_IMODE(os.stat(tgt).st_mode))
		except EnvironmentError:
			pass

		# following is for shared libs and stale inodes (-_-)
		try:
			os.remove(tgt)
		except OSError:
			pass

		try:
			self.copy_fun(src, tgt, **kw)
		except IOError:
			try:
				os.stat(src)
			except EnvironmentError:
				Logs.error('File %r does not exist' % src)
			raise Errors.WafError('Could not install the file %r' % tgt)
开发者ID:kenmasumitsu,项目名称:waf,代码行数:61,代码来源:Build.py

示例7: exec_install_files

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import check_dir [as 别名]
	def exec_install_files(self):
		destpath=self.get_install_path()
		for x,y in zip(self.source,self.inputs):
			if self.relative_trick:
				destfile=os.path.join(destpath,y.path_from(self.path))
				Utils.check_dir(os.path.dirname(destfile))
			else:
				destfile=os.path.join(destpath,y.name)
			self.generator.bld.do_install(y.abspath(),destfile,self.chmod)
开发者ID:RunarFreyr,项目名称:waz,代码行数:11,代码来源:Build.py

示例8: exec_install_files

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import check_dir [as 别名]
	def exec_install_files(self):
		"""predefined method for installing files"""
		destpath = self.get_install_path()
		for x, y in zip(self.source, self.inputs):
			if self.relative_trick:
				destfile = os.path.join(destpath, x)
				Utils.check_dir(os.path.dirname(destfile))
			else:
				destfile = os.path.join(destpath, y.name)
			self.generator.bld.do_install(y.abspath(), destfile, self.chmod)
开发者ID:zsx,项目名称:waf,代码行数:12,代码来源:Build.py

示例9: configure

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import check_dir [as 别名]
def configure(conf):
    """
    The configure function for the bundle dependency tool
    :param conf: the configuration context
    """
    conf.load('wurf_dependency_resolve')

    # Get the path where the bundled dependencies should be
    # placed
    bundle_path = expand_path(conf.options.bundle_path)

    # List all the dependencies to be bundled
    bundle_list = expand_bundle(conf, conf.options.bundle)

    # List all the dependencies with an explicit path
    explicit_list = explicit_dependencies(conf.options)

    # Make sure that no dependencies were both explicitly specified
    # and specified as bundled
    overlap = set(bundle_list).intersection(set(explicit_list))

    if len(overlap) > 0:
        conf.fatal("Overlapping dependencies %r" % overlap)

    conf.env['BUNDLE_DEPENDENCIES'] = dict()

    # Loop over all dependencies and fetch the ones
    # specified in the bundle_list
    for name in bundle_list:

        Utils.check_dir(bundle_path)

        conf.start_msg('Resolve dependency %s' % name)

        key = DEPENDENCY_CHECKOUT_KEY % name
        dependency_checkout = getattr(conf.options, key, None)

        dependency_path = dependencies[name].resolve(
            ctx=conf,
            path=bundle_path,
            use_checkout=dependency_checkout)

        conf.end_msg(dependency_path)

        conf.env['BUNDLE_DEPENDENCIES'][name] = dependency_path

    for name in explicit_list:
        key = DEPENDENCY_PATH_KEY % name
        dependency_path = getattr(conf.options, key)
        dependency_path = expand_path(dependency_path)

        conf.start_msg('User resolve dependency %s' % name)
        conf.env['BUNDLE_DEPENDENCIES'][name] = dependency_path
        conf.end_msg(dependency_path)
开发者ID:nitesh5513,项目名称:external-waf,代码行数:56,代码来源:wurf_dependency_bundle.py

示例10: exec_install_files

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import check_dir [as 别名]
 def exec_install_files(self):
     destpath = self.get_install_path()
     if not destpath:
         raise Errors.WafError("unknown installation path %r" % self.generator)
     for x, y in zip(self.source, self.inputs):
         if self.relative_trick:
             destfile = os.path.join(destpath, y.path_from(self.path))
             Utils.check_dir(os.path.dirname(destfile))
         else:
             destfile = os.path.join(destpath, y.name)
         self.generator.bld.do_install(y.abspath(), destfile, self.chmod)
开发者ID:asivakum,项目名称:EE563Project,代码行数:13,代码来源:Build.py

示例11: store_pickle

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import check_dir [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

示例12: install_dir

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import check_dir [as 别名]
def install_dir(self,path):
	if not path:
		return[]
	destpath=Utils.subst_vars(path,self.env)
	if self.is_install>0:
		Logs.info('* creating %s'%destpath)
		Utils.check_dir(destpath)
	elif self.is_install<0:
		Logs.info('* removing %s'%destpath)
		try:
			os.remove(destpath)
		except OSError:
			pass
开发者ID:PseudoSky,项目名称:voodoo,代码行数:15,代码来源:compat15.py

示例13: do_install

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import check_dir [as 别名]
	def do_install(self, src, tgt, chmod=Utils.O644):
		"""
		Copy a file from src to tgt with given file permissions. The actual copy is not performed
		if the source and target file have the same size and the same timestamps. When the copy occurs,
		the file is first removed and then copied (prevent stale inodes).

		This method is overridden in :py:meth:`waflib.Build.UninstallContext.do_install` to remove the file.

		:param src: file name as absolute path
		:type src: string
		:param tgt: file destination, as absolute path
		:type tgt: string
		:param chmod: installation mode
		:type chmod: int
		"""
		d, _ = os.path.split(tgt)
		Utils.check_dir(d)

		srclbl = src.replace(self.srcnode.abspath() + os.sep, '')
		if not Options.options.force:
			# check if the file is already there to avoid a copy
			try:
				st1 = os.stat(tgt)
				st2 = os.stat(src)
			except OSError:
				pass
			else:
				# same size and identical timestamps -> make no copy
				if st1.st_mtime >= st2.st_mtime and st1.st_size == st2.st_size:
					Logs.info('- install %s (from %s)' % (tgt, srclbl))
					return False

		Logs.info('+ install %s (from %s)' % (tgt, srclbl))

		# following is for shared libs and stale inodes (-_-)
		try:
			os.remove(tgt)
		except OSError:
			pass

		try:
			shutil.copy2(src, tgt)
			os.chmod(tgt, chmod)
		except IOError:
			try:
				os.stat(src)
			except (OSError, IOError):
				Logs.error('File %r does not exist' % src)
			raise Errors.WafError('Could not install the file %r' % tgt)
开发者ID:SjB,项目名称:waf,代码行数:51,代码来源:Build.py

示例14: do_link

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import check_dir [as 别名]
	def do_link(self,src,tgt):
		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
			Logs.info('+ symlink %s (to %s)'%(tgt,src))
			os.symlink(src,tgt)
		else:
			Logs.info('- symlink %s (to %s)'%(tgt,src))
开发者ID:RunarFreyr,项目名称:waz,代码行数:17,代码来源:Build.py

示例15: do_link

# 需要导入模块: from waflib import Utils [as 别名]
# 或者: from waflib.Utils import check_dir [as 别名]
	def do_link(self, src, tgt):
		"""create a symlink from tgt to src (will be overridden in UninstallContext)"""
		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
			Logs.info('+ symlink %s (to %s)' % (tgt, src))
			os.symlink(src, tgt)
		else:
			Logs.info('- symlink %s (to %s)' % (tgt, src))
开发者ID:zsx,项目名称:waf,代码行数:20,代码来源:Build.py


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