zoukankan      html  css  js  c++  java
  • genPanel.py

    #!/usr/bin/python
    # -*- coding: UTF-8 -*-
    import os
    import sys
    import re
    import shutil
    import glob
    '''
    脚本使用说明 
                 1. 执行命令./genPanel.py -a 分辨率 :代表生成这种分辨率的软件包
                 2. 如果想要编译特定的几个分辨率的软件,可在make radissonconfig中选择多个分辨率,然后执行命令./genPanel.py -b 即可
    '''
    cfgFileName = "radisson.config"
    buildNowfile = "../BUILD_RECORD/BUILD_NOW.h"
    g_ratioAMode = 0
    g_ratioBMode = 0 
    def CreatebinDir(): 
        global binDir
        try:
            fd = open(cfgFileName, "r")
            data = fd.readlines()
            for linedata in data:
                if re.search("^CONFIG_CUSDEF_MI.*",linedata):
             #获取字串linedata以“_”分开的第四个字串,linedata.split('_')返回一个列表 Customer = (linedata.split('_'))[3] elif re.search("^CONFIG_CUSDEF_BD.*",linedata): ChipType = (linedata.split('_'))[4] BoardType = (linedata.split('_'))[5].split('=')[0] BDCfg = ChipType+"_"+BoardType binDir = Customer+"_"+BDCfg fd.close() except IOError as err: binDir = "binFile" print('File Error: ' + str(err)) if os.path.exists(binDir): shutil.rmtree(binDir) os.mkdir(binDir) #编译某一分辨率的所有软件。 def RatioA(Resolution): PANEL_floder_path = ("../CUS_FILE/PN").replace('"','') for dirPath, dirNames, fileNames in os.walk(PANEL_floder_path): break for panelName in dirNames: #筛选符合需求的分辨率 if Resolution not in panelName: continue print "===Start Panel %s Please Wait ===" %panelName listSave = [] try: cfgFile = open(buildFile,"r") list = cfgFile.readlines() for each in list: if re.search("^#define PN_CUSDEF.*",each): continue else: listSave.append(each) each = "#define PN_CUSDEF %s" %(panelName) listSave.append(each) listSave.append(" ") cfgFile = open(buildFile,"w") cfgFile.writelines(listSave) cfgFile.close() except IOError as err: print('File Error: ' + str(err)) os.system('make clean;./build_history.sh') #将生成的bin文件移进软件包目录
         #glob模块返回一个完整的路径列表,而不是查找到的文件名 binPath=glob.glob(r"./mergedir/RR*.bin") if len(binPath) != 0: os.mkdir(panelName) shutil.copy(binPath[0],panelName) shutil.move(panelName,binDir) else: print "compile error!" sys.exit() #编译make radissonconfig中选中的多个分辨率 def RatioB(): try: panelSet = [] setStr = set() cfgFile = open(buildFile,"r") list = cfgFile.readlines() for each in list: if re.search("^#define PN_CUSDEFd?(.*)",each): setStr.add(re.search("^#define PN_CUSDEFd?(.*)",each).group(1)) for line in setStr: line1=line.strip() panelSet.append(line1) except IOError as err: print('File Error: ' + str(err)) for panelName in panelSet: print "===Start Panel %s Please Wait ===" %panelName listSave = [] try: cfgFile = open(buildFile,"r") list = cfgFile.readlines() for each in list: if re.search("^#define PN_CUSDEF .*",each): continue else: listSave.append(each) each = "#define PN_CUSDEF %s" %(panelName) listSave.append(each) listSave.append(" ") cfgFile = open(buildFile,"w") cfgFile.writelines(listSave) cfgFile.close() except IOError as err: print('File Error: ' + str(err)) os.system('make clean;./build_history.sh') #将生成的bin文件移进软件包目录 binPath=glob.glob(r"./mergedir/RR*.bin") if len(binPath) != 0: os.mkdir(panelName) shutil.copy(binPath[0],panelName) shutil.move(panelName,binDir) else: print "compile error!" sys.exit() def fun_parse_InputParam(): global g_ratioAMode global g_ratioBMode #获取脚本带入参数的长度 if len(sys.argv) < 2: print "The number of parameters is wrong!" sys.exit() else:
        #sys.argv[1]表示脚本带入的第一个的参数 opt1 = sys.argv[1] opt2 = ["1366x768","1440x900","1024x768","1400x1050","1920x1080","1024x600","1280x1024","1280x800","1400x1050","1600x900","1680x1050","1920x1200","1600x1200"] if opt1 == "-a" and len(sys.argv) == 3: g_ratioAMode = 1 if sys.argv[2] not in opt2: print("parameter2: unhandled option!") sys.exit() elif opt1 == "-b" and len(sys.argv) == 2: g_ratioBMode = 1 else: print("parameter error!") sys.exit() if __name__ == "__main__": #处理脚本带入的参数 fun_parse_InputParam() #从BUILD_NOW.h中获取build_setting.h所在的目录名 try: buildNow = open(buildNowfile,"r") list = buildNow.readlines() for line in list: if re.search("^#define BUILD_NAME .*",line): buildDir = re.search("^#define BUILD_NAME (.*)",line).group(1) buildNow.close() except IOError as err: print('File Error: ' + str(err)) buildFile = "../BUILD_RECORD/"+buildDir+"/BUILD_SETTING.h" #创建软件包目录 CreatebinDir() if g_ratioAMode: #编译某一分辨率的所有软件。 RatioA(sys.argv[2]) if g_ratioBMode: #编译make radissonconfig中选中的多个分辨率 RatioB()
  • 相关阅读:
    如何在 Knative 中部署 WebSocket 和 gRPC 服务?
    全球首个开放应用模型 OAM 开源 | 云原生生态周报 Vol. 23
    从零开始入门 K8s | Kubernetes 网络概念及策略控制
    重磅发布 | 全球首个云原生应用标准定义与架构模型 OAM 正式开源
    成都,我们来啦 | Dubbo 社区开发者日
    一文读懂分布式架构知识体系(内含超全核心知识大图)
    阿里巴巴开源 Dragonwell JDK 最新版本 8.1.1-GA 发布
    可能是国内第一篇全面解读 Java 现状及趋势的文章
    从零开始入门 K8s | 可观测性:监控与日志
    阿里巴巴的云原生与开发者
  • 原文地址:https://www.cnblogs.com/yuanqiangfei/p/8360238.html
Copyright © 2011-2022 走看看