Re: Leo's HOME directory

2017-02-15 Thread john lunzer
I was afraid of that. Thanks for the thorough response. I was trying to cut 
some corners to just get a feel for things, but I think much more thought 
will have to go into this.

On Wednesday, February 15, 2017 at 10:40:59 AM UTC-5, Terry Brown wrote:
>
> I think as a general rule with os.chdir()/os.getcwd() in Python apps. you 
> can't assume its value, it's a single piece of state shared across the 
> entire app. and all libraries, so really the best thing to do is not use it 
> or rely on it.
>
> Your result is not surprising, Leo is setting it between script calls. 
>  Possibly Leo is doing this intentionally in a constructive way, setting 
> the cwd to the path implied by the node you're in (taking into account the 
> location of the .leo file and all parent @path directives.  If you think 
> about it a truly Leonine shell representation might use the tree to 
> represent directories.
>
> For your application I'm not sure what the best approach might be.  You 
> could sandwich your shell work between calls to some get_last_cwd() / 
> save_last_cwd() that stores a cwd in a uA per node or something.
>
> Or perhaps a custom cd() function that does both get_last_cwd() and 
> save_last_cwd() at once, saves having to remember to use the other 
> functions.
>
> Cheers -Terry
>
>
> --
> *From:* john lunzer >
> *To:* leo-editor > 
> *Cc:* lar...@gmail.com 
> *Sent:* Wednesday, February 15, 2017 7:58 AM
> *Subject:* Re: Leo's HOME directory
>
> I'll use this thread because it seems relevant. I'm trying to do some 
> experiments using Leo as a shell. Amongst other things I'm trying to change 
> this current working directory. I have a small node script:
>
> @language python
>
> import os
> os.chdir("..")
> g.es(os.getcwd(), color="green")
>
> Perhaps naively I expected the log to show that I keeping dropping down a 
> level, as it would in a interactive python session. Unfortunately the 
> output is the same each time.
>
> Any suggestions on changing the working directory? Or suggestions on 
> alternatives to keeping track of working directory in scripts.
>
> On Thursday, April 21, 2016 at 7:20:52 PM UTC-4, Edward K. Ream wrote:
>
> On Thu, Apr 21, 2016 at 1:44 PM, Largo84  wrote:
>
> Sorry I don't know the whole back story on this, but why was this plugin 
> disabled?
>
>
> ​I have no recollection of 2008 :-)
> ​
>  
>
> What's the alternative way to explicitly specify a different HOME 
> directory than the OS default?
>
>
> ​According to lm.computeHomeDir, ​
>  
> ​the home directory is
>
> os.path.expanduser("~")
>
> ​There is a comment in Leo's code that Windows searches the HOME, HOMEPATH 
> and HOMEDRIVE environment vars. Full details here 
> <https://docs.python.org/2/library/os.path.html>. (Search for expanduser 
> on this page).
>
> Edward
>
> -- 
> 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 leo-editor+...@googlegroups.com .
> To post to this group, send email to leo-e...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/leo-editor.
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Leo's HOME directory

2017-02-15 Thread 'Terry Brown' via leo-editor
I think as a general rule with os.chdir()/os.getcwd() in Python apps. you can't 
assume its value, it's a single piece of state shared across the entire app. 
and all libraries, so really the best thing to do is not use it or rely on it.
Your result is not surprising, Leo is setting it between script calls.  
Possibly Leo is doing this intentionally in a constructive way, setting the cwd 
to the path implied by the node you're in (taking into account the location of 
the .leo file and all parent @path directives.  If you think about it a truly 
Leonine shell representation might use the tree to represent directories.
For your application I'm not sure what the best approach might be.  You could 
sandwich your shell work between calls to some get_last_cwd() / save_last_cwd() 
that stores a cwd in a uA per node or something.
Or perhaps a custom cd() function that does both get_last_cwd() and 
save_last_cwd() at once, saves having to remember to use the other functions.
Cheers -Terry

  From: john lunzer 
 To: leo-editor  
Cc: larg...@gmail.com
 Sent: Wednesday, February 15, 2017 7:58 AM
 Subject: Re: Leo's HOME directory
   
I'll use this thread because it seems relevant. I'm trying to do some 
experiments using Leo as a shell. Amongst other things I'm trying to change 
this current working directory. I have a small node script:
@language python

