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("\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的更多相关文章
- python调用py中rar的路径问题。
1.python调用py,在py中的os.getcwd()获取的不是py的路径,可以通过os.path.split(os.path.realpath(__file__))[0]来获取py的路径. 2. ...
- Python导入其他文件中的.py文件 即模块
import sys sys.path.append("路径") import .py文件
- import renumber.py in pymol
cp renumber.py /usr/local/lib/python2.7/dist-packages/pymol import renumber or run /path/to/renumber ...
- python gettitle.py
#!/usr/bin/env python # coding=utf-8 import threading import requests import Queue import sys import ...
- 解决 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 ...
- caffe机器学习自带图片分类器classify.py实现输出预测结果的概率及caffe的web_demo例子运行实例
caffe机器学习环境搭建及python接口编译参见我的上一篇博客:机器学习caffe环境搭建--redhat7.1和caffe的python接口编译 1.运行caffe图片分类器python接口 还 ...
- 【转】Windows下使用libsvm中的grid.py和easy.py进行参数调优
libsvm中有进行参数调优的工具grid.py和easy.py可以使用,这些工具可以帮助我们选择更好的参数,减少自己参数选优带来的烦扰. 所需工具:libsvm.gnuplot 本机环境:Windo ...
- MySqlNDB使用自带的ndb_setup.py安装集群
在用Mysql做集群时,使用Mysql的NDB版本更易于集群的扩展,稳定和数据的实时性. 我们可以使用Mysql自带的工具进行集群安装与管理:ndb_setup.py.位于Mysql的安装目录bin下 ...
- 将做好的py文件打包成模块,供别人安装调用
现在要将写完的3个py文件,打包. 步骤: 1.新建一个文件夹setup(名字随便取),在setup文件夹下,再新建一个文件夹financeapi. 2.将上面4个py文件拷贝至financeapi文 ...
随机推荐
- JAVA核心技术I---JAVA回顾
一:基础类型运算 大部分的指令都没有支持byte.char.short,没有任何指令支持boolean类型.编译器在编译期或者运行期将byte和short类型的数据带符号扩展为相应的int类型数据,将 ...
- Hadoop记录-变更
1.安装salt-minion sed -i 's/^#//g' /etc/yum.repos.d/centos7.4.repo sed -i 's/enabled=0/enabled=1/g' /e ...
- webapi快速开发框架
一.webapi快速开发框架搭建之后台 从0开始搭建webapi基本框架.权限控制.异常管理.日志管理.缓存管理 源码:https://github.com/shengyu-kmust/webapi ...
- 前台ajax传参数,后台spring mvc用对象接受
第二种方法:利用spring mvc的机制,调用对象的get方法,要求对象的属性名和传的参数名字一致(有兴趣的同学看 springmvc源码) 1.将参数名直接写成对象的属性名 $.ajax({ ur ...
- MySQL-5.7数据库主从同步实战教程
主从形式 MySQ主从复制原理(主库写入数据,从库读取数据) MySql常用命令: MySQL5.7设置密码 ') where user='root': MySQL5.6设置密码 ') WHERE U ...
- 【三】Eureka服务注册与发现
1.是什么 Eureka是Netflix的一个子模块,也是核心模块之一.Eureka是一个基于 REST 服务,用于定位服务,以实现云端中间层服务发现和故障转移.服务注册与发现对于微服务架构来说是非常 ...
- 开发mis系统需要的技术
一.b/s架构 b/s架构:就broser/server,浏览器/服务器的说法.服务器端要运行tomcat,提供链接数据库服务供java代码读写数据,这个可以在eclipse中配置运行.浏览器则解释j ...
- [C++]2-1 水仙花数
/* 水仙花数 输出100-999中的所有水仙花数.若三位数ABC满足ABC=A^3+B^3+C^3,则 称其为水仙花数.例如:153 = 1^3 + 5^3 + 3^3,故153是水仙花数. */ ...
- MongoDB初探-基本语句和数据结构
MySQL: 1 金老板 18 15512351234 2 小哪吒 20 15312341234 3 Alex 73 15512341234 MongoDB: { { id : 1, name:金老板 ...
- Ubuntu安装MongoDB
一.下载安装 首先,更新软件包列表以获取最新版本的存储库列表: sudo apt update 2.接着安装MongoDB包本身: sudo apt install -y mongodb ×加-y是为 ...