def screenshot():
    path = PATH("%s/screenshot" %os.getcwd())
    utils.shell("screencap -p /data/local/tmp/tmp.png").wait()
    if not os.path.isdir("%s/screenshot" %PATH(os.getcwd())):
        os.makedirs(path)
    utils.adb("pull /data/local/tmp/tmp.png %s" %PATH("%s/%s.png" %(path, utils.timestamp()))).wait()
    utils.shell("rm /data/local/tmp/tmp.png")   
示例#2
0
    def run(self):
        """
        基于UID获取App的网络流量的方法
        从/proc/net/xt_qtaguid/stats获取网络流量统计,进行判断
        """
        while True:
            if utils.stop != True:
                break
            sleep(1)
            totalNet = []
            flag_net = utils.shell(
                "cat /proc/net/xt_qtaguid/stats").stdout.readline()
            if "No such file or directory" not in flag_net:
                list_rx = []  # 接收网络数据流量列表
                list_tx = []  # 发送网络数据流量列表

                str_uid_net_stats = utils.shell(
                    "cat /proc/net/xt_qtaguid/stats|findstr %s" %
                    utils.app_uid(self.pkg)).stdout.readlines()
                try:
                    for item in str_uid_net_stats:
                        rx_bytes = item.split()[5]  # 接收网络数据流量
                        tx_bytes = item.split()[7]  # 发送网络数据流量
                        list_rx.append(int(rx_bytes))
                        list_tx.append(int(tx_bytes))
                    tm = utils.timestamp()
                    floatTotalNetTraffic = (sum(list_rx) +
                                            sum(list_tx)) / 1024.0 / 1024.0
                    floatTotalNetTraffic = round(floatTotalNetTraffic, 2)
                    # print "接受:", list_rx
                    # print "发送:", list_tx
                    # print "总消耗:%sKB" % floatTotalNetTraffic
                    totalNet.append(floatTotalNetTraffic)
                    totalNet.insert(0, tm)
                    self.ls.append(totalNet)
                except:
                    print "[ERROR]: cannot get the /proc/net/xt_qtaguid/stats"
                    return 0.0
            else:
                strTotalTxBytes = utils.shell(
                    "cat proc/uid_stat/%s/tcp_snd" %
                    utils.app_uid(self.pkg)).stdout.readline()
                strTotalRxBytes = utils.shell(
                    "cat proc/uid_stat/%s/tcp_rcv" %
                    utils.app_uid(self.pkg)).stdout.readline()
                try:
                    tm = utils.timestamp()
                    floatTotalTraffic = (
                        int(strTotalTxBytes) +
                        int(strTotalRxBytes)) / 1024.0 / 1024.0
                    floatTotalTraffic = round(floatTotalTraffic, 2)
                    # print "总消耗:%sKB" % floatTotalTraffic
                    totalNet.append(floatTotalTraffic)
                    totalNet.insert(0, tm)
                    self.ls.append(totalNet)
                except:
                    return 0.0
def record():
    utils.shell("screenrecord /data/local/tmp/video.mp4")  
    input_key = raw_input("Please press the Enter key to  stop recording:\n")
    if input_key == "":
        utils.adb("kill-server")
    
    print "Get Video file..."
    
    path = PATH("%s/video" %os.getcwd())
    if not os.path.isdir(path):
        os.makedirs(path)
    
    utils.adb("pull /data/local/tmp/video.mp4 %s"  %PATH("%s/%s.mp4" %(path, utils.timestamp()))).wait()
示例#4
0
def record():
    utils.shell("screenrecord /data/local/tmp/video.mp4")  
    input_key = raw_input("Please press the Enter key to  stop recording:\n")
    if input_key == "":
        utils.adb("kill-server")
    
    print "Get Video file..."
    
    path = PATH("%s/video" %os.getcwd())
    if not os.path.isdir(path):
        os.makedirs(path)
    
    utils.adb("pull /data/local/tmp/video.mp4 %s" % PATH("%s/%s.mp4" % (path, utils.timestamp()))).wait()
