Ejemplo n.º 1
0
def config_qsst(raw_key='', value=''):
    """
    @type raw_key: string
    @param raw_key: name of the item that to be set.
    @type value: string
    @param : value of the item .
    """
    res = FAILED
    if not raw_key.startswith(PUBLIC_ITEM_PREFIX) and not raw_key.startswith(
            PRIVATE_ITEM_PREFIX):
        raw_key_list = raw_key.split(".")
        if len(raw_key_list) != 2:
            return res
        suitname = raw_key_list[0]
        casename = raw_key_list[1]
        status = value
        if status == '1':
            return enable_case(suitname, casename)
        if status == '0':
            return disable_case(suitname, casename)

    SU.init_filepath()
    config_path = SU.FILE_PATH_CONFIG
    tree = ET.parse(config_path)
    root = tree.getroot()

    if raw_key.startswith(PUBLIC_ITEM_PREFIX):
        raw_key_list = raw_key.split(".")
        if len(raw_key_list) != 2:
            return res
        key = raw_key_list[1]
        for child in root.findall(PUBLIC_ITEM_PREFIX):
            if child.get('name') == key:
                res = SUCCEED
                child.text = value

    if raw_key.startswith(PRIVATE_ITEM_PREFIX):
        raw_key_list = raw_key.split(".")
        if len(raw_key_list) != 3:
            return res
        key = raw_key_list[1:]
        for child in root.findall(PRIVATE_ITEM_PREFIX):
            if child.get('name') == key[0]:
                for item in child.findall('item'):
                    if item.get('name') == key[1]:
                        res = SUCCEED
                        item.text = value
    if res == SUCCEED:
        tree.write(config_path)
        SU.update()
    return res
Ejemplo n.º 2
0
def getConfigValue(moduleName,keyName):
    '''
    get the configuration value of the key in the module. moduleName can be empty

    @type moduleName: name of the module
    @param keyName: name of the key
    '''
    #update the setting, make sure the config is the newest
    import settings.update as SU
    SU.update()
    import settings.common
    attrName = ""
    if moduleName==None or moduleName=="":
        attrName = "PUBLIC_"+keyName.upper()
    else:
        attrName = "PRIVATE_"+moduleName.upper()+"_"+keyName.upper()
    try:
        result = getattr(settings.common, attrName)
        return result
    except Exception as e:
        return ""
Ejemplo n.º 3
0
def getConfigValue(moduleName, keyName):
    '''
    get the configuration value of the key in the module. moduleName can be empty

    @type moduleName: name of the module
    @param keyName: name of the key
    '''
    #update the setting, make sure the config is the newest
    import settings.update as SU
    SU.update()
    import settings.common
    attrName = ""
    if moduleName == None or moduleName == "":
        attrName = "PUBLIC_" + keyName.upper()
    else:
        attrName = "PRIVATE_" + moduleName.upper() + "_" + keyName.upper()
    try:
        result = getattr(settings.common, attrName)
        return result
    except Exception as e:
        return ""
import os
import sys
from performance import html
from logging_wrapper import init_logging_file
import settings.update as SU

l = len("performance_report.py")
TEST_ENV_DIR = sys.argv[0][0:-l]
TEST_DATE_PATH = ""
TEST_REPORT_PATH = ""
print sys.argv
if len(sys.argv) >= 3:
    TEST_DATE_PATH = sys.argv[1]#get test_main.py file location
    TEST_REPORT_PATH = sys.argv[2]#get the report result
else:
    print >> sys.stderr, "You should give me a path of the KPI data and the path of the report"
    exit(1)
os.chdir(TEST_ENV_DIR)
SU.update()

init_logging_file(test_env_xxx=TEST_ENV_DIR)

print html(TEST_DATE_PATH,TEST_REPORT_PATH)
exit(0)
Ejemplo n.º 5
0
import os
import sys
import settings.update as SU
if len(sys.argv) >= 2:
    TEST_ENV_DIR = sys.argv[1]  #get test_main.py file location
else:
    # get path 'data/test_env_xxx/' from argument 'data/test_env_xxx/test_main.py'
    l = 'test_main.py'
    TEST_ENV_DIR = sys.argv[0][0:-l]
os.chdir(TEST_ENV_DIR)
SU.update()
import settings.common as SC
print "LOGGING_PATH:" + SC.PUBLIC_LOG_PATH