Bookmarks plugin - crashes saving layout

37 views
Skip to first unread message

lewis

unread,
Jul 31, 2017, 10:04:07 AM7/31/17
to leo-editor
Running latest Leo 5.5, build 20170721094758, Fri Jul 21 09:47:58 CDT 2017
Git repo info: branch = master, commit = a1043408d36f
Python 3.6.2, PyQt version 5.9.1
Windows 10 AMD64 (build 10.0.15063) SP0
isPython3: True

Leo loads but my bookmarks aren't showing. Here is message in log pane:

read outline in 0.09 seconds
hook failed: after-create-leo-frame2, <bound method FreeLayoutController.loadLayouts of <leo.plugins.free_layout.FreeLayoutController object at 0x000001A572AAD4E0>>, <no module>
Traceback (most recent call last):

  File "N:\git\leo-editor\leo\core\leoPlugins.py", line 341, in callTagHandler
    result = handler(tag, keywords)

  File "N:\git\leo-editor\leo\plugins\free_layout.py", line 241, in loadLayouts
    layout = d.get(name)

AttributeError: 'NoneType' object has no attribute 'get'

If I then reload a bookmarks node and attempt to save the layout, python stops working, leo crashes. Here is the trace from console:

Traceback (most recent call last):
  File "N:\git\leo-editor\leo\plugins\nested_splitter.py", line 350, in cb
    splitter.context_cb(id_, index)
  File "N:\git\leo-editor\leo\plugins\nested_splitter.py", line 650, in context_cb
    provided = provider.ns_do_context(id_, self, index)
  File "N:\git\leo-editor\leo\plugins\free_layout.py", line 301, in ns_do_context
    d[name] = layout
TypeError: 'NoneType' object does not support item assignment

Regards
Lewis

Terry Brown

unread,
Jul 31, 2017, 10:43:06 AM7/31/17
to leo-e...@googlegroups.com, vita...@gmail.com
On Mon, 31 Jul 2017 07:04:07 -0700 (PDT)
lewis <lewi...@operamail.com> wrote:

> Running latest Leo 5.5, build 20170721094758, Fri Jul 21 09:47:58 CDT
> 2017 Git repo info: branch = master, commit = a1043408d36f
> Python 3.6.2, PyQt version 5.9.1
> Windows 10 AMD64 (build 10.0.15063) SP0
> isPython3: True

This must be caused by the switch to the SQLite back end. It looks
like bookmarks.py is getting None instead of the config object.
bookmarks.py is one of the non-cache uses of the c.db/g.db mechanism.

As an aside, Vitalije, I see you don't have the git commit hooks that
update the build number for Leo - a1043408d36f is more recent than
20170721094758.

Cheers -Terry

> Leo loads but my bookmarks aren't showing. Here is message in log
> pane:
>
> *read outline in 0.09 secondshook failed: after-create-leo-frame2,
> <bound method FreeLayoutController.loadLayouts of
> <leo.plugins.free_layout.FreeLayoutController object at
> 0x000001A572AAD4E0>>, <no module>Traceback (most recent call last):
> 0x000001A572AAD4E0>>File
> "N:\git\leo-editor\leo\core\leoPlugins.py", line 341, in
> callTagHandler result = handler(tag, keywords) File
> "N:\git\leo-editor\leo\plugins\free_layout.py", line 241, in
> loadLayouts layout = d.get(name)AttributeError: 'NoneType' object has
> no attribute 'get'*
>
> If I then reload a bookmarks node and attempt to save the layout,
> python stops working, leo crashes. Here is the trace from console:
>
> *Traceback (most recent call last): File
> "N:\git\leo-editor\leo\plugins\nested_splitter.py", line 350, in
> cb splitter.context_cb(id_, index) File
> "N:\git\leo-editor\leo\plugins\nested_splitter.py", line 650, in
> context_cb provided = provider.ns_do_context(id_, self, index)
> File "N:\git\leo-editor\leo\plugins\free_layout.py", line 301, in
> ns_do_context d[name] = layoutTypeError: 'NoneType' object does
> not support item assignment*
>
> Regards
> Lewis

Terry Brown

unread,
Jul 31, 2017, 10:49:37 AM7/31/17
to leo-e...@googlegroups.com
On Mon, 31 Jul 2017 09:43:03 -0500
Terry Brown <terry...@gmail.com> wrote:

> On Mon, 31 Jul 2017 07:04:07 -0700 (PDT)
> lewis <lewi...@operamail.com> wrote:
>
> > Running latest Leo 5.5, build 20170721094758, Fri Jul 21 09:47:58
> > CDT 2017 Git repo info: branch = master, commit = a1043408d36f
> > Python 3.6.2, PyQt version 5.9.1
> > Windows 10 AMD64 (build 10.0.15063) SP0
> > isPython3: True
>
> This must be caused by the switch to the SQLite back end. It looks
> like bookmarks.py is getting None instead of the config object.
> bookmarks.py is one of the non-cache uses of the c.db/g.db mechanism.

p.s. strange this didn't hit me, seeing I've tested with bookmarks and
the new backend, but not with Python 3 in Windows, so it might be
something of an edge case.

Cheers -Terry

vitalije