示例#5
0
    def run(self):
        """
        基于UID获取App的网络流量的方法
        从/proc/net/xt_qtaguid/stats获取网络流量统计,进行判断
        """
        while True:
            if utils.stop!=True:
                break
            sleep(1)
            totalNet = []
            flag_net = utils.shell("cat /proc/net/xt_qtaguid/stats").stdout.readline()
            if "No such file or directory" not in flag_net:
                list_rx = []  # 接收网络数据流量列表
                list_tx = []  # 发送网络数据流量列表

                str_uid_net_stats = utils.shell(
                    "cat /proc/net/xt_qtaguid/stats|findstr %s" % utils.get_app_uid(
                        self.pkg)).stdout.readlines()
                try:
                    for item in str_uid_net_stats:
                        rx_bytes = item.split()[5]  # 接收网络数据流量
                        tx_bytes = item.split()[7]  # 发送网络数据流量
                        list_rx.append(int(rx_bytes))
                        list_tx.append(int(tx_bytes))
                    tm = utils.timestamp()
                    floatTotalNetTraffic = (sum(list_rx) + sum(list_tx)) / 1024.0 / 1024.0
                    floatTotalNetTraffic = round(floatTotalNetTraffic, 2)
                    # print "接受:", list_rx
                    # print "发送:", list_tx
                    # print "总消耗:%sKB" % floatTotalNetTraffic
                    totalNet.append(floatTotalNetTraffic)
                    totalNet.insert(0, tm)
                    self.ls.append(totalNet)
                except:
                    print "[ERROR]: cannot get the /proc/net/xt_qtaguid/stats"
                    return 0.0
            else:
                strTotalTxBytes = utils.shell(
                    "cat proc/uid_stat/%s/tcp_snd" % utils.get_app_uid(self.pkg)).stdout.readline()
                strTotalRxBytes = utils.shell(
                    "cat proc/uid_stat/%s/tcp_rcv" % utils.get_app_uid(self.pkg)).stdout.readline()
                try:
                    tm = utils.timestamp()
                    floatTotalTraffic = (int(strTotalTxBytes) + int(strTotalRxBytes)) / 1024.0 / 1024.0
                    floatTotalTraffic = round(floatTotalTraffic, 2)
                    # print "总消耗:%sKB" % floatTotalTraffic
                    totalNet.append(floatTotalTraffic)
                    totalNet.insert(0, tm)
                    self.ls.append(totalNet)
                except:
                    return 0.0
示例#6
0
def get_app_permission():
    entry.delete(0, END)  #清空entry里面的内容
    listbox_filename.delete(1.0, END)

    package_name = utils.get_current_package_name()
    permission_list = []
    result_list = utils.shell(
        "dumpsys package %s | %s android.permission" %
        (package_name, utils.find_util)).stdout.readlines()

    for permission in result_list:
        permission_list.append(permission.strip())

    permission_json_file = file("permission.json")

    file_content = json.load(permission_json_file)["PermissList"]

    if utils.system is "Windows":
        listbox_filename.insert(END, "package:" + package_name)
        for permission in permission_list:
            for permission_dict in file_content:
                if permission == permission_dict["Key"]:
                    listbox_filename.insert(END, permission_dict["Key"])
                    listbox_filename.insert(END, "\n")
                    listbox_filename.insert(END, permission_dict["Memo"])
                    listbox_filename.insert(END, "\n")
def get_crash_log(time_list):
    log_file = PATH("%s/crash_log/%s.txt" % (os.getcwd(), utils.timestamp()))
    f = open(log_file, "w")
    for time in time_list:
        cash_log = utils.shell("dumpsys dropbox --print %s" % time).stdout.read()
        f.write(cash_log)
    f.close()
示例#8
0
def get_crash_log(time_list):
    log_file = PATH("%s/crash_log/%s.txt" % (os.getcwd(), utils.timestamp()))
    f = open(log_file, "w")
    for time in time_list:
        cash_log = utils.shell("dumpsys dropbox --print %s" % time).stdout.read()
        f.write(cash_log)
    f.close()
