It works:

I have in ~/.pymol.rc:
# let's add the custom srctip repo dir:
sys.path.append(os.path.expanduser('~/.local/lib/python2.7/site-packages/pymol/scripts'))

# custom scripts:
import pmlrc

And here's a pmlrc.py (which I put in
~/.local/lib/python2.7/site-packages/pymol/scripts):
# code to be executed on start-up:

from pymol import cmd

# run from script dir:
import os
def Run(filename):
    for Path in ['',
os.path.expanduser('~/.local/lib/python2.7/site-packages/pymol/scripts')]:
        full = os.path.join(Path, filename)
        if os.path.exists(full):
            cmd.do('run ' + full)
            return
    print ' Error: no such file: {0}'.format(filename)
cmd.extend('Run', Run)

Then
Run script.py
runs the script if it is either in a current dir, or in the
~/.local/lib/python2.7/site-packages/pymol/scripts

Thanks to all responders,
Boris.


On Tue, May 15, 2012 at 4:58 PM, Thomas Holder
<spel...@users.sourceforge.net> wrote:
> Hi Boris,
>
> you can make your own run command which searches a path:
>
> python
> import os
> def run2(filename):
>    for p in ['', '/path/to']:
>        full = os.path.join(p, filename)
>        if os.path.exists(full):
>            cmd.do('run ' + full)
>            return
>    print ' Error: no such file'
> cmd.extend('run2', run2)
> python end
>
> Cheers,
>  Thomas
>
>
> On 05/15/2012 02:51 PM, Boris Kheyfets wrote:
>>
>> That's the point - I can import from these directories - but can't
>> 'run' from there.
>>
>> I can only run a script by specifying the full path.
>>
>> Boris.
>>
>> On Tue, May 15, 2012 at 4:45 PM, Troels Emtekær Linnet
>> <tlin...@gmail.com>  wrote:
>>>
>>> write this in pymol command window:
>>>
>>> import sys
>>> print sys.path
>>>
>>> There you can see where pymol is looking.
>>>
>>> Or you can this to your .pymolrc in your home folder:
>>>
>>> import sys
>>> sys.path.append("/Path/to/your/Pymol-script/modules")
>>>
>>> Troels Emtekær Linnet
>>> Ved kløvermarken 9, 1.th
>>> 2300 København S
>>> Mobil: +45 60210234
>>>
>>>
>>>
>>> 2012/5/15 Boris Kheyfets<kheyfbo...@gmail.com>
>>>>
>>>>
>>>> Is there a way I can add a path to 'run' - so not to type the full
>>>> path to the script when I run it:
>>>>
>>>> run /path/to/script.py
>
>
> --
> Thomas Holder
> MPI for Developmental Biology
> Spemannstr. 35
> D-72076 Tübingen

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net

Reply via email to