#!/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("\n") 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_CUSDEF\d?(.*)",each):
setStr.add(re.search("^#define PN_CUSDEF\d?(.*)",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("\n") 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()

genPanel.py的更多相关文章

  1. python调用py中rar的路径问题。

    1.python调用py,在py中的os.getcwd()获取的不是py的路径,可以通过os.path.split(os.path.realpath(__file__))[0]来获取py的路径. 2. ...

  2. Python导入其他文件中的.py文件 即模块

    import sys sys.path.append("路径") import .py文件

  3. import renumber.py in pymol

    cp renumber.py /usr/local/lib/python2.7/dist-packages/pymol import renumber or run /path/to/renumber ...

  4. python gettitle.py

    #!/usr/bin/env python # coding=utf-8 import threading import requests import Queue import sys import ...

  5. 解决 odoo.py: error: option --addons-path: The addons-path 'local-addons/' does not seem to a be a valid Addons Directory!

    情况说明 odoo源文件路径-/odoo-dev/odoo/: 我的模块插件路径 ~/odoo-dev/local-addons/my-module 在my-module中创建了__init__.py ...

  6. caffe机器学习自带图片分类器classify.py实现输出预测结果的概率及caffe的web_demo例子运行实例

    caffe机器学习环境搭建及python接口编译参见我的上一篇博客:机器学习caffe环境搭建--redhat7.1和caffe的python接口编译 1.运行caffe图片分类器python接口 还 ...

  7. 【转】Windows下使用libsvm中的grid.py和easy.py进行参数调优

    libsvm中有进行参数调优的工具grid.py和easy.py可以使用,这些工具可以帮助我们选择更好的参数,减少自己参数选优带来的烦扰. 所需工具:libsvm.gnuplot 本机环境:Windo ...

  8. MySqlNDB使用自带的ndb_setup.py安装集群

    在用Mysql做集群时,使用Mysql的NDB版本更易于集群的扩展,稳定和数据的实时性. 我们可以使用Mysql自带的工具进行集群安装与管理:ndb_setup.py.位于Mysql的安装目录bin下 ...

  9. 将做好的py文件打包成模块,供别人安装调用

    现在要将写完的3个py文件,打包. 步骤: 1.新建一个文件夹setup(名字随便取),在setup文件夹下,再新建一个文件夹financeapi. 2.将上面4个py文件拷贝至financeapi文 ...

随机推荐

  1. 【C#】使用bat文件安装卸载Window服务

    1.安装服务 @echo off @title 安装windows服务path %SystemRoot%\Microsoft.NET\Framework\v4.0.30319echo========= ...

  2. JAVA核心技术I---JAVA基础知识(列表List)

    一:List了解 (一)List:列表 –有序的Collection –允许重复元素 –{,,,{,},,} (二)List:主要实现 同步/非同步:针对线程而言 –ArrayList(非同步的) – ...

  3. Git(查看修改记录)

    我们已经成功地添加并提交了一个readme.txt文件,现在,是时候继续工作了,于是,我们继续修改readme.txt文件,改成如下内容: Git is a distributed version c ...

  4. ACM-ICPC 2018 焦作赛区网络预赛 A Magic Mirror(签到)

    https://nanti.jisuanke.com/t/31710 题意 若输入的是Jessie或jessie,输出Good guy!,否则输出Dare you say that again? 分析 ...

  5. weblogic安装错误记录

    问题1:/opt/oraInventory路径无效(无法读取/写入/执行) 查看目录权限,发现此目录属于dba,如果用这个目录的话,可能会覆盖掉Oracle数据库相关的东西 再参照weblogic静默 ...

  6. 使用yield和send实现简单的协程函数

    使用yield和send实现协程 协程的本质是在一个线程里实现多个任务之间的来回切换,我们使用yield和send可以实现简单的协程 def pro(): print(1) n = yield &qu ...

  7. Servlet 快速开始 表单中文字段

    req.getParameter | getParameterValue 一大特点是 返回null表示没有. [web.xml] <servlet> <serlvlet-mappin ...

  8. MYSQL ERROR 1045 (28000) Access denied for user (using password YES)问题的解决

    我的Linux是Centos6.7的版本,本机上Mysql突然怎么连接都进不去 报错:MYSQL ERROR 1045 (28000) Access denied for user (using pa ...

  9. 【bzoj 2588】Spoj 10628. Count on a tree

    Description 给定一棵N个节点的树,每个点有一个权值,对于M个询问(u,v,k),你需要回答u xor lastans和v这两个节点间第K小的点权.其中lastans是上一个询问的答案,初始 ...

  10. 【SRM-06 D】五色战队&&【codeforces 788E】 New task

    原题链接:788E - New task Description 游行寺家里人们的发色多种多样,有基佬紫.原谅绿.少女粉.高级黑.相簿白等. 日向彼方:吾令人观其气,气成五彩,此天子气也. 琉璃:我们 ...