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


Python FileUtils.deleteFile方法代码示例

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


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

示例1: _updateJobData

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import deleteFile [as 别名]
    def _updateJobData(self, uiDict):
        paths = uiDict.get("paths", [])
        jobId = uiDict.get("jobId", None)
        
        path = pack("{}.tar".format(jobId), *paths)
        if path:                
            self.logger.debug("Sending File... {} ".format(path))
            returnValue = self.network.sendCommand("requestFileUpload", jobId=jobId)
            if not returnValue:
                return

            remotePath = returnValue.get("path", None)

            if remotePath:
                path = pack("{}.tar".format(jobId), *paths)
                self.logger.info("Sending Files... ")
                if path:                
                    self.network.sendFileSFTP(path, remotePath, callback=None)                    
                    FileUtils.deleteFile(path)
                    self.network.sendCommand("fileUploadCompleted", waitForResponse=True, path=remotePath, jobId=jobId)
                    return True
        else:
            return False

        return False
开发者ID:Fanris,项目名称:PySchedUI,代码行数:27,代码来源:__init__.py

示例2: copyFiles

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import deleteFile [as 别名]
def copyFiles(configData):
	if False == configData.has_key(s_copyFileKey):
		ColorPrint.errorPrint("没有定义复制文件")
		return
	copyFilesConfig = configData[s_copyFileKey]
	for _, value in enumerate(copyFilesConfig):
		targetFolder = getFileTargetFolder(value)
		source = value[s_sourceKey]
		isNew = isNewFromConfig(value)
		isFilter = isFilterFormConfig(value)

		if s_jsonTrue == isFilter:
			continue

		if not os.path.exists(g_projectPath + targetFolder):
			FileUtils.newFolder(g_projectPath + targetFolder)

		if s_jsonTrue == isNew:
			FileUtils.deleteFile(g_projectPath + targetFolder + source)
			FileUtils.copyFile(s_sourcePath + source , g_projectPath + targetFolder + source)
			ColorPrint.colorPrint("Copy " + s_sourcePath + source)

		elif not os.path.isfile(g_projectPath + targetFolder + source):
			FileUtils.copyFile(s_sourcePath + source , g_projectPath + targetFolder + source)
			ColorPrint.colorPrint("Copy " + s_sourcePath + source)
开发者ID:adroitly,项目名称:boom,代码行数:27,代码来源:CopyResource.py

示例3: _addJob

# 需要导入模块: import FileUtils [as 别名]
# 或者: from FileUtils import deleteFile [as 别名]
    def _addJob(self, uiDict):
        '''
        @summary: Adds a job with a template
        @param userId: the userId
        @param template: the path to the template or a template
        @result:
        '''
        uiDict["userId"] = self.userId
        if uiDict.get("template", None):
            jobDict = TemplateParser.ParseTemplate(uiDict.get("template", None))
            uiDict.update(jobDict)
            del uiDict["template"]

        paths = uiDict.get("paths", [])
        if "paths" in uiDict:
            del uiDict["paths"]

        self.logger.debug(paths)

        returnValue = self.network.sendCommand("addJob", **uiDict)

        if returnValue.get("result", False):
            jobId = returnValue.get("jobId", None)

            if not jobId:
                return False

            returnValue = self.network.sendCommand("requestFileUpload", jobId=jobId)
            if not returnValue:
                return

            remotePath = returnValue.get("path", None)

            if remotePath:
                try:
                    path = pack("{}.tar".format(jobId), *paths)
                    if path:                
                        self.network.sendFileSFTP(path, remotePath, callback=None)                    
                        FileUtils.deleteFile(path)
                        self.network.sendCommand("fileUploadCompleted", waitForResponse=True, path=remotePath, jobId=jobId)
                        return True
                    else:
                        self.deleteJobs([jobId])
                        return False
                except:
                    self.deleteJobs([jobId])
                    #self.lastError = e
            
        return False
开发者ID:Fanris,项目名称:PySchedUI,代码行数:51,代码来源:__init__.py


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