import os
os.chdir("..")
g.es(os.getcwd(), color="green")
Perhaps naively I expected the log to show that I keeping dropping down a 
level, as it would in a interactive python session. Unfortunately the output is 
the same each time.
Any suggestions on changing the working directory? Or suggestions on 
alternatives to keeping track of working directory in scripts.
On Thursday, April 21, 2016 at 7:20:52 PM UTC-4, Edward K. Ream wrote:
On Thu, Apr 21, 2016 at 1:44 PM, Largo84  wrote:

Sorry I don't know the whole back story on this, but why was this plugin 
disabled?

​I have no recollection of 2008 :-)
​ 
What's the alternative way to explicitly specify a different HOME directory 
than the OS default?

​According to lm.computeHomeDir, ​ ​the home directory is

    os.path.expanduser("~")

​There is a comment in Leo's code that Windows searches the HOME, HOMEPATH and 
HOMEDRIVE environment vars. Full details here. (Search for expanduser on this 
page).

Edward
-- 
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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


   

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Leo's HOME directory

2017-02-15 Thread john lunzer
I'll use this thread because it seems relevant. I'm trying to do some 
experiments using Leo as a shell. Amongst other things I'm trying to change 
this current working directory. I have a small node script:

@language python

import os
os.chdir("..")
g.es(os.getcwd(), color="green")

Perhaps naively I expected the log to show that I keeping dropping down a 
level, as it would in a interactive python session. Unfortunately the 
output is the same each time.

Any suggestions on changing the working directory? Or suggestions on 
alternatives to keeping track of working directory in scripts.

On Thursday, April 21, 2016 at 7:20:52 PM UTC-4, Edward K. Ream wrote:
>
> On Thu, Apr 21, 2016 at 1:44 PM, Largo84 > 
> wrote:
>
>> Sorry I don't know the whole back story on this, but why was this plugin 
>> disabled?
>>
>
> ​I have no recollection of 2008 :-)
> ​
>  
>
>> What's the alternative way to explicitly specify a different HOME 
>> directory than the OS default?
>>
>
> ​According to lm.computeHomeDir, ​
>  
> ​the home directory is
>
> os.path.expanduser("~")
>
> ​There is a comment in Leo's code that Windows searches the HOME, HOMEPATH 
> and HOMEDRIVE environment vars. Full details here 
> . (Search for expanduser 
> on this page).
>
> Edward
>

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Leo's HOME directory

2016-04-21 Thread Edward K. Ream
On Thu, Apr 21, 2016 at 1:44 PM, Largo84  wrote:

> Sorry I don't know the whole back story on this, but why was this plugin
> disabled?
>

​I have no recollection of 2008 :-)
​


> What's the alternative way to explicitly specify a different HOME
> directory than the OS default?
>

​According to lm.computeHomeDir, ​

​the home directory is

os.path.expanduser("~")

​There is a comment in Leo's code that Windows searches the HOME, HOMEPATH
and HOMEDRIVE environment vars. Full details here
. (Search for expanduser on
this page).

Edward

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Leo's HOME directory

2016-04-21 Thread Largo84
Sorry I don't know the whole back story on this, but why was this plugin 
disabled? What's the alternative way to explicitly specify a different HOME 
directory than the OS default?

Rob

On Sunday, December 14, 2008 at 5:22:32 PM UTC-5, Edward K. Ream wrote:
>
> On Sun, Dec 14, 2008 at 4:20 PM, Edward K. Ream  > wrote:
>
> > rev 1358 contains the following tested code for setHomeDirectory.py::
>
> This plugin is enabled in rev 1258, and disabled in rev 1359 :-)
>
> Edward
>
>

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: Leo's HOME directory

2008-12-14 Thread Edward K. Ream

On Sun, Dec 14, 2008 at 4:20 PM, Edward K. Ream  wrote:

> rev 1358 contains the following tested code for setHomeDirectory.py::

This plugin is enabled in rev 1258, and disabled in rev 1359 :-)

Edward

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~--~~~~--~~--~--~---



Re: Leo's HOME directory

2008-12-14 Thread Edward K. Ream

On Wed, Dec 10, 2008 at 2:17 PM, bpursley  wrote:

> I noticed that Leo's Home directory is tied to Python's HOME
> environment variable.  Furthermore, Leo uses os.expanduser('~') to
> determine the HOME directory when no HOME environment variable exists.
>
> I make extensive use of python's virtualenv to keep my python
> development activities separate from my production desktop
> environment.  Is there any clever way to set Leo's Home directory to a
> directory of my choosing?  That is, without forcing a change to my
> default python home directory on the production work environment.

