本文整理汇总了Python中rapuma.core.tools.Tools.isExecutable方法的典型用法代码示例。如果您正苦于以下问题:Python Tools.isExecutable方法的具体用法?Python Tools.isExecutable怎么用?Python Tools.isExecutable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rapuma.core.tools.Tools
的用法示例。
在下文中一共展示了Tools.isExecutable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ProjScript
# 需要导入模块: from rapuma.core.tools import Tools [as 别名]
# 或者: from rapuma.core.tools.Tools import isExecutable [as 别名]
#.........这里部分代码省略.........
self.projectConfig['Groups'][self.gid]['preprocessScript'] = fileName
elif scriptType == 'postprocess' :
self.projectConfig['Groups'][self.gid]['postprocessScript'] = fileName
else :
self.log.writeToLog(self.errorCodes['1030'], [scriptType])
self.tools.writeConfFile(self.projectConfig)
self.log.writeToLog(self.errorCodes['1010'], [fileName])
return True
else :
self.log.writeToLog(self.errorCodes['1020'], [fileName])
###############################################################################
############################ Script Remove Functions ##########################
###############################################################################
######################## Error Code Block Series = 2000 #######################
###############################################################################
def removeScriptFiles (self, scriptType) :
'''Remove processing script files for a group.'''
if scriptType == 'preprocess' :
fileName = self.projectConfig['Groups'][self.gid]['preprocessScript']
elif scriptType == 'postprocess' :
fileName = self.projectConfig['Groups'][self.gid]['postprocessScript']
else :
self.log.writeToLog(self.errorCodes['1030'], [scriptType])
target = os.path.join(self.local.projScriptFolder, fileName)
# Remove the script (if it's not there, we don't care)
try :
os.remove(target)
except :
pass
if not os.path.isfile(target) :
if scriptType == 'preprocess' :
self.projectConfig['Groups'][self.gid]['preprocessScript'] = ''
elif scriptType == 'postprocess' :
self.projectConfig['Groups'][self.gid]['postprocessScript'] = ''
else :
self.log.writeToLog(self.errorCodes['1030'], [scriptType])
self.tools.writeConfFile(self.projectConfig)
self.log.writeToLog(self.errorCodes['2010'], [fileName])
return True
else :
self.log.writeToLog(self.errorCodes['2020'], [fileName])
###############################################################################
########################## General Script Functions ###########################
###############################################################################
######################## Error Code Block Series = 4000 #######################
###############################################################################
def runProcessScript (self, target, scriptFile) :
'''Run a text processing script on a component. This assumes the
component and the script are valid and the component lock is turned
off. If not, you cannot expect any good to come of this.'''
# subprocess will fail if permissions are not set on the
# script we want to run. The correct permission should have
# been set when we did the installation.
err = subprocess.call([scriptFile, target])
if err == 0 :
self.log.writeToLog(self.errorCodes['4210'], [self.tools.fName(target), self.tools.fName(scriptFile)])
else :
self.log.writeToLog(self.errorCodes['4220'], [self.tools.fName(target), self.tools.fName(scriptFile), str(err)])
return False
return True
def scriptInstall (self, source, target) :
'''Install a script. A script can be a collection of items in
a zip file or a single .py script file.'''
scriptTargetFolder, fileName = os.path.split(target)
if self.tools.isExecutable(source) :
if not shutil.copy(source, target) :
self.tools.makeExecutable(target)
return True
elif self.tools.fName(source).split('.')[1].lower() == 'zip' :
myZip = zipfile.ZipFile(source, 'r')
for f in myZip.namelist() :
data = myZip.read(f, source)
# Pretty sure zip represents directory separator char as "/" regardless of OS
myPath = os.path.join(scriptTargetFolder, f.split("/")[-1])
try :
myFile = open(myPath, "wb")
myFile.write(data)
myFile.close()
except :
pass
myZip.close()
return True
else :
self.log.writeToLog(self.errorCodes['4310'], [self.tools.fName(source)])
示例2: ProjProcess
# 需要导入模块: from rapuma.core.tools import Tools [as 别名]
# 或者: from rapuma.core.tools.Tools import isExecutable [as 别名]
#.........这里部分代码省略.........
# Check and copy if needed
if not os.path.isfile(self.local.groupPreprocessFile) :
shutil.copy(self.local.rpmPreprocessFile, self.local.groupPreprocessFile)
self.tools.makeExecutable(self.local.groupPreprocessFile)
self.log.writeToLog(self.errorCodes['1260'])
else :
self.log.writeToLog(self.errorCodes['1265'])
def runProcessScript (self, target, scriptFile) :
'''Run a text processing script on a component. This assumes the
component and the script are valid and the component lock is turned
off. If not, you cannot expect any good to come of this.'''
# subprocess will fail if permissions are not set on the
# script we want to run. The correct permission should have
# been set when we did the installation.
err = subprocess.call([scriptFile, target])
if err == 0 :
self.log.writeToLog(self.errorCodes['1210'], [self.tools.fName(target), self.tools.fName(scriptFile)])
else :
self.log.writeToLog(self.errorCodes['1220'], [self.tools.fName(target), self.tools.fName(scriptFile), str(err)])
return False
return True
def scriptInstall (self, source, target) :
'''Install a script. A script can be a collection of items in
a zip file or a single .py script file.'''
scriptTargetFolder, fileName = os.path.split(target)
if self.tools.isExecutable(source) :
shutil.copy(source, target)
self.tools.makeExecutable(target)
elif self.tools.fName(source).split('.')[1].lower() == 'zip' :
myZip = zipfile.ZipFile(source, 'r')
for f in myZip.namelist() :
data = myZip.read(f, source)
# Pretty sure zip represents directory separator char as "/" regardless of OS
myPath = os.path.join(scriptTargetFolder, f.split("/")[-1])
try :
myFile = open(myPath, "wb")
myFile.write(data)
myFile.close()
except :
pass
myZip.close()
return True
else :
self.tools.dieNow('Script is an unrecognized type: ' + self.tools.fName(source) + ' Cannot continue with installation.')
def installPostProcess (self, cType, script, force = None) :
'''Install a post process script into the main components processing
folder for a specified component type. This script will be run on
every file of that type that is imported into the project. Some
projects will have their own specially developed post process
script. Use the "script" var to specify a process (which should be
bundled in a system compatable way). If "script" is not specified
we will copy in a default script that the user can modify. This is
currently limited to Python scripts only which do in-place processes
on the target files. The script needs to have the same name as the
zip file it is bundled in, except the extention is .py instead of
the bundle .zip extention.'''