taotoolkit 2.0.6__tar.gz → 2.0.8__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: taotoolkit
3
- Version: 2.0.6
3
+ Version: 2.0.8
4
4
  Summary: Tao ToolKit
5
5
  Author-email: taotaoli <taotaoli@asrmicro.com>
6
6
  License-Expression: MIT
@@ -9,7 +9,7 @@ Description-Content-Type: text/markdown
9
9
  Requires-Dist: chardet>=5.0.0
10
10
  Requires-Dist: colorama>=0.4.5
11
11
  Requires-Dist: func_timeout>=4.3.5
12
- Requires-Dist: Pillow>=9.0.0
12
+ Requires-Dist: Pillow>=9.1.0
13
13
  Requires-Dist: numpy>=1.23.0
14
14
  Requires-Dist: matplotlib>=3.5.0
15
15
  Requires-Dist: opencv-python>=4.5.0
@@ -19,7 +19,7 @@ Requires-Dist: beautifulsoup4>=4.10.0
19
19
  Requires-Dist: pyyaml>=6.0.3
20
20
  Requires-Dist: pywinpty>=3.0.5; platform_system == "Windows"
21
21
  Provides-Extra: uiautomator
22
- Requires-Dist: uiautomator2>=2.0.6; extra == "uiautomator"
22
+ Requires-Dist: uiautomator2>=2.0.7; extra == "uiautomator"
23
23
 
24
24
  # TAO - Toolkit
