magnax 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- magnax/__init__.py +3 -0
- magnax/__main__.py +25 -0
- magnax/debug.py +65 -0
- magnax/public/__init__.py +1 -0
- magnax/public/adb/linux/adb +0 -0
- magnax/public/adb/linux_arm/adb +0 -0
- magnax/public/adb/mac/adb +0 -0
- magnax/public/adb/windows/AdbWinApi.dll +0 -0
- magnax/public/adb/windows/AdbWinUsbApi.dll +0 -0
- magnax/public/adb/windows/adb.exe +0 -0
- magnax/public/adb.py +96 -0
- magnax/public/android_fps.py +750 -0
- magnax/public/apm.py +1306 -0
- magnax/public/apm_pk.py +184 -0
- magnax/public/common.py +1598 -0
- magnax/public/config.json +1 -0
- magnax/public/ios_perf_adapter.py +790 -0
- magnax/public/report_template/android.html +526 -0
- magnax/public/report_template/ios.html +482 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/AdbWinApi.dll +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/AdbWinUsbApi.dll +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/SDL2.dll +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/adb.exe +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/avcodec-60.dll +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/avformat-60.dll +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/avutil-58.dll +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/icon.png +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/libusb-1.0.dll +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/open_a_terminal_here.bat +1 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/scrcpy-console.bat +2 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/scrcpy-noconsole.vbs +7 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/scrcpy-server +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/scrcpy.exe +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/swresample-4.dll +0 -0
- magnax/public/scrcpy/scrcpy-win64-v2.4/AdbWinApi.dll +0 -0
- magnax/public/scrcpy/scrcpy-win64-v2.4/AdbWinUsbApi.dll +0 -0
- magnax/public/scrcpy/scrcpy-win64-v2.4/SDL2.dll +0 -0
- magnax/public/scrcpy/scrcpy-win64-v2.4/avformat-60.dll +0 -0
- magnax/public/scrcpy/scrcpy-win64-v2.4/avutil-58.dll +0 -0
- magnax/public/scrcpy/scrcpy-win64-v2.4/open_a_terminal_here.bat +1 -0
- magnax/public/scrcpy/scrcpy-win64-v2.4/scrcpy-noconsole.vbs +7 -0
- magnax/public/scrcpy/scrcpy-win64-v2.4/scrcpy-server +0 -0
- magnax/public/scrcpy/scrcpy-win64-v2.4/scrcpy.exe +0 -0
- magnax/public/scrcpy/scrcpy-win64-v2.4/swresample-4.dll +0 -0
- magnax/static/css/highlight.min.css +9 -0
- magnax/static/css/magnax-dark-theme.css +1237 -0
- magnax/static/css/select2-bootstrap-5-theme.min.css +3 -0
- magnax/static/css/select2-bootstrap-5-theme.rtl.min.css +3 -0
- magnax/static/css/select2.min.css +1 -0
- magnax/static/css/sweetalert2.min.css +1 -0
- magnax/static/css/tabler.demo.min.css +9 -0
- magnax/static/css/tabler.min.css +14 -0
- magnax/static/image/500.png +0 -0
- magnax/static/image/avatar.png +0 -0
- magnax/static/image/empty.png +0 -0
- magnax/static/image/readme/home.png +0 -0
- magnax/static/image/readme/pk.png +0 -0
- magnax/static/js/apexcharts.js +14 -0
- magnax/static/js/gray.js +16 -0
- magnax/static/js/highlight.min.js +1173 -0
- magnax/static/js/highstock.js +803 -0
- magnax/static/js/html2canvas.min.js +20 -0
- magnax/static/js/jquery.min.js +2 -0
- magnax/static/js/magnax-chart-theme.js +492 -0
- magnax/static/js/select2.min.js +2 -0
- magnax/static/js/sweetalert2.min.js +1 -0
- magnax/static/js/tabler.demo.min.js +9 -0
- magnax/static/js/tabler.min.js +9 -0
- magnax/static/logo/logo.png +0 -0
- magnax/templates/404.html +30 -0
- magnax/templates/analysis.html +1375 -0
- magnax/templates/analysis_compare.html +600 -0
- magnax/templates/analysis_pk.html +680 -0
- magnax/templates/base.html +365 -0
- magnax/templates/index.html +2471 -0
- magnax/templates/pk.html +743 -0
- magnax/templates/report.html +416 -0
- magnax/view/__init__.py +1 -0
- magnax/view/apis.py +952 -0
- magnax/view/pages.py +146 -0
- magnax/web.py +345 -0
- magnax-1.0.0.dist-info/METADATA +242 -0
- magnax-1.0.0.dist-info/RECORD +87 -0
- magnax-1.0.0.dist-info/WHEEL +5 -0
- magnax-1.0.0.dist-info/entry_points.txt +2 -0
- magnax-1.0.0.dist-info/licenses/LICENSE +21 -0
- magnax-1.0.0.dist-info/top_level.txt +1 -0
magnax/__init__.py
ADDED
magnax/__main__.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
MagnaX - Real-time performance monitoring tool for Android/iOS apps.
|
|
5
|
+
|
|
6
|
+
Usage:
|
|
7
|
+
magnax [--host=HOST] [--port=PORT]
|
|
8
|
+
python -m magnax [--host=HOST] [--port=PORT]
|
|
9
|
+
|
|
10
|
+
Examples:
|
|
11
|
+
magnax # Start with default settings (localhost:50003)
|
|
12
|
+
magnax --host=0.0.0.0 --port=8080 # Custom host and port
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import fire
|
|
16
|
+
from magnax.web import main as web_main
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def main():
|
|
20
|
+
"""Entry point for the magnax command."""
|
|
21
|
+
fire.Fire(web_main)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
if __name__ == '__main__':
|
|
25
|
+
main()
|
magnax/debug.py
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import multiprocessing
|
|
2
|
+
import subprocess
|
|
3
|
+
import time
|
|
4
|
+
import os
|
|
5
|
+
import webbrowser
|
|
6
|
+
import requests
|
|
7
|
+
import socket
|
|
8
|
+
import psutil
|
|
9
|
+
import sys
|
|
10
|
+
from view.apis import api
|
|
11
|
+
from view.pages import page
|
|
12
|
+
from loguru import logger
|
|
13
|
+
from flask import Flask
|
|
14
|
+
from pyfiglet import Figlet
|
|
15
|
+
from magnax import __version__
|
|
16
|
+
|
|
17
|
+
app = Flask(__name__, template_folder='templates', static_folder='static')
|
|
18
|
+
app.register_blueprint(api)
|
|
19
|
+
app.register_blueprint(page)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def ip() -> str:
|
|
23
|
+
try:
|
|
24
|
+
ip = socket.gethostbyname(socket.gethostname())
|
|
25
|
+
except:
|
|
26
|
+
ip = '127.0.0.1'
|
|
27
|
+
return ip
|
|
28
|
+
|
|
29
|
+
def listen(port):
|
|
30
|
+
net_connections = psutil.net_connections()
|
|
31
|
+
conn = [c for c in net_connections if c.status == "LISTEN" and c.laddr.port == port]
|
|
32
|
+
if conn:
|
|
33
|
+
pid = conn[0].pid
|
|
34
|
+
logger.warning('Port {} is used by process {}'.format(port, pid))
|
|
35
|
+
logger.info('you can start magnax : python -m magnax --host={ip} --port={port}')
|
|
36
|
+
return False
|
|
37
|
+
return True
|
|
38
|
+
|
|
39
|
+
def status(host: str, port: int):
|
|
40
|
+
r = requests.get('http://{}:{}'.format(host, port), timeout=2.0)
|
|
41
|
+
flag = (True, False)[r.status_code == 200]
|
|
42
|
+
return flag
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def open_url(host: str, port: int):
|
|
46
|
+
flag = True
|
|
47
|
+
while flag:
|
|
48
|
+
logger.info('start magnax server ...')
|
|
49
|
+
f = Figlet(font="slant", width=300)
|
|
50
|
+
print(f.renderText("MAGNAX {}".format(__version__)))
|
|
51
|
+
flag = status(host, port)
|
|
52
|
+
webbrowser.open('http://{}:{}/?platform=Android&lan=en'.format(host, port), new=2)
|
|
53
|
+
logger.info('Running on http://{}:{}/?platform=Android&lan=en (Press CTRL+C to quit)'.format(host, port))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def start(host: str, port: int):
|
|
57
|
+
logger.info('Running on http://{}:{}/?platform=Android&lan=en (Press CTRL+C to quit)'.format(host, port))
|
|
58
|
+
app.run(host=host, port=port, debug=True)
|
|
59
|
+
|
|
60
|
+
def main(host=ip(), port=50003):
|
|
61
|
+
start(host, port)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
if __name__ == '__main__':
|
|
65
|
+
main()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
File without changes
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
magnax/public/adb.py
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/python
|
|
2
|
+
# encoding=utf-8
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
@Author : Lijiawei
|
|
6
|
+
@Date : 2022/6/19
|
|
7
|
+
@Desc : adb line.
|
|
8
|
+
@Update : 2022/7/14 by Rafa chen
|
|
9
|
+
"""
|
|
10
|
+
import os
|
|
11
|
+
import platform
|
|
12
|
+
import stat
|
|
13
|
+
import subprocess
|
|
14
|
+
|
|
15
|
+
STATICPATH = os.path.dirname(os.path.realpath(__file__))
|
|
16
|
+
DEFAULT_ADB_PATH = {
|
|
17
|
+
"Windows": os.path.join(STATICPATH, "adb", "windows", "adb.exe"),
|
|
18
|
+
"Darwin": os.path.join(STATICPATH, "adb", "mac", "adb"),
|
|
19
|
+
"Linux": os.path.join(STATICPATH, "adb", "linux", "adb"),
|
|
20
|
+
"Linux-x86_64": os.path.join(STATICPATH, "adb", "linux", "adb"),
|
|
21
|
+
"Linux-armv7l": os.path.join(STATICPATH, "adb", "linux_arm", "adb"),
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def make_file_executable(file_path):
|
|
26
|
+
"""
|
|
27
|
+
If the path does not have executable permissions, execute chmod +x
|
|
28
|
+
:param file_path:
|
|
29
|
+
:return:
|
|
30
|
+
"""
|
|
31
|
+
if os.path.isfile(file_path):
|
|
32
|
+
mode = os.lstat(file_path)[stat.ST_MODE]
|
|
33
|
+
executable = True if mode & stat.S_IXUSR else False
|
|
34
|
+
if not executable:
|
|
35
|
+
os.chmod(file_path, mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
|
|
36
|
+
return True
|
|
37
|
+
return False
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def builtin_adb_path():
|
|
41
|
+
"""
|
|
42
|
+
Return built-in adb executable path
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
adb executable path
|
|
46
|
+
|
|
47
|
+
"""
|
|
48
|
+
system = platform.system()
|
|
49
|
+
machine = platform.machine()
|
|
50
|
+
adb_path = DEFAULT_ADB_PATH.get('{}-{}'.format(system, machine))
|
|
51
|
+
proc = subprocess.Popen('adb devices', stdout=subprocess.PIPE, shell=True)
|
|
52
|
+
result = proc.stdout.read()
|
|
53
|
+
if not isinstance(result, str):
|
|
54
|
+
result = str(result, 'utf-8')
|
|
55
|
+
if result and "command not found" not in result:
|
|
56
|
+
adb_path = "adb"
|
|
57
|
+
return adb_path
|
|
58
|
+
|
|
59
|
+
if not adb_path:
|
|
60
|
+
adb_path = DEFAULT_ADB_PATH.get(system)
|
|
61
|
+
if not adb_path:
|
|
62
|
+
raise RuntimeError("No adb executable supports this platform({}-{}).".format(system, machine))
|
|
63
|
+
|
|
64
|
+
# overwrite uiautomator adb
|
|
65
|
+
if "ANDROID_HOME" in os.environ:
|
|
66
|
+
del os.environ["ANDROID_HOME"]
|
|
67
|
+
if system != "Windows":
|
|
68
|
+
# chmod +x adb
|
|
69
|
+
make_file_executable(adb_path)
|
|
70
|
+
return adb_path
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class ADB(object):
|
|
74
|
+
|
|
75
|
+
def __init__(self):
|
|
76
|
+
self.adb_path = builtin_adb_path()
|
|
77
|
+
|
|
78
|
+
def shell(self, cmd, deviceId):
|
|
79
|
+
run_cmd = f'{self.adb_path} -s {deviceId} shell {cmd}'
|
|
80
|
+
result = subprocess.Popen(run_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[
|
|
81
|
+
0].decode("utf-8").strip()
|
|
82
|
+
return result
|
|
83
|
+
|
|
84
|
+
def tcp_shell(self, deviceId, cmd):
|
|
85
|
+
run_cmd = f'{self.adb_path} -s {deviceId} {cmd}'
|
|
86
|
+
result = os.system(run_cmd)
|
|
87
|
+
return result
|
|
88
|
+
|
|
89
|
+
def shell_noDevice(self, cmd):
|
|
90
|
+
run_cmd = f'{self.adb_path} {cmd}'
|
|
91
|
+
result = os.system(run_cmd)
|
|
92
|
+
return result
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
adb = ADB()
|