Skip to content

Commit

Permalink
v2.6.8
Browse files Browse the repository at this point in the history
  • Loading branch information
rafa0128 committed Jun 30, 2023
1 parent 963cef5 commit 88b7b18
Show file tree
Hide file tree
Showing 15 changed files with 186 additions and 234 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ We are committed to solving inefficient, cumbersome test execution, and our goal
### default

```shell
pip install -U solox (pip install solox==2.6.4)
pip install -U solox (pip install solox==2.6.8)
```

### mirrors
Expand Down
2 changes: 1 addition & 1 deletion README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ SoloX - Android/iOS性能数据的实时采集工具。
### 默认

```shell
pip install -U solox (指定版本:pip install solox==2.6.4)
pip install -U solox (指定版本:pip install solox==2.6.8)
```

### 镜像
Expand Down
2 changes: 1 addition & 1 deletion solox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

from __future__ import absolute_import

__version__ = '2.6.7'
__version__ = '2.6.8'
4 changes: 2 additions & 2 deletions solox/public/adb.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ def shell(self, cmd, deviceId):
0].decode("utf-8").strip()
return result

def tcp_shell(self, cmd, deviceId):
run_cmd = f'{self.adb_path} -s {deviceId} shell {cmd}'
def tcp_shell(self, deviceId, cmd):
run_cmd = f'{self.adb_path} -s {deviceId} {cmd}'
result = os.system(run_cmd)
return result

Expand Down
5 changes: 2 additions & 3 deletions solox/public/apm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import re
import time
import os
import traceback
from logzero import logger
import tidevice
import multiprocessing
Expand Down Expand Up @@ -494,7 +493,7 @@ def collectAll(self):
self.setPerfs()
except KeyboardInterrupt:
self.setPerfs()
except Exception:
traceback.print_exc()
except Exception as e:
logger.exception(e)
finally:
logger.info('End of testing')
33 changes: 13 additions & 20 deletions solox/public/apm_pk.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime
import re
import os
import time
from solox.public.adb import adb
from solox.public.common import Devices, File
Expand Down Expand Up @@ -52,31 +53,28 @@ def getAndroidCpuRate(self):
"""get the Android cpu rate of a process"""
processCpuTime1_first = self.getprocessCpuStat(pkgName=self.pkgNameList[0], deviceId=self.deviceId1)
totalCpuTime1_first = self.getTotalCpuStat(deviceId=self.deviceId1)
time.sleep(1)
time.sleep(0.5)
processCpuTime1_second = self.getprocessCpuStat(pkgName=self.pkgNameList[0], deviceId=self.deviceId1)
totalCpuTime1_second = self.getTotalCpuStat(deviceId=self.deviceId1)

if len(self.pkgNameList) == 1:
processCpuTime2_first = self.getprocessCpuStat(pkgName=self.pkgNameList[0], deviceId=self.deviceId2)
totalCpuTime2_first = self.getTotalCpuStat(deviceId=self.deviceId2)
time.sleep(1)
time.sleep(0.5)
processCpuTime2_second = self.getprocessCpuStat(pkgName=self.pkgNameList[0], deviceId=self.deviceId2)
totalCpuTime2_second = self.getTotalCpuStat(deviceId=self.deviceId2)
else:
processCpuTime2_first = self.getprocessCpuStat(pkgName=self.pkgNameList[1], deviceId=self.deviceId2)
totalCpuTime2_first = self.getTotalCpuStat(deviceId=self.deviceId2)
time.sleep(1)
time.sleep(0.5)
processCpuTime2_second = self.getprocessCpuStat(pkgName=self.pkgNameList[1], deviceId=self.deviceId2)
totalCpuTime2_second = self.getTotalCpuStat(deviceId=self.deviceId2)

appCpuRate1 = round(float((processCpuTime1_second - processCpuTime1_first) / (totalCpuTime1_second - totalCpuTime1_first) * 100), 2)
appCpuRate2 = round(float((processCpuTime2_second - processCpuTime2_first) / (totalCpuTime2_second - totalCpuTime2_first) * 100), 2)

apm_time = datetime.datetime.now().strftime('%H:%M:%S.%f')
f.add_log(f'{f.report_dir}/cpu_app1.log', apm_time, appCpuRate1)
f.add_log(f'{f.report_dir}/cpu_app2.log', apm_time, appCpuRate2)


f.add_log(os.path.join(f.report_dir, 'cpu_app1.log'), apm_time, appCpuRate1)
f.add_log(os.path.join(f.report_dir, 'cpu_app2.log'), apm_time, appCpuRate2)
return appCpuRate1, appCpuRate2