The relevant code is presumably g.computeHomeDirectory.  At present,
the code uses

# home = os.getenv('HOME',default=None)
home = os.path.expanduser("~")

I don't recall the pros and cons of this.

Anyway, the "clever" way is to override g.computeHomeDirectory in a plugin.

rev 1358 contains the following tested code for setHomeDirectory.py::

import leo.core.leoGlobals as g

def init ():
g.app.homeDir = path = 'c:\\'
print('setHomeDirectory.py g.app.homeDir set to %s' % path)
return True

You can put in a hard-coded directory as I did, or use whatever
algorithm you want.

Edward

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~--~~~~--~~--~--~---



Re: Leo's HOME directory

2008-12-12 Thread bpursley



On Dec 11, 6:48 pm, Alia K  wrote:

> - In your project directory create an empty leo file, let's call it
> project.leo

Thank you for your reply.  I am now making great headway.  My failure
was two-fold:

  I treated @shadow the same way as I had treated @folder.
  I was confused about the "@path" statements in the body.
   (my problem - not the docs)

I now understand that my project.leo file operates on the parent
directory of it's current location.  I had been trying some funky
things in organizing my source files, .leo files, and derived files.
Now that I passed this first speed-bump, I am diving into this
wonderful tool.
It looks like it is going to be a lot of fun.

Thanks again for being so responsive.

Bernie Pursley
Simsbury, CT

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~--~~~~--~~--~--~---



Re: Leo's HOME directory

2008-12-12 Thread bpursley



On Dec 11, 5:56 pm, Mike Crowe  wrote:
> Your @shadow is the node name.   Here's how I created:

Thank you for your reply.  You and Alia K have shown me the way
forward.  I experimented with the @file and @shadow at the file level
without any problems.  However, when I tried to operate on a directory
level - that is when I ran into trouble.  At first, I tried the
@folder plugin which seemed to work at getting the nodes built.
However, it left the task of importing code for each node to a
cumbersome file by file process.  My failure was in treating @shadow
the same way I treated @folder.  That is what led to my confusion and
my first two posts.  Additional details in my response to Alia K.

Thanks again for being so responsive.

Bernie Pursley
Simsbury, CT

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~--~~~~--~~--~--~---



Re: Leo's HOME directory

2008-12-11 Thread Alia K

Bernie wrote:
> I have specifically been attempting to
> use the @shadows script as described here:http://leo.zwiki.org/CreateShadows.
> I do not get the expected results.  Instead, when I launch the
> CreateShadows button, Leo plugs an "@path ." in the node body and
> proceeds to build nodes against my HOME directory.

It really depends how you run leo, my personal practice is to create
an executable (chmod +x) script as follows:


#!/usr/local/bin/python

""" Leo launcher script

A minimal script to launch leo.
"""
import leo.core.runLeo
leo.core.runLeo.run()



which I've placed in my /Library/Frameworks/Python.framework/Versions/
Current/bin/ (in mac os x), but this can go in /usr/local/bin as well.

I'm assuming you are in your project directory and not in your HOME
directory.

- In your project directory create an empty leo file, let's call it
project.leo
- add the @button create-shadows node containing the CreateShadows
script
- add another node below it to be the root of your project (let's call
it 'code' for now).
- save the project.leo file and reopen it again with leo
- a button should appear on the tool-bar
- select the code node and press the create-shadows button
- the code node should have the @path "." in the body and should have
bunch of empty @shadow nodes and directory nodes respectively
representing relevant files and directories in your project directory.
- save project.leo and reopen it again with leo.
- the @shadow files should be populated now...

Hope this helps. (see also http://leo.zwiki.org/LeoDirectory for more
customized directory parsing)

AliaKhouri
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~--~~~~--~~--~--~---



Re: Leo's HOME directory

2008-12-11 Thread Mike Crowe
Your @shadow is the node name.   Here's how I created:

If you have an existing file:

   1. Do a File -> Import -> Import to @file
   2. The resulting file will be look something like:
  @file /home/mcrowe/project/mynode.py
   3. Change @file to @shadow
   4. The first line of the imported file *may* be @ignore (or it may be
  further down).  This is inserted to insure you review the file
  before saving it.

If you want to create a new file:

   1. Do a ctrl-I to create a new node
   2. Name the node:
  @shadow /bcp/lib/Pylons/myfirsttest.py
   3. Start writing code