示例#9
0
    def start_dump_latency_data(self, ignore_pending_fence_time = False):
        results = []
        if self.__clear_buffer():
            time.sleep(self.dump_time)
            results = utils.shell("{0} {1}".format(self.FRAME_LATENCY_CMD, self.activity_name))\
                .stdout.readlines()
            self.refresh_period = int(results[0].strip())

            if self.refresh_period < 0:
                return False

            data_invalid_flag = False
            for line in results:
                if not line.strip():
                    break

                if len(line.split()) == 1 or line.split()[0] == "0":
                    continue
                elif line.split()[1] == str(self.PENDING_FENCE_TIME):
                    if ignore_pending_fence_time:
                        data_invalid_flag = True
                    else:
                        return False

                self.frame_buffer_data.append(line.split())
                if not data_invalid_flag:
                    self.frame_latency_data_size += 1

            return True
示例#10
0
 def get_process_cpu_time(self):
     time = utils.shell(
         "cat /proc/%s/stat|gawk '{print $14,$15,$16,$17}'" % self.get_pid()).stdout.readline().split()
     pro_time = 0
     for i in time:
         pro_time += int(i)
     return pro_time
示例#11
0
 def get_process_cpu_time(self):
     time = utils.shell("cat /proc/%s/stat|gawk '{print $14,$15,$16,$17}'" %
                        self.get_pid()).stdout.readline().split()
     pro_time = 0
     for i in time:
         pro_time += int(i)
     return pro_time
示例#12
0
def get_match_apk(package_name, path):
    list = []
    for packages in utils.shell("pm list packages -f %s" %package_name).stdout.readlines():
        if packages.split(":")[0] == "package":
            list.append(packages.split(":")[-1].split("=")[0])

    utils.adb("pull %s %s" %(list[0], path)).wait()
示例#13
0
 def get_total_cpu_time():
     time = utils.shell(
         "cat /proc/stat|gawk '{print $2,$3,$4,$5,$6,$7,$8,$9,$10,$11}'"
     ).stdout.readline().split()
     total_time = 0
     for i in time:
         total_time += int(i)
     return total_time
示例#14
0
def get_match_apk(package_name):
    list = []
    for packages in utils.shell("pm list packages -f %s" %package_name).stdout.readlines():
        list.append(packages.split(":")[-1].split("=")[0])
    apk_name = list[0].split("/")[-1]
    utils.adb("pull %s %s" %(list[0], tempFile)).wait()

    return "%s\\%s" %(tempFile, apk_name)
def get_permission_list(package_name):
    permission_list = []
    result_list = utils.shell(
        "dumpsys package %s | %s android.permission" % (package_name, utils.find_util)).stdout.readlines()

    for permission in result_list:
        permission_list.append(permission.strip())

    return permission_list
示例#16
0
 def get_frame_data(self):
     """
     获取帧数据及时间戳
     :return:字典
     """
     result = utils.shell(
         "su -c 'service call SurfaceFlinger 1013'").stdout.readline()
     cur_surface = int(result.split("(")[1].split()[0], 16)
     return {"surface": cur_surface, "timestamp": time.time()}
def get_permission_list(package_name):

    permission_list = []
    result_list = utils.shell("dumpsys package %s | %s android.permission" %(package_name, utils.find_util)).stdout.readlines()

    for permission in result_list:
        permission_list.append(permission.strip())

    return permission_list
示例#18
0
def get_crash_time_list():
    time_list = []
    result_list = utils.shell("dumpsys dropbox | %s data_app_crash" % utils.find_util).stdout.readlines()
    for time in result_list:
        temp_list = time.split(" ")
        temp_time = []
        temp_time.append(temp_list[0])
        temp_time.append(temp_list[1])
        time_list.append(" ".join(temp_time))

    return time_list
