Python get bash double-tab completion output -


i programming ros interface in python, , able select node want run list showing available nodes once choose package.

in other words create list of nodes contained in package getting output have in terminal if type:

rosrun <package-name> \t\t 

in terms of python code, wrong example of trying be:

from subprocess import popen, pipe  p = popen (["rosrun", "<package-name>", "\t\t"], stdout = pipe, stderr = pipe) out, err = p.communicate () print (out.decode ("ascii")) print (err.decode ("ascii")) 

but not work because "\t\t" not processed in popen in terminal.

is there way working or impossible emulate double-tab completion of terminal inside python script?

is popen used in different way or should totally change code using other facilities?

please me :)

finally solved myself, went right throw ros own code , found out how generates bash completion output.

my code this:

from subprocess import popen, pipe package = "<package>" comm = str("catkin_find --first-only --without-underlays --libexec " + package).split () out, err = popen (comm, stdout = pipe, stderr = pipe).communicate () out = out.decode ("ascii") if (out.strip () == ""):     return comm = "find -l " + out.strip () + " -type f -exec basename {} ';'" out, err = popen (comm, shell = true, stdout = pipe, stderr = pipe).communicate () out = out.decode ("ascii") print (out.strip ()) 

i simplified ros code, more complicated, version need now.

i hope can useful others.

thanks advices :)


Comments