添加自研批检仪检测命令
This commit is contained in:
100
mycopy.py
Normal file
100
mycopy.py
Normal file
@@ -0,0 +1,100 @@
|
||||
import shutil
|
||||
import sys
|
||||
import os
|
||||
import prebuild as time
|
||||
import mysql
|
||||
import quest
|
||||
|
||||
|
||||
|
||||
# 定义数据库目录
|
||||
SQL_APP_PATH = "checker_host_app"
|
||||
|
||||
|
||||
|
||||
def find_type(str):
|
||||
path = os.getcwd()
|
||||
#print(path)
|
||||
list=os.listdir(path)
|
||||
file_list=[]
|
||||
for i in list:
|
||||
if(i[-len(str):]==str):
|
||||
file_list.append(i)
|
||||
return file_list
|
||||
|
||||
|
||||
# 把ext_name打包到name之后
|
||||
def pack_file(name,ext_name):
|
||||
with open(name, "ab") as f:
|
||||
data=bytearray(256)
|
||||
data[4:len(ext_name)+4]=bytearray(ext_name,"utf-8")
|
||||
with open(ext_name,"rb") as g:
|
||||
g.seek(0, os.SEEK_END)
|
||||
size=g.tell()+256
|
||||
g.seek(0, os.SEEK_SET)
|
||||
data[0]=size&0xff
|
||||
data[1]=(size>>8)&0xff
|
||||
data[2]=(size>>16)&0xff
|
||||
data[3]=(size>>24)&0xff
|
||||
print("name:",ext_name,"size=",size)
|
||||
f.write(data)
|
||||
f.write(g.read())
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
#src ="~/QtWorkSpace/build-QtTcpClient-ATK_MP157-Debug/QtTcpClient"
|
||||
#dst="~/linux/nfs/qt_tcp_client.app"
|
||||
if(len(sys.argv)<3):
|
||||
print("argv num too less")
|
||||
return
|
||||
src=sys.argv[1]
|
||||
dst=sys.argv[2]
|
||||
cp=""
|
||||
if(len(sys.argv)>3):
|
||||
cp=sys.argv[3]
|
||||
|
||||
if not os.path.exists(src):
|
||||
print(src+' File Error!!!')
|
||||
else:
|
||||
|
||||
if os.path.exists(dst):
|
||||
os.remove(dst)
|
||||
shutil.copy(src,dst)
|
||||
#os.remove(src)
|
||||
file = open(dst,"ab")
|
||||
file.seek(0, os.SEEK_END)
|
||||
print("File Size is :", file.tell())
|
||||
list_file=find_type('.sh')
|
||||
for i in list_file:
|
||||
pack_file(dst,i)
|
||||
list_file=find_type('.json')
|
||||
for i in list_file:
|
||||
pack_file(dst,i)
|
||||
list_file=find_type('.bin')
|
||||
for i in list_file:
|
||||
pack_file(dst,i)
|
||||
list_file=find_type('.lua')
|
||||
for i in list_file:
|
||||
pack_file(dst,i)
|
||||
file.seek(0, os.SEEK_END)
|
||||
print("File Size is :", file.tell())
|
||||
file.close()
|
||||
if(len(cp)>0):
|
||||
cp=cp+'/'+"checker_"+time.get_date()+".elf"
|
||||
print(cp)
|
||||
shutil.copy(dst,cp)
|
||||
sql=mysql.sql()
|
||||
if(sql.init(SQL_APP_PATH)==True):
|
||||
q=quest.quest_text("请输入本次提交的描述信息")
|
||||
ack,text=q.show()
|
||||
if(ack==True):
|
||||
sql.insert(cp,text)
|
||||
else:
|
||||
print("user cancelled.")
|
||||
print("time:",time.get_time())
|
||||
print(dst+' File copy success.')
|
||||
|
||||
|
||||
if __name__=="__main__":
|
||||
main()
|
Reference in New Issue
Block a user