25
25
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "taotoolkit"
7
- version = "2.0.6"
7
+ version = "2.0.8"
8
8
  description = "Tao ToolKit"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -16,7 +16,7 @@ dependencies = [
16
16
  "chardet>=5.0.0",
17
17
  "colorama>=0.4.5",
18
18
  "func_timeout>=4.3.5",
19
- "Pillow>=9.0.0",
19
+ "Pillow>=9.1.0",
20
20
  "numpy>=1.23.0",
21
21
  "matplotlib>=3.5.0",
22
22
  "opencv-python>=4.5.0",
@@ -29,5 +29,5 @@ dependencies = [
29
29
 
30
30
  [project.optional-dependencies]
31
31
  uiautomator = [
32
- "uiautomator2>=2.0.6",
32
+ "uiautomator2>=2.0.7",
33
33
  ]
@@ -43,7 +43,7 @@ from .tao_camDvt import camDvtMain as camDvtMain, printHelp as camDvtHelp, CamDv
43
43
 
44
44
  from .asrVrf import Vrf
45
45
 
46
- __version__ = "2.0.6"
46
+ __version__ = "2.0.8"
47
47
 
48
48
  __all__ = [
49
49
  "debugCtrl",
@@ -86,8 +86,8 @@ def fix_windows_encoding():
86
86
  return
87
87
  import ctypes
88
88
 
89
- ctypes.windll.kernel32.SetConsoleOutputCP(65001)
90
- ctypes.windll.kernel32.SetConsoleCP(65001)
89
+ ctypes.windll.kernel32.SetConsoleOutputCP(65001) # type: ignore
90
+ ctypes.windll.kernel32.SetConsoleCP(65001) # type: ignore
91
91
  sys.stdout.reconfigure(encoding="utf-8", errors="replace") # type: ignore
92
92
  sys.stderr.reconfigure(encoding="utf-8", errors="replace") # type: ignore
93
93
 
@@ -98,7 +98,7 @@ def supports_ansi():
98
98
  if sys.platform == "win32":
99
99
  import ctypes
100
100
 
101
- kernel32 = ctypes.windll.kernel32
101
+ kernel32 = ctypes.windll.kernel32 # type: ignore
102
102
  kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)
103
103
  return os.environ.get("TERM") != "" or "WT_SESSION" in os.environ or "ANSICON" in os.environ or sys.stdout.isatty()
104
104
  return sys.stdout.isatty()
@@ -14,7 +14,7 @@ from typing import Callable, Dict, List, Optional, Any, Union, Iterable, NoRetur
14
14
  from colorama import Back, Fore, Style, init
15
15
 
16
16
  try:
17
- from winpty import PtyProcess # pip install pywinpty
17
+ from winpty import PtyProcess # type: ignore # pip install pywinpty(仅 Windows)
18
18
  WINPTY_AVAILABLE = True
19
19
  except ImportError:
20
20
  WINPTY_AVAILABLE = False
@@ -266,7 +266,7 @@ def run_as_admin() -> bool:
266
266
  try:
267
267
  import ctypes
268
268
 
269
- return ctypes.windll.shell32.IsUserAnAdmin()
269
+ return ctypes.windll.shell32.IsUserAnAdmin() # type: ignore
270
270
  except Exception:
271
271
  return False
272
272
 
@@ -164,10 +164,17 @@ class DevOp:
164
164
  out = self._probeDevices()
165
165
  cache = _load_cache()
166
166
 
167
- # 判断缓存是否命中
168
- if cache is not None and cache.get("serial") in out:
167
+ # 判断缓存是否命中: 显式指定 serial 时, 必须与缓存中的设备一致才可复用
168
+ req_serial = (serial or "").strip()
169
+ if (
170
+ cache is not None
171
+ and cache.get("serial") in out
172
+ and (req_serial == "" or req_serial == cache.get("serial"))
173
+ ):
169
174
  cache_hit = True
170
175
  else:
176
+ if req_serial and cache is not None and req_serial != cache.get("serial"):
177
+ logd(f"[cache] 指定设备 {req_serial} 与缓存设备 {cache.get('serial')} 不一致, 忽略缓存")
171
178
  cache_hit = False
172
179
 
173
180
  if cache_hit and cache is not None:
@@ -652,10 +659,12 @@ class DevOp:
652
659
  self.soc = value
653
660
  self.chipId = key
654
661
  return self.soc
655
- # 不阻塞等 input: 直接失败并说明读了哪些属性, 便于区分"属性缺失"与"adb shell 卡死"
662
+ # chip 不在 chipIdDict 中: 说明该设备不属于 ASR soc, 不退出, 标记为 unknown
663
+ self.soc = "unknown"
664
+ self.chipId = None
656
665
  detail = ", ".join(f"{k}={v or '<空>'}" for k, v in props.items())
657
- eExit(f"get SOC from prop failed ({detail}), expected ASR chip in {list(self.chipIdDict)}; "
658
- f"if all props are empty, adb shell may be stuck, try: adb kill-server")
666
+ logw(f"device is not ASR soc ({detail}), expected ASR chip in {list(self.chipIdDict)}, set soc=unknown")
667
+ return self.soc
659
668
 
660
669
  # ── 相机 ─────────────────────────────────────────────
661
670
 
@@ -1308,15 +1317,19 @@ def CLI_scrcpy(argsList):
1308
1317
 
1309
1318
 
1310
1319
  def CLI_power(argsList):
1311
- parser = argparse.ArgumentParser(prog="power", description="android power on/off")
1320
+ parser = argparse.ArgumentParser(prog="po", description="android power on/off")
1321
+ parser.add_argument(
1322
+ "state", nargs="?", default="1", choices=["0", "1"],
1323
+ help="1=打开屏幕(默认), 0=关闭屏幕, 可直接输入(po 0)",
1324
+ )
1312
1325
  parser.add_argument("-s", "--serial", type=str, default="", help="设备SN号(多设备需指定)")
1313
- parser.add_argument("--off", action="store_false", dest="power", help="关闭屏幕")
1314
- parser.set_defaults(power=True)
1326
+ parser.add_argument("--off", action="store_true", help="关闭屏幕(等价于 po 0)")
1315
1327
  args = parser.parse_args(argsList)
1316
1328
 
1329
+ power = args.state != "0" and not args.off
1317
1330
  dev = DevOp(args.serial)
1318
- logi("power on" if args.power else "power off")
1319
- dev.lcdOnAndUnlock(args.power)
1331
+ logi("power on" if power else "power off")
1332
+ dev.lcdOnAndUnlock(power)
1320
1333
 
1321
1334
 
1322
1335
  def CLI_cam(args):
@@ -1332,7 +1345,8 @@ def CLI_cam(args):
1332
1345
 
1333
1346
  def CLI_screenCap(argsList):
1334
1347
  parser = argparse.ArgumentParser(prog="sc", description="android设备截屏")
1335
- parser.add_argument("-f", "--file", default="tmp", help="输出文件名(不含 .png)")
1348
+ parser.add_argument("posFile", nargs="?", default=None, help="输出文件名,可直接输入(sc test)")
1349
+ parser.add_argument("-f", "--file", default=None, help="输出文件名(不含 .png)")
1336
1350
  parser.add_argument("-s", "--serial", default="", help="设备SN号")
1337
1351
  parser.add_argument("-d", "--display", default=None, help="屏幕 Display ID(完整长ID)")
1338
1352
  parser.add_argument("--sub", action="store_true", help="截取副屏")
@@ -1340,6 +1354,8 @@ def CLI_screenCap(argsList):
1340
1354
  parser.add_argument("--hdr", action="store_true", help="启用 HDR 模式(Android 17+)")
1341
1355
  parser.add_argument("--list", action="store_true", help="列出所有屏幕信息")
1342
1356
  args = parser.parse_args(argsList)
1357
+ if args.file is None:
1358
+ args.file = args.posFile if args.posFile is not None else "tmp"
1343
1359
 
1344
1360
  dev = DevOp(args.serial)
1345
1361
  if not dev.isLcdOn():
@@ -1367,7 +1383,8 @@ def CLI_screenCap(argsList):
1367
1383
 
1368
1384
  def CLI_screenRec(argsList):
1369
1385
  parser = argparse.ArgumentParser(prog="screenRec", description="对android设备录屏")
1370
- parser.add_argument("-f", "--file", required=False, default="tmp", help="录制文件名,自动添加后缀.mp4 (默认tmp,可选)")
1386
+ parser.add_argument("posFile", nargs="?", default=None, help="录制文件名,可直接输入(sr test)")
1387
+ parser.add_argument("-f", "--file", required=False, default=None, help="录制文件名,自动添加后缀.mp4 (默认tmp,可选)")
1371
1388
  parser.add_argument("-t", "--time", required=False, default="30", help="录制时间,单位秒 (默认30秒,可选)")
1372
1389
  parser.add_argument("-b", "--bitrate", required=False, default="2", help="录制比特率,单位Mbps (默认2,可选)")
1373
1390
  parser.add_argument("-s", "--serial", type=str, default="", help="设备SN号(多设备需指定)")
@@ -1382,6 +1399,8 @@ def CLI_screenRec(argsList):
1382
1399
  parser.set_defaults(debug=True) # 设置默认值为 True
1383
1400
  parser.set_defaults(showTouch=False)
1384
1401
  args = parser.parse_args(argsList)
1402
+ if args.file is None:
1403
+ args.file = args.posFile if args.posFile is not None else "tmp"
1385
1404
 
1386
1405
  dev = DevOp(args.serial)
1387
1406
  if not dev.isLcdOn():
@@ -821,7 +821,7 @@ class jenkinsTool:
821
821
  if len(out.split("\n")) != 3:
822
822
  dev = DevOp()
823
823
  serial = dev.serial
824
- if dev.soc != None:
824
+ if dev.soc not in (None, "unknown"):
825
825
  boardTag = dev.soc + "_"
826
826
 
827
827
  # pCmd("adb reboot download", showCmd=True, waitDone=False)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: taotoolkit
3
- Version: 2.0.6
3
+ Version: 2.0.8
4
4
  Summary: Tao ToolKit
5
5
  Author-email: taotaoli <taotaoli@asrmicro.com>
6
6
  License-Expression: MIT
@@ -9,7 +9,7 @@ Description-Content-Type: text/markdown
9
9
  Requires-Dist: chardet>=5.0.0
10
10
  Requires-Dist: colorama>=0.4.5
11
11
  Requires-Dist: func_timeout>=4.3.5
12
- Requires-Dist: Pillow>=9.0.0
12
+ Requires-Dist: Pillow>=9.1.0
13
13
  Requires-Dist: numpy>=1.23.0
14
14
  Requires-Dist: matplotlib>=3.5.0
15
15
  Requires-Dist: opencv-python>=4.5.0
@@ -19,7 +19,7 @@ Requires-Dist: beautifulsoup4>=4.10.0
19
19
  Requires-Dist: pyyaml>=6.0.3
20
20
  Requires-Dist: pywinpty>=3.0.5; platform_system == "Windows"
21
21
  Provides-Extra: uiautomator
22
- Requires-Dist: uiautomator2>=2.0.6; extra == "uiautomator"
22
+ Requires-Dist: uiautomator2>=2.0.7; extra == "uiautomator"
23
23
 
24
24
  # TAO - Toolkit
25
25
 
@@ -1,7 +1,7 @@
1
1
  chardet>=5.0.0
2
2
  colorama>=0.4.5
3
3
  func_timeout>=4.3.5
4
- Pillow>=9.0.0
4
+ Pillow>=9.1.0
5
5
  numpy>=1.23.0
6
6
  matplotlib>=3.5.0
7
7
  opencv-python>=4.5.0
@@ -14,4 +14,4 @@ pyyaml>=6.0.3
14
14
  pywinpty>=3.0.5
15
15
 
16
16
  [uiautomator]
17
- uiautomator2>=2.0.6
17
+ uiautomator2>=2.0.7
File without changes
File without changes