When you save, you will see a status message like:
created:   /bcp/lib/Pylons/.leo_shadow/xmyfirsttest.py

created:   /bcp/lib/Pylons/myfirsttest.py


LMK if this doesn't work.

Mike

bpursley wrote:
>
> On Dec 11, 1:22 pm, zpcspm  wrote:
>   
>> The cool thing about leo is that you can get a fresh copy from
>> launchpad using "bzr branch", then you cd to that directory and run
>> leo by "python launchLeo.py" or "python launchLeo.py --gui=qt".
>> You'll get a .leo directory in your user HOME directory, with user-
>> specific settings, no matter where you run leo from.
>> 
>
> Thank you for your response.  I have been running some tests in a leo
> project directory with both  the stable leo-4-5-1-final version and a
> more recent #1341 revision.  I have specifically been attempting to
> use the @shadows script as described here: http://leo.zwiki.org/CreateShadows.
> I do not get the expected results.  Instead, when I launch the
> CreateShadows button, Leo plugs an "@path ." in the node body and
> proceeds to build nodes against my HOME directory.
>
> I have read the Leo users guide (really) and searched and scanned
> through this site for possible answers.  I tried several variations on
> the @shadow node shown below but the results were always the same.
>
> @shadow /bcp/lib/Pylons
> @shadow /bcp/lib/Pylons/
> @path /bcp/lib/ @shadow Pylons/
> @path /bcp/lib/Pylons/ @shadow /bcp/lib/Pylons/
>
> This is what led me to consider the possibility of a default to my
> HOME directory as the culprit .  Could you direct me to a working
> example of @shadow ?
>
> Thanks again,
>
> Bernie Pursley
> Simsbury CT
> >
>   

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~--~~~~--~~--~--~---



Re: Leo's HOME directory

2008-12-11 Thread bpursley



On Dec 11, 1:22 pm, zpcspm  wrote:
> The cool thing about leo is that you can get a fresh copy from
> launchpad using "bzr branch", then you cd to that directory and run
> leo by "python launchLeo.py" or "python launchLeo.py --gui=qt".
> You'll get a .leo directory in your user HOME directory, with user-
> specific settings, no matter where you run leo from.

Thank you for your response.  I have been running some tests in a leo
project directory with both  the stable leo-4-5-1-final version and a
more recent #1341 revision.  I have specifically been attempting to
use the @shadows script as described here: http://leo.zwiki.org/CreateShadows.
I do not get the expected results.  Instead, when I launch the
CreateShadows button, Leo plugs an "@path ." in the node body and
proceeds to build nodes against my HOME directory.

I have read the Leo users guide (really) and searched and scanned
through this site for possible answers.  I tried several variations on
the @shadow node shown below but the results were always the same.

@shadow /bcp/lib/Pylons
@shadow /bcp/lib/Pylons/
@path /bcp/lib/ @shadow Pylons/
@path /bcp/lib/Pylons/ @shadow /bcp/lib/Pylons/

This is what led me to consider the possibility of a default to my
HOME directory as the culprit .  Could you direct me to a working
example of @shadow ?

Thanks again,

Bernie Pursley
Simsbury CT
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~--~~~~--~~--~--~---



Re: Leo's HOME directory

2008-12-11 Thread zpcspm

The cool thing about leo is that you can get a fresh copy from
launchpad using "bzr branch", then you cd to that directory and run
leo by "python launchLeo.py" or "python launchLeo.py --gui=qt".
You'll get a .leo directory in your user HOME directory, with user-
specific settings, no matter where you run leo from.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~--~~~~--~~--~--~---



Leo's HOME directory

2008-12-11 Thread bpursley

I just discovered your fine tool this week.  At first blush, it looks
like it will help me scratch an itch I have had for a long time.
Thank you for your excellent contribution to open source.

It also appears to have a steep learning curve.  I will provide more
feedback in a couple of weeks when I have passed through the early
fog.

I noticed that Leo's Home directory is tied to Python's HOME
environment variable.  Furthermore, Leo uses os.expanduser('~') to
determine the HOME directory when no HOME environment variable exists.

I make extensive use of python's virtualenv to keep my python
development activities separate from my production desktop
environment.  Is there any clever way to set Leo's Home directory to a
directory of my choosing?  That is, without forcing a change to my
default python home directory on the production work environment.

Thanks,

Bernie Pursley
Simsbury, CT


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~--~~~~--~~--~--~---