def get_crash_time_list():
    time_list = []
    result_list = utils.shell("dumpsys dropbox | %s data_app_crash" % utils.find_util).stdout.readlines()
    for time in result_list:
        temp_list = time.split(" ")
        temp_time = []
        temp_time.append(temp_list[0])
        temp_time.append(temp_list[1])
        time_list.append(" ".join(temp_time))

    return time_list
示例#20
0
    def run(self):
        user = utils.shell(
            "su -c 'ls'").stdout.readline()  # 检查手机是否可以ROOT用户执行命令

        if "not found" in user:  # 非ROOT手机执行该方式
            serial_number = utils.get_serialno()
            command = android_commands.AndroidCommands(serial_number)
            collector = surface_stats_collector.SurfaceStatsCollector(command)
            collector.DisableWarningAboutEmptyData()
            collector.Start()
            while True:
                if utils.stop != True:
                    break
                tm = utils.timestamp()
                results = collector.SampleResults()
                fpsdata = []
                if not results:
                    pass
                else:
                    for i in results:

                        if i.name == "avg_surface_fps":
                            if i.value == None:
                                fpsdata.insert(0, tm)
                                fpsdata.append(0)

                            else:
                                fpsdata.insert(0, tm)
                                fpsdata.append(i.value)
                self.ls.append(fpsdata)
            collector.Stop()

        else:  # ROOT手机执行该方式
            value1 = self.get_frame_data()
            self.time_before = value1["timestamp"]
            self.surface_before = value1["surface"]
            while True:
                if utils.stop != True:
                    break
                y = []
                time.sleep(1)
                value2 = self.get_frame_data()
                self.time_after = value2["timestamp"]
                self.surface_after = value2["surface"]
                time_difference = int(
                    round((self.time_after - self.time_before), 2))
                frame_count = (self.surface_after - self.surface_before)
                tm = utils.timestamp()
                fps = int(frame_count / time_difference)
                y.append(fps)
                self.time_before = self.time_after
                self.surface_before = self.surface_after
                y.insert(0, tm)
                self.ls.append(y)
示例#21
0
def top():
    cpu = []
    mem = []

    top_info = utils.shell("top -n %s | %s %s$" %(str(times), utils.find_util, pkg_name)).stdout.readlines()

    for info in top_info:
        temp_list = del_space(info)
        cpu.append(temp_list[2])
        mem.append(temp_list[6])
    
    return (cpu, mem)
示例#22
0
 def run(self):
     while True:
         if utils.stop!=True:
             break
         sleep(1)
         y = []
         tm = utils.timestamp()
         result = utils.shell("cat /sys/class/thermal/thermal_zone0/temp").stdout.readline()
         if "No such file or directory" in result:
             result = 0
         y.append(tm)
         y.append("".join(list(result)[0:2])+"."+"".join(list(result)[2:]))
         self.ls.append(y)
示例#23
0
def top():
    cpu = []
    mem = []

    top_info = utils.shell("top -n %s | %s %s$" % (str(times), utils.find_util, pkg_name)).stdout.readlines()

    for info in top_info:
        # temp_list = del_space(info)
        temp_list = info.split()
        cpu.append(temp_list[2])
        mem.append(temp_list[6])

    return (cpu, mem)
示例#24
0
 def run(self):
     while True:
         if utils.stop!=True:
             break
         sleep(1)
         y = []
         dictionaries = {}
         tm = utils.timestamp()
         result = utils.shell("dumpsys battery").stdout.readlines()
         for i in result[1:]:
             new = i.split(":")
             dictionaries[new[0].strip()] = new[1].strip()
         y.append(tm)
         y.append("".join(list(dictionaries["temperature"])[0:2])+"."+"".join(list(dictionaries["temperature"])[2:]))
         self.ls.append(y)
示例#25
0
 def run(self):
     while True:
         if utils.stop != True:
             break
         sleep(1)
         y = []
         tm = utils.timestamp()
         result = utils.shell(
             "cat /sys/class/thermal/thermal_zone0/temp").stdout.readline()
         if "No such file or directory" in result:
             result = 0
         y.append(tm)
         y.append("".join(list(result)[0:2]) + "." +
                  "".join(list(result)[2:]))
         self.ls.append(y)
