Problems running leoInteg

239 views
Skip to first unread message

Edward K. Ream

unread,
Jun 8, 2021, 11:31:28 AM6/8/21
to leo-editor
One of  the advantages of forgetting things is that it is easy to relate to newbies :-)

I'll soon be asking all Leonistas to experiment with the leoInteg plugin for vs-code. But first, I have to get it working myself.

Félix created an excellent installation video.  Loosely following the video, I pulled the latest version of leointeg, switched to the master branch and did `npm install`. All went well, apparently.

From the leointeg directory I did `code .`  to launch vs-code.

At one time I was able to start leoInteg.  Now, however, I get the following error when hitting F5:

Error - Cannot start server: stderr: Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

I'm not sure what to do now. `python` does work from the vs-code terminal window:

C:\leo.repo\leointeg>C:\Users\edreamleo\Python\Python39\python.exe
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927
64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.>>>


So I'm stuck.  Félix, what should I do now?

I'm actually glad I'm having this trouble. We'll want to make all the mistakes that newbies could possibly make before releasing leoInteg 1.0 :-)

Edward

tbp1...@gmail.com

unread,
Jun 8, 2021, 12:19:52 PM6/8/21
to leo-editor
That setting is from Windows, not vscode.  I get that same error if I try to run "python3", even though I have 3.9 installed.  I think that leointeg must be asking for python using some name that triggers the response from windows.  I went to that Windows setting location, and I could turn off the offer to get Python3.9 from the Microsoft store, but then there would probably be nothing th launch by that name.  

Felix probably needs to make the name used for Python configurable, or else python3.9 isn't on the system path.

Edward K. Ream

unread,
Jun 8, 2021, 12:42:38 PM6/8/21
to leo-editor
On Tue, Jun 8, 2021 at 11:19 AM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
That setting is from Windows, not vscode.  I get that same error if I try to run "python3", even though I have 3.9 installed. 

I tried creating a python3.bat file, but that didn't work. I already had a python.bat file.
 
I think that leointeg must be asking for python using some name that triggers the response from windows.  I went to that Windows setting location, and I could turn off the offer to get Python3.9 from the Microsoft store, but then there would probably be nothing th launch by that name.

The message said it was trying to execute `python`, so python.bat should work.

Edward

tbp1...@gmail.com

unread,
Jun 8, 2021, 3:23:26 PM6/8/21
to leo-editor
I found out how to get VScode to run a particular file for the Python command:

" Under the view menu select 'show command pallet'. One of the commands you can then select from the command palette is 'Python: Select Interpreter'. Selecting this option will allow you to choose which version of python to use."

To actually find this command I used the search line, otherwise scrolling through all the commands would have been a chore.  I needed to do this so I could set PYTHONPATH to point to my Leo git repo. I wrote a little cmd file to do it.

tbp1...@gmail.com

unread,
Jun 8, 2021, 3:43:54 PM6/8/21
to leo-editor
That sets the python version for vscode, but it didn't seem to set it for leointeg.  There is some setting for leo-integ where you can set it.  I've found it twice, but I still don't actually know how to get to the setting.  But it's there.

I still haven't gotten leointeg to run, though.

Once I start the Leo Bridge from a console, how do I know it's still running and how do I stop it?

tbp1...@gmail.com

unread,
Jun 8, 2021, 4:24:34 PM6/8/21
to leo-editor
I still can't get it working.  It's using my cmd file to set the right PYTHONPATH before running Python.  I don't get any error messages when things get launched.  But connection attempts fail.  The only message is 

Leo Bridge Connection Failed: Websocket closed, code: 1006

Félix

unread,
Jun 8, 2021, 5:50:40 PM6/8/21
to leo-editor
Hi all :)

First - make sure you ran 'npm install' in leointeg's project folder to fetch any new dependencies that may have been updated since last time.

Second - (most important) specify how you want to start the server, otherwise it's hard to help and give instructions : There are 3 ways to start the leobridgeserver while in developement - (by vscode itself to debug it while it runs, by leointeg itself using the command string in its options settings, or starting it yourself in a terminal) after the release, there will be only 2 ways (unless running in debug) 

So to specify this,  goto the debug view of vscode, (the triangle with the bug)  right at the top you have to choose what you want to debug (and what will be started by vscode itself)  the extension, the server, or both

If you want vscode to start the server , (like in Edwards original post in this thread I presumed from his description) then it's vscode's own python development settings that will decide how it starts it. (users using v1.0 will not be using this method) So leointeg has nothing to do with it.

