本文整理汇总了Python中InventoryUtils.isUnix方法的典型用法代码示例。如果您正苦于以下问题:Python InventoryUtils.isUnix方法的具体用法?Python InventoryUtils.isUnix怎么用?Python InventoryUtils.isUnix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InventoryUtils
的用法示例。
在下文中一共展示了InventoryUtils.isUnix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upgradePrePostScript
# 需要导入模块: import InventoryUtils [as 别名]
# 或者: from InventoryUtils import isUnix [as 别名]
def upgradePrePostScript(scannersConfigFile, scannerPlatformConfig, Framework):
logger.debug('Installing pre/post script')
BASEDIR = Framework.getProperty(InventoryUtils.STATE_PROPERTY_RESOLVED_BASEDIR)
platform = Framework.getProperty(InventoryUtils.STATE_PROPERTY_PLATFORM)
unixConfig = scannersConfigFile.getPlatformConfiguration('unix', "")
#whether run or not pre-scan and post-scan scripts
isPrePostScriptAllowed = Boolean.parseBoolean(Framework.getParameter('IsPrePostScriptAllowed'))
logger.debug("isPrePostScriptAllowed:", isPrePostScriptAllowed)
if not isPrePostScriptAllowed:
return
isAllUnix = False
preScanScriptLocalPath = getPrePostScriptLocalPath(scannerPlatformConfig.getScannerPreScanScriptLocalFile())
logger.debug('preScanScriptLocalPath:', preScanScriptLocalPath)
if InventoryUtils.isUnix(platform) and not os.path.exists(preScanScriptLocalPath):
logger.debug("No specific platform for the device, use all-unix.")
isAllUnix = True
preScanScriptLocalPath = getPrePostScriptLocalPath(unixConfig.getScannerPreScanScriptLocalFile())
logger.debug("preScanScriptLocalPath:", preScanScriptLocalPath)
postScanScriptLocalPath = getPrePostScriptLocalPath(scannerPlatformConfig.getScannerPostScanScriptLocalFile())
logger.debug('postScanScriptLocalPath:', postScanScriptLocalPath)
if InventoryUtils.isUnix(platform) and not os.path.exists(postScanScriptLocalPath):
logger.debug("No specific platform for the device, use all-unix.")
isAllUnix = True
postScanScriptLocalPath = getPrePostScriptLocalPath(unixConfig.getScannerPostScanScriptLocalFile())
logger.debug('postScanScriptLocalPath:', postScanScriptLocalPath)
preScanScriptRemotePath = BASEDIR + scannerPlatformConfig.getScannerPreScanScriptRemoteFile()
logger.debug('preScanScriptRemotePath:', preScanScriptRemotePath)
postScanScriptRemotePath = BASEDIR + scannerPlatformConfig.getScannerPostScanScriptRemoteFile()
logger.debug('postScanScriptRemotePath:', postScanScriptRemotePath)
if os.path.exists(preScanScriptLocalPath):
InventoryUtils.copyLocalFileToRemote(Framework, preScanScriptLocalPath, preScanScriptRemotePath)
if os.path.exists(postScanScriptLocalPath):
InventoryUtils.copyLocalFileToRemote(Framework, postScanScriptLocalPath, postScanScriptRemotePath)
# upgrade resource files for PrePostScript
upgradePrePostScriptResource(isAllUnix, Framework)
Framework.setProperty(InventoryUtils.SCANNER_PRE_SCAN_SCRIPT_REMOTE_PATH, preScanScriptRemotePath)
Framework.setProperty(InventoryUtils.SCANNER_POST_SCAN_SCRIPT_REMOTE_PATH, postScanScriptRemotePath)
示例2: terminateScanner
# 需要导入模块: import InventoryUtils [as 别名]
# 或者: from InventoryUtils import isUnix [as 别名]
def terminateScanner(Framework, shell, scannerRemoteExecutable):
platform = Framework.getProperty(InventoryUtils.STATE_PROPERTY_PLATFORM)
if InventoryUtils.isUnix(platform):
psArgs = ' -e '
if platform == 'macosx':
psArgs = ' -A '
cmdOutput = shell.execCmd('ps' + psArgs + '| grep ' + scannerRemoteExecutable)
if cmdOutput and len(cmdOutput) > 0:
pid = cmdOutput.split()[0]
if pid.isdigit():
shell.execCmd('kill ' + pid)
else:
cmdOutput = shell.execCmd('tasklist /FO csv | findstr ' + scannerRemoteExecutable)
if cmdOutput and len(cmdOutput) > 0:
pid = cmdOutput.split('","')[1]
if pid.isdigit():
shell.execCmd('taskkill /PID ' + pid)