示例#26
0
    def run(self):
        mem_command = "dumpsys meminfo %s|gawk '/MEMINFO/,/App Summary/'|grep TOTAL|gawk '{print $2,$3,$4,$5,$6,$7,$8}'" % self.pkg
        while True:
            if utils.stop != True:
                break
            sleep(1)
            y = []
            tm = utils.timestamp()
            results = utils.shell(mem_command).stdout.readline().split()
            # print "内存:%s" % results

            y.append(tm)
            for index in results:
                y.append(index)
            self.ls.append(y)
示例#27
0
    def gfxinfo(self):
        # 获取绘制帧的时间数组
        times = utils.shell(
            "dumpsys gfxinfo com.longtu.weifuhua|gawk '/Execute/,/View hierarchy/'|gawk NF'{print $1,$2,$3,$4}'|grep -v '^Draw'|grep -v '^View hierarchy'").stdout.readlines()

        # 计算帧数量
        frame_count = len(times)

        # 计算绘制每一帧的总时间,单位:ms
        count_time = []
        for gfx in times:
            time = gfx.split()
            sum_time = float(time[0]) + float(time[1]) + float(time[2]) + float(time[3])
            count_time.append(sum_time)

        return frame_count, count_time
示例#28
0
    def gfxinfo(self):
        # 获取绘制帧的时间数组
        times = utils.shell(
            "dumpsys gfxinfo com.longtu.weifuhua|gawk '/Execute/,/View hierarchy/'|gawk NF'{print $1,$2,$3,$4}'|grep -v '^Draw'|grep -v '^View hierarchy'"
        ).stdout.readlines()

        # 计算帧数量
        frame_count = len(times)

        # 计算绘制每一帧的总时间,单位:ms
        count_time = []
        for gfx in times:
            time = gfx.split()
            sum_time = float(time[0]) + float(time[1]) + float(
                time[2]) + float(time[3])
            count_time.append(sum_time)

        return frame_count, count_time
示例#29
0
def top():
    cpu = []
    mem = []

    top_info = utils.shell("top  | %s %s$" %( utils.find_util, pkg_name)).stdout.readlines()
    print top_info
    input_key = raw_input("Please press the Enter key to  stop :\n")
    if input_key == "":
        utils.adb("kill-server")
    
    print "Get top data..."
    
    for info in top_info:
        #temp_list = del_space(info)
        temp_list = info.split()
        cpu.append(temp_list[2])
        mem.append(temp_list[6])
    
    return (cpu, mem)
示例#30
0
def top():
    cpu = []
    mem = []

    top_info = utils.shell("top  | %s %s$" %
                           (utils.find_util, pkg_name)).stdout.readlines()
    print top_info
    input_key = raw_input("Please press the Enter key to  stop :\n")
    if input_key == "":
        utils.adb("kill-server")

    print "Get top data..."

    for info in top_info:
        #temp_list = del_space(info)
        temp_list = info.split()
        cpu.append(temp_list[2])
        mem.append(temp_list[6])

    return (cpu, mem)
示例#31
0
def get_match_apk(package_name):
    list = []

    for packages in utils.shell("pm list packages -f %s" %
                                package_name).stdout.readlines():
        print packages.split(":")[-1].split("=")[0]
        list.append(packages.split(":")[-1].split("=")[0])
    apk_name = list[0].split("/")[-1]

    print tempFile, apk_name

    print u"---上传App到本地temp目录----"
    if apk_name not in os.listdir(tempFile):
        utils.adb("pull %s %s" % (list[0], tempFile)).wait()
        print u"---上传App结束---"
    else:

        print u"---本地app已存在,不需要上传---"

    #

    return PATH("%s/%s" % (tempFile, apk_name))
def record():
    utils.shell("rm -f /data/local/tmp/video.mp4")
    limit_time = raw_input(
        "Please set the maximum recording time, in seconds.  Maximum is 180.\n"
    )
    if limit_time == "":
        utils.shell("screenrecord --time-limit 180 /data/local/tmp/video.mp4")
    try:
        _limit_time = int(limit_time) + 1
    except:
        record()
    if 0 < _limit_time <= 180:
        utils.shell("screenrecord --time-limit %s /data/local/tmp/video.mp4" %
                    limit_time).wait()
    else:
        print "Please set again!"
        record()
示例#33
0
# -*- coding: utf-8 -*-
from time import sleep
from scriptUtils import utils

app_time = []
system_time = []
app_start_time = utils.shell(
    "am start -W -n com.longtu.weifuhua/com.longtu.weifuhua.ui.homepage.activity.ServiceActivity"
).stdout.readlines()[4:6]

result = []
for i in app_start_time:
    result.append(i.split()[1])

app_time.append(result[0])
system_time.append(result[1])

print "APP自身启动耗时:", app_time
print "系统启动APP耗时:", system_time

utils.kill_application("com.longtu.weifuhua")
# -*- coding: utf-8 -*-
from time import sleep
from scriptUtils import utils


app_time = []
system_time = []
app_start_time = utils.shell("am start -W -n com.longtu.weifuhua/com.longtu.weifuhua.ui.homepage.activity.ServiceActivity").stdout.readlines()[4:6]

result = []
for i in app_start_time:
    result.append(i.split()[1])

app_time.append(result[0])
system_time.append(result[1])

print "APP自身启动耗时:", app_time
print "系统启动APP耗时:", system_time

utils.kill_application("com.longtu.weifuhua")
示例#35
0
import string
import sys
import time

from scriptUtils import utils

# 需要Android4.4及4.4以上版本,运行脚本后可录制设备上的操作,默认使用手机分辨率,时间3min。手动按Enter结束录制。
# 录制结果存放于当前目录下的video目录下

PATH = lambda p: os.path.abspath(p)


def record():
<<<<<<< HEAD
<<<<<<< HEAD
    utils.shell("screenrecord /data/local/tmp/video.mp4")
    input_key = raw_input("Please press the Enter key to  stop recording:\n")
=======
    utils.shell("screenrecord /data/local/tmp/video.mp4")  
    input_key = raw_input("Please press the Enter key to stop recording:\n")
>>>>>>> upstream/master
=======
    utils.shell("screenrecord /data/local/tmp/video.mp4")  
    input_key = raw_input("Please press the Enter key to stop recording:\n")
>>>>>>> upstream/master
    if input_key == "":
        utils.adb("kill-server")

    print "Get Video file..."
<<<<<<< HEAD
<<<<<<< HEAD
        utils.shell("screenrecord --time-limit 180 /data/local/tmp/video.mp4")
    try:
        _limit_time = int(limit_time) + 1
    except:
        record()
    if 0 < _limit_time <= 180:
        utils.shell("screenrecord --time-limit %s /data/local/tmp/video.mp4" %
                    limit_time).wait()
    else:
        print "Please set again!"
        record()


if __name__ == "__main__":
    sdk = string.atoi(
        utils.shell("getprop ro.build.version.sdk").stdout.read())
    if sdk < 19:
        print "sdk version is %s, less than 19!"
        sys.exit(0)
    else:
        record()
        print "Get Video file..."
        time.sleep(3)

        path = PATH("%s/video" % os.getcwd())
        if not os.path.isdir(path):
            os.makedirs(path)

        utils.adb("pull /data/local/tmp/video.mp4 %s" %
                  PATH("%s/%s.mp4" % (path, utils.timestamp())))
        print "Completed"
示例#37
0
def total_mem():
    total_mem = utils.shell(
        "cat /proc/meminfo|grep MemTotal").stdout.readlines()
    return total_mem