If you choose to have leointeg start the server itself, choose "run extension" only,  in the top debug dropdown. (equivalent with the real finished product,) then  start with F5, then, in the extension host that just popped and runs leointeg, open the leointeg settings panel and select 'start server automatically', (and later come back here to also set the python launch string if you need something other than 'python' on linux and 'python3' on windows. (you may need to close the extention host and hit F5 again to restart after setting the options if you want to actually see leointeg start it by itself. ) 

On the other hand, after starting leointeg with F5, there are buttons in leo's main outline panel to start the server  and / or connect to it. (regardless if started automatically or not) 

Another (third)  way to start the server, is to simply start the leobridgeserver.py script in a terminal program of your choice.

To access leointeg's  settings (while running leointeg in the extention host) use ctrl+shift+P to open the command palette  and start typing leo settings (or leo welcome) to access the leointeg options. (to set your python command line option for when you want leointeg to start the server itself) 

I know it wont help you, hehe,  but on both my windows and linux machines, everything works without any special settings / string with my vanilla installations of python. (I'm not a python expert who has many pythons/anaconda/etc...) 

Note: the leointeg welcome/settings webview are not visible in your regular window of vscode, because it's generated by leointeg - so its only available and visible in the extension host window that opens once you press F5. 
--
Félix 

Félix

unread,
Jun 8, 2021, 5:58:32 PM6/8/21
to leo-editor
tbp1, you might have problems finding the leointeg welcome/settings view because your looking for it in your base vscode window -> it's in the extension host that runs leointeg (its part of leointeg) once you start it with F5. 

no need to have a server running or be connected to the server to have leointeg 'running')  in fact, you can start the server after startgin leointeg  and connect to it with controls in the outline pane that replace the outline (gets replaced with the outline once connected ) 

--
Félix

tbp1...@gmail.com

unread,
Jun 8, 2021, 8:56:51 PM6/8/21
to leo-editor
I got it running by starting the server in a separate console, as you suggested.  Everything else I had already gotten installed and apparently working.  I have to say, it looks really good.  The few things I have tried have worked pretty much as expected, including inserting a node with CNTL-I.  Even my script that navigates to a node by getting its gnx from a special text line worked, once I attached it to a button.

One thing that does not work is deleting a node with <DEL>.  I can delete it from the context menu.

I cannot run an @file program by pressing the F5 or CNTL-F5 keys. Vscode says I don't have an extension for debugging "Leo Body Python".  I'd be happy to run without debugging (supposedly CNTL-F5) but I get the same message.  I was able to run several @file Qt programs I have in one outline by using my own launching command and attaching it to a button.

I'd like to congratulate Felix for doing such a remarkable job, figuring all this out and getting it to work and look good!

tbp1...@gmail.com

unread,
Jun 8, 2021, 9:18:13 PM6/8/21
to leo-editor
On Tuesday, June 8, 2021 at 5:50:40 PM UTC-4 Félix wrote:
Hi all :)

First - make sure you ran 'npm install' in leointeg's project folder to fetch any new dependencies that may have been updated since last time.
 
I finally realized to do this, but it took some time.  It brought in a lot of things.

Second - (most important) specify how you want to start the server, otherwise it's hard to help and give instructions : There are 3 ways to start the leobridgeserver while in developement - (by vscode itself to debug it while it runs, by leointeg itself using the command string in its options settings, or starting it yourself in a terminal) after the release, there will be only 2 ways (unless running in debug)

It's very hard to understand what the difference is.  I tried the three ways offered in the "run" dropdown, but they always failed.  
 
So to specify this,  goto the debug view of vscode, (the triangle with the bug)  right at the top you have to choose what you want to debug (and what will be started by vscode itself)  the extension, the server, or both

If you want vscode to start the server , (like in Edwards original post in this thread I presumed from his description) then it's vscode's own python development settings that will decide how it starts it. (users using v1.0 will not be using this method) So leointeg has nothing to do with it.

