pymobiledevice3 6.1.0__py3-none-any.whl → 6.1.2__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.
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '6.1.0'
32
- __version_tuple__ = version_tuple = (6, 1, 0)
31
+ __version__ = version = '6.1.2'
32
+ __version_tuple__ = version_tuple = (6, 1, 2)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -50,7 +50,7 @@ def format_line(color, pid, syslog_entry, include_label: bool, image_offset: boo
50
50
  image_name = posixpath.basename(syslog_entry.image_name)
51
51
  message = syslog_entry.message
52
52
  process_name = posixpath.basename(filename)
53
- image_offset_str = f"+0x{syslog_entry.image_offset:x}" if image_offset else ""
53
+ image_offset_str = f"+0x{syslog_entry.image_offset:x}" if image_offset and image_name else ""
54
54
  label = ""
55
55
 
56
56
  if (pid != -1) and (syslog_pid != pid):
@@ -8,7 +8,7 @@ import struct
8
8
  import time
9
9
  import xml
10
10
  from enum import Enum
11
- from typing import Any, Optional
11
+ from typing import Any, Optional, Union
12
12
 
13
13
  import IPython
14
14
  from pygments import formatters, highlight, lexers
@@ -282,29 +282,29 @@ class ServiceConnection:
282
282
  msg = b"".join([hdr, data])
283
283
  return self.sendall(msg)
284
284
 
285
- def recv_plist(self, endianity: str = ">") -> dict:
285
+ def recv_plist(self, endianity: str = ">") -> Union[dict, list]:
286
286
  """
287
- Receive a plist from the socket and parse it into a dictionary.
287
+ Receive a plist from the socket and parse it into a native type.
288
288
 
289
289
  :param endianity: The byte order ('>' for big-endian, '<' for little-endian).
290
- :return: The received plist as a dictionary.
290
+ :return: The received plist as a native type.
291
291
  """
292
292
  return parse_plist(self.recv_prefixed(endianity=endianity))
293
293
 
294
294
  async def aio_recv_plist(self, endianity: str = ">") -> dict:
295
295
  """
296
- Asynchronously receive a plist from the socket and parse it into a dictionary.
296
+ Asynchronously receive a plist from the socket and parse it into a native type.
297
297
 
298
298
  :param endianity: The byte order ('>' for big-endian, '<' for little-endian).
299
- :return: The received plist as a dictionary.
299
+ :return: The received plist as a native type.
300
300
  """
301
301
  return parse_plist(await self.aio_recv_prefixed(endianity))
302
302
 
303
- def send_plist(self, d: dict, endianity: str = ">", fmt: Enum = plistlib.FMT_XML) -> None:
303
+ def send_plist(self, d: Union[dict, list], endianity: str = ">", fmt: Enum = plistlib.FMT_XML) -> None:
304
304
  """
305
- Send a dictionary as a plist to the socket.
305
+ Send a native type as a plist to the socket.
306
306
 
307
- :param d: The dictionary to send.
307
+ :param d: The native type to send.
308
308
  :param endianity: The byte order ('>' for big-endian, '<' for little-endian).
309
309
  :param fmt: The plist format (e.g., plistlib.FMT_XML).
310
310
  """
@@ -319,7 +319,7 @@ class ServiceConnection:
319
319
  self.writer.write(payload)
320
320
  await self.writer.drain()
321
321
 
322
- async def aio_send_plist(self, d: dict, endianity: str = ">", fmt: Enum = plistlib.FMT_XML) -> None:
322
+ async def aio_send_plist(self, d: Union[dict, list], endianity: str = ">", fmt: Enum = plistlib.FMT_XML) -> None:
323
323
  """
324
324
  Asynchronously send a dictionary as a plist to the socket.
325
325
 
@@ -3,9 +3,12 @@ import datetime
3
3
  import shutil
4
4
  import struct
5
5
  import warnings
6
+ from collections.abc import Iterable, Mapping, Sequence
6
7
  from pathlib import Path
8
+ from typing import Any, Callable, Optional, cast
7
9
 
8
10
  from pymobiledevice3.exceptions import NotEnoughDiskSpaceError, PyMobileDevice3Exception
11
+ from pymobiledevice3.service_connection import ServiceConnection
9
12
 
10
13
  SIZE_FORMAT = ">I"
11
14
  CODE_FORMAT = ">B"
@@ -26,12 +29,16 @@ ERRNO_TO_DEVICE_ERROR = {
26
29
  28: -15,
27
30
  }
28
31
 
32
+ DLMessage = Sequence[Any]
33
+ ProgressCallback = Callable[[Any], None]
34
+ DLHandler = Callable[[DLMessage], None]
35
+
29
36
 
30
37
  class DeviceLink:
31
- def __init__(self, service, root_path: Path):
32
- self.service = service
33
- self.root_path = root_path
34
- self._dl_handlers = {
38
+ def __init__(self, service: ServiceConnection, root_path: Path) -> None:
39
+ self.service: ServiceConnection = service
40
+ self.root_path: Path = root_path
41
+ self._dl_handlers: dict[str, DLHandler] = {
35
42
  "DLMessageCreateDirectory": self.create_directory,
36
43
  "DLMessageUploadFiles": self.upload_files,
37
44
  "DLMessageGetFreeDiskSpace": self.get_free_disk_space,
@@ -43,7 +50,12 @@ class DeviceLink:
43
50
  "DLMessagePurgeDiskSpace": self.purge_disk_space,
44
51
  }
45
52
 
46
- def dl_loop(self, progress_callback=lambda x: None):
53
+ def dl_loop(self, progress_callback: Optional[ProgressCallback] = None) -> Any:
54
+ def _noop(_: Any) -> None:
55
+ return None
56
+
57
+ callback: ProgressCallback = progress_callback if progress_callback is not None else _noop
58
+
47
59
  while True:
48
60
  message = self.receive_message()
49
61
  command = message[0]
@@ -55,9 +67,9 @@ class DeviceLink:
55
67
  "DLMessageRemoveFiles",
56
68
  "DLMessageRemoveItems",
57
69
  ):
58
- progress_callback(message[3])
70
+ callback(message[3])
59
71
  elif command == "DLMessageUploadFiles":
60
- progress_callback(message[2])
72
+ callback(message[2])
61
73
 
62
74
  if command == "DLMessageProcessMessage":
63
75
  if not message[1]["ErrorCode"]:
@@ -66,7 +78,7 @@ class DeviceLink:
66
78
  raise PyMobileDevice3Exception(f"Device link error: {message[1]}")
67
79
  self._dl_handlers[command](message)
68
80
 
69
- def version_exchange(self):
81
+ def version_exchange(self) -> None:
70
82
  dl_message_version_exchange = self.receive_message()
71
83
  version_major = dl_message_version_exchange[1]
72
84
  self.service.send_plist(["DLMessageVersionExchange", "DLVersionsOk", version_major])
@@ -74,12 +86,13 @@ class DeviceLink:
74
86
  if dl_message_device_ready[0] != "DLMessageDeviceReady":
75
87
  raise PyMobileDevice3Exception("Device link didn't return ready state")
76
88
 
77
- def send_process_message(self, message):
89
+ def send_process_message(self, message: Mapping[str, Any]) -> None:
78
90
  self.service.send_plist(["DLMessageProcessMessage", message])
79
91
 
80
- def download_files(self, message):
81
- status = {}
82
- for file in message[1]:
92
+ def download_files(self, message: DLMessage) -> None:
93
+ status: dict[str, dict[str, Any]] = {}
94
+ files = cast(Iterable[str], message[1])
95
+ for file in files:
83
96
  self.service.sendall(struct.pack(SIZE_FORMAT, len(file)))
84
97
  self.service.sendall(file.encode())
85
98
 
@@ -114,9 +127,9 @@ class DeviceLink:
114
127
  else:
115
128
  self.status_response(0)
116
129
 
117
- def contents_of_directory(self, message):
130
+ def contents_of_directory(self, message: DLMessage) -> None:
118
131
  data = {}
119
- path = self.root_path / message[1]
132
+ path = self.root_path / cast(str, message[1])
120
133
  for file in path.iterdir():
121
134
  ftype = "DLFileTypeUnknown"
122
135
  if file.is_dir():
@@ -132,7 +145,7 @@ class DeviceLink:
132
145
  }
133
146
  self.status_response(0, status_dict=data)
134
147
 
135
- def upload_files(self, message):
148
+ def upload_files(self, _message: DLMessage) -> None:
136
149
  while True:
137
150
  device_name = self._prefixed_recv()
138
151
  if not device_name:
@@ -158,20 +171,21 @@ class DeviceLink:
158
171
  assert code == CODE_SUCCESS
159
172
  self.status_response(0)
160
173
 
161
- def get_free_disk_space(self, message):
174
+ def get_free_disk_space(self, _message: DLMessage) -> None:
162
175
  freespace = shutil.disk_usage(self.root_path).free
163
176
  self.status_response(0, status_dict=freespace)
164
177
 
165
- def move_items(self, message):
166
- for src, dst in message[1].items():
178
+ def move_items(self, message: DLMessage) -> None:
179
+ items = cast(Mapping[str, str], message[1])
180
+ for src, dst in items.items():
167
181
  dest = self.root_path / dst
168
182
  dest.parent.mkdir(parents=True, exist_ok=True)
169
183
  shutil.move(self.root_path / src, dest)
170
184
  self.status_response(0)
171
185
 
172
- def copy_item(self, message):
173
- src = self.root_path / message[1]
174
- dest = self.root_path / message[2]
186
+ def copy_item(self, message: DLMessage) -> None:
187
+ src = self.root_path / cast(str, message[1])
188
+ dest = self.root_path / cast(str, message[2])
175
189
  dest.parent.mkdir(parents=True, exist_ok=True)
176
190
  if src.is_dir():
177
191
  shutil.copytree(src, dest)
@@ -179,11 +193,11 @@ class DeviceLink:
179
193
  shutil.copy(src, dest)
180
194
  self.status_response(0)
181
195
 
182
- def purge_disk_space(self, message) -> None:
196
+ def purge_disk_space(self, _message: DLMessage) -> None:
183
197
  raise NotEnoughDiskSpaceError()
184
198
 
185
- def remove_items(self, message):
186
- for path in message[1]:
199
+ def remove_items(self, message: DLMessage) -> None:
200
+ for path in cast(Iterable[str], message[1]):
187
201
  rm_path = self.root_path / path
188
202
  if rm_path.is_dir():
189
203
  shutil.rmtree(rm_path)
@@ -191,12 +205,12 @@ class DeviceLink:
191
205
  rm_path.unlink(missing_ok=True)
192
206
  self.status_response(0)
193
207
 
194
- def create_directory(self, message):
195
- path = message[1]
208
+ def create_directory(self, message: DLMessage) -> None:
209
+ path = cast(str, message[1])
196
210
  (self.root_path / path).mkdir(parents=True, exist_ok=True)
197
211
  self.status_response(0)
198
212
 
199
- def status_response(self, status_code, status_str="", status_dict=None):
213
+ def status_response(self, status_code: int, status_str: str = "", status_dict: Any = None) -> None:
200
214
  self.service.send_plist([
201
215
  "DLMessageStatusResponse",
202
216
  ctypes.c_uint64(status_code).value,
@@ -204,12 +218,12 @@ class DeviceLink:
204
218
  status_dict if status_dict is not None else {},
205
219
  ])
206
220
 
207
- def receive_message(self):
208
- return self.service.recv_plist()
221
+ def receive_message(self) -> DLMessage:
222
+ return cast(DLMessage, self.service.recv_plist())
209
223
 
210
- def disconnect(self):
224
+ def disconnect(self) -> None:
211
225
  self.service.send_plist(["DLMessageDisconnect", "___EmptyParameterString___"])
212
226
 
213
- def _prefixed_recv(self):
227
+ def _prefixed_recv(self) -> str:
214
228
  (size,) = struct.unpack(SIZE_FORMAT, self.service.recvall(struct.calcsize(SIZE_FORMAT)))
215
229
  return self.service.recvall(size).decode()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pymobiledevice3
3
- Version: 6.1.0
3
+ Version: 6.1.2
4
4
  Summary: Pure python3 implementation for working with iDevices (iPhone, etc...)
5
5
  Author-email: doronz88 <doron88@gmail.com>, matan <matan1008@gmail.com>
6
6
  Maintainer-email: doronz88 <doron88@gmail.com>, matan <matan1008@gmail.com>
@@ -8,7 +8,7 @@ misc/understanding_idevice_protocol_layers.md,sha256=8tEqRXWOUPoxOJLZVh7C7H9JGCh
8
8
  misc/usbmux_sniff.sh,sha256=iWtbucOEQ9_UEFXk9x-2VNt48Jg5zrPsnUbZ_LfZxwA,212
9
9
  pymobiledevice3/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  pymobiledevice3/__main__.py,sha256=hpLgWH1Pmwkf1pX-JvYkfJUkphpEb4YhoRV3qQUwbOs,12718
11
- pymobiledevice3/_version.py,sha256=oi6TX3BV_lJKewictnXlp6Z_C5gyJqyHQKAhpLK1dSk,704
11
+ pymobiledevice3/_version.py,sha256=mk9sCN9hGxv8dqR-nX3zSI5Ryd216nakWDxgdlQubxg,704
12
12
  pymobiledevice3/bonjour.py,sha256=y1Zd-__GnvK2ShxmvqFpNfi5NGF6PEWGcuKp8mJVFNA,13419
13
13
  pymobiledevice3/ca.py,sha256=5_Y4F-zDFX_KeDL-M_TRCKKyrRRb9h1lBE8MGTWv91o,10606
14
14
  pymobiledevice3/common.py,sha256=FZzF0BQYV5fCEUPbLo6jbt2Ig9s5YwR8AvX_iR124Ew,329
@@ -18,7 +18,7 @@ pymobiledevice3/irecv_devices.py,sha256=Mpp0AZYwFxqtqS9dTPdLZfxnj6UiDf8HbGGrHpsS
18
18
  pymobiledevice3/lockdown.py,sha256=xq4psDQir4CBIlMgRRkAZ6GxhjXPz-I6D5vdcfmjTw4,39570
19
19
  pymobiledevice3/lockdown_service_provider.py,sha256=mj5Hf3fNWdVYYUayKnLO3NWNgvD0xDMAiSIXKDcXCuk,1814
20
20
  pymobiledevice3/pair_records.py,sha256=4T32UPcBuN_4e-QFzGLoDoUBg3k7hgQh72Yo3CTi18M,6001
21
- pymobiledevice3/service_connection.py,sha256=TQGEG99MVSXk5Jxo4sUI8ivL6u-h4Ln9HHqJSbEtbp4,14976
21
+ pymobiledevice3/service_connection.py,sha256=lnTpnnXMtelOqqWmUtP1Rby9mmLMzyXqdhNNhflGW1g,15028
22
22
  pymobiledevice3/tcp_forwarder.py,sha256=imOTd76bh5bknOMJ4KAnWoe68eL3F3TpYlNM8eR7eXA,8971
23
23
  pymobiledevice3/usbmux.py,sha256=GmQTB3V5_6oYErBlZrFRi7XjPKVU1p0RUj147vT9-eg,16835
24
24
  pymobiledevice3/utils.py,sha256=Udx6xubsWYtJU9x7R-PrlSHseY438ua9_DPvzHd3XrQ,2210
@@ -47,7 +47,7 @@ pymobiledevice3/cli/provision.py,sha256=SofHAYdmxb54n9KSRyPKol6jOMUXN1hBACr2VBQr
47
47
  pymobiledevice3/cli/remote.py,sha256=xkIVR4bu1Vdpw-sswH1b-pekBM6rV6AS7YUeYQU5UyY,12375
48
48
  pymobiledevice3/cli/restore.py,sha256=xwiUIofoyCMxDSgRq4bndAn5GNUq1P-RcC446M_6I7Y,8085
49
49
  pymobiledevice3/cli/springboard.py,sha256=hVoLqLU_gHxXa6q17ar61lc2ovmWejeu-rvxQpHXWD0,3094
50
- pymobiledevice3/cli/syslog.py,sha256=-1qdNTMj_eRynv2-fbjOXOtxuftTznv_xkLERV-wjK8,8097
50
+ pymobiledevice3/cli/syslog.py,sha256=MV3fsg3lFKha2gYr6L_-7oiLXrk9QB_hH1nxNNbm3Gw,8112
51
51
  pymobiledevice3/cli/usbmux.py,sha256=Bx-5OSxEbHBhLeYaRt9LvZzp3RIazn49Q86pFi-EtpQ,2354
52
52
  pymobiledevice3/cli/version.py,sha256=N7UY328WNR6FpQ2w7aACyL74XQxkRmi53WV5SVlCgCo,345
53
53
  pymobiledevice3/cli/webinspector.py,sha256=dUsaaZZBV2OQPaYCj8C809ElO0O-G-NSSLvj7x26L94,16705
@@ -106,7 +106,7 @@ pymobiledevice3/services/companion.py,sha256=6rvL1KF2-Gflv77rL9txINMoiQplVouL_nn
106
106
  pymobiledevice3/services/crash_reports.py,sha256=ODsgT3WgpOHIFM-ht9za_-xI9AAh7dKiq50NsRB5q3I,10945
107
107
  pymobiledevice3/services/debugserver_applist.py,sha256=Pm65WDKua_zG8veFPp5uemuox6A49gydMlJD6UVvjhA,548
108
108
  pymobiledevice3/services/device_arbitration.py,sha256=xdVC8nhpQ0VdsCSzpaUGme7TfZw3rftJZrYnrjfYHj4,1134
109
- pymobiledevice3/services/device_link.py,sha256=fRHuMrEcoebEyem-rIZbK7_VA1V2UFfAM3fi8ts0d-c,8566
109
+ pymobiledevice3/services/device_link.py,sha256=TVrNB215eHvc7qMRv5CeyVKZgsEBf66aaEWXzp6VPEE,9542
110
110
  pymobiledevice3/services/diagnostics.py,sha256=Azx2g30hio3RQNRJ-5zs94qMUPeV4Qoix9T_Krdp8cU,29909
111
111
  pymobiledevice3/services/dtfetchsymbols.py,sha256=xyi5bXxPSrYaZSFx46zkbpDUk2qNEMAWAk0TZnQuquU,1505
112
112
  pymobiledevice3/services/file_relay.py,sha256=8VFaqqvKvb21OvUxvSgKaC5av5SyRzwybyxmBnGnpME,1368
@@ -167,9 +167,9 @@ pymobiledevice3/services/web_protocol/switch_to.py,sha256=TCdVrMfsvd18o-vZ0owVrE
167
167
  pymobiledevice3/tunneld/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
168
168
  pymobiledevice3/tunneld/api.py,sha256=Lwl1OdhPTgX6Zqezy8T4dEcXRfaEPwyGNClioTx3fUc,2338
169
169
  pymobiledevice3/tunneld/server.py,sha256=dMEZAv_X-76l0vSalpq4x0IVkbE-MNGR77T-u1TiHuE,25752
170
- pymobiledevice3-6.1.0.dist-info/licenses/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
171
- pymobiledevice3-6.1.0.dist-info/METADATA,sha256=Kc1aB01LI303p-FzJbxI_232-MeLu_CM-ZMla141-eU,17416
172
- pymobiledevice3-6.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
173
- pymobiledevice3-6.1.0.dist-info/entry_points.txt,sha256=jJMlOanHlVwUxcY__JwvKeWPrvBJr_wJyEq4oHIZNKE,66
174
- pymobiledevice3-6.1.0.dist-info/top_level.txt,sha256=MjZoRqcWPOh5banG-BbDOnKEfsS3kCxqV9cv-nzyg2Q,21
175
- pymobiledevice3-6.1.0.dist-info/RECORD,,
170
+ pymobiledevice3-6.1.2.dist-info/licenses/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
171
+ pymobiledevice3-6.1.2.dist-info/METADATA,sha256=wFmodFPWGqmZ2Esap6rHCj2bre9J17I8_ywdTVbt3Mw,17416
172
+ pymobiledevice3-6.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
173
+ pymobiledevice3-6.1.2.dist-info/entry_points.txt,sha256=jJMlOanHlVwUxcY__JwvKeWPrvBJr_wJyEq4oHIZNKE,66
174
+ pymobiledevice3-6.1.2.dist-info/top_level.txt,sha256=MjZoRqcWPOh5banG-BbDOnKEfsS3kCxqV9cv-nzyg2Q,21
175
+ pymobiledevice3-6.1.2.dist-info/RECORD,,