ividyon / WitchyBND

Unpacks/repacks FromSoftware archive formats and serializes FromSoftware data formats.
Other
100 stars 10 forks source link

Bulk Unpacking using Python #30

Closed samjviana closed 1 week ago

samjviana commented 1 month ago

I realize this might be a "python-related" issue rather than directly within the scope of WitchyBND. However, since the exception occurs because WitchyBND attempts to set the visibility of the cursor (which fails when there isn't a "cursor-valid" terminal), I wanted to bring this issue up in case there's a way to handle this scenario within WitchyBND (if applicable) even though I can work around it.

Environment Information:

Code I'm running:

command = ['C:/WitchyBND/WitchyBND.exe', '--location', './unpacked_files', 'C:/Program Files (x86)/Steam/steamapps/common/ELDEN RING/Game/regulation.bin']

result = subprocess.run(command, capture_output=True, text=True)
print('stdout:', result.stdout)
print('stderr:', result.stderr)

Expected Behavior:

I expected WitchyBND to unpack the regulation.bin file successfully, just as it does when called directly from the command prompt or PowerShell.

Actual Behavior:

I encountered the following error:

Unhandled exception. System.TypeInitializationException: The type initializer for 'WitchyBND.Program' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'PPlus.PromptPlus' threw an exception.
 ---> System.IO.IOException: Identificador inválido.
   at System.ConsolePal.set_CursorVisible(Boolean)
   at PPlus.PromptPlus..cctor()
   --- End of inner exception stack trace ---
   at WitchyBND.Services.OutputService..ctor() in ./WitchyBND/Services/OutputService.cs:line 46
   at WitchyBND.Services.ServiceProvider.CreateProvider() in ./WitchyBND/Services/ServiceProvider.cs:line 17
   at WitchyBND.Program..cctor() in ./WitchyBND/Program.cs:line 34
   --- End of inner exception stack trace ---
   at WitchyBND.Program.Main(String[] args)

(Translation: "Identificador inválido" means "Invalid Handle" - my environment is set up in my native locale)

Steps to Reproduce:

  1. Use the provided Python code to call WitchyBND.
  2. Ensure Witchy path and regulation.bin are correct.
  3. Run the Python script.
ividyon commented 1 month ago

The library I use, PromptPlus, sometimes seems to have some trouble with console things like this. It doesn't even work in Wine on Macs, as I'm told. Quite annoying, but I also kind of depend on it to be fixed on the PromptPlus end.

samjviana commented 1 month ago

I see, afaik PromptPlus kinda like "attaches" to the console/terminal handle and works from there ... by passing a stream to WitchyBND.exe in python there will be no actual handle.

I cloned the repo to take a look at the inner code, but ... how hard would it be to "bypass" the OutputService provider if the flag --silent is passed? since there will be no outputs, i think this could solve this kind of problem.

ividyon commented 1 month ago

Might make sense to do a different OutputService for the "silent" mode, yeah.

ividyon commented 1 month ago

@samjviana Try grabbing this artifact build, see if it works as expected.

samjviana commented 1 month ago

Sorry for the late reply. Everything is working just fine. As expected, there aren't any outputs. However, if any errors occur, they seem to be successfully streamed to stderr, which is nice.

lugia19 commented 1 month ago

I've also run into this, albeit the update did indeed make it so it works fine in silent mode. It would be cool if we could get passive, non-silent mode working properly as well, however, to be able to get the output.