If you choose to have leointeg start the server itself, choose "run extension" only,  in the top debug dropdown. (equivalent with the real finished product,) then  start with F5, then, in the extension host that just popped and runs leointeg, open the leointeg settings panel and select 'start server automatically', (and later come back here to also set the python launch string if you need something other than 'python' on linux and 'python3' on windows. (you may need to close the extension host and hit F5 again to restart after setting the options if you want to actually see leointeg start it by itself. ) 

F5 did work to start the extension, as you said.  The F5 that wouldn't work for me (mentioned in my last post) is in the extension window, where I wanted to run an @file program.  However, I seem to like using the arrowhead-like icon in the lefthand icon panel.  It's the fourth one down.  That gives you the view where you can select to run the "extension only" up at the left top.
 
Another (third)  way to start the server, is to simply start the leobridgeserver.py script in a terminal program of your choice.

This is what worked for me.  I started leobridgeserver outside of vscode.  Then I used the little "run" button next to the dropdown where I had selected "run extension". Running the server from within vscode just hasn't worked for me.  vsc runs my python batch file but the server apparently does not start.

Oh, yes, this is on Windows 10.

Félix

unread,
Jun 8, 2021, 11:20:07 PM6/8/21
to leo-editor

Thanks tbp1!! Much appreciated!!!

I'm french so I may have difficulty expressing myself properly, so bear with me ;) 

I gather that I might not have explained properly what I mean by 3 ways to start the server. ( i do not mean the 3 options in the debug dropdown! Those '3' choices are just a confusing coincidence!)

What I mean by that is that those 3 ways have completely different 'settings' applied (such as what environment, what working dir path, what string to start python with 'py', 'python' , 'python3', etc.) and may not necessarily be setup in advance for your python and /or vscode installations on your machine: 

1- (for experienced python programmers who want to debug the leoserver live in vscode) Starting the server by/with vscode (choose "server and extension" in the debug top dropdown.) means that python is setup and started by vscode. As-if the leobridgeserver itself was the python project that vscode tries to run and debug , So it will use the vscode settings for running and debugging python that you have set in your vscode settings. (not leointeg's settings) leointeg has no control, so this is for people who have already setup their vscode to run/debug with python.

2- another way, is in another external terminal like you did . (settings are all controlled by what you type to start python and the script - if it worked, take note of it and copy it in leointeg's settings panel so it can start it itself with the proper command to start python on your machine.)

Screenshot below is vscode's run/debug choices. this is not 'leointeg's options'. Choose 'run extension' to have the real "1.0 user experience".
debug-menu.png

3- Third (and best way) is by having leointeg start the server itself. so in the debug top dropdown choose "Run Extension"  (then start leointeg with F5, then in the new vscode window that opens i.e. the 'extension host' goto the command palette and start typing 'leo welcome' to access leointeg's settings page.) you can enter a specific string to start python if the defaults don't work on your machine. (That's where noting what worked by trying in an external terminal might come handy!)

You don't have to necessarily have a server started beforehand. Leointeg has buttons to start and connect to a server in it's outline pane while not connected to a server.

Please zoom in the parts noted in red to see what I mean.
Screenshot from 2021-06-08 22-33-22.png

Leointeg has a special 'welcome/settings' screen where everything is customizable and has somewhat helpful explanation text beneath each option. 

Note: leointeg settings only exist/make sense in the extension host window that was started with F5 while it's in development.  (So yes, its kind of counter intuitive to have to start the extension before going into its settings to, say, change the python command string for the server, etc.) Once released as a real extension the options and the settings panel will exist all the time in vscode.

Now, when leointeg tries to start the server, either automatically at startup if you checked the 'start server' option, or, with the 'start server' button in the leointegration panel, you will see what command leointeg tried to use in the output pane below. (see text circled in red below).

Screenshot from 2021-06-08 22-56-27.png
thats it :)

Also : What do you mean:  'F5' on an @file? This does not make any sense to me at all?!?

F5 is a vscode command to start running and debugging the main project in it's workspace that the workspace is configured to do. So unless you have cursor focus in an opened file,  i.e. the actual file derived by the @file node, not the body pane of the @file, ...and that vscode considers that file in its workspace etc... then F5 will start it in the correct interpreter/compiler that your vscode is configured to use for a given language in a given workspace.  

So thanks a lot to tbp1 and to every one who would like to give this a try! and don't hesitate to ask questions!

I realize now that the instructional video about how to run and start the development version had no other choice than 'run extension' at the time. since then I've added 'run server' and 'run both', which trips most people. I should make it more explicit to choose 'run extension' in vscode's debug view to have the final, true experience of a (soon to be released )1.0 version.
--
Félix

Félix

unread,
Jun 8, 2021, 11:37:12 PM6/8/21
to leo-editor
Also note this small vscode bug that may affect the visuals while in development. https://github.com/microsoft/vscode/issues/118338

(minor and only while in development)

tbp1...@gmail.com

unread,
Jun 9, 2021, 8:27:45 AM6/9/21
to leo-editor
Felix, I had already worked through your various screens before I finally got leointeg working.  The only way I could get it to run was by starting the server externally, in a console window.  Just now I manually started it in a terminal window within vscode and that worked (as expected).  It is only having vscode start the server automatically  that fails.

As I think about it, I recall that when I ask vsc to launch the leointeg server, I see a terminal-like panel that shows my python batch file being launched but doesn't show any command line arguments.  That's probably why the server does not get launched.  The settings show that the right location for the server is known, but that information isn't getting sent to the command line.

On Tuesday, June 8, 2021 at 11:20:07 PM UTC-4 Félix wrote:

Thanks tbp1!! Much appreciated!!!

Also : What do you mean:  'F5' on an @file? This does not make any sense to me at all?!?
 
Sorry.  I meant trying use F5 to run an external file in a Leo outline whose root node starts with @file (or it could be @clean), when that root node is selected.  I suppose it's to be expected, but I thought I'd try it anyway.

As an aside, I wish I had started out running the extension using CTRL-F5 instead of F5. That way, I don't get all that debug clutter and messages, and it is a lot easier to read and understand what is going on. I suggest changing that in the directions.

As an aside, this morning vscode took so long to start up (minutes) that I thought the installation had become corrupted.  Turns out that Windows had just updated itself last night and I had restarted it.  That makes me think that the update may have triggered vscode or npm to update itself, which took a very long time.  But there were no messages, so it seemed as if vscode had simply failed.

 

tbp1...@gmail.com

unread,
Jun 9, 2021, 8:44:39 AM6/9/21
to leo-editor
On Wednesday, June 9, 2021 at 8:27:45 AM UTC-4 tbp1...@gmail.com wrote:
 
As I think about it, I recall that when I ask vsc to launch the leointeg server, I see a terminal-like panel that shows my python batch file being launched but doesn't show any command line arguments.  That's probably why the server does not get launched.  The settings show that the right location for the server is known, but that information isn't getting sent to the command line.

When I click on the "Start Server" button, here is what I see in vscode's "Output" tab:

Starting server with command: py-leo-git

py-leo-git is a batch file on the system path that sets PYTHONPATH before running python on the program on the command line.  However, in fact the server is not actually started.  The "output" tab always shows this message:

Leo Bridge Connection Failed: Websocket closed, code: 1006

Now if I go to the "Terminal" tab and manually enter

py-leo-git C:\Tom\git\leointeg\leobridgeserver.py

then the server gets started successfully.  The above location was copied directly from the "Leo Server Path" option and pasted into the terminal, so I know that the option is set correctly.

Edward K. Ream

unread,
Jun 9, 2021, 8:57:34 AM6/9/21
to leo-editor
On Wed, Jun 9, 2021 at 7:27 AM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
Felix, I had already worked through your various screens before I finally got leointeg working.  The only way I could get it to run was by starting the server externally, in a console window.  Just now I manually started it in a terminal window within vscode and that worked (as expected).  It is only having vscode start the server automatically  that fails.

Hi Thomas,

Thanks for this. Starting the server manually is a great idea. However, leo is not on sys.path (on purpose, in my installation), so I must start the server from the leo-editor folder with: python -m leo.core.leoserver. This at least does work.

Still having trouble connecting to the server after launching leoInteg.

Within Leointeg I pointed leointeg setting to <full path to>leoserver.py. The setting is in the panel with the big Leo logo on it. Sometimes I have trouble finding the panel!

When I attempt to start the server from leoInteg I get a traceback in leoserver.py at line 24:

Error - Cannot start server: stderr: Traceback (most recent call last):
  File "c:\leo.repo\leo-editor\leo\core\leoserver.py", line 24, in <module>

Line 24 is: from leo.core.leoNodes import Position

This is (I think) expected because on my machine leo is not on sys.path.

Perhaps leointeg should add leo to sys.path (if necessary) using the path to leoserver.py. Or something like that.

One last comment. There seem to be at least 3 separate places for settings, not counting the User/Workspace distinction. Félix may have said one would go away when leoInteg becomes an official plugin. Things are pretty confusing right now, which to repeat may be a good thing, because we all get to be newbies :-)

Edward

Edward K. Ream

unread,
Jun 9, 2021, 9:09:03 AM6/9/21
to leo-editor
On Wednesday, June 9, 2021 at 7:57:34 AM UTC-5 Edward K. Ream wrote:

> One last comment. There seem to be at least 3 separate places for settings, not counting the User/Workspace distinction.

Hehe. The panel I was looking for is shown as a blue link after leoInteg starts.

To summarize what I have so far, in the "Leo Integration Settings" panel (the blue link) I have:

Start Server: Off
Connect to Sever: Off
Leo Server Path: c:\leo.repo\leo-editor\leo\core\leoserver.py
Python Command: C:\Users\edreamleo\Python\Python39\python.exe

Now nothing (apparently) happens when I hit the "Connect to Sever" button the first time, but the second time I hit the button it says "Already Connected". So something is amiss :-)

Félix, it may be time for a zoom meeting.

Edward


tbp1...@gmail.com

unread,
Jun 9, 2021, 9:18:42 AM6/9/21
to leo-editor
Let me spell out a little more thoroughly how my system is set up. Python 3.9 is launched with "py".  I have one repo with Leo, and another with leointeg, which I pulled from Felix's yesterday.  I'm using the leointeg code from the clone of Felix's repo, not from the Leo repo.

To run Leo using the code in the devel branch, I have created a little batch file named py-leo-git.cmd to set PYTHONPATH first:

@set PYTHONPATH=c:\tom\git\leo-editor
py %*

This batch file is on the system path.

I set the python command for leointeg to be py-leo-git (do *not* include the .cmd extension).
This works for running leointeg, but not for starting the server.  

tbp1...@gmail.com

unread,
Jun 9, 2021, 9:26:59 AM6/9/21
to leo-editor
On Wednesday, June 9, 2021 at 9:09:03 AM UTC-4 Edward K. Ream wrote:

To summarize what I have so far, in the "Leo Integration Settings" panel (the blue link) I have:

Start Server: Off
Connect to Sever: Off
Leo Server Path: c:\leo.repo\leo-editor\leo\core\leoserver.py
Python Command: C:\Users\edreamleo\Python\Python39\python.exe

Mine settings are slightly different:

Start Server: On
Connect to Sever: On
Leo Server Path: C:\Tom\git\leointeg\leobridgeserver.py
Python Command: py-leo-git

I get the same result whether the server settings are on or off, because of the failure of the start-server command. 
 
Now nothing (apparently) happens when I hit the "Connect to Sever" button the first time, but the second time I hit the button it says "Already Connected". So something is amiss :-)

When I run the extension after starting the server, the "Leo Integration" panel shows the message "Connecting" but nothing happens.  If you hover over the top line of that panel, two icons appear, one for settings and the other apparently showing two connectors being mated.  If I click on that one (and sometimes when I hover over it), then the connection happens and the extension starts to work.

Edward K. Ream

unread,
Jun 9, 2021, 11:21:27 AM6/9/21
to leo-editor
On Wed, Jun 9, 2021 at 8:09 AM Edward K. Ream <edre...@gmail.com> wrote:

Leo Server Path: c:\leo.repo\leo-editor\leo\core\leoserver.py
Python Command: C:\Users\edreamleo\Python\Python39\python.exe

In keeping with the goal of not needing anything on python's path, I'll change leoserver.py so that it uses __file__ to add leo-editor to the path. This should allow the imports in leoserver.py to "just work", regardless of where leoserver.py was invoked. One less thing for leoInteg (or leoInteg users) to worry about.

Edward

Edward K. Ream

unread,
Jun 9, 2021, 11:23:35 AM6/9/21
to leo-editor
On Wed, Jun 9, 2021 at 8:27 AM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
On Wednesday, June 9, 2021 at 9:09:03 AM UTC-4 Edward K. Ream wrote:

To summarize what I have so far, in the "Leo Integration Settings" panel (the blue link) I have:

Start Server: Off
Connect to Sever: Off
Leo Server Path: c:\leo.repo\leo-editor\leo\core\leoserver.py
Python Command: C:\Users\edreamleo\Python\Python39\python.exe

Mine settings are slightly different:

Start Server: On
Connect to Sever: On
Leo Server Path: C:\Tom\git\leointeg\leobridgeserver.py
Python Command: py-leo-git

Interesting. leobridgeserver.py is part of leointeg, leoserver.py is part of Leo.

Apparently the "Leo Server Path" label isn't explicit enough.

Edward

tbp1...@gmail.com

unread,
Jun 9, 2021, 11:25:26 AM6/9/21
to leo-editor
Here is the simplest, cleanest way I have found to get the extension working.  I assume that the leo settings have already been set:

1. Open vscode and load the leointeg folder.
2. Press CNTL-F5.
3. Wait for a second window to open.  In the second window, the left-hand strip of icons should have a Leo icon: a square with eyes and some whiskers sticking out.  If it doesn't, the the extension hasn't launched.
4.  Go to the "Terminal"  tab in  this new window. In the Terminal panel. type 

<python> <path-to-leobridgeserver.py> <ENTER>

where <python> is your python launcher (e.g., py-leo-git for me, or "py" for many Windows users), and < path-to-leobridgeserver.py> can be gotten from the extension's settings (see below).  This will launch the leo bridge server.
5. There should be a pane in the left-hand pane labeled "Integration". It will show "Connecting". Hover the mouse above the top line of the panel and two icons will appear.  The left icon resembles a pair of connectors to be mated.  Click that icon and the extension  will connect to Leo through the server.

If you have not set the settings yet, or need to copy the location of the leobridgerserver, after step 3, hover over the top line of the "Integration" pane and click on the settings icon (the right-hand one of the two icons that will appear).  This will open a settings pane where you can enter or change the path to the server file.

tbp1...@gmail.com

unread,
Jun 9, 2021, 11:30:40 AM6/9/21
to leo-editor
I wrote -

On Wednesday, June 9, 2021 at 11:25:26 AM UTC-4 tbp1...@gmail.com wrote:
Here is the simplest, cleanest way I have found to get the extension working.  I assume that the leo settings have already been set:
... 
5. There should be a pane in the left-hand pane labeled "Integration". It will show "Connecting". Hover the mouse above the top line of the panel and two icons will appear.  The left icon resembles a pair of connectors to be mated.  Click that icon and the extension  will connect to Leo through the server.

If you have not set the settings yet, or need to copy the location of the leobridgerserver, after step 3, hover over the top line of the "Integration" pane and click on the settings icon (the right-hand one of the two icons that will appear).  This will open a settings pane where you can enter or change the path to the server file.

I forgot to write that you should click on that square Leo icon before clicking on the "Settings" icon or the "Connect" icon. 

Edward K. Ream

unread,
Jun 9, 2021, 3:49:38 PM6/9/21
to leo-editor
On Wed, Jun 9, 2021 at 10:25 AM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
Here is the simplest, cleanest way I have found to get the extension working.  I assume that the leo settings have already been set:

Thanks for this. We are getting close. It fails in leobridgeserver.py because it can't import leo itself. This is expected. There should be a simple fix that doesn't depend on Leo being on python's path.  I'll report on my proposed fix soon.

Edward

Edward K. Ream

unread,
Jun 9, 2021, 4:13:08 PM6/9/21
to leo-editor
Hmm.  Still no joy. I copied leobridgeserver.py to leo/core/leoserver.py to make sure they are identical. Then I added the following to leoserver.py:

_path = __file__
_leo_path = os.path.abspath(os.path.join(__file__, '..', '..', '..'))
print('leoserver.py::_leo_path:', _leo_path)
if _leo_path not in sys.path:
    sys.path.append(_leo_path)

Now the imports succeed, and the server runs as expected. However, nothing else happens and there is no obvious way to load a .leo file.

Instead of this, perhaps leoInteg could ask for a path to Leo itself.

Thomas, would you like to zoom with Félix and me when Félix is available?

Edward

tbp1...@gmail.com

unread,
Jun 9, 2021, 4:21:37 PM6/9/21
to leo-editor
At the top of the Leo "Outline" panel there are some little icons. One of them is a file folder.  Click that and you can open a Leo outline.

tbp1...@gmail.com

unread,
Jun 9, 2021, 4:23:26 PM6/9/21
to leo-editor
On Wednesday, June 9, 2021 at 4:13:08 PM UTC-4 Edward K. Ream wrote:
Thomas, would you like to zoom with Félix and me when Félix is available?

Sure, I'd be happy to. I've got the Zoom app on this new computer;  this would be its first outing. 

tbp1...@gmail.com

unread,
Jun 9, 2021, 4:50:40 PM6/9/21
to leo-editor
I have updated my local repo devel branch from Leo's github rep.  Now I can run the leoserver.py file that's in the Leo repo.  But, as Edward reported, it doesn't actually work with leointeg.  I get an announcement that the extension is connected, but it's not. Sometimes when I try to connect there is a message that it's already connected, but it still acts like it is not.

OTOH, when I start Felix's leobridgeserver from the leointeg directory, then it works as I described earlier. 

BTW. after some of these failed attempts I had to close vscode and restart it to get the whole mechanism working again.

tbp1...@gmail.com

unread,
Jun 9, 2021, 5:18:05 PM6/9/21
to leo-editor
So we may have been talking about different versions.  My last post used the current devel version of leoserver.  Now I see that there is a felix-server branch in the leo-editor repo.  So I fetched that and checked it out.  It still doesn't work for me.  I did notice that it opens a web page in my browser - nice touch, Felix - but that page doesn't actually work in the sense that you can't do the expression evals in the box at the top.  With the browser debug tools I saw that the jquery script couldn't be downloaded.  I haven't tried to find out why.

However, even though the http server continues to run, the vscode Leo extension window claims that the web socket is closed.  I'd suggest that the web server side could be used to query the server to see if it thinks its websocket service side is still working.

If I go back to Felix's own repo and use leobridgeserver.py from there, everything works as before.

Edward K. Ream

unread,
Jun 9, 2021, 5:59:54 PM6/9/21
to leo-editor
On Wed, Jun 9, 2021 at 4:18 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
So we may have been talking about different versions. 

Yes, it's all confusing.

As another data point, I added leo to sys.path in sitecustomize.py and switched back to leobridgeserver in the leoInteg settings.

Now there is more progress, but still no real joy. When starting the server I get:

Starting server with command: C:\Users\edreamleo\Python\Python39\python.exe
Starting Leobridgeserver.py (Launch with -h for help)
LeoBridge started at localhost on port: 32125 [ctrl+c] to break
ERROR: Error in openFiles
Looking at the code in leobridgeserver.py, it appears that this message happens when the server can't find any open files.  Imo, this shouldn't really be an error. Or at least the user should be given the opportunity to switch directories.

Edward

Edward K. Ream

unread,
Jun 9, 2021, 6:05:35 PM6/9/21
to leo-editor
Ok. I'll keep you in mind :-)

Edward

Edward K. Ream

unread,
Jun 9, 2021, 6:06:05 PM6/9/21
to leo-editor
On Wed, Jun 9, 2021 at 3:21 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
At the top of the Leo "Outline" panel there are some little icons. One of them is a file folder.  Click that and you can open a Leo outline.

I haven't gotten that much joy.

Edward

tbp1...@gmail.com

unread,
Jun 9, 2021, 6:11:40 PM6/9/21
to leo-editor
When I look in the felix-server branch, leoserver.py is only an http server, not a websocket server.  Which branch of the leo-editor repo are you working with? Neither the felix-server nor the devel branches contain leobridgeserver.py.  So, as far as I can see, it is not possible to run leointeg without using leobridgeserver from Felix's repo.

Edward K. Ream

unread,
Jun 9, 2021, 6:13:10 PM6/9/21
to leo-editor
On Wed, Jun 9, 2021 at 4:59 PM Edward K. Ream <edre...@gmail.com> wrote:

Now there is more progress, but still no real joy. When starting the server I get:

Starting server with command: C:\Users\edreamleo\Python\Python39\python.exe
Starting Leobridgeserver.py (Launch with -h for help)
LeoBridge started at localhost on port: 32125 [ctrl+c] to break
ERROR: Error in openFiles
Looking at the code in leobridgeserver.py, it appears that this message happens when the server can't find any open files.  Imo, this shouldn't really be an error. Or at least the user should be given the opportunity to switch directories.

And another data point.  The Leo log window (not the leoserver.py log) shows:

Leo 6.4-devel, devel branch, build 7c335ea4bc
2021-06-08 05:06:19 -0500
Python 3.9.0, LeoGui: dummy version
Windows 10 AMD64 (build 10.0.19041) SP0
read outline in 0.24 seconds
read 373 files in 2.37 seconds
read outline in 2.66 seconds

This is very much like what I see when I just run `leo` from a console outside of vs-code.

So it looks like leoInteg is opening leoPy.leo because of Leo's automatic session cashing (I'm guessing), but leobridgeserver doesn't see the open file, maybe because of path problems.

