don't crash if editor file was not saved (treat it as read mode) close #12

This commit is contained in:
Stephan Gabler 2012-04-26 09:58:46 +02:00
parent f2e207de85
commit 0a56658c43

View file

@ -396,12 +396,16 @@ if __name__ == "__main__":
if config['editor']: if config['editor']:
tmpfile = os.path.join(tempfile.gettempdir(), "jrnl") tmpfile = os.path.join(tempfile.gettempdir(), "jrnl")
subprocess.call(config['editor'].split() + [tmpfile]) subprocess.call(config['editor'].split() + [tmpfile])
if os.path.exists(tmpfile):
with open(tmpfile) as f: with open(tmpfile) as f:
raw = f.read() raw = f.read()
os.remove(tmpfile) os.remove(tmpfile)
else:
print('nothing saved to file')
raw = ''
else: else:
raw = raw_input("Compose Entry: ") raw = raw_input("Compose Entry: ")
if raw: if raw:
args.text = [raw] args.text = [raw]
else: else: