使用python判断Android自动化的渠道包是否全部打完

Android客户端测试上线总会有很多的渠道包,渠道的打包可以使用自动化,但是每次打完都是好几十个或者几百个apk,很难确定是不是所有的渠道都已经打完,所以就有了下面的一段代码,主要就是为了检查是否将所有的渠道包打包完毕:

 1 # coding=utf-8
 2 import os
 3 import xlrd
 4 import shutil
 5 #获取给定excel列表中的所有渠道号
 6 def add_Qudao_Name(channel_excel_path):
 7     data=xlrd.open_workbook(channel_excel_path)
 8     table=data.sheets()[0]
 9     nrows=table.nrows
10     a=[]
11     for i in xrange(1,nrows):
12         channel=table.cell_value(i,1).encode('utf-8').strip()
13         a.append(channel)
14     return a
15 #获取给定excel列表中的每个渠道号和source的对应
16 def add_Qudao_Source(channel_excel_path):
17     data=xlrd.open_workbook(channel_excel_path)
18     table=data.sheets()[0]
19     nrows=table.nrows
20     a={}
21     for i in xrange(1,nrows):
22         channel=table.cell_value(i,1).encode('utf-8').strip()
23         source=int(table.cell_value(i,2))
24         a[channel]=source
25     return a
26 #从指定打包的apk文件名中截取到渠道号
27 def find_Package_Name(start_str,end_str,name):
28     start=name.find(start_str)
29     if start>=0:
30         end=name.find(end_str)-1
31         if end>=0:
32             return name[start:end]
33 #筛选已有的渠道号是否全部打包完成
34 def check_Package_Name(dir):#dir为渠道包所在路径
35      channels=add_Qudao_Name()
36      a=[]
37      for i in os.listdir(dir):
38         s=find_Package_Name('A','r',i)
39         if s!=None:
40             a.append(s)
41      b=[]
42      for m in channels:
43          if m not in(a):
44             b.append(m)
45 
46      return b
47 #将指定列表中的渠道包从打出的所有渠道包中拷贝出来
48 def copy_Package_list(dir):#dir为渠道包路径
49     channels=add_Qudao_Name()
50     for m in channels:
51         for i in os.listdir(dir):
52             s=find_Package_Name('A','r',i)
53             if s!=".DS_Store" and s==m:
54                 shutil.copy(dir+i,r'/Users/tangyao/Desktop/test')

 

posted @ 2014-12-09 18:35  guoke1001  阅读(360)  评论(7编辑  收藏  举报