GUI: Added a large set of possible output formats to the right-click menu.

To do: We still need better error handling.
- File exists: overwrite?
- Write failed popup.
- Check for empty file at the end (what if dot does not support this particular
  output format?)
This commit is contained in:
Cas Cremers
2008-08-27 10:04:22 +02:00
parent 63471c5053
commit e3268bb8e5
3 changed files with 61 additions and 14 deletions

View File

@@ -62,3 +62,22 @@ def mypath(file):
basedir = os.path.dirname(__file__)
return os.path.join(basedir,file)
# commands: push data in, get fp.write out
def cmdpushwrite(cmd,data,fname):
"""
Feed stdin data to cmd, write the output to a freshly created file
'fname'. The file is flushed and closed at the end.
"""
fp = open(fname,'w')
# execute command
cin,cout = os.popen2(cmd,'b')
cin.write(data)
cin.close()
for l in cout.read():
fp.write(l)
cout.close()
fp.flush()
fp.close()
#---------------------------------------------------------------------------
# vim: set ts=4 sw=4 et list lcs=tab\:>-: