Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 0.36 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Get current working directory from Vte (GTK Terminal Widget) in Python
  2. import vte
  3. import os
  4. v = vte.Terminal()
  5. vPid = v.fork_command()
  6. workingDir = os.readlink('/proc/%s/cwd' % vPid)
  7.        
  8. import vte
  9. import os
  10. v = vte.Terminal()
  11. vPid = v.fork_command()
  12. # make a system call to pwdx to get working director
  13. sIn, sOut = os.popen2("pwdx " + vPid)
  14. workingDir = sOut.read()