123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937 |
- # -*- coding:utf-8 -*-
- import sys, os, time
- reload(sys)
- sys.setdefaultencoding("utf-8")
- from utils.platform_Util import *
- from ConfigParser import *
- import json
- class TConfig:
- def __init__(self, ini_path):
- self.path = ini_path
- # 保存修改;
- def save_config(self, cfgParser):
- with open(self.path, 'wb') as configfile:
- if cfgParser:
- cfgParser.write(configfile)
- # 字符转字典;
- def get_dict(self, value):
- return json.loads(value)
- def get_value_dict(self, section, option):
- value = self.get_value(section, option)
- if value is None:
- return {}
- return json.loads(value)
- # 获取参数值;默认返回字符串
- def get_value(self, section, option):
- # 读取配置文件;
- cfgParser = ConfigParser()
- cfgParser.read(self.path)
- if cfgParser.has_option(section, option):
- return cfgParser.get(section, option)
- return None
- # 获取参数值;
- def get_int(self, section, option):
- # 读取配置文件;
- cfgParser = ConfigParser()
- cfgParser.read(self.path)
- if cfgParser.has_option(section, option):
- return cfgParser.getint(section, option)
- return None
- # 获取参数值;
- def get_float(self, section, option):
- # 读取配置文件;
- cfgParser = ConfigParser()
- cfgParser.read(self.path)
- if cfgParser.has_option(section, option):
- return cfgParser.getfloat(section, option)
- return None
- # 获取参数值;
- def get_boolean(self, section, option):
- # 读取配置文件;
- cfgParser = ConfigParser()
- cfgParser.read(self.path)
- if cfgParser.has_option(section, option):
- return cfgParser.getboolean(section, option)
- return None
- # 获取键值;
- def get_options(self, section):
- # 读取配置文件;
- cfgParser = ConfigParser()
- cfgParser.read(self.path)
- if cfgParser.has_section(section):
- return cfgParser.options(section)
- return None
- # 获取所有sections;
- def get_sections(self):
- # 读取配置文件;
- cfgParser = ConfigParser()
- cfgParser.read(self.path)
- return cfgParser.sections()
- # 获取指定section所有items;
- def get_items(self, section):
- # 读取配置文件;
- cfgParser = ConfigParser()
- cfgParser.read(self.path)
- if cfgParser.has_section(section):
- return cfgParser.items(section)
- return None
- # 添加section;
- def add_section(self, section):
- # 读取配置文件;
- cfgParser = ConfigParser()
- cfgParser.read(self.path)
- if cfgParser.has_section(section) is False:
- cfgParser.add_section(section)
- # 保存修改;
- self.save_config(cfgParser)
- # 设置值;
- def set_value(self, section, option, value):
- # 读取配置文件;
- cfgParser = ConfigParser()
- cfgParser.read(self.path)
- if cfgParser.has_section(section) is False:
- cfgParser.add_section(section)
- cfgParser.set(section, option, value)
- # 保存修改;
- self.save_config(cfgParser)
- # 删除指定option;
- def del_option(self, section, option):
- # 读取配置文件;
- cfgParser = ConfigParser()
- cfgParser.read(self.path)
- cfgParser.remove_option(section, option)
- # 保存修改;
- self.save_config(cfgParser)
- # 删除section;
- def del_section(self, section):
- # 读取配置文件;
- cfgParser = ConfigParser()
- cfgParser.read(self.path)
- cfgParser.remove_section(section)
- # 保存修改;
- self.save_config(cfgParser)
- def has_section(self, section):
- # 读取配置文件;
- cfgParser = ConfigParser()
- cfgParser.read(self.path)
- return cfgParser.has_section(section)
- def has_option(self, section, option):
- # 读取配置文件;
- cfgParser = ConfigParser()
- cfgParser.read(self.path)
- return cfgParser.has_option(section, option)
- try:
- # Python_Home = os.environ["PYTHONHOME"].split(";")[0]
- Python_Home = sys.prefix
- # Resource_CFG_Path = Python_Home + Environment.SDK_Relative_Path + "config/resource.cfg"
- Resource_CFG_Path = Python_Home + Environment.SDK_Relative_Path + "config/resource_run.cfg"
- Resource_CFG_Local_Path = Python_Home + Environment.SDK_Relative_Path + "config/resource.cfg"
- if not os.path.exists(Resource_CFG_Path):
- print 'server_run.cfg文件不存在,复制server.cfg文件'
- shutil.copy(Resource_CFG_Local_Path, Resource_CFG_Path)
- # Resource_CFG_Path = "config/resource.cfg"
- # 获取22293的配置路径
- COMConfigPath = os.path.join(Python_Home, 'Tools', 'Config', 'COMConfig.txt')
- Home_Init = True
- except KeyError, e:
- print "KeyError:", e.message
- Home_Init = False
- CFG_DICT = {}
- def getResourceConfigPath():
- return Resource_CFG_Path
- def mkCHdir(dir):
- # print "mkCHdir,dir=", dir
- if (os.path.exists(dir)):
- return dir
- # 例如:D:/SAT/result_schedule_id_schedule_name_task_number//detail
- # os.path.splite结果:('D:/SAT/result_schedule_id_schedule_name_task_number', 'detail')
- # 过滤//多个分割符的情况
- preDir = os.path.split(dir)[0]
- # print "mkdir,preDir=", preDir
- if (not os.path.exists(preDir)):
- mkCHdir(preDir)
- # 防止目录字符串最后带有/的情况,会出现两次创建同一个目录
- # 例如: D:/SAT/。会创建D:/SAT和D:/SAT/
- if (not os.path.exists(dir)):
- os.mkdir(dir)
- return dir
- def setLineParam(line):
- global CFG_DICT
- lineArr = line.split("=")
- # print "setLineParam,lineArr:", lineArr
- if (lineArr.__len__() == 2):
- CFG_DICT[lineArr[0].strip(" ")] = lineArr[1].strip(" ")
- def loadResourceCfg():
- global CFG_DICT
- if Home_Init == False:
- print "Not found config file,Please set the os path of PYTHONHOME"
- return False
- cfgFile = open(Resource_CFG_Path, "r", -1)
- strline = "init"
- while (strline <> None and strline <> ""):
- strline = cfgFile.readline().strip("\n").strip("\r")
- # print "line:", strline
- info = strline.decode("utf-8", "error")
- # 防止文本读取结束时,“#”判断出错
- if (info.__len__() > 1 and info[0] <> "#"):
- setLineParam(info)
- cfgFile.close()
- return True
- g_cfgParser = None
- def parseResourceCfg():
- global g_cfgParser
- global CFG_DICT
- if Home_Init == False:
- print "Not found config file,Please set the os path of PYTHONHOME"
- return False
- g_cfgParser = TConfig(Resource_CFG_Path)
- return True
- parseResourceCfg()
- def getOCRIpAddr():
- try:
- return g_cfgParser.get_value("COMM", "Env_OCR_IP_ADDR")
- except Exception, e:
- print e
- return ""
- def getOCRPort():
- try:
- return g_cfgParser.get_int("COMM", "Env_OCR_PORT")
- except Exception, e:
- print e
- return -1
- def getSerialCOM():
- try:
- return g_cfgParser.get_value("COMM", "Serial_Communicator_Port")
- except Exception, e:
- print e
- return ""
- def getSATHome():
- try:
- return g_cfgParser.get_value("COMM", "SAT_HOME")
- except Exception, e:
- print e
- return ""
- def getScriptExecDIR():
- satHome = getSATHome()
- return os.path.join(satHome, "ScriptExec")
- def getSATTmpDIR():
- path = g_cfgParser.get_value("COMM", "sat_tmp")
- if path is None:
- satHome = getSATHome()
- return os.path.join(satHome, "tmp")
- else:
- return path
- def getSATTranslationDIR():
- satHome = getSATHome()
- return os.path.join(satHome, "translation")
- def getSATRCUDIR():
- satHome = getSATHome()
- return os.path.join(satHome, "resource", "RCU")
- def getSATRCUGeneralDIR():
- SATRCUDIR = getSATRCUDIR()
- return os.path.join(SATRCUDIR, "general")
- def getSATRCUProductDIR():
- SATRCUDIR = getSATRCUDIR()
- return os.path.join(SATRCUDIR, "product")
- def getSATSmokingDIR():
- satHome = getSATHome()
- return os.path.join(satHome, "smoking")
- def getSATSmokingDownloaDIR():
- SATSmokingDIR = getSATSmokingDIR()
- return os.path.join(SATSmokingDIR, "download")
- def getSATSmokingOTAAPKDIR():
- SATSmokingDIR = getSATSmokingDIR()
- return os.path.join(SATSmokingDIR, "ota_apk")
- def getSATMenuTreeDIR():
- satHome = getSATHome()
- return os.path.join(satHome, "resource", "MenuTree")
- def getOCRTmpDir():
- tmpDir = getSATTmpDIR()
- return os.path.join(tmpDir, "ocr")
- def getOCRErrDir():
- tmpDir = getSATTmpDIR()
- return os.path.join(tmpDir, "ocr_err")
- def getSATProjectCfgDIR():
- return os.path.join(getSATHome(), "resource", "projectCfg")
- def getResourceBaseDIR():
- satHome = getSATHome()
- return os.path.join(satHome, "resource")
- def getHDMIResourceDIR():
- return os.path.join(getResourceBaseDIR(), "HDMI")
- def getHDMIstdTPDIR():
- return os.path.join(getHDMIResourceDIR(), "std_timing_pattern")
- def getAVResourceDIR():
- return os.path.join(getResourceBaseDIR(), "AV")
- def getAVstdTPDIR():
- return os.path.join(getAVResourceDIR(), "std_timing_pattern")
- def getVGAResourceDIR():
- return os.path.join(getResourceBaseDIR(), "VGA")
- def getVGAstdTPDIR():
- return os.path.join(getVGAResourceDIR(), "std_timing_pattern")
- def getYpbprResourceDIR():
- return os.path.join(getResourceBaseDIR(), "YPBPR")
- def getYpbprstdTPDIR():
- return os.path.join(getYpbprResourceDIR(), "std_timing_pattern")
- def getDTVResourceDIR():
- return os.path.join(getResourceBaseDIR(), "DTV")
- def getDTVstdTPDIR():
- return os.path.join(getDTVResourceDIR(), "std_ts")
- def getATVResourceDIR():
- return os.path.join(getResourceBaseDIR(), "ATV")
- def getATVstdTPDIR():
- return os.path.join(getATVResourceDIR(), "std_ts")
- def getResultDir():
- try:
- return g_cfgParser.get_value("COMM", "SAT_RESULT_DIR")
- except Exception, e:
- print e
- return "Error"
- def getPathModelDIR():
- return os.path.join(getSATHome(), "model")
- def getAbnormalDir():
- return os.path.join(getSATHome(), "abnormal")
- def initDirs():
- print mkCHdir(getSATHome())
- print mkCHdir(getResourceBaseDIR())
- print mkCHdir(getScriptExecDIR())
- print mkCHdir(getSATTmpDIR())
- print mkCHdir(getSATMenuTreeDIR())
- print mkCHdir(getHDMIResourceDIR())
- print mkCHdir(getHDMIstdTPDIR())
- print mkCHdir(getAVResourceDIR())
- print mkCHdir(getAVstdTPDIR())
- print mkCHdir(getVGAResourceDIR())
- print mkCHdir(getVGAstdTPDIR())
- print mkCHdir(getYpbprResourceDIR())
- print mkCHdir(getYpbprstdTPDIR())
- print mkCHdir(getDTVResourceDIR())
- print mkCHdir(getDTVstdTPDIR())
- print mkCHdir(getATVResourceDIR())
- print mkCHdir(getATVstdTPDIR())
- print mkCHdir(getResultDir())
- print mkCHdir(getPathModelDIR())
- print mkCHdir(getAbnormalDir())
- print mkCHdir(getOCRTmpDir())
- print mkCHdir(getSATTranslationDIR())
- print mkCHdir(getSATRCUDIR())
- print mkCHdir(getSATRCUGeneralDIR())
- print mkCHdir(getSATRCUProductDIR())
- print mkCHdir(getSATSmokingDIR())
- print mkCHdir(getSATSmokingDownloaDIR())
- print mkCHdir(getSATSmokingOTAAPKDIR())
- initDirs()
- def setSATHome(dir):
- try:
- g_cfgParser.set_value("COMM", "SAT_HOME", dir)
- # g_cfgParser.write(open(Resource_CFG_Path, "w"))
- except Exception, e:
- print e
- def setSATTmpDir(dir):
- try:
- g_cfgParser.set_value("COMM", "sat_tmp", dir)
- # g_cfgParser.write(open(Resource_CFG_Path, "w"))
- except Exception, e:
- print e
- def setResultDir(dir):
- try:
- g_cfgParser.set_value("COMM", "SAT_RESULT_DIR", dir)
- # g_cfgParser.write(open(Resource_CFG_Path, "w"))
- except Exception, e:
- print e
- def setScriptResultDIR(dir):
- try:
- g_cfgParser.set_value("COMM", "sat_script_dir", dir)
- # g_cfgParser.write(open(Resource_CFG_Path, "w"))
- except Exception, e:
- print e
- def getUB530_Port():
- return g_cfgParser.get_value("COMM", "ub530_port")
- def getTG39_Port():
- return g_cfgParser.get_value("COMM", "tg39_port")
- def get22293_Port():
- f = open(COMConfigPath)
- data = f.read()
- f.close()
- data_dict = eval(data)
- sourcegeninput = data_dict['SourceGenInput']
- return sourcegeninput
- def getRCUDeviceList():
- try:
- return eval(g_cfgParser.get_value("devices", "rcudevice_list"))
- except Exception,e:
- return ['redrat3','redrat4']
- def getRCUDeviceSelected():
- try:
- return g_cfgParser.get_value("devices", "rcudevice_selected")
- except Exception,e:
- return 'redrat3'
- def writeRCUDeviceSelected(rcu_device):
- g_cfgParser.set_value('devices', 'rcudevice_selected', rcu_device)
- def getRCUSelected():
- return g_cfgParser.get_value("devices", "rcu_selected")
- def getCcardSelected():
- return g_cfgParser.get_value("devices", "ccard_selected")
- def getATVSelected():
- return g_cfgParser.get_value("devices", "atv_selected")
- def getDTVSelected():
- return g_cfgParser.get_value("devices", "dtv_selected")
- def getAtv_list():
- return eval(g_cfgParser.get_value("devices", "atv_list"))
- def getDtv_list():
- return eval(g_cfgParser.get_value("devices", "dtv_list"))
- def writeDtv_list(dtv_list):
- g_cfgParser.set_value('devices', 'dtv_list', str(dtv_list))
- def getCcard_list():
- return eval(g_cfgParser.get_value("devices", "ccard_list"))
- def writeCcard_list(ccard_list):
- g_cfgParser.set_value('devices', 'ccard_list', str(ccard_list))
- def getVoicecard_list():
- return eval(g_cfgParser.get_value("devices", "voicecard_list"))
- def getSignalcard_list():
- return eval(g_cfgParser.get_value("devices", "signalcard_list"))
- def getSerialport_list():
- return eval(g_cfgParser.get_value("devices", "serialport_list"))
- def writeRCUSelected(rcu_selected_value):
- g_cfgParser.set_value('devices', 'rcu_selected', rcu_selected_value)
- def writeCcardSelected(ccard_selected_value):
- g_cfgParser.set_value('devices', 'ccard_selected', ccard_selected_value)
- def writeATVSelected(atv_selected_value):
- g_cfgParser.set_value('devices', 'atv_selected', atv_selected_value)
- def writeDTVSelected(dtv_selected_value):
- g_cfgParser.set_value('devices', 'dtv_selected', dtv_selected_value)
- def writeTG39_Port(port_number):
- g_cfgParser.set_value('COMM', 'tg39_port', 'COM' + port_number)
- def write22293_Port(port_number):
- f = open(COMConfigPath)
- data = f.read()
- data_dict = eval(data)
- f.close()
- f1 = open(COMConfigPath, 'w')
- data_dict['SourceGenInput'] = 'COM' + port_number
- f1.write(str(data_dict))
- f1.close()
- def writeSerialCOM(port_number):
- g_cfgParser.set_value('COMM', 'serial_communicator_port', 'COM' + port_number)
- def writeMenuTreeRootDir(menuTreeRootDir):
- try:
- g_cfgParser.add_section('MenuTree')
- except Exception, e:
- print e
- g_cfgParser.set_value('MenuTree', 'menuTreeRootDir', menuTreeRootDir)
- def writeMenuTreeSelectedChip(selectedChip):
- try:
- g_cfgParser.add_section('MenuTree')
- except Exception, e:
- print e
- g_cfgParser.set_value('MenuTree', 'menuTreeSelectedChip', selectedChip)
- def writeMenuTreeSelectedStyle(selectedStyle):
- try:
- g_cfgParser.add_section('MenuTree')
- except Exception, e:
- print e
- g_cfgParser.set_value('MenuTree', 'menuTreeSelectedStyle', selectedStyle)
- def writeMenuTreeSelectedChannel(selectedChannel):
- try:
- g_cfgParser.add_section('MenuTree')
- except Exception, e:
- print e
- g_cfgParser.set_value('MenuTree', 'menuTreeSelectedChannel', selectedChannel)
- def writeMenuTreeSelectedTVUI(selectedTVUI):
- try:
- g_cfgParser.add_section('MenuTree')
- except Exception, e:
- print e
- g_cfgParser.set_value('MenuTree', 'menuTreeSelectedTVUI', selectedTVUI)
- def getRCUSelectedFilePath():
- # rootPath = os.path.join(Python_Home, 'Tools', 'redhathub', 'data')
- rootPath = getSATRCUProductDIR()
- fileName = getRCUSelected() + '.xml'
- filePath = os.path.join(rootPath, fileName)
- print 'filePath:', filePath
- return filePath
- def getBaiduOCR_APPID():
- return g_cfgParser.get_value("baidu_ocr", "APP_ID")
- def getBaiduOCR_APIKey():
- return g_cfgParser.get_value("baidu_ocr", "API_KEY")
- def getBaiduOCR_SecretKey():
- return g_cfgParser.get_value("baidu_ocr", "SECRET_KEY")
- def getMenuTreeRootDir():
- value = None
- try:
- value = g_cfgParser.get_value('MenuTree', 'menuTreeRootDir')
- return value
- except Exception, e:
- print e
- return value
- def getMenuTreeSelectedChip():
- value = None
- try:
- value = g_cfgParser.get_value('MenuTree', 'menuTreeSelectedChip')
- return value
- except Exception, e:
- print e
- return value
- def getMenuTreeSelectedStyle():
- value = None
- try:
- value = g_cfgParser.get_value('MenuTree', 'menuTreeSelectedStyle')
- return value
- except Exception, e:
- print e
- return value
- def getMenuTreeSelectedChannel():
- value = None
- try:
- value = g_cfgParser.get_value('MenuTree', 'menuTreeSelectedChannel')
- return value
- except Exception, e:
- print e
- return value
- def getMenuTreeSelectedTVUI():
- value = None
- try:
- value = g_cfgParser.get_value('MenuTree', 'menuTreeSelectedTVUI')
- except Exception, e:
- print e
- if not value:
- return -1
- return int(value)
- def getMenuTreeSelectedTreePath():
- return os.path.join(getCurrentMenuTreeDir(), 'uitree.ini')
- def getMenuTreeSelectedProjectCfgPath():
- return os.path.join(getSATProjectCfgDIR(), getMenuTreeSelectedChip(), getMenuTreeSelectedStyle())
- # return os.path.join(getSATMenuTreeDIR(), getMenuTreeSelectedChip(), getMenuTreeSelectedStyle())
- def getCurrentMenuTreeDir():
- return os.path.join(getSATMenuTreeDIR(), getMenuTreeSelectedChip(), getMenuTreeSelectedStyle())
- def getMenuTree3SelectedProjectCfgPath():
- # return os.path.join(getSATProjectCfgDIR(), getMenuTreeSelectedChip(), getMenuTreeSelectedStyle())
- return os.path.join(getCurrentMenuTreeDir())
- def getMenuTree3SelectedPExcelPath():
- print u"MenuTree3框架加载的非tv表格路径为:", os.path.join(getCurrentMenuTreeDir(), "MenuTree.xls")
- return os.path.join(getCurrentMenuTreeDir(), "MenuTree.xls")
- def getMenuTree3SelectedTvExcelPath():
- # return os.path.join(getSATProjectCfgDIR(), getMenuTreeSelectedChip(), getMenuTreeSelectedStyle())
- channel = getMenuTreeSelectedChannel()
- if not channel or str(channel) == "":
- print u"未能读取到tv表格!!MenuTree3框架将使用默认的表格路径:", os.path.join(getCurrentMenuTreeDir(),
- "MenuTree.xls")
- return os.path.join(getCurrentMenuTreeDir(), "MenuTree.xls")
- else:
- print u"当前加载的TV制式为%s,MenuTree3框架载入的TV表格路径为:"%channel, os.path.join(getCurrentMenuTreeDir(),
- "MenuTree_" + channel + ".xls")
- return os.path.join(getCurrentMenuTreeDir(),
- "MenuTree_" + channel + ".xls")
- return os.path.join(getCurrentMenuTreeDir())
- def getChroma22293():
- try:
- return json.loads(g_cfgParser.get_value("COMM", "Chroma22293"))
- except Exception, e:
- print e
- return {}
- def setChroma22293(strJson):
- g_cfgParser.set_value('COMM', 'Chroma22293', strJson)
- # 获取Runner端TCPServer的port
- def getRunnerTcpPort():
- port = 9900
- prot_cfg_str = readConfigFile('COMM', 'runner_tcp_port')
- if prot_cfg_str:
- prot_cfg_int = int(prot_cfg_str)
- port = prot_cfg_int
- # print 'port:', port, type(port)
- return port
- # 写入Runner端TCPServer的port
- def writeRunnerTcpPort(port):
- writeConfigFile('COMM', 'runner_tcp_port', str(port))
- # 获取Tester端 设备监听TCPServer的port
- def getTesterListenTcpPort():
- port = 20000
- try:
- prot_cfg_str = readConfigFile('COMM', 'tester_listen_tcp_port')
- except Exception:
- prot_cfg_str = None
- if prot_cfg_str:
- prot_cfg_int = int(prot_cfg_str)
- port = prot_cfg_int
- # print 'port:', port, type(port)
- return port
- # 写入脚本中全步骤截图的开关
- def writeRestart(isSendKeyTakePicture):
- writeConfigFile('COMM', 'isRestart', str(isSendKeyTakePicture))
- # 获取脚本中全步骤截图的开关
- def getIsRestart():
- # isSendKeyTakePicture = "False"
- try:
- isSendKeyTakePicture = readConfigFile('COMM', 'isRestart')
- except Exception:
- isSendKeyTakePicture = "False"
- return isSendKeyTakePicture
- # 写入脚本中全步骤截图的开关
- def writeIsSendKeyTakePicture(isSendKeyTakePicture):
- writeConfigFile('COMM', 'isSendKeyTakePicture', str(isSendKeyTakePicture))
- # 获取脚本中全步骤截图的开关
- def getIsSendKeyTakePicture():
- # isSendKeyTakePicture = "False"
- try:
- isSendKeyTakePicture = readConfigFile('COMM', 'isSendKeyTakePicture')
- except Exception:
- isSendKeyTakePicture = "False"
- return isSendKeyTakePicture
- # 写入Tester界面中中全步骤截图的开关
- def writeIsSendKeyTakePictureTester(isSendKeyTakePicture):
- writeConfigFile('COMM', 'isSendKeyTakePicture_tester', str(isSendKeyTakePicture))
- # 读取Tester界面中中全步骤截图的开关
- def getIsSendKeyTakePictureTester():
- # isSendKeyTakePicture = "False"
- try:
- isSendKeyTakePicture = readConfigFile('COMM', 'isSendKeyTakePicture_tester')
- except Exception:
- isSendKeyTakePicture = "False"
- return isSendKeyTakePicture
- # 写入Runner端TCPServer的port
- def writeTesterListenTcpPort(port):
- writeConfigFile('COMM', 'tester_listen_tcp_port', str(port))
- # 写入配置文件接口
- def writeConfigFile(section, key, value):
- try:
- g_cfgParser.add_section(section)
- except Exception, e:
- print e
- g_cfgParser.set_value(section, key, value)
- # 读取配置文件接口
- def readConfigFile(session, key):
- value = None
- try:
- value = g_cfgParser.get_value(session, key)
- return value
- except Exception, e:
- print e
- return value
- # 读取音频设备列表;
- def getVoicecards():
- try:
- return json.loads(g_cfgParser.get_value("devices", "voicecards"))
- except Exception, e:
- print e
- return {}
- # 写入音频设备列表;
- def setVoicecards(strJson):
- g_cfgParser.set_value('devices', 'voicecards', strJson)
- '''
- 获取视频采集卡型号
- '''
- def getCCard_Selected():
- return readConfigFile('devices', 'ccard_selected')
- def getSoundList():
- try:
- sound_list_str = g_cfgParser.get_value("Sound", "sound_list")
- if type(sound_list_str) == type(''):
- sound_list = eval(sound_list_str)
- else:
- sound_list = sound_list_str
- if sound_list == []:
- sound_list = [1000, 1000]
- writeSoundList(sound_list)
- return sound_list
- except Exception, e:
- print e
- sound_list = [1000, 1000]
- writeSoundList(sound_list)
- return sound_list
- def writeSoundList(sound_list):
- writeConfigFile('Sound', 'sound_list', str(sound_list))
- def getOtaParamUrl_dict():
- return eval(g_cfgParser.get_value("URL", "getParam"))
- '''
- adb设备可用或不可用状态;
- return ture:可用,false:不可用
- '''
- def getAdbDeviceSatatus():
- Online = "Online"
- options = g_cfgParser.get_options("ADBSTATUS")
- # print "getAdbDeviceSatatus,options:",options
- if options is None:
- return False
- for option in options:
- status = g_cfgParser.get_value("ADBSTATUS",option)
- # print "getAdbDeviceSatatus,%s:"%option, status
- if status == Online:
- return True
- return False
- '''
- 获取adb设备状态描述
- return: none表示没有这个设备,Unauthorized表示设备未授权,offline表示设备离线,online表示在线可用
- '''
- def getAdbDevSTDesc():
- Online = "Online"
- options = g_cfgParser.get_options("ADBSTATUS")
- # print "getAdbDeviceSatatus,options:",options
- if options is None:
- return "none"
- for option in options:
- status = g_cfgParser.get_value("ADBSTATUS", option)
- return status
- return "none"
- if __name__ == "__main__":
- dict = getOtaParamUrl_dict()
- print "CN:",dict["CN"]
- print "ME:",dict["ME"]
- # print "OCR IP addr:", getOCRIpAddr()
- # print "OCR port:", getOCRPort()
- # print "Serial port:", getSerialCOM()
- # print "SAT Home:", getSATHome()
- # # setResultDir("D:/SAT/result_schedule_id_schedule_name_task_number/")
- # # print "Result DIR:", getResultDir()
- #
- # print 'getTG39_Port:', getTG39_Port()
- # print 'getRCUSelected:', getRCUSelected()
- # print 'getAtv_list:', getAtv_list(), type(getAtv_list())
- # writeRCUSelected('RC322')
- # list = getChroma22293()
- # for item in list:
- # print item["name"],item["port"]
- # print list
- # getDtv_list()
- # getRunnerTcpPort()
- # writeRunnerTcpPort(9966)
- # getRunnerTcpPort()
|