示例#38
0
'''

import os

from scriptUtils import utils

# 打开手机上的应用(包括系统应用),运行脚本,会将该应用对应的apk复制到本地的App文件夹下

PATH = lambda p: os.path.abspath(p)


def get_match_apk(package_name, path):
    list = []
<<<<<<< HEAD
<<<<<<< HEAD
    for packages in utils.shell("pm list packages -f %s" % package_name).stdout.readlines():
        list.append(packages.split(":")[-1].split("=")[0])
=======
    for packages in utils.shell("pm list packages -f %s" %package_name).stdout.readlines():
        if packages.split(":")[0] == "package":
            list.append(packages.split(":")[-1].split("=")[0])
>>>>>>> upstream/master

    utils.adb("pull %s %s" % (list[0], path)).wait()
=======
    for packages in utils.shell("pm list packages -f %s" %package_name).stdout.readlines():
        if packages.split(":")[0] == "package":
            list.append(packages.split(":")[-1].split("=")[0])
>>>>>>> upstream/master

示例#39
0
 def get_sdkVersion(self):
     print "SDK版本:", utils.shell("cat /system/build.prop | findstr ro.build.version.sdk").stdout.readline().split("=")[1]
def get_apk_list():
    apps = []
    for apk in utils.shell("pm list packages -f -3").stdout.readlines():
        apps.append(apk.split(":")[-1].split("=")[0])
        
    return apps
示例#41
0
 def get_systemVersion(self):
     print "系统版本:", utils.shell("cat /system/build.prop | findstr ro.build.version.release").stdout.readline().split("=")[1]
示例#42
0
 def get_DisplayDeviceInfo(self):
     result = utils.shell("dumpsys display | findstr DisplayDeviceInfo").stdout.readline().split(",")[1].strip()
     print "分辨率:", result
 def get_memInfo(self):
     result = utils.shell('cat /proc/meminfo|findstr "MemTotal"').stdout.readline().split(":")[1].strip()
     MemTotal = "{val}MB".format(val=int(result.split()[0])/1024)
     print "总内存:%s" % MemTotal
 def get_cpuModel(self):
     print "CPU型号:", utils.shell("cat /proc/cpuinfo|findstr Hardware").stdout.readline().strip().split(":")[1]
示例#45
0
 def get_total_cpu_time():
     time = utils.shell("cat /proc/stat|gawk '{print $2,$3,$4,$5,$6,$7,$8,$9,$10,$11}'").stdout.readline().split()
     total_time = 0
     for i in time:
         total_time += int(i)
     return total_time
示例#46
0
def pid():
    pid = utils.shell("dumpsys package " + pkg +
                      "|grep packageSetting|cut -d \"/\" -f2|cut -d \"}\" -f1"
                      ).stdout.readline().strip("\n")
    return pid
from scriptUtils import utils

#需要Android4.4及4.4以上版本,运行脚本后可录制设备上的操作,默认使用手机分辨率,时间5min。手动按Enter结束录制。
#录制结果存放于当前目录下的video目录下

PATH = lambda p: os.path.abspath(p)

def record():
    utils.shell("screenrecord --time-limit 300 /data/local/tmp/video.mp4")
    
    input_key = raw_input("Please press the Enter key to  stop recording:\n")
    if input_key == "":
        utils.adb("kill-server")
    
    print "Get Video file..."
    
    path = PATH("%s/video" %os.getcwd())
    if not os.path.isdir("%s/video" %PATH(os.getcwd())):
        os.makedirs(path)
    
    utils.adb("pull /data/local/tmp/video.mp4 %s"  %PATH("%s/%s.mp4" %(path, utils.timestamp()))).wait()
        
if __name__ == "__main__":
    sdk = string.atoi(utils.shell("getprop ro.build.version.sdk").stdout.read())
    if sdk < 19:
        print "sdk version is %s, less than 19!"
        sys.exit(0)
    else:
        record()
        print "Completed"
示例#48
0
def uid():
    uid = utils.shell("ps | grep " + pkg +
                      "| gawk '{ print $2 }'").stdout.readline().strip("\n")
    return uid
示例#49
0
 def __clear_buffer(self):
     results = utils.shell("{0} {1}".format(self.CLEAR_BUFFER_CMD, self.activity_name))\
         .stdout.readlines()
     return not len(results)