Python VIL Realse

 

#!/usr/bin/python
#-*- coding:utf-8 –*-

import os
import sys
import re
import shutil
import xlrd
import xlwt
from xlutils.copy import copy

'''
提取相关RELEASE信息,追加“SW Release Note.xls”
运行命令 ./gen_release.py "Modified reason"
'''

def fun_genRelease():
    list = []
    curLine = ""
    book = xlrd.open_workbook(r'./mergedir/SW Release Note.xls',formatting_info=True)
    sheet = book.sheet_by_index(0)
    
    newBook = copy(book)
    newSheet = newBook.get_sheet(0)
    list.append(sheet.nrows-1)
    with open("./drivers/include/project.h", "r") as mFile:
        proData = mFile.read()
        
    with open("./aps/include/common_patch.h","r") as comFile:
        comData = comFile.read()
    modeId = re.search(".*DEFAULT_MODE_ID\s+(\d+).*",comData).group(1)
        
    pat = re.compile(".*?(\d+).*\{.*\"((\d+)_.*)\",\s+&\w+\[\d+\],\s+/\*(.*?)\*/\s+&\w+\[\d+\],\s+/\*(.*)\*/.*")
    
    list.append(re.search(".*CONFIG_APP_FOLDER_NAME.*\"(.*)\"", proData).group(1))
    board = re.search(".*CONFIG_MODEL_BOARD_NAME\s+\"(\w+)\"",proData).group(1)
    
    with open("./aps/customer/radisson/%s/adaptable/model_data.c" %board,"r") as modeFile:
        modeList = modeFile.readlines()
        
    for line in modeList:
        if pat.search(line) and pat.search(line).group(1) == modeId:
            curLine = line
            break
        
    list.append(pat.search(curLine).group(2))
    list.append(pat.search(curLine).group(3))
    list.append(pat.search(curLine).group(4))
    list.append(pat.search(curLine).group(5))
    list.append("LL" if "LL" in pat.search(curLine).group(2) else "NON LL")
    list.append("" if len(sys.argv) ==1 else sys.argv[1])
    
    with open("./aps/include/timestamp.h","r") as verFile:
        verData = verFile.read()
        
    list.append("%s%s" %(board,re.search(".*TIME_VERSION\s+\"(\w+)\".*",verData).group(1)))
    list.append("")
    list.append("")
    list.append("bjornLee")
    
    #写EXCEL
    #for col in range(sheet.ncols):
    col = 0
    for cell in list:
        newSheet.write(sheet.nrows,col,cell)
        col = col+1
        #newSheet.write(sheet.nrows,col,"test")
    newBook.save(r'./mergedir/SW Release Note.xls')
    print "\n",list,"\n"
    
    

def main():
    fun_genRelease()
    
if __name__ == '__main__':
    main()





    
    



    
    


    

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值