Reputation: 705
I'd like to open an editor (cli or gui-based) via Python script. I can do this with os.system('vim file')
, but I'd also like to get output in case command fails. subprocess.getstatusoutput('vim file')
doesn't work for opening programs with specific interface.
What's the best alternative?
Upvotes: 0
Views: 843
Reputation: 363707
subprocess.check_call([EDITOR, file_path])
will raise an OSError
exception if EDITOR
fails to run.
Upvotes: 2