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


Python Resource.addAttribute方法代码示例

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


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

示例1: get_initial_run_info

# 需要导入模块: from Resource import Resource [as 别名]
# 或者: from Resource.Resource import addAttribute [as 别名]
def get_initial_run_info(resIdx, attrs, eInfo, ptds):
    """Parses the run data file and addes the information to the Execution
       object, exe."""

    runMachineArg = eInfo.machineName
    # expect only one execution resource in resIdx
    [exe] = resIdx.findResourcesByType("execution")
    (runMachine, runOS, exe, numberOfProcesses, threadsPerProcess) = getInitialAVs(
        resIdx, attrs, exe, runMachineArg, ptds
    )

    envNewName = ptds.getNewResourceName("env")
    env = Resource(envNewName, "environment")
    resIdx.addResource(env)
    if attrs.getCurrent()[0] != "RunDataEnd":
        (exe) = getSubmission(resIdx, attrs, exe, ptds)
    if attrs.getCurrent()[0] != "RunDataEnd":
        (exe) = getFilesystems(resIdx, attrs, exe, ptds)
    if attrs.getCurrent()[0] != "RunDataEnd":
        (env) = getLibraries(resIdx, attrs, env, exe)
        # env.dump(recurse=True)
    if attrs.getCurrent()[0] != "RunDataEnd":
        (exe) = getInputDecks(resIdx, attrs, exe, ptds)

    # expect only one build resource in resIdx
    [build] = resIdx.findResourcesByType("build")

    # check to see if we figured out how many processes there were
    if numberOfProcesses != -1:
        # yes, so create resource entries for all processes and threads
        i = 0
        while i < int(numberOfProcesses):
            process = Resource(
                exe.name + Resource.resDelim + "Process-" + str(i), "execution" + Resource.resDelim + "process"
            )
            resIdx.addResource(process)
            process.addAttribute("environment", env.name, "resource")
            process.addAttribute("build", build.name, "resource")
            process.addAttribute("OS name", runOS.name, "resource")
            if runMachine:
                process.addAttribute("machine name", runMachine.name, "resource")
            j = 0
            while j < int(threadsPerProcess):
                thread = Resource(
                    process.name + Resource.resDelim + "Thread-" + str(j),
                    "execution" + Resource.resDelim + "process" + Resource.resDelim + "thread",
                )
                resIdx.addResource(thread)
                j += 1
            i += 1
    # couldn't figure out number of processes, so link up resources with
    # the execution resource
    else:
        exe.addAttribute("environment", env.name, "resource")
        exe.addAttribute("build", build.name, "resource")
        exe.addAttribute("OS name", runOS.name, "resource")
        if runMachine:
            exe.addAttribute("machine name", runMachine.name, "resource")
开发者ID:heathharrelson,项目名称:PerfTrack,代码行数:60,代码来源:Run.py

示例2: getInitialAVs

# 需要导入模块: from Resource import Resource [as 别名]
# 或者: from Resource.Resource import addAttribute [as 别名]

#.........这里部分代码省略.........

    for name, value, type in attrs:
        if name == "BuildDataBegin":
            pass
        elif name == "BuildDataEnd":
            break
        # Get executable specific data
        elif name == "ApplicationName":
            AppName = value
        elif name == "ApplicationExeTrialName" or name == "ApplicationExeUserComment":
            AppTrialName = value
        elif name.startswith("Application"):
            if name == "ApplicationLanguages":
                value = fixListFormat(value)
                executableAVs.append(("Languages", value, "string"))
            elif name == "ApplicationParadigms":
                value = fixListFormat(value)
                executableAVs.append(("Concurrency", value, "string"))
            elif name == "ApplicationExeName":
                executableAVs.append(("Executable Name", value, "string"))
            elif name == "ApplicationExeSize":
                executableAVs.append(("Executable Size", value, "string"))
            elif name == "ApplicationExePerms":
                executableAVs.append(("Executable Permissions", value, "string"))
            elif name == "ApplicationExeUID":
                executableAVs.append(("Executable UID", value, "string"))
            elif name == "ApplicationExeGID":
                executableAVs.append(("Executable GID", value, "string"))
            elif name == "ApplicationExeTimestamp":
                executableAVs.append(("Executable Timestamp", value, "string"))
            elif name == "ApplicationExeUsername":
                executableAVs.append(("Username", value, "string"))
        # get Build specific data
        elif name.startswith("Build") and not (name.find("BuildOS") >= 0):
            if name == "BuildEnv":
                BuildEnv = []  # a list of attr value pairs
                # where attr = "BuildEnv"+ (enviroment variable name)
                # and value is the environment variable's value
                # e.g.  for PATH=/usr/bin:/usr/local/bin
                # attr = BuildEnvPATH
                # value = /usr/bin:/usr/local/bin
                BuildEnv = StringToList("Env_", "@@@", value)
                for (n, v) in BuildEnv:
                    if v != "":
                        buildAVs.append((n, v, "string"))
            else:
                if name == "BuildNode" or name == "BuildMachine":
                    BuildMachine = value
                if name == "BuildNode":
                    BuildMachType = "node"
                    buildAVs.append(("Node Name", value, "string"))
                elif name == "BuildMachine":
                    BuildMachType = "machine"
                    buildAVs.append(("Machine Name", value, "string"))
                if name == "BuildDateTime":
                    buildAVs.append(("DateTime", value, "string"))
                # get Build operating system  specific data
        elif name.startswith("BuildOS"):
            if name == "BuildOSName":
                BuildOSName = value
            elif name == "BuildOSReleaseVersion":
                BuildOSVersion = value
            elif name == "BuildOSReleaseType":
                BuildOSType = value

    if exeName == "" or exeName == None:
        raise PTexception("missing execution name in Build.getInitialAVs")

    exeNewName = ptds.getNewResourceName(exeName)
    # ATTR CHANGE TODO
    # executableAVs should be attrs of build, not execution
    exe = Execution(exeNewName, executableAVs)
    resIdx.addResource(exe)

    newBuildName = ptds.getNewResourceName("build")
    build = Resource(newBuildName, "build", buildAVs)
    resIdx.addResource(build)

    if BuildMachine == "" or BuildMachine == None:
        raise PTexception("missing build machine name in build data file for " " execution:%s" % exeName)

    if BuildMachType == "node":
        fullname, type = getMachineName(ptds, BuildMachine, BuildMachType)
        # print fullname
        buildMachine = Resource(fullname, type)
    else:  # machine
        fullname, type = getMachineName(ptds, BuildMachine, BuildMachType)
        buildMachine = Resource(fullname, type)

    if BuildOSName == "" or BuildOSName == None:
        raise PTexception("missing build operating system name for execution" "execution:%s" % exeName)
    if BuildOSVersion == "" or BuildOSVersion == None or BuildOSType == "" or BuildOSType == None:
        raise PTexception("missing build operating system details for execution" "execution:%s" % exeName)
    buildOSNewName = ptds.getNewResourceName(BuildOSName + " " + BuildOSVersion + " " + BuildOSType)
    buildOS = Resource(buildOSNewName, "operatingSystem", buildOSAVs)
    resIdx.addResources([buildOS, buildMachine])
    build.addAttribute("Node Name", buildMachine.name, "resource")
    build.addAttribute("OS Name", buildOS.name, "resource")

    return (build, exe)
开发者ID:heathharrelson,项目名称:PerfTrack,代码行数:104,代码来源:Build.py


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