python执行gradle脚本
生活随笔
收集整理的這篇文章主要介紹了
python执行gradle脚本
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
1 import os
2 import shutil
3 import subprocess
4
5 #拷貝文件
6 def copyFile(srcFile, dstFile):
7 #檢查源文件是否存在
8 if not os.path.isfile(srcFile):
9 print('%s not exist' % srcFile)
10 return False
11 #如果目的路徑不存在創(chuàng)建目錄
12 fpath, fname = os.path.split(dstFile)
13 if not os.path.exists(fpath):
14 os.makedirs(fpath)
15 shutil.copyfile(srcFile, dstFile)
16 print('copy %s -> %s' %(srcFile,dstFile))
17 return True
18
19 #刪除文件
20 def deleteFile(path) :
21 if os.path.exists(path):
22 os.remove(path)
23
24 #執(zhí)行g(shù)radle task
25 def gradleBuild(task, gradlePath, **kwargs):
26 args = ''
27 for key in kwargs:
28 args += '-P' + key + '=' + '\"' + kwargs[key] + '\"' + " "
29
30 cmd = 'gradle %s %s -b %s/build.gradle' % (task, args, gradlePath)
31 mystr = os.popen(cmd)
32 mystr = mystr.read()
33 #print(mystr)
34 if mystr.find('BUILD SUCCESSFUL') != -1:
35 print('execute task succ:%s' % cmd)
36 return True
37
38 print('execute task failed:%s' % cmd)
39 return False
?
轉(zhuǎn)載于:https://www.cnblogs.com/llh1874/p/9208827.html
總結(jié)
以上是生活随笔為你收集整理的python执行gradle脚本的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 学习笔记(38):Python实战编程-
- 下一篇: 学习笔记(39):Python实战编程-