It all seems too confusing. We've got to do better :-)

Edward

Edward K. Ream

unread,
Jun 9, 2021, 6:16:16 PM6/9/21
to leo-editor
On Wed, Jun 9, 2021 at 5:11 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
When I look in the felix-server branch, leoserver.py is only an http server, not a websocket server.  Which branch of the leo-editor repo are you working with? Neither the felix-server nor the devel branches contain leobridgeserver.py.  So, as far as I can see, it is not possible to run leointeg without using leobridgeserver from Felix's repo.

I'm in devel, for Leo. I'm in master for leointeg. I pointed leoInteg to leobridgeserver.py in the leointeg folder.

I'm hoping this kind of confusion won't be possible when leoInteg is a real plugin.

Edward

tbp1...@gmail.com

unread,
Jun 9, 2021, 7:32:31 PM6/9/21
to leo-editor
I was originally using devel in leo-editor, and master in Felix's repo.

I see what you see in the "Output" tab in vscode when the extension starts.  One caution - whenever I shutdown the extension (or it shuts down by itself),  I cannot get it to show up when I run it again.  vscode goes through the motions but the Leo icon never appears. I have to close vscode and restart it.  On top of that, closing the extension also closes the leobridgeserver.  So after a shutdown, you have to:

1. Restart the leobridge server;
2. Restart vscode.

