mirror of
https://github.com/aaru-dps/Aaru.git
synced 2026-02-04 00:54:33 +00:00
Console-related exception if Aaru is launched as subprocess in Python #906
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @bitsgalore on GitHub (Sep 28, 2022).
Version
5.3.0
Commit hash
No response
Tested debug version?
Which operating systems have you used?
What is the architectural bit size you're using?
What processor are you using?
Description
Calling Aaru as a subprocess from a Python script using the standard Python subprocess module results in an Aaru exception if the script is not launched from a terminal. I'm using Python 3.8.10 on Linux Mint 20.1 (ulyssa).
I'll try to demonstrate the issue using the following minimal script, which uses Aaru to create a dump of a 3.5" floppy (the actual Python code I'm developing is a GUI application, but for the sake of simplicity I left the GUI struff out of the example):
The Python subprocess call opens pipes to capture Aaru's stdout and sderr output, and the capture output is written to 2 files.
Exact command line used
aaru media dump --encoding utf-8 --metadata -d /dev/sdd test-aaru.img
Expected behavior
The script runs without problems when run from the terminal like this:
However, if I run it by double-clicking on it (the script is executable), an exception is raised in Aaru (and the dump isn't completed).
Actual behavior
See debug output below.
The exception appears to be related to happen while Aaru tries to send output to the console. I'm getting the exact same exception in my (more complex) GUI application.
I also tried to disable stdout/stderr output altogether by using:
However this doesn't make any difference (apart from the fact that I cannot see the exception description in this case). I also experimented with changing the
shellvalue, but this isn't the culprit either. Since I've used similar subrprocess calls many times in the past without any issues, I suspect something in Aaru's console output routines might be the culprit.I can work around this issue in the development version of my GUI application by launching it from a terminal, but this isn't a good option for the packaged version (which has a clickable desktop launcher).
On a side note, this issue happens on a Windows 10 VM as well (using the Aaru Windows binaries), but since subprocess calls on Windows work slightly differently relative to Linux I won't go into details here, as that might make this bug report unnecessarily convoluted.
Output of command execution with debug output enabled
@claunia commented on GitHub (Sep 28, 2022):
Hi,
In 5.3.0 we were using System.Console that is, quite peculiar, with any kind of TTY that's not the Win32 basic one.
Please try in -devel where we use Spectre.Console and comment the results.
@robin-francois commented on GitHub (Sep 29, 2022):
Hi @bitsgalore,
If necesarry, we can provide you with a version to test the new behaviour in the 6.0-devel version.
I have been through your repository and I have seen that you have been integrating aaru in your existing workflow. We are very happy about that and would love to discuss and exchange with you if you have any questions. We have a Discord server but we can use any communication mean you prefer.
Regards
@bitsgalore commented on GitHub (Sep 29, 2022):
Hi @claunia and @robin-francois,
Thanks for the prompt response! I tried to build the development version (after first installing the .NET SDK and runtime following the instructions here), as well as pcregrep (which is not listed as a dependency, but is needed anyway).
However, running the build script fails with various reported errors and warnings. One recurring error is:
But if I check project.assets.json, I see:
and in project.assets.json:
So I don't really understand what I'm doing wrong (should perhaps add that I've never built a .NET application before).
I uploaded the full build log (stdout + stderr) here, in case that helps.
But if you would be able to provide me with binaries of the 6.0 devel version that might perhaps be easier.
(BTW I'll try to sett up a Discord account later today)
@robin-francois commented on GitHub (Sep 29, 2022):
Hello @bitsgalore,
You will find the two amd64 tarballs here (standard and debug): https://www.swisstransfer.com/d/393d3d82-8880-4389-bf5b-abcf81d0ca38
Please be aware that dumps with the
develversion should not be kept anddevelversions should only be used for debugging.Regards
@bitsgalore commented on GitHub (Sep 29, 2022):
Hi @robin-francois,
That's perfect, I just gave it a spin and now it all works perfectly, also inside my workflow. Thanks for that! Do you have any indication at what time (roughly) these changes will make it into a regular release?
As for Discord: I tried to set up an account, but after completing the lengthy verification process (which involved several CAPTCHA rounds, including a pretty bizarre one involving swimming rabbits), Discord then instantly disabled the account for violating their Terms Of Service. No idea why, but it looks like that's not going to work. Anyway, as I saw you also DMed me on Twitter, I'll drop you a message there with my email address. Thanks again for your help!
@claunia commented on GitHub (Sep 30, 2022):
Hi @bitsgalore,
There is not a timeframe for when 6.0 will be released (it has a huge roadmap and 5.3 is stable on all it does so no hurries for 6.0 until all that needs to be done is done).
However, if you can provide me with the smallest python snippet that exhibits the error I'll see how to fix it in the -stable (5.3) branch, as what makes it work in -devel is a huge framework change that added thousands of bugs in the process, so backporting is unfortunately, not an option.
@bitsgalore commented on GitHub (Oct 3, 2022):
@claunia If that's possible that would be perfect, thanks! I think the snippet in my original issue description is already pretty much the smallest one I can think of. Just save the code to a text file, make it executable (
chmod 755 test.py), modify aaruBin and inDevice to your local situation if necessary and then double-click in a file explorer window. Of course I can prepare a minimal GUI example, but it won't make any difference for the purpose of reproducing the error (and adding the GUI code will make it quite a bit more convoluted). But if you prefer a GUI example just let me know, and I'll prepare one.As an aside, I'm wondering if simply adding an option to suppress all stdout/stderr output (perhaps using a
--quietoption) could be a viable fix here? My software doesn't really need or use the stdout/stderr output anyway (aaru's exit code + the generated output files provide all the info it needs). Just thought I'd mention this, as I imagine this might perhaps be relatively simple to implement?@bitsgalore commented on GitHub (Nov 16, 2022):
Hi @claunia, a small update on this: for the time being I've now added a wrapper for ddrescue to my own workflow software (I had already developed that several years ago for another project), and made the wrapped imaging application user-defined, with Ddrescue and Aaru as current options.
I would suggest to leave this issue in the Aaru 5.3 branch as-is (i.e. don't fix it). Once 6.0 is out, my software will readily support it, and in the meantime me and my colleagues can just move ahead with ddrescue. This way we also prevent that this issue ends up eating up time for you that would perhaps be better spent on the 6.0 release.
Does that make sense? Feel free to close the issue if you like. Thanks again for your help!
@claunia commented on GitHub (Nov 25, 2022):
Sounds perfect, but the issue shall only be closed if you know it doesn't fail with 6.0.
@bitsgalore commented on GitHub (Nov 25, 2022):
OK, I will let you know once 6.0 is out! (BTW it worked fine for me with the 6.0 development version I tried, so I don't expect that will change in the eventual release.)
@claunia commented on GitHub (Apr 26, 2024):
Same as #843 works in
-devel. Closing.