summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/GUI/xasyCodeEditor.py
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/utils/asymptote/GUI/xasyCodeEditor.py')
-rwxr-xr-xBuild/source/utils/asymptote/GUI/xasyCodeEditor.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/Build/source/utils/asymptote/GUI/xasyCodeEditor.py b/Build/source/utils/asymptote/GUI/xasyCodeEditor.py
index 1f7ad60328f..d09196a41be 100755
--- a/Build/source/utils/asymptote/GUI/xasyCodeEditor.py
+++ b/Build/source/utils/asymptote/GUI/xasyCodeEditor.py
@@ -21,21 +21,26 @@ import xasyOptions
def getText(text=""):
"""Launch the external editor"""
temp = mkstemp()
- tempf = fdopen(temp[0],"r+w")
+ tempf = fdopen(temp[0],"w")
tempf.write(text)
- tempf.flush()
+ tempf.close()
try:
- cmdpath,cmd = path.split(xasyOptions.options['externalEditor'])
+ cmdpath,cmd = path.split(path.expandvars(xasyOptions.options['externalEditor']))
split_cmd = split(cmd)
cmdpart = [path.join(cmdpath,split_cmd[0])]
argpart = split_cmd[1:]+[temp[1]]
arglist = cmdpart+argpart
call(arglist)
- except:
+ except Exception as e:
raise Exception('Error launching external editor.')
- tempf.seek(0)
- text = tempf.read()
- remove(temp[1])
+
+ try:
+ tempf = open(temp[1],"r")
+ text = tempf.read()
+ tempf.close()
+ remove(temp[1])
+ except Exception as e:
+ raise Exception('Error reading from external editor.')
return text
if __name__ == '__main__':