Esempio n. 1
0
def getActionppArgs(modelDir,targetDir,options):
    if options.actionpp_args:
        return options.actionpp_args
    mddFile = getMddFileWithPath(modelDir)
    reader = Reader(mddFile)
    targets = getTargetDevices(modelDir,options)
    actionpp_args = ""
    tdFiles = getTdFilesWithPath(targetDir,options)
    for d,l,p in targets:
        devices = reader.getValue('devices',[p]).split('\n')
        for tdFile in tdFiles:
            for device in devices:
                if tdFile.endswith(urllib.quote(device) + ".td"):
                    try:
                        handle = open(tdFile,'r')
                        contents = handle.readline()
                    finally:
                        if handle:
                            handle.close()
                            handle = None

                    log_cmp = datareader.getDataInfo(contents)[0]
                    if l == log_cmp:        
                        locales = reader.getValue('locales',[p]).split('\n')
                        actionpp_args += "file:%s:%s.csv," % (tdFile,os.path.join(targetDir,p))
                        d_quot = urllib.quote(d)
                        if d_quot in options.devices and options.devices[d_quot] not in locales and options.devices[d_quot].strip() != '':
                            raise RunModelPackageFailed(
                                "Unknown locale '%s' for device '%s'" % (options.devices[d_quot],d))
                        elif d_quot in options.devices and options.devices[d_quot].strip() != '':
                            actionpp_args += "lang:%s:%s," % (tdFile,options.devices[d_quot])
                        else:
                            actionpp_args += "lang:%s:%s," % (tdFile,locales[0])

    return actionpp_args
Esempio n. 2
0
def getAllTargetDevices(mddFile):
    """Returns a list of (devicename,productname) tuples."""
    reader = Reader(mddFile)
    products = reader.getValue("products").split("\n")
    targets = []
    for p in products:
        devices = [d for d in reader.getValue("devices", [p]).split("\n") if d]
        targets.extend([(d, p) for d in devices])
    return targets
Esempio n. 3
0
def getAllTargetDevices(mddFile):
    """Returns a list of (devicename,productname) tuples."""
    reader = Reader(mddFile)
    products = reader.getValue('products').split('\n')
    targets = []
    for p in products:
        devices = [d for d in reader.getValue('devices',[p]).split('\n') if d]
        targets.extend( [(d,p) for d in devices] )
    return targets
Esempio n. 4
0
def getActionppArgs(modelDir, targetDir, options):
    if options.actionpp_args:
        return options.actionpp_args
    mddFile = getMddFileWithPath(modelDir)
    reader = Reader(mddFile)
    targets = getTargetDevices(modelDir, options)
    actionpp_args = ""
    tdFiles = getTdFilesWithPath(targetDir, options)
    for d, l, p in targets:
        devices = reader.getValue("devices", [p]).split("\n")
        for tdFile in tdFiles:
            for device in devices:
                if tdFile.endswith(urllib.quote(device) + ".td"):
                    try:
                        handle = open(tdFile, "r")
                        contents = handle.readline()
                    finally:
                        if handle:
                            handle.close()
                            handle = None

                    log_cmp = datareader.getDataInfo(contents)[0]
                    if l == log_cmp:
                        locales = reader.getValue("locales", [p]).split("\n")
                        actionpp_args += "file:%s:%s.csv," % (tdFile, os.path.join(targetDir, p))
                        d_quot = urllib.quote(d)
                        if (
                            d_quot in options.devices
                            and options.devices[d_quot] not in locales
                            and options.devices[d_quot].strip() != ""
                        ):
                            raise RunModelPackageFailed(
                                "Unknown locale '%s' for device '%s'" % (options.devices[d_quot], d)
                            )
                        elif d_quot in options.devices and options.devices[d_quot].strip() != "":
                            actionpp_args += "lang:%s:%s," % (tdFile, options.devices[d_quot])
                        else:
                            actionpp_args += "lang:%s:%s," % (tdFile, locales[0])

    return actionpp_args
Esempio n. 5
0
def getLstsFilesOfDevice(device,product,modelDir,options):
    mddFile = getMddFileWithPath(modelDir)
    reader = Reader(mddFile)
    concunits = reader.getValue('concurrentunits',[product]).split('\n')
    if device in options.applications:
        for selectedCu in options.applications[device]:
            if selectedCu.strip() not in concunits:
                raise RunModelPackageFailed(
                    "Error: no application named '%s' in product '%s' in device '%s'." % (selectedCu,product,device))
        concunits = options.applications[device]
    
    lstsFiles = getLstsFiles(modelDir,options)
    productLstsFiles = []
    for cu in concunits:
        cu = cu.strip()
        for lf in lstsFiles:
            if lf.startswith(cu.replace(' ','%20')):
                productLstsFiles.append(lf)
    return productLstsFiles
Esempio n. 6
0
def getLstsFilesOfDevice(device, product, modelDir, options):
    mddFile = getMddFileWithPath(modelDir)
    reader = Reader(mddFile)
    concunits = reader.getValue("concurrentunits", [product]).split("\n")
    if device in options.applications:
        for selectedCu in options.applications[device]:
            if selectedCu.strip() not in concunits:
                raise RunModelPackageFailed(
                    "Error: no application named '%s' in product '%s' in device '%s'." % (selectedCu, product, device)
                )
        concunits = options.applications[device]

    lstsFiles = getLstsFiles(modelDir, options)
    productLstsFiles = []
    for cu in concunits:
        cu = cu.strip()
        for lf in lstsFiles:
            if lf.startswith(cu.replace(" ", "%20")):
                productLstsFiles.append(lf)
    return productLstsFiles