PDA

View Full Version : [SOLVED] python root access



bschleusner
March 14th, 2008, 02:57 AM
How can I get my python programs to request root (gksu?) access when it is run? I would like it to be like what synaptic does..

Any help would be greatly appreciated.

mssever
March 14th, 2008, 03:01 AM
Either you can modify the .desktop file to call gksudo yourprogram, or you can write a wrapper that calls your program with gksudo.

bschleusner
March 14th, 2008, 03:04 AM
could the wrapper for calling gksudo be in the same source file as the rest of my program?

mssever
March 14th, 2008, 03:08 AM
could the wrapper for calling gksudo be in the same source file as the rest of my program?

Probably. You could call your program recursively (especially if Python has an equivalent of Bash's exec; I don't know Python very well). But your code might be more readable if you use separate files. In fact, you might even write your wrapper in Bash, for example.

pmasiar
March 14th, 2008, 04:07 AM
writing "gksudo python yourprogram" kind of bash wrappers seems to be the easiest :-)

themusicwave
March 14th, 2008, 04:53 AM
I had a thread that did this recently...search for it...

My computer is testing a script and about to shut off so I can't go dig it up =)