unread,
Jul 31, 2017, 12:28:27 PM7/31/17
to leo-editor
Fixed at dcc57b01f. Sorry for the inconvenience. It was my fault in implementing `__get_item__` of new cache object. It didn't raise KeyError for non existent keys, but rather was returning None. I couldn't spot bug because on my machine keys for layouts already existed. Just when starting witht empty global cache this bug was visible. 

Vitalije

vitalije

unread,
Jul 31, 2017, 12:42:37 PM7/31/17
to leo-editor

> As an aside, Vitalije, I see you don't have the git commit hooks that
> update the build number for Leo - a1043408d36f is more recent than
> 20170721094758.
>
> Cheers -Terry
>

I am not aware of this hooks. How can I install them?
Vitalije 

Terry Brown

unread,
Jul 31, 2017, 1:10:25 PM7/31/17
to leo-e...@googlegroups.com
I had tried the search function on
https://leo-editor.github.io/leo-editor/ to provide a link, but didn't
find anything.

Anyway, in your leo folder you copy

leo/extensions/hooks/commit-msg and leo/extensions/hooks/pre-commit
to
.git/hooks

On every commit, this updates leo/core/commit_timestamp.json and adds
something like

Leo build: 20170721094758

to the end of your commit log messages.

Most mailing list regulars use git hashes, but this date based build ID
is useful - while Edward insists only git users can use Leo ;-) I point
newcomers to the simple .zip file download
https://github.com/leo-editor/leo-editor/archive/master.zip
(from https://leo-editor.github.io/leo-editor/download.html) which
doesn't contain the commit hash.

Also having the correct build date/time is good when you want to know
if you're using what Vitalije did this morning, or Friday afternoon ;-)

Cheers -Terry

vitalije

unread,
Jul 31, 2017, 1:24:22 PM7/31/17
to leo-editor
Thanks. I have installed hooks now and made first commit/push. I hope it worked now.

It changed asctime to localized representation of time. I don't know if it matters.

Vitalije

Terry Brown

unread,
Jul 31, 2017, 2:19:44 PM7/31/17
to leo-e...@googlegroups.com
Ha, well, I think it looks cool, Leo correctly displays the Cyrillic
characters. But various attempts to copy paste give these results:

Leo 5.5, build 20170731192022, ???, 31. ??? 2017. 19:20:22 CEST

Leo 5.5, build 20170731192022, \u043f\u043e\u043d, 31.
\u0458\u0443\u043b 2017. 19:20:22 CEST

so I guess we should force it to use English. Maybe we should force it
to use GMT at the same time. That makes more sense than local time,
which could potentially mis-order commits when people are trying to
resolve issues.

Well duh, in the middle of a discussion about the bash git hooks I just
spent time searching the Leo code base for where the time is formatted
- of course it's formatted in the bash hooks. I think the way to make
it appear the same everywhere is to add

export LC_ALL=C.UTF-8
export TZ=Greenwich

to the start of the commit-msg hook

Could you test that pls. Vitalije? Thanks.

Cheers -Terry

vitalije

unread,
Jul 31, 2017, 2:25:11 PM7/31/17
to leo-editor
I figured it out. It was enough just to insert a line:

LC_ALL=en_US.utf-8

in commit-msg hook.

The next commit will have English date in asctime field.
Vitalije

vitalije

unread,
Jul 31, 2017, 2:28:47 PM7/31/17
to leo-e...@googlegroups.com
Is it necessary to have TZ set? If it needs to be UTC maybe it would be better to use  {date -u}.

Vitalije

PS: I didn't read everything you wrote. Now I see that you already answered my question. Ok. I have changed my hooks script accordingly. 
PPS: Setting TZ has no effect, however adding -u to date command gives time in UTC.

Terry Brown

unread,
Jul 31, 2017, 3:05:30 PM7/31/17
to leo-e...@googlegroups.com
On Mon, 31 Jul 2017 11:28:47 -0700 (PDT)
vitalije <vita...@gmail.com> wrote:

> Is it necessary to have TZ set? If it needs to be UTC maybe it would
> be better to use {date -u}.
>
> Vitalije

Yes, `date -u` is better, just wasn't aware of it. Thanks.

lewis

unread,
Jul 31, 2017, 5:41:48 PM7/31/17
to leo-editor
All fixed. Thank you Vitalije.

Regards
Lewis

lewis

unread,
Jul 31, 2017, 8:36:09 PM7/31/17
to leo-editor
Console gui doesn't run, here is console log:
launchleo.py --gui=console

[snip]

Found /help/
replace TypeDict: None is not a valid key traverse,visitNode,doData,set
can not create curses gui.
createDefaultGui: Leo requires Qt to be installed.

Leo 5.5, build 20170731192022, пон, 31. јул 2017.  19:20:22 CEST
Git repo info: branch = master, commit = 754cf6957439
Python 3.6.2, no gui!

Windows 10 AMD64 (build 10.0.15063) SP0
** isPython3: True
** caching enabled

Regards
Lewis

lewis

unread,
Aug 1, 2017, 8:05:42 AM8/1/17
to leo-editor
Console gui is working again with commit 8d3c368.
Apologies for being slightly off topic :/

Regards
Lewis
Reply all
Reply to author
Forward
0 new messages