Expand All @@ -103,10 +101,9 @@ def getProcessMem(self):
else:
totalPass1 = self.getAndroidMem(self.pkgNameList[0], self.deviceId1)
totalPass2 = self.getAndroidMem(self.pkgNameList[1], self.deviceId2)

apm_time = datetime.datetime.now().strftime('%H:%M:%S.%f')
f.add_log(f'{f.report_dir}/mem1.log', apm_time, totalPass1)
f.add_log(f'{f.report_dir}/mem2.log', apm_time, totalPass2)
f.add_log(os.path.join(f.report_dir, 'mem1.log'), apm_time, totalPass1)
f.add_log(os.path.join(f.report_dir, 'mem1.log'), apm_time, totalPass2)

return totalPass1, totalPass2

Expand All @@ -126,7 +123,7 @@ def getAndroidNet(self, pkgName, deviceId):
m_pre = re.search(r'wlan0:\s*(\d+)\s*\d+\s*\d+\s*\d+\s*\d+\s*\d+\s*\d+\s*\d+\s*(\d+)', output_pre)
sendNum_pre = round(float(float(m_pre.group(2)) / 1024), 2)
recNum_pre = round(float(float(m_pre.group(1)) / 1024), 2)
time.sleep(1)
time.sleep(0.5)
output_final = adb.shell(cmd=cmd, deviceId=deviceId)
m_final = re.search(r'wlan0:\s*(\d+)\s*\d+\s*\d+\s*\d+\s*\d+\s*\d+\s*\d+\s*\d+\s*(\d+)', output_final)
sendNum_final = round(float(float(m_final.group(2)) / 1024), 2)
Expand All @@ -144,10 +141,9 @@ def getNetWorkData(self):
else:
network1 = self.getAndroidNet(self.pkgNameList[0], self.deviceId1)
network2 = self.getAndroidNet(self.pkgNameList[1], self.deviceId2)

apm_time = datetime.datetime.now().strftime('%H:%M:%S.%f')
f.add_log(f'{f.report_dir}/network1.log', apm_time, network1)
f.add_log(f'{f.report_dir}/network2.log', apm_time, network2)
f.add_log(os.path.join(f.report_dir, 'network1.log'), apm_time, network1)
f.add_log(os.path.join(f.report_dir, 'network2.log'), apm_time, network2)
return network1, network2


Expand All @@ -173,15 +169,12 @@ def getFPS(self):
if len(self.pkgNameList) == 1:
fps1 = self.getAndroidFps(pkgName=self.pkgNameList[0], deviceId=self.deviceId1)
fps2 = self.getAndroidFps(pkgName=self.pkgNameList[0], deviceId=self.deviceId2)

else:
fps1 = self.getAndroidFps(pkgName=self.pkgNameList[0], deviceId=self.deviceId1)
fps2 = self.getAndroidFps(pkgName=self.pkgNameList[1], deviceId=self.deviceId2)

apm_time = datetime.datetime.now().strftime('%H:%M:%S.%f')
f.add_log(f'{f.report_dir}/fps1.log', apm_time, fps1)
f.add_log(f'{f.report_dir}/fps2.log', apm_time, fps2)

f.add_log(os.path.join(f.report_dir, 'fps1.log'), apm_time, fps1)
f.add_log(os.path.join(f.report_dir, 'fps2.log'), apm_time, fps2)
return fps1, fps2


66 changes: 31 additions & 35 deletions solox/public/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from logzero import logger
from solox.public.adb import adb
from tqdm import tqdm
import traceback
import socket
from urllib.request import urlopen
import ssl
Expand All @@ -30,7 +29,7 @@ def __init__(self, platform=Platform.Android):
def execCmd(self, cmd):
"""Execute the command to get the terminal print result"""
r = os.popen(cmd)
text = r.read().strip()
text = r.buffer.read().decode(encoding='utf-8').strip()
r.close()
return text

Expand Down Expand Up @@ -67,7 +66,7 @@ def getIdbyDevice(self, deviceinfo, platform):
if platform == Platform.Android:
deviceId = re.sub(u"\\(.*?\\)|\\{.*?}|\\[.*?]", "", deviceinfo)
if deviceId not in self.getDeviceIds():
raise Exception('no found device: %s'.format(deviceId))
raise Exception('no device found')
else:
deviceId = deviceinfo.split(':')[1]
return deviceId
Expand All @@ -79,9 +78,9 @@ def getPid(self, deviceId, pkgName):
processList = ['{}:{}'.format(process.split()[1],process.split()[7]) for process in result]
processList.reverse()
if len(processList) == 0:
logger.warning('no pid found')
except Exception:
traceback.print_exc()
logger.warning('{}: no pid found'.format(pkgName))
except Exception as e:
logger.exception(e)
return processList

def checkPkgname(self, pkgname):
Expand Down Expand Up @@ -119,7 +118,7 @@ def getPkgnameByiOS(self, udid):
pkgNames = [pkgResult[i].split(' ')[0] for i in range(len(pkgResult))]
return pkgNames

def localIP(self):
def get_pc_ip(self):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(('8.8.8.8', 80))
Expand All @@ -131,13 +130,14 @@ def localIP(self):
s.close()
return ip

def tcpConnect(self, deviceId, port):
logger.info('TCP mode port')
adb.tcp_shell(deviceId=deviceId, cmd='tcpip {}'.format(port))
logger.info('Connect result')
result = adb.tcp_shell(cmd='connect {}:{}'.format(self.localIP(), port))
return result

def get_device_ip(self, deviceId):
content = os.popen(f"{self.adb} -s {deviceId} shell ip addr show wlan0").read()
logger.info(content)
math_obj = re.search(r'inet\s(\d+\.\d+\.\d+\.\d+).*?wlan0', content)
if math_obj and math_obj.group(1):
return math_obj.group(1)
return None

def devicesCheck(self, platform, deviceid=None, pkgname=None):
"""Check the device environment"""
match(platform):
Expand Down Expand Up @@ -675,6 +675,21 @@ def _setValue(cls, value, default = 0):
except Exception:
result = default
return result

@classmethod
def _get_setting(cls, request):
content = {}
content['cpuWarning'] = (0, request.cookies.get('cpuWarning'))[request.cookies.get('cpuWarning') not in [None, 'NaN']]
content['memWarning'] = (0, request.cookies.get('memWarning'))[request.cookies.get('memWarning') not in [None, 'NaN']]
content['fpsWarning'] = (0, request.cookies.get('fpsWarning'))[request.cookies.get('fpsWarning') not in [None, 'NaN']]
content['netdataRecvWarning'] = (0, request.cookies.get('netdataRecvWarning'))[request.cookies.get('netdataRecvWarning') not in [None, 'NaN']]
content['netdataSendWarning'] = (0, request.cookies.get('netdataSendWarning'))[request.cookies.get('netdataSendWarning') not in [None, 'NaN']]
content['betteryWarning'] = (0, request.cookies.get('betteryWarning'))[request.cookies.get('betteryWarning') not in [None, 'NaN']]
content['duration'] = (0, request.cookies.get('duration'))[request.cookies.get('duration') not in [None, 'NaN']]
content['solox_host'] = ('', request.cookies.get('solox_host'))[request.cookies.get('solox_host') not in [None, 'NaN']]
content['host_switch'] = request.cookies.get('host_switch')
return content


class Install:

Expand All @@ -683,8 +698,8 @@ def uploadFile(self, file_path, file_obj):
try:
file_obj.save(file_path)
return True
except:
traceback.print_exc()
except Exception as e:
logger.exception(e)
return False

def downloadLink(self,filelink=None, path=None, name=None):
Expand Down Expand Up @@ -723,22 +738,3 @@ def installIPA(self, path):
return True, result
else:
return False, result

# class Config:

# def __init__(self):
# self.configRoot = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'config')

# def get_devices(self):
# config_path = os.path.join(self.configRoot, 'devices.json')
# content = {}
# with open(config_path, "r", encoding="utf-8") as f:
# content = json.load(f)
# devices = content['content']
# return devices

# def set_devices(self):
# pass

