0

I'm trying to debug a python script in which passing arguments is required. Since I want to debug, using -b flag is not an option (otherwise there is no problem when running the code in a background mode).

I tried the following thing

filename = "/full/path/to/script.py --Arg1 arg1 ...."
exec(compile(open(filename).read(), filename, 'exec'))

Obviously that didn't work since exec tries to execute a file without additional arguments.

Few notes:

1) If I try to debug w/o passing arguments everything works fine I can debug and do what I want.

2) Some system pros: running docker container with 4 NVIDIA 1080-Ti cards on ubuntu os.

How can this be done?

AvivSham
  • 185
  • 2
  • 13
  • @RobertGützkow | These examples demonstrate passing arguments in a background mode Blender. I want to debug my code, hence I need to run it from Blender's GUI. Any suggestions? – AvivSham May 04 '20 at 10:58
  • 1
    Simply don't use the -b or --background argument? This will start Blender with GUI as usual. – Robert Gützkow May 04 '20 at 11:01
  • @RobertGützkow | Tried that, doesn't work because I need to setup the connection to Pycharm debugger before I run the code. – AvivSham May 04 '20 at 11:05
  • 1
    Then it would be very helpful if you could give a precise description of what you're doing and what your goal is. I don't see why the PyCharm debugger wouldn't work when starting Blender from the command line, as long as the debugger is connected. Is this issue related to your old question? – Robert Gützkow May 04 '20 at 11:46
  • @RobertGützkow | No the old question solved. I have a code that I want to debug, this code includes passing arguments in order to run. What are the steps I should perform in order to be able to pass these arguments and debug the code? Is that more clear to you? – AvivSham May 04 '20 at 12:01
  • 1
    With the limited information available, I'd say create two python scripts which are then called from the CLI. The first script connects the debugger by calling the operator that implements this feature (e.g. bpy.ops.debug.connect_debugger_pycharm if you're using the add-on from the old answer). The second script is the one you would like to test and pass arguments to. It has to be the last CLI argument, followed by the arguments you would like to pass into the script. – Robert Gützkow May 04 '20 at 12:12
  • @RobertGützkow Thank you for helping indeed this was the right way to do it. I wasn't aware of the fact that it is possible to activate the linkage between blender and pycharm through script. – AvivSham May 05 '20 at 14:05

0 Answers0