Android 借助 Python 实现自动上传蒲公英
2017-11-30 21:59
585 查看
感言下:程序猿是懒出来的,一切动力来源于方便
使用前提
本地电脑上安装Python 和 pip
使用pip安装requests库( pip3 install requests )
附上蒲公英上传App文档 : https://www.pgyer.com/doc/view/api#uploadApp
万事俱备只欠东风,codeing -_- ~~
把文件放在AndroidStudio工程目录下,配置build.gradle文件
最后嘛,当然是runing
在终端输入 ./gradlew releaseToPGYER
灵感来源:http://www.jianshu.com/p/0ec4c4e132e7
使用前提
本地电脑上安装Python 和 pip
使用pip安装requests库( pip3 install requests )
附上蒲公英上传App文档 : https://www.pgyer.com/doc/view/api#uploadApp
万事俱备只欠东风,codeing -_- ~~
# UploadToPGY.py 主要上传文件 # coding=utf-8 # encoding=utf-8 import requests import sys def uploadFile(): # 获取运行传递过来的参数 _upload_url = sys.argv[1] _api_key = sys.argv[2] _apk_path = sys.argv[3] _description = sys.argv[4] # 上传apk try: file = {'file': open(_apk_path, 'rb')} param = {'_api_key': _api_key, 'updateDescription': _description} req=requests.post(url=_upload_url,files=file,data=param,verify=False) print(req.status_code) except Exception as e: print("upload:" + e) if __name__ == '__main__': uploadFile()
把文件放在AndroidStudio工程目录下,配置build.gradle文件
task releaseToPGYER { dependsOn 'assembleRelease' doLast { def _upload_url = "https://www.pgyer.com/apiv2/app/upload" def _api_key = "$apikey(填写蒲公英上的key)" def _apk_path = "$buildDir/outputs/apk/app-release.apk" def _update_description = "Python auto upload -_- " //执行Python脚本 def process = "python UploadToPGY.py ${_upload_url} ${_api_key} ${_apk_path} ${_update_description}".execute() println "开始上传至蒲公英" //获取Python脚本日志,便于出错调试 ByteArrayOutputStream result = new ByteArrayOutputStream() def inputStream = process.getInputStream() byte[] buffer = new byte[1024] int length while ((length = inputStream.read(buffer)) != -1) { result.write(buffer, 0, length) } println(result.toString("UTF-8")) println "上传结束" } }
最后嘛,当然是runing
在终端输入 ./gradlew releaseToPGYER
灵感来源:http://www.jianshu.com/p/0ec4c4e132e7
相关文章推荐
- Android 借助 Python 实现自动打包上传 fir
- Jenkins+Gradle实现android开发 自动打包 上传蒲公英
- [置顶] Jenkins+Gradle实现android开发 自动打包 上传蒲公英
- Android自动打包,加固/上传蒲公英/修改数据库等Python版
- 用shell和python实现FTP自动登陆然后上传和下载
- android使用第三方平台(蒲公英)和DownloadManager实现APP自动更新
- 【Android】使用Jenkins+Gradle+FTP,实现自动打包,自动上传文件至FTP
- Python实现 跳一跳 自动运行( windows+android)
- Python+ADB实现Android手机QQ自动点赞
- python实现的ftp自动上传下载程序(支持目录递归操作)----转
- Android 通过蒲公英pgyer的接口 Service 实现带进度下载App 通知栏显示 在线更新 自动更新Demo
- Android 通过蒲公英pgyer的接口 Service 实现带进度下载App 通知栏显示 在线更新 自动更新Demo
- Editplus借助python实现根据方法参数自动生成php注释
- Python实现腾讯云CDB备份文件自动上传到COS
- python 实现自动上传文件到百度网盘(附程序源码及实现过程)
- eWebEditor不能实现远程文件自动上传的解决方法
- 借助WebService实现多线程上传文件
- WEB环境中后台自动上传文件至数据库的实现
- 将C++代码全部写到头文件:)python脚本帮助自动生成相应的实现文件初始框架
- shell实现ftp自动上传