mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
don't crash if editor file was not saved (treat it as read mode) close #12
This commit is contained in:
parent
3ca6ef89f4
commit
1b8ad23a19
1 changed files with 8 additions and 4 deletions
12
jrnl.py
12
jrnl.py
|
@ -404,12 +404,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])
|
||||||
with open(tmpfile) as f:
|
if os.path.exists(tmpfile):
|
||||||
raw = f.read()
|
with open(tmpfile) as f:
|
||||||
os.remove(tmpfile)
|
raw = f.read()
|
||||||
|
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:
|
||||||
|
|
Loading…
Add table
Reference in a new issue