#!/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. oracle数据泵导入导出命令

    1.在PL/SQL的界面,找到Directories文件夹,找到目录文件的路径 2.通过SSH进入服务器 找到相应的路径 cd /u01/oracle/dpdir 输入指令 df -h   查看资源使 ...

  2. hibernate关联关系映射之配置文件

    词汇解释 关系:事物之间相互作用.相互联系的状态.范围最大. 联系:在关系数据库中表示实体与实体之间的联系,1:1,1:n,m:n. 关联:表示对象之间的关系,既有数量性,又有方向性:动词:将对象之间 ...

  3. 解决mysql:Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)

    (一)出现问题的的报错信息 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111) ( ...

  4. EJB到底是什么

    EJB到底是什么?   1. 我们不禁要问,什么是"服务集群"?什么是"企业级开发"? 既然说了EJB 是为了"服务集群"和"企业 ...

  5. jquery遇到的问题

    1.关于$.fn $.fn是指jquery的命名空间,加上fn上的方法及属性,会对jquery实例每一个有效. 如扩展$.fn.abc(),即$.fn.abc()是对jquery扩展了一个abc方法, ...

  6. in和hasOwnProperty的区别

    两者都代表查看某个属性是不是对象自己的,返回布尔值 in判断的是对象的所有属性,包括对象实例及其原型的属性 hasOwnProperty则是判断对象实例的是否具有某个属性

  7. sql parser

    最近在整理很多SQL代码, 需要分析出每个SQL的目标表和源表各有哪些, 网上没有找到工作具, 打算写个工具. Java调研结果:1. 商业组件包 sqlparser 有试用版组件, 限制SQL少于1 ...

  8. overflow:auto学习

    一直认为没认为这个属性没什么大的用处,最近在使用一次iscroll时一直浮动到顶部层上面找了半天,发现可以用这个属性解决. 1.功能1,清除浮动.设置overflow并不会在该元素上清除浮动,它将清除 ...

  9. JS判断是电脑浏览器还是手机端浏览器,并根据不同的终端跳转到不同的网址

    <!DOCTYPE html> <html> <script> function browserRedirect() { var sUserAgent = navi ...

  10. 微信接口 output {"errMsg":"translateVoice:fail, the permission value is offline verifying"}

    jsApiList : [ 'checkJsApi', 'startRecord', 'stopRecord','translateVoice','scanQRCode', 'openCard' ]增 ...