20140702 (Wednesday, 02 July 2014)¶
After some hours of sleep I looked back at what I learned and did yesterday.
First of all, I optimized the pavement.py
file once more: the
self-signed version is in example and the signed version in
example/signed. No longer in two siblings called example/mykey and
example/codegears. After years of fiddling with the Makefile,
this was a mere joy since we are now in Python.
fabric versus paver¶
Then I asked: why did I not use fabric instead of paver?
Answer: because I wanted to try something new. Because I did not feel fully satisfied with fabric…
But let’s verify that feeling. I simply copied the content of pavement.py into the fabfile.py, made some minor changes, and the result is amazing: it gets yet more elegant because unipath has a needs_update and a copy method. Yes, I liked paver’s path trick to override __divide__ operator, but the child method in unipath is more explicit and secure.
My resolution: fabric is clearly better than paver. fabric can easily do what paver did, has better documentation and is more mature.
$ git rm pavement.py
$ pip uninstall paver
BTW my feeling came mainly from the fact that I don’t really like the output of fab -l…
A pitfall in unipath¶
I fell into a pitfall with unipath. The first one after more than a year, and -after thinking at it- an unevitable one. Here is an excerpt from some of my code:
jarfile = outdir.child(n)
libfile = LIBDIR.child(n)
if libfile.needs_update([jarfile]):
libfile.copy(jarfile)
In a first attempt I had written:
if libfile.needs_update(jarfile):
which gave me a strange traceback:
Traceback (most recent call last):
...
File "/home/luc/hgwork/eid/fabfile.py", line 40, in sign_jars
if libfile.needs_update(jarfile):
File "/home/luc/pythonenvs/py27/local/lib/python2.7/site-packages/unipath/path.py", line 298, in needs_update
if p.isdir():
AttributeError: 'str' object has no attribute 'isdir'
Yes, the documentation clearly says that the argument to needs_update must be an iterable, and that Path objects behave like strings… and to avoid that pitfall, unipath would have to test on each whether it is a directory or not… so my suggestion is to just update the documentation to warn about this pitfall.
Automatic refresh every 10 seconds¶
Added a button “autorefresh” which causes the home screen to start refreshing every 10 seconds. Opening any window stops the autorefresh.
This is a quick workaround, not yet very user-friedly:
no feedback indicating that it is activated.
no protection against repeated clicks. every click starts a queue of autorefreshes.
TypeError: expected string or buffer¶
Lino made an Internal Server Error when reading a Belgian eID card which had the following address data:
streetAndNumber: null
zip: null
municipality: null
This caused me some work:
Added a new test case for which reproduces the problem.
Discovered that these test cases were not being tested anymore. Now they are, but I am not yet fully satisfied with how this is being done. They are in lino_welfare/projects/docs/tests (not in /tests, because they are written for the Django test runner. But the general test suite now invokes a
django-admin test
in this directory).These test cases need to specify no_local=True because they need e.g. use_java.
Added the case of an incomplete birth date to the docstring of
lino.utils.ssin
.The bug itself (in
ml.beid.BaseBeIdReadCardAction
) was of course easy to fix.