Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Methods to debug Ubuntu Nautilus scripts written in Python

When writing a Nautilus Script (e.g. using Python), I currently am aware of two methods for basic debugging:

  1. Using (e.g. Zenity) pop-up windows as "print" statements.
  2. Capturing stderr and stdout in text files for later reference.

These methods work reasonably well, but I suspect that there are more effective methods that I am not aware of. Can anyone suggest other methods?

Edit:

Context: I sought methods to debug a python script launched from the Ubuntu right click menu in Nautilus.

Using cedric's answer of relaunching nautilus with --no-desktop option means that stderr and stdout becomes visible at the terminal window. However, this terminal does not appear to be usable as a pdb console for debugging (it seems to be output-only).

In my search for a way to get input and output access to the script process when launched from the right click menu, I found the information listed in my answer below.

(Also, while I agree that unit testing and logging is best practice, I would argue that there is still a place for interactive debugging, particularly with small scripts.)

like image 228
whichone Avatar asked Dec 17 '10 20:12

whichone


1 Answers

What you asked for is just to see your script outputs, that can be done by relaunching nautilus with --no-desktop option:

$ nautilus -q
$ nautilus --no-desktop

This way you will see any outputs (stderr / stdout) made by your script or by the python interpreter. Should be usefull...

like image 110
cedric Avatar answered Sep 18 '22 13:09

cedric