*Issue #1425 <https://github.com/leo-editor/leo-editor/issues/1425>. 
Settings > Open A Theme File can look like it's not working. The Leo 
session that spawns the Leo-with-themefile locks and says "Not Responding" 
in the title bar until the Leo-with-themefile session is closed. Read the 
issue for more context. This is an ENB as I work towards resolution,*

 

...


As currently written this menu command, defined in 
../commands/commanderFileCommands.py-->Themes-->c_file.open_theme_file, 
will only work in Leo source code checkouts. That is, it's broken for 
anyone who installs from Pypi.org, from pip in a non-editable mode, or some 
other deployment mode that works similarly.


The problem part:


command = f'python launchLeo.py "{fn}"'
os.system(command) 


launchLeo.py doesn't exist outside a source code repo. In a pip deployment 
Leo is launched with PYTHONHOME/Scripts/leo. Others use their own launch 
wrapper somewhere else.


A few different fixes suggest themselves:

   1. search PATH for leo
   2. ask current Leo session what it's launch command is/was
   3. reproduce the contents of launchLeo.py as a python -c '...{py 
   code}...' command line expression. (It's short enough that this is 
   practical)

I don't like 1 & 3 much. I do like 2 but don't know yet how much work it 
will be. Well, time to start learning!


Along the way, we might as well replace os.command with a current 
recommended 
<https://docs.python.org/3.6/library/subprocess.html#replacing-os-system> 
method as 
*"The subprocess 
<https://docs.python.org/3.6/library/subprocess.html#module-subprocess> 
module provides more powerful facilities for spawning new processes and 
retrieving their results; using that module is preferable to using this 
function. See the Replacing Older Functions with the subprocess Module 
<https://docs.python.org/3.6/library/subprocess.html#subprocess-replacements> 
section in the subprocess 
<https://docs.python.org/3.6/library/subprocess.html#module-subprocess> 
documentation for some helpful recipes." (ref 
<https://docs.python.org/3.6/library/os.html#os.system>)*


-matt

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/71d32e63-d6f9-4c0c-ad59-c6cc2d0730da%40googlegroups.com.

Reply via email to