get log
C:\Users\wb_changxiang.chen\Desktop\get_log_adb.py
#! /usr/bin/env python
import os
import sys
import time
import zipfile
import subprocess
import shutil
import urllib2
from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
import poster
adb_prg = "adb"
def main(outdir):
global adb_prg
timestr = str(time.time())
timestr = timestr[0:10]
os.system("%s root"%adb_prg)
print ("wait-for-device ...")
os.system("%s wait-for-device"%adb_prg)
print ("device is ok.")
dirname = os.path.join(outdir,"upload_log_%s"%timestr)
if not os.path.exists(dirname):
os.makedirs(dirname)
os.system("%s shell getprop ro.yunos.build.version >%s"%(adb_prg,os.path.join(dirname,"version.txt")))
os.system("%s shell getprop >%s"%(adb_prg,os.path.join(dirname,"prop.txt")))
args = [adb_prg,"shell","ls","/data/","/mnt/sdcard/"]
retval,output = execute2(args)
datadir = []
items = output.split("\n")
for item in items:
item = item.strip()
if item == "anr":
datadir.append("/data/anr")
elif item == "apr":
datadir.append("/data/apr")
elif item == "tombstones":
datadir.append("/data/tombstones")
elif item == "tombstones_apr":
datadir.append("/data/tombstones_apr")
elif item == "aee_exp":
datadir.append("/mnt/sdcard/aee_exp")
for dirs in datadir:
os.system("%s pull %s %s >/dev/null 2>&1"%(adb_prg,dirs,dirname))
'''
os.system("%s pull /data/anr/ %s"%(adb_prg,dirname))
os.system("%s pull /data/apr/ %s"%(adb_prg,dirname))
os.system("%s pull /data/tombstones/ %s"%(adb_prg,dirname))
os.system("%s pull /data/tombstones_apr/ %s"%(adb_prg,dirname))
os.system("%s pull /mnt/sdcard/mtklog/aee_exp/ %s"%(adb_prg,dirname))
'''
zipname = dirname + ".zip"
zip = zipfile.ZipFile(zipname,"w",zipfile.ZIP_DEFLATED,True)
filecount = 0
for root,dirs,files in os.walk(dirname):
for file in files:
if file.startswith("anr") or file.startswith("tombstone") or file.startswith("error") or file.startswith("db."):
filename = os.path.join(root,file)
zip.write(filename,file)
filecount += 1
zip.write(os.path.join(dirname,"version.txt"),"version.txt")
zip.write(os.path.join(dirname,"prop.txt"),"prop.txt")
zip.close()
shutil.rmtree(dirname)
if filecount == 0:
os.remove(zipname)
print "Not found anr,apr,tombstone,mtk log file"
else:
print "create zip file %s"%zipname
#upload_file(zipname,"123456789")
def execute2(args):
global adb_prog
p = subprocess.Popen(args,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=False)
str = ""
for line in p.stdout:
str += line
p.wait()
return p.returncode,str
def upload_file(filename,bug_id):
register_openers()
datagen, headers = multipart_encode({"userfile": open(filename, "rb"),"action":"upload_log_file","from":"bugfree","bug_id":bug_id,"log_type":"", "username":"alibaba-test1","access_token":"Yu7&8qse.;<>mm","client_type":"python_client"})
request = urllib2.Request("http://10.125.224.50/php/upload.php", datagen, headers)
print urllib2.urlopen(request).read()
def usage(procname):
procname = os.path.basename(procname)
print "\nUsage: %s output_dir"%procname
print "example:"
print "\t%s . "%procname
print "\t%s log_dir\n"%procname
print "Syser tools for %s, version 1.0.0"%procname
print "Copyright (C) 2014 make by Wu yanfeng"
quit()
if __name__ == "__main__":
basename = os.path.basename(sys.argv[0])
if basename.endswith("adb.py"):
adb_prg = "adb"
elif basename.endswith("acb.py"):
adb_prg = "acb"
if len(sys.argv) == 1:
usage(sys.argv[0])
quit()
main(sys.argv[1])
C:\Users\wb_changxiang.chen\Desktop\get_log_adc.py
#! /usr/bin/env python
import os
import sys
import time
import zipfile
import subprocess
import shutil
import urllib2
from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
import poster
adb_prg = "adb"
def main(outdir):
global adb_prg
timestr = str(time.time())
timestr = timestr[0:10]
os.system("%s root"%adb_prg)
print ("wait-for-device ...")
os.system("%s wait-for-device"%adb_prg)
print ("device is ok.")
dirname = os.path.join(outdir,"upload_log_%s"%timestr)
if not os.path.exists(dirname):
os.makedirs(dirname)
os.system("%s shell getprop ro.yunos.build.version >%s"%(adb_prg,os.path.join(dirname,"version.txt")))
os.system("%s shell getprop >%s"%(adb_prg,os.path.join(dirname,"prop.txt")))
args = [adb_prg,"shell","ls","/data/","/mnt/sdcard/"]
retval,output = execute2(args)
datadir = []
items = output.split("\n")
for item in items:
item = item.strip()
if item == "anr":
datadir.append("/data/anr")
elif item == "apr":
datadir.append("/data/apr")
elif item == "tombstones":
datadir.append("/data/tombstones")
elif item == "tombstones_apr":
datadir.append("/data/tombstones_apr")
elif item == "aee_exp":
datadir.append("/mnt/sdcard/aee_exp")
for dirs in datadir:
os.system("%s pull %s %s >/dev/null 2>&1"%(adb_prg,dirs,dirname))
'''
os.system("%s pull /data/anr/ %s"%(adb_prg,dirname))
os.system("%s pull /data/apr/ %s"%(adb_prg,dirname))
os.system("%s pull /data/tombstones/ %s"%(adb_prg,dirname))
os.system("%s pull /data/tombstones_apr/ %s"%(adb_prg,dirname))
os.system("%s pull /mnt/sdcard/mtklog/aee_exp/ %s"%(adb_prg,dirname))
'''
zipname = dirname + ".zip"
zip = zipfile.ZipFile(zipname,"w",zipfile.ZIP_DEFLATED,True)
filecount = 0
for root,dirs,files in os.walk(dirname):
for file in files:
if file.startswith("anr") or file.startswith("tombstone") or file.startswith("error") or file.startswith("db."):
filename = os.path.join(root,file)
zip.write(filename,file)
filecount += 1
zip.write(os.path.join(dirname,"version.txt"),"version.txt")
zip.write(os.path.join(dirname,"prop.txt"),"prop.txt")
zip.close()
shutil.rmtree(dirname)
if filecount == 0:
os.remove(zipname)
print "Not found anr,apr,tombstone,mtk log file"
else:
print "create zip file %s"%zipname
#upload_file(zipname,"123456789")
def execute2(args):
global adb_prog
p = subprocess.Popen(args,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=False)
str = ""
for line in p.stdout:
str += line
p.wait()
return p.returncode,str
def upload_file(filename,bug_id):
register_openers()
datagen, headers = multipart_encode({"userfile": open(filename, "rb"),"action":"upload_log_file","from":"bugfree","bug_id":bug_id,"log_type":"", "username":"alibaba-test1","access_token":"Yu7&8qse.;<>mm","client_type":"python_client"})
request = urllib2.Request("http://10.125.224.50/php/upload.php", datagen, headers)
print urllib2.urlopen(request).read()
def usage(procname):
procname = os.path.basename(procname)
print "\nUsage: %s output_dir"%procname
print "example:"
print "\t%s . "%procname
print "\t%s log_dir\n"%procname
print "Syser tools for %s, version 1.0.0"%procname
print "Copyright (C) 2014 make by Wu yanfeng"
quit()
if __name__ == "__main__":
basename = os.path.basename(sys.argv[0])
if basename.endswith("adb.py"):
adb_prg = "adb"
elif basename.endswith("acb.py"):
adb_prg = "acb"
if len(sys.argv) == 1:
usage(sys.argv[0])
quit()
main(sys.argv[1])
get log的更多相关文章
- 如何正确使用日志Log
title: 如何正确使用日志Log date: 2015-01-08 12:54:46 categories: [Python] tags: [Python,log] --- 文章首发地址:http ...
- UWP开发之Mvvmlight实践七:如何查找设备(Mobile模拟器、实体手机、PC)中应用的Log等文件
在开发中或者后期测试乃至最后交付使用的时候,如果应用出问题了我们一般的做法就是查看Log文件.上章也提到了查看Log文件,这章重点讲解下如何查看Log文件?如何找到我们需要的Packages安装包目录 ...
- const let,console.log('a',a)跟console.log('a'+a)的区别
const 创建一个只读的常量 let块级作用域 const let重复赋值都会报错 console.log('a',a) a console.log('a'+a) a2 逗号的值会有空格:用加号的值 ...
- CYQ.Data V5 从入门到放弃ORM系列:教程 - Log、SysLogs两个日志类使用
Log 静态类介绍: Public Static (Shared) Methods GetExceptionMessage 获取异常的内部信息 WriteLogToDB Overloaded. 将日志 ...
- your password has expired.to log in you must change it
今天应用挂了,log提示密码过期.客户端连接不上. 打开mysql,执行sql语句提示密码过期 执行set password=new password('123456'); 提示成功,但客户端仍然连接 ...
- console.log("A"-"B"+"3")=?
(点击上方的订阅号,可快速关注,关注有惊喜哦^_^) 前不久看到一道JS基础题目,做了一下竟然错了一半...在此分享一下: 先把题目放上来,大家可以自己测试一下再看答案哦^_^ ①console.lo ...
- 监视EntityFramework中的sql流转你需要知道的三种方式Log,SqlServerProfile, EFProfile
大家在学习entityframework的时候,都知道那linq写的叫一个爽,再也不用区分不同RDMS的sql版本差异了,但是呢,高效率带来了差灵活性,我们 无法控制sql的生成策略,所以必须不要让自 ...
- 关于Quartz.NET作业调度框架的一点小小的封装,实现伪AOP写LOG功能
Quartz.NET是一个非常强大的作业调度框架,适用于各种定时执行的业务处理等,类似于WINDOWS自带的任务计划程序,其中运用Cron表达式来实现各种定时触发条件是我认为最为惊喜的地方. Quar ...
- 解决MyEclipe出现An error has occurred,See error log for more details的错误
今晚在卸载MyEclipse时出现An error has occurred,See error log for more details的错误,打开相应路径下的文件查看得如下: !SESSION 2 ...
- MySQL5.7 error log时间显示问题
最近有两三套环境升级到了5.7.16,发现mysql.err中的时间好像有些问题,经查是mysql 5.7后的变更,如下: root@localhost [(none)]>select now( ...
随机推荐
- hadoop部署之防火墙
在部署hadoop时,好多资料上都写了要关闭防火墙,如果不关闭可能出现节点间无法通信的情况,于是大家也都这样做了,因此集群通信正常.当然集群一般是处于局域网中的,因此关闭防火墙一般也不会存在安全隐患, ...
- UVA-11082 Matrix Decompressing(有上下界的最大流)
题目链接: Matrix Decompressing 题意: 给一个矩阵的每行和每列的和,(给的是前i行或者列的和); 矩阵中每个元素的值在1到20之间,找出这样的一个矩阵: 思路: 把它转化成一个二 ...
- mac上python3安装HTMLTestRunner
下载支持python3版本的HTMLTestRunner.py文件后,拷贝到python3的lib目录下 在终端输入如下命令: 将HTMLTestRunner.py文件拷贝到如下目录后,pycharm ...
- #define WM_COMM_BREAK_DETECTED WM_USER+1
一.#define WM_COMM_BREAK_DETECTED WM_USER+1定义一个用户自定义消息WM_COMM_BREAK_DETECTED,它是自定义消息,非系统消息 为了防止用户定义的消 ...
- Task用法
转: https://www.cnblogs.com/wyy1234/p/9172467.html
- ASP.NET Core MVC 2.x 全面教程_ASP.NET Core MVC 15. 用户管理
源码的github的地址 https://github.com/solenovex/ASP.NET-Core-MVC-Tutorial-Code 语雀上的人的地址: https://github.co ...
- 详细讲解:零知识证明 之 ZCash 完整的匿名交易流程
作者:林冠宏 / 指尖下的幽灵 博客:http://www.cnblogs.com/linguanh/ 掘金:https://juejin.im/user/587f0dfe128fe100570ce2 ...
- SCUT - 243 - 宝华复习 - 二分 - 桶计数
https://scut.online/p/243 这道题唯一难点在于如何快速确定m合法.可以统计滑动窗口中已有元素的数量. #include<bits/stdc++.h> using n ...
- Codeforces Round #331 (Div. 2)【未完待续】
http://codeforces.com/problemset/problem/596/B GGGGGGGGGGGGGGGGGGG
- 51单片机 HC05蓝牙模块
一.注意事项 1.烧写程序时,要把蓝牙tx,rx信号线拔掉,对烧写程序有影响. 2.执行HC05集命令时,均以\r\n结尾.串口中断若选择“发送新行”时,不用添加\r\n.原理相同. 二.准备软硬件 ...