【script】一个打包应用的脚本

来源:互联网 发布:mac 创建.gitignore 编辑:程序博客网 时间:2024/05/01 18:25
#!/usr/bin/python# -*- #coding:utf-8import osimport reimport subprocessimport syschannelXml1 = './res/values/channel.xml'channelXml2 = './res/values-zh-rCN/channel.xml'XML_TEXT="<?xml version=\"1.0\" encoding=\"utf-8\"?><resources><string name=\"channel_id\">%s</string></resources>"def changeClientChannelId(newChannelId,channel):    writeFile = open(channel, 'w')    writeFile.write(XML_TEXT%(newChannelId))    writeFile.flush()    writeFile.close()def makesureApksDir():    if not os.path.exists("./apks"):        os.mkdir("apks")        def validateArgs():    if len(sys.argv) < 3:        return False    start = int(sys.argv[1])    end = int(sys.argv[2])    if start > end:        return False    return Truedef main():        if not validateArgs():        print "please entry start-end position, ex: python xwifi.py 1 100"        return    start = int(sys.argv[1])    end = int(sys.argv[2])    makesureApksDir()    for clientChannelId in range(start, end+1):        print clientChannelId        changeClientChannelId(clientChannelId,channelXml1)        changeClientChannelId(clientChannelId,channelXml2)        handle = subprocess.Popen("ant clean,release", shell=True,  stdout=subprocess.PIPE)        print handle.communicate()[0]        os.rename('./bin/ticket_12306-release.apk', './apks/brontosaurus_ticket-release_%s.apk' %(clientChannelId))        print './apks/brontosaurus_ticket_%s.apk is over' %(clientChannelId)    main()

0 0
原创粉丝点击