Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aaru fails with exit code 1 if Ipmlab is run from PyPi package #23

Open
bitsgalore opened this issue Sep 14, 2022 · 8 comments
Open

Aaru fails with exit code 1 if Ipmlab is run from PyPi package #23

bitsgalore opened this issue Sep 14, 2022 · 8 comments
Labels

Comments

@bitsgalore
Copy link
Member

This happens under Linux Mint 19.3. No useful info from Aaru log/error log.

However, everything works fine when running Ipmlab from local script (launcher in Git repo). I suspect this has something to do with Aaru trying to write to stdout/stderr (which is shown in terminal for local script), and fact that stdout and stderr are not captured. But capturing stdout/stderr leads to the problems described here:

#16

@bitsgalore
Copy link
Member Author

bitsgalore commented Sep 14, 2022

Update - if the packaged version of Ipmlab is launched from the terminal Aaru works as expected. So issue is definitely caused by Aaru's stdout/stderr handliing.

Does this help:

https://stackoverflow.com/questions/2804543/read-subprocess-stdout-line-by-line

@bitsgalore
Copy link
Member Author

bitsgalore commented Sep 14, 2022

Update, changed call to Aaru to this (this sends all stout/stderr to a file):

        with open('/home/johan/test/ipmlab.stdout', "w") as outfile:
            sub.run(args, stderr=sub.STDOUT, stdout=outfile)

Result (from /ipmlab.stdout):

aaru 5.3.1
Copyright © 2011-2022 Natalia Portillo

Output image format: Raw Disk Image.
Unhandled exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.ArgumentOutOfRangeException: Count cannot be less than zero. (Parameter 'count')
   at System.String.Ctor(Char c, Int32 count)
   at Aaru.Progress.ClearCurrentConsoleLine()
   at Aaru.Progress.UpdateStatus(String text)
   at Aaru.Core.Devices.Dumping.Dump.Start() in /home/claunia/Development/Aaru/Aaru/Aaru.Core/Devices/Dumping/Dump.cs:line 214
   at Aaru.Commands.Media.DumpMediaCommand.Invoke(Boolean debug, Boolean verbose, String cicmXml, String devicePath, Boolean resume, String encoding, Boolean firstPregap, Boolean fixOffset, Boolean force, Boolean metadata, Boolean trim, String outputPath, String options, Boolean persistent, UInt16 retryPasses, UInt32 skip, Byte speed, Boolean stopOnError, String format, String subchannel, Boolean private, Boolean fixSubchannelPosition, Boolean retrySubchannel, Boolean fixSubchannel, Boolean fixSubchannelCrc, Boolean generateSubchannels, Boolean skipCdiReadyHole, Boolean eject, UInt32 maxBlocks, Boolean useBufferedReads, Boolean storeEncrypted, Boolean titleKeys)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseErrorReporting>b__19_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass14_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass21_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__20_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseDirective>b__18_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseDebugDirective>b__10_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__9_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<<UseExceptionHandler>b__0>d.MoveNext()

@bitsgalore
Copy link
Member Author

Possibly (un?)related :

robotframework/robotframework#4173

@bitsgalore
Copy link
Member Author

Todo: make minimal demo script that demonstrates the issue.

@bitsgalore
Copy link
Member Author

Update, in Windows, Ipmlab launches Aaru in a separate console Window (which closes automatically upon completion:

VirtualBox_Windows 10_15_09_2022_18_44_43

A bit ugly, but at least it works.

@bitsgalore
Copy link
Member Author

bitsgalore commented Sep 15, 2022

Another twist to this - in Windows, setting "shell=True" gets rid of the terminal, and Aaru completes normally (in Linux this won't even run!):

 # Run Aaru as subprocess
 p = sub.run(args, shell=True)

In another interesting twist, if I change the above code and use the more low-level Popen method:

p = sub.Popen(args, shell=True)

In this case Ipmlab doesn't wait for aaru to complete. Remedied by adding:

output, errors = p.communicate()

Provisional solution: added OS-specific shell flag that makes sure everything at least works under Windows: 92f5a4e.

In Linux, Aaru execution only works if ipmlab is launched from a terminal (launching from menu shortcut will result in failure).

@bitsgalore
Copy link
Member Author

bitsgalore commented Sep 28, 2022

Opened Aaru issue for this:

aaru-dps/Aaru#749

All works without problems on Linux Mint with the binaries of the Aaru 6.0 development version!

@bitsgalore bitsgalore added enhancement New feature or request aaru and removed enhancement New feature or request labels Feb 27, 2023
@bitsgalore
Copy link
Member Author

Fixed now in Aaru:

aaru-dps/Aaru#749

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant