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


Python InventoryUtils.isUnix方法代码示例

本文整理汇总了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)
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:47,代码来源:UpgradeScanner.py

示例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)
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:19,代码来源:UpgradeScanner.py


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