import sys, os, os.path
import time
import subprocess
import Image
def depress(picture):
filepath = os.path.join(os.path.abspath('.'), picture)
print filepath
img = Image.open(filepath)
w, h = img.size
img.resize((w / 2, h / 2)).save(filepath)
def catchLog(devicesID):
mDevicesID = devicesID
mCommand = "adb -s " + mDevicesID + " logcat -v time >" + mDevicesID + "_log_" + time.strftime("%Y_%m_%d_%H_%M_%S", time.localtime()) + ".log"
mP_log = subprocess.Popen(mCommand, shell=True);
print 'catching'
def catchPictures(devicesID, sleeptime):
mNumber = 0;
mDevicesID = devicesID
mSleepTime = sleeptime;
mRunning = True;
mCommand_catch = "adb -s " + mDevicesID + " shell /system/bin/screencap -p /sdcard/screenshot.png"
while mRunning:
os.system(mCommand_catch)
#mP = subprocess.Popen(mCommand, shell=True);
#time.sleep(3);
mPictureName = mDevicesID + "_screenshot_" + str(mNumber) + ".png"
mCommand_copy = "adb -s " + mDevicesID + " pull /sdcard/screenshot.png " + mPictureName
os.system(mCommand_copy)
#mP = subprocess.Popen(mCommand, shell=True);
time.sleep(25);
depress(mPictureName)
mNumber = mNumber + 1;
print 'Done'
def main(args):
import getopt, sys
opts, args = getopt.getopt(args, 's:t:')
mDevice = ''
mSleepTime = 5
for op, value in opts:
if op in ('-s'):
mDevice = value;
if op in ('-t'):
mSleepTime = value
catchLog(mDevice)
catchPictures(mDevice, mSleepTime)
print args
if __name__ == "__main__":
main(sys.argv[1:])
评论0
最新资源