Tuesday, October 8, 2019

Fixed some bugs in getlino

Trying to reproduce Amber’s problem. Her is how I started:

$ cd ~/tmp
$ virtualenv -p python3 amber
$ . amber/bin/activate
$ getlino
getlino: command not found

That’s correct because I did not install getlino.

Note that when you uninstall getlino, the config files are not being deleted. So in order to reproduce Amber’s problem, I remove my own config files:

$ sudo mv /etc/getlino/getlino.conf /etc/getlino/getlino.conf.old
$ mv .getlino.conf .getlino.conf.old

Note that I had both config files, that’s perfectly possible if you run getlino configure once as root and once not.

Amber reported that he had only the system-wide /etc/getlino/getlino.conf. Which means that he has been running getlino configure as root. Which indicates that he was confused by the installation page (Installing getlino). He should have chosen either “developer environment” or “contributor environment”. And then he didn’t know that you must use env PATH=$PATH when running it as root. So he probably chose to configure a demo server and installed getlino system-wide. No wonder that he stumbled into problems! I reviewed the Installing getlino page quite thoroughly. Now there is some hope that future volunteer contributors won’t get lost in the jungle again.

Oh, and I saw only now that he was using getlino 19.9.7, a quite old version. That might explain many of his problems! See Changes in getlino for details.

And when I tested the installation instructions I stumbled into the next problems:

  • Running getlino configure without --db-port caused an error Invalid value for "--db-port": invalid choice: . (choose from 5432, 3306, 0). The --db-port option is not a choice : it is not limited to these values.

  • The --clone option sometimes had True as default value. That’s not good, this option shouldn’t have magic behaviour.

  • getlino startsite said PermissionError: [Errno 1] Operation not permitted: '/home/luc/.cookiecutters/cookiecutter-startsite/COPYING'. But that was just a local problem on my machine because I had been running it also as root.

  • Found a bug: getlino forgot to run “pip install lino lino-xl” when a shared-env was being used. That was probably the main issue for Amber. Fixed.

  • I am still experimenting with what cookiecutter-startsite should write into settings.py if no db-port is given.

  • Released Lino Noi to PyPI because this was still an old version (and updated 2019).

I tested the developer environment manually, and it seems to work at least for noi. TODO: several other applications probably need a PyPI release.

Actually Amber should install a developer environment. So I tried that, too. And found another bug:

ERROR: cd is not a valid editable requirement. It should either be a path to a local project or a VCS URL (beginning with svn+, git+, hg+, or bzr+).

Fixed the bug and released 19.10.2 to fix it.

Now finally the installation should work for Amber! At least they passed my manual tests.

All this is great and fun, but why did I have to do it? Why didn’t Hamza have these ideas? OMG there is some much more to do! Actually we should now extend the getlino test suites. Actually we should review the Developer and the Contributor Guides! Should I ask Amber to stop trying because we simply lack manpower?!

PS: I know that Hamza is a skilled guy and I don’t doubt his competence. My explanation why he didn’t have these ideas is that he is somebody who rather finds solutions, not problems. He was focused on helping Amber to formulate his problem more precisely so that we can reproduce it. He just didn’t realize that Amber’s problem was actually already reproducible. And of course we lack manpower, but that’s not a reason to worry because Amber knows that and is big enough to live with it. The last paragraph was also an example of the fears and worries I have when I realize how difficult it is to become useless! (Did you know that becoming useless before you die is the most important task of your life? ;-)

Recurring event every 3rd Wednesday or every last Friday of month

I opened #3255. No customer has asked this so far but I have the feeling that this is a missing feature in our calendar plugin.

Inspired by dateutil we should add a field lino_xl.lib.cal.RecurrenceSet.bysetpos : “If given, it must be either an integer, or a sequence of integers, positive or negative. Each given integer will specify an occurrence number, corresponding to the nth occurrence of the rule inside the frequency period. For example, a bysetpos of -1 if combined with a MONTHLY frequency, and a byweekday of (MO, TU, WE, TH, FR), will result in the last work day of every month.” It should be a CharField and the integers would be stored as space-separated strings. Our standup meetings would have bysetpos = “1 3 5” and every_unit=weekly (and every=1 because they are every week, not e.g. every second week).

>>> from dateutil.rrule import rrule, MONTHLY, FR
>>> from datetime import datetime
>>> start_date = datetime(2019, 10, 25)
>>> list(rrule(freq=MONTHLY, count=5, dtstart=start_date, bysetpos=-1, byweekday=FR))
... 
[datetime.datetime(2019, 10, 25, 0, 0),
datetime.datetime(2019, 11, 29, 0, 0),
datetime.datetime(2019, 12, 27, 0, 0),
datetime.datetime(2020, 1, 31, 0, 0),
datetime.datetime(2020, 2, 28, 0, 0)]