本文整理匯總了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.'''