Intercept common IO errors exceptions.
When the task directory doesn't exist or when a file can't be read or written,
t.py fails with a full stacktrace exception. This change allows t.py to fail
more gracefully, printing the exception message, the relevant file, and then
exiting with an errorlevel code of 1.
# Non existant directory issue
/home/dereckson/dev/t ] ./t.py -t /nonexistent Lorem ipsum dolor
No such file or directory - /nonexistent/tasks
# File permission issue
/home/dereckson/dev/t ] mkdir test
/home/dereckson/dev/t ] ./t.py -t test Lorem ipsum dolor
/home/dereckson/dev/t ] chmod 000 test/.tasks.done
/home/dereckson/dev/t ] ./t.py -t test Lorem ipsum dolor
Permission denied - test/.tasks.done
author |
Dereckson |
date |
Sat, 31 Aug 2013 10:31:43 +0200 |
parents |
2693d5c857a5 |
children |
831123b0359f |
Setup:
$ alias xt="python $TESTDIR/../t.py --task-dir `pwd` --list test"
Add tasks of varying width:
$ xt Short.
$ xt Longcat is long.
Test paddings:
$ xt
4 - Longcat is long.
5 - Short.
$ cat test
Longcat is long. | id:4c623ab4df5cc1a10d32558768c2c21bddf2c053
Short. | id:5a7a65db2caa6313a70ceb75b1bd806f7879f6b7
$ cat >> test << EOF
> Long one. | id: long1
> Very long two. | id: long2
> EOF
$ xt -f 5
$ xt
4 - Longcat is long.
long1 - Long one.
long2 - Very long two.
$ cat test
Longcat is long. | id:4c623ab4df5cc1a10d32558768c2c21bddf2c053
Long one. | id:long1
Very long two. | id:long2