Hopefully Felix will be able to fix 1) - so that vscode will successfully launch the server - and 2) is probably a good idea so that we don't end up with forgotten zombie servers lying around.

tbp1...@gmail.com

unread,
Jun 9, 2021, 7:36:23 PM6/9/21
to leo-editor
On Wednesday, June 9, 2021 at 6:13:10 PM UTC-4 Edward K. Ream wrote:
On Wed, Jun 9, 2021 at 4:59 PM Edward K. Ream <edre...@gmail.com> wrote:

Now there is more progress, but still no real joy. When starting the server I get:

Starting server with command: C:\Users\edreamleo\Python\Python39\python.exe
Starting Leobridgeserver.py (Launch with -h for help)
LeoBridge started at localhost on port: 32125 [ctrl+c] to break
ERROR: Error in openFiles
Looking at the code in leobridgeserver.py, it appears that this message happens when the server can't find any open files.  Imo, this shouldn't really be an error. Or at least the user should be given the opportunity to switch directories.

So it looks like leoInteg is opening leoPy.leo because of Leo's automatic session cashing (I'm guessing), but leobridgeserver doesn't see the open file, maybe because of path problems.

I don't get that so far.  Of course, I haven't been able to get the extension to open the server on its own yet, so maybe that's the reason. 

Félix

