doronz88 / pymobiledevice3

Pure python3 implementation for working with iDevices (iPhone, etc...).
https://discord.gg/52mZGC3JXJ
GNU General Public License v3.0
1.16k stars 162 forks source link

app afc pull raise ValueError: I/O operation on closed file. #759

Open ShawnPanxiaoming opened 6 months ago

ShawnPanxiaoming commented 6 months ago

1.enter pymobiledevice3 apps afc ${bundle_id} will enter the terminal env under the debug app path 2.enter "show-help" will display a serious of available commands like below: wc 👾 grep 👾 egrep 👾 sed 👾 awk 👾 yes 👾 cat 👾 file 👾 ls 👾 pwd 👾 link 👾 cd 👾 rm 👾 pull 👾 push 👾 walk 👾 head 👾 hexdump 👾 mkdir 👾 info 👾 mv 👾 stat 👾 show-help

3.enter "pull xxx.sqlite ~/Desltop/ " will raise a exec error: Traceback (most recent call last): File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/base_shell.py", line 391, in default raise exc_info[1] File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/codecache.py", line 63, in run_compiled_code func(code, glb, loc) File "", line 1, in File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/built_ins.py", line 205, in subproc_captured_hiddenobject return xonsh.procs.specs.run_subproc(cmds, captured="hiddenobject", envs=envs) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/procs/specs.py", line 901, in run_subproc return _run_specs(specs, cmds) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/procs/specs.py", line 936, in _run_specs command.end() File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/procs/pipelines.py", line 458, in end self._end(tee_output=tee_output) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/procs/pipelines.py", line 466, in end for in self.tee_stdout(): File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/procs/pipelines.py", line 372, in tee_stdout sys.stdout.buffer.write(line) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/base_shell.py", line 109, in write return self.membuf.write(b) ValueError: I/O operation on closed file.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/main.py", line 473, in main sys.exit(main_xonsh(args)) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/main.py", line 517, in main_xonsh shell.shell.cmdloop() File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/ptk_shell/shell.py", line 407, in cmdloop self.default(line, raw_line) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/base_shell.py", line 402, in default print_exception(exc_info=exc_info) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/tools.py", line 1048, in print_exception sys.stderr.write( File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/procs/proxies.py", line 182, in write r = h.write(s) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/base_shell.py", line 182, in write self.mem.write(s) ValueError: I/O operation on closed file.

doronz88 commented 6 months ago

Does pymobiledevice3 afc shell behaves the same? Does it occur on specific files? Are you doing it on your own app?

ShawnPanxiaoming commented 6 months ago

Does pymobiledevice3 afc shell behaves the same? Does it occur on specific files? Are you doing it on your own app?

yes, while in afc shell, pull operation also raised error, which occured in every file in the phone, eg, files in DCIM. See below tracestack: Traceback (most recent call last): File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/base_shell.py", line 391, in default raise exc_info[1] File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/codecache.py", line 63, in run_compiled_code func(code, glb, loc) File "", line 1, in File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/built_ins.py", line 205, in subproc_captured_hiddenobject return xonsh.procs.specs.run_subproc(cmds, captured="hiddenobject", envs=envs) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/procs/specs.py", line 901, in run_subproc return _run_specs(specs, cmds) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/procs/specs.py", line 936, in _run_specs command.end() File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/procs/pipelines.py", line 458, in end self._end(tee_output=tee_output) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/procs/pipelines.py", line 466, in end for in self.tee_stdout(): File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/procs/pipelines.py", line 372, in tee_stdout sys.stdout.buffer.write(line) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/base_shell.py", line 109, in write return self.membuf.write(b) ValueError: I/O operation on closed file.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/main.py", line 473, in main sys.exit(main_xonsh(args)) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/main.py", line 517, in main_xonsh shell.shell.cmdloop() File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/ptk_shell/shell.py", line 407, in cmdloop self.default(line, raw_line) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/base_shell.py", line 402, in default print_exception(exc_info=exc_info) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/tools.py", line 1048, in print_exception sys.stderr.write( File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/procs/proxies.py", line 182, in write r = h.write(s) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/xonsh/base_shell.py", line 182, in write self.mem.write(s) ValueError: I/O operation on closed file. Xonsh encountered an issue during launch Failback to /bin/zsh

My iOS version is 17.2.1

doronz88 commented 6 months ago

I wasn't able to reproduce the issue. Please try to update xonsh and make sure the error persists. Otherwise I'll update the requirements.

ShawnPanxiaoming commented 6 months ago

I wasn't able to reproduce the issue. Please try to update xonsh and make sure the error persists. Otherwise I'll update the requirements.

Hi, my xonsh version is 0.14,should be lastest. xonsh under my local terminal env works fine, every command works as expected. However, if I entered afc shell with xonsh, even "ls -l " will raise exception.

BTW, I also found that “ ~/Dev/Python_Work/venv/bin/pymobiledevice3 developer dvt netstat --rsd fdb6:b703:39f2::1 49443 ” command is not working. Traceback (most recent call last): File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/construct/lib/containers.py", line 98, in getattr return self[name] KeyError: 'hostname'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/panxiaoming/Dev/Python_Work/venv/bin/pymobiledevice3", line 8, in sys.exit(main()) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/pymobiledevice3/main.py", line 101, in main cli() File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/click/core.py", line 1157, in call return self.main(args, kwargs) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/click/core.py", line 783, in invoke return __callback(args, kwargs) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/pymobiledevice3/cli/cli_common.py", line 134, in wrap_callback_calling callback(service_provider=service_provider, kwargs) File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/pymobiledevice3/cli/developer.py", line 252, in netstat f'Connection detected: {event.local_address.data.hostname}:{event.local_address.port} -> ' File "/Users/panxiaoming/Dev/Python_Work/venv/lib/python3.8/site-packages/construct/lib/containers.py", line 100, in getattr raise AttributeError(name) AttributeError: hostname

doronz88 commented 2 months ago

Can you verify with latest version?

ViRb3 commented 2 months ago

Just tested using the latest version 3.4.3. Experiencing the same issue no matter whether I do push or pull, in both afc shell and per-app afc.

ViRb3 commented 2 months ago

Actually, the regular afc push/pull commands seem to work great, for both files an directories. So it's just a shell issue:

Sadly, for pymobiledevice3 apps afc there's no push or pull, only shell, so this is a bit of a blocker.

doronz88 commented 2 months ago

That should be easy enough to implement. Feel free to submit this as a PR