# def remove_device(self, deviceid):
# pass
Binary file modified solox/static/image/empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 10 additions & 10 deletions solox/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ <h2 class="page-title">
</li>
<li class="list-inline-item">
<a href="https://github.com/smart-test-ti/SoloX/releases" target="_blank" class="link-secondary" rel="noopener">
{% if lan == 'cn' %} 版本 {% else %} Releases {% endif %} . V2.6.7
{% if lan == 'cn' %} 版本 {% else %} Releases {% endif %} . V2.6.8
</a>
</li>
</ul>
Expand Down Expand Up @@ -169,27 +169,27 @@ <h2 class="offcanvas-title" id="offcanvasEndLabel">
<div class="col-md-6 col-xl-12">
<div class="mb-3">
<label class="form-label">{% if lan == 'cn' %} CPU告警值 {% else %} CPU warning value {% endif %}</label>
<input id="cpu_warning_value" type="text" class="form-control" placeholder="Input placeholder" value="{{ cpuWarning }}">
<input id="cpu_warning_value" type="text" class="form-control" placeholder="Input placeholder" value="{{ settings.cpuWarning }}">
</div>
<div class="mb-3">
<label class="form-label">{% if lan == 'cn' %} 内存告警值 {% else %} Memory warning value {% endif %}</label>
<input id="mem_warning_value" type="text" class="form-control" placeholder="Input placeholder" value="{{ memWarning }}">
<input id="mem_warning_value" type="text" class="form-control" placeholder="Input placeholder" value="{{ settings.memWarning }}">
</div>
<div class="mb-3">
<label class="form-label">{% if lan == 'cn' %} FPS告警值 {% else %} FPS warning value {% endif %}</label>
<input id="fps_warning_value" type="text" class="form-control" placeholder="Input placeholder" value="{{ fpsWarning }}">
<input id="fps_warning_value" type="text" class="form-control" placeholder="Input placeholder" value="{{ settings.fpsWarning }}">
</div>
<div class="mb-3">
<label class="form-label">{% if lan == 'cn' %} 电量告警值 {% else %} Battery warning value {% endif %}</label>
<input id="battery_warning_value" type="text" class="form-control" placeholder="Input placeholder" value="{{ betteryWarning }}">
<input id="battery_warning_value" type="text" class="form-control" placeholder="Input placeholder" value="{{ settings.betteryWarning }}">
</div>
<div class="mb-3">
<label class="form-label">{% if lan == 'cn' %} 上行流量告警值 {% else %} Send network data warning value {% endif %}</label>
<input id="upflow_warning_value" type="text" class="form-control" placeholder="Input placeholder" value="{{ netdataSendWarning }}">
<input id="upflow_warning_value" type="text" class="form-control" placeholder="Input placeholder" value="{{ settings.netdataSendWarning }}">
</div>
<div class="mb-3">
<label class="form-label">{% if lan == 'cn' %} 下行流量告警值 {% else %} Recv network data warning value {% endif %}</label>
<input id="downflow_warning_value" type="text" class="form-control" placeholder="Input placeholder" value="{{ netdataRecvWarning }}">
<input id="downflow_warning_value" type="text" class="form-control" placeholder="Input placeholder" value="{{ settings.netdataRecvWarning }}">
</div>
</div>
</div>
Expand All @@ -202,7 +202,7 @@ <h2 class="offcanvas-title" id="offcanvasEndLabel">
<div class="col-md-6 col-xl-12">
<div class="mb-3">
<label class="form-label">{% if lan == 'cn' %} 持续执行时间(分钟) {% else %} Duration(minutes) {% endif %}</label>
<input id="duration" type="text" class="form-control" placeholder="Input placeholder" value="{{ duration }}">
<input id="duration" type="text" class="form-control" placeholder="Input placeholder" value="{{ settings.duration }}">
</div>
</div>
</div>
Expand All @@ -225,11 +225,11 @@ <h2 class="offcanvas-title" id="offcanvasEndLabel">
<svg t="1680252875419" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="19154" width="50" height="50"><path d="M471.04 727.04h81.92v184.32h-81.92z" p-id="19155"></path><path d="M307.2 911.36m30.72 0l348.16 0q30.72 0 30.72 30.72l0 0q0 30.72-30.72 30.72l-348.16 0q-30.72 0-30.72-30.72l0 0q0-30.72 30.72-30.72Z" p-id="19156"></path><path d="M20.48 51.2m51.2 0l880.64 0q51.2 0 51.2 51.2l0 573.44q0 51.2-51.2 51.2l-880.64 0q-51.2 0-51.2-51.2l0-573.44q0-51.2 51.2-51.2Z" p-id="19157"></path><path d="M122.88 645.12m20.48 0l737.28 0q20.48 0 20.48 20.48l0 0q0 20.48-20.48 20.48l-737.28 0q-20.48 0-20.48-20.48l0 0q0-20.48 20.48-20.48Z" fill="#EBBA50" p-id="19158"></path></svg>
</td>
<td>
<input id="host" type="text" class="form-control form-control-sm" placeholder="ex : 192.168.10.10:6006" value="{{ solox_host }}">
<input id="host" type="text" class="form-control form-control-sm" placeholder="ex : 192.168.10.10:6006" value="{{ settings.solox_host }}">
</td>
<td>
<label class="form-check form-switch">
{% if host_switch == '1' %}
{% if settings.host_switch == '1' %}
<input class="form-check-input host_switch" type="checkbox" checked>
{% else %}
<input class="form-check-input host_switch" type="checkbox">
Expand Down
Loading

0 comments on commit 88b7b18

Please sign in to comment.