unread,
Jun 9, 2021, 7:49:08 PM6/9/21
to leo-editor
you guys wanna zoom at 8:20 EST ? or around that time?

tbp1...@gmail.com

unread,
Jun 9, 2021, 7:54:02 PM6/9/21
to leo-editor
On Wednesday, June 9, 2021 at 7:36:23 PM UTC-4 tbp1...@gmail.com wrote:

... Of course, I haven't been able to get the extension to open the server on its own yet, so maybe that's the reason. 

I finally got the extension to launch the leobridgeserver on its own.  I wrote a batch file that sets the PYTHONPATH and starts the server:

@echo off
set PYTHONPATH=c:\tom\git\leo-editor
py "C:\Tom\git\leo-editor\leobridgeserver.py"

Note that I arbitrarily have copied  the server into the leo-editor tree, for no very good reason except that it should end up there at some point.  This confirms my suspicion that command line arguments are being passed in some way that does not work with a batch file.

One thing I now notice - I can't find a way to bring up the leointeg settings once it succeeds in running.  So I can't change the server start options.  I think the options need to be easy to find even after the extension is working.

tbp1...@gmail.com

unread,
Jun 9, 2021, 7:55:46 PM6/9/21
to leo-editor
I guess I could do that.  You will need to send me a zoom meeting number, and password if one is needed (I am supposing that your will reuse the number you used from a previous meeting with Edward).

Edward K. Ream

unread,
Jun 9, 2021, 8:22:00 PM6/9/21
to leo-editor
On Wed, Jun 9, 2021 at 6:49 PM Félix <felix...@gmail.com> wrote:
you guys wanna zoom at 8:20 EST ? or around that time?

Sure. That's about now :-)  Do you want me to start the meeting?

Edward

Félix

unread,
Jun 9, 2021, 8:23:25 PM6/9/21
to leo-editor
good idea :) 

tbp1...@gmail.com

unread,
Jun 9, 2021, 8:25:20 PM6/9/21
to leo-editor
I'll need the meeting info ...

Edward K. Ream

unread,
Jun 9, 2021, 8:26:31 PM6/9/21
to leo-editor


On Wed, Jun 9, 2021 at 6:32 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:

Edward Ream is inviting you to a scheduled Zoom meeting.

Topic: Edward Ream's Personal Meeting Room

Join Zoom Meeting
https://us02web.zoom.us/j/4804959221

Meeting ID: 480 495 9221

Reply to this if you have problems joining.

Edward

Félix

unread,
Jun 9, 2021, 8:30:12 PM6/9/21
to leo-editor
Hey Thomas (or anyone else who wants to contact me directly for whatever reason)

Here's my personal email adress

felixgraphx (...at...) gmail.com

Edward K. Ream

unread,
Jun 9, 2021, 8:31:30 PM6/9/21
to leo-editor
On Wed, Jun 9, 2021 at 7:25 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
I'll need the meeting info ...

Edward Ream is inviting you to a scheduled Zoom meeting.

Topic: Edward Ream's Personal Meeting Room

Join Zoom Meeting
https://us02web.zoom.us/j/4804959221

Meeting ID: 480 495 9221

Edward

Félix

unread,
Jun 9, 2021, 10:07:41 PM6/9/21
to leo-editor

Thanks Thomas and Edward!  That was great bug hunting! 

tbp1...@gmail.com

unread,
Jun 9, 2021, 10:53:58 PM6/9/21
to leo-editor
:)

Félix

unread,
Jun 10, 2021, 12:57:00 AM6/10/21
to leo-editor
New master branch update for the 'clear recent files' to temporarily avoid the bug and reset to 'opening nothing ' at startup.

Edward K. Ream

unread,
Jun 10, 2021, 10:53:19 AM6/10/21
to leo-editor
On Wed, Jun 9, 2021 at 11:57 PM Félix <felix...@gmail.com> wrote:
New master branch update for the 'clear recent files' to temporarily avoid the bug and reset to 'opening nothing ' at startup.

Thanks. I'll play with it soon.

PR #1969 reports the leo-editor directory in the log. This PR has been merged into devel.

Imo, giving this directory to leoInteg should (eventually) suffice to make leoInteg "just work" as follows:

1. leoInteg can use this directory to find leo/core/leoserver.py.
2. #1970 suggests using __file__ in leoserver.py to adjust sys.path. This will allow leoserver.py to import leo modules regardless of the cwd. I'll complete this issue later today.

Edward
Reply all
Reply to author
Forward
0 new messages