Fetching scripts

From PyMOLWiki
Jump to: navigation, search

Contents

Overview

I'm considering building in a mechanism for automatically fetching scripts from PyMOLWiki. The goal is to allow users to say

fetch findSurfaceResidues, type=script
findSurfaceResidues doShow=True, cutoff=0.5

The convenience benefits are obvious, especially for new users, and I think that lowering the barrier to script usage will greatly increase both the number of people who use various scripts and the incentive to place scripts on the wiki (especially if the fetch mechanism makes it easy for script authors to provide a citation/DOI/etc.).

Issues

Security

Running untrusted code is trouble. Some ideas

Convenience options

The main benefit is to make things as convenient and easy as possible, especially for new users.

Validation


Format

My guess is that we'll require fetchable scripts to follow a certain format on the wiki pages. That should include some metadata like

I think all of these things should be function attributes

def myScript(a,b,c):
    """ Documentation for myScript goes here """
    myScript.citation = "I. Coder, A Journal, 2011, Vol. 2, Issue 1, pages 64-66"
    myScript.version = 1.2
 
    blah
    blah
 
cmd.extend('myScript',myScript)

Implementation

Github repository

To download and update github scripts

Make a text file "github.sh" and make it executable

chmod u+x github.sh

Put this in the file, modify the first 2 lines

#!/bin/bash -e
pymolscripts=/home/tlinnet/Software/pymol/Pymol-script-repo
pymoldir=/home/tlinnet/Software/pymol
 
if [ -d $pymolscripts ]; then
echo "### Script library exist, updating it ###"
cd $pymolscripts
git pull
fi
 
if [ ! -d $pymolscripts ]; then
echo "### Script library does not exist, downloading it ###"
sudo apt-get install git
git clone https://github.com/tlinnet/Pymol-script-repo.git $pymolscripts
t="'"
if grep -Fxq "import sys" ~/.pymolrc
then
echo "# 'import sys' already exist in ~/.pymolrc #"
else
echo "# Adding 'import sys' to ~/.pymolrc #"
echo "import sys" >> ~/.pymolrc
fi
if grep -Fxq "sys.path.append($t$pymolscripts$t)" ~/.pymolrc
then
echo "# sys.path.append($t$pymolscripts$t) already exist in ~/.pymolrc #"
else
echo "# adding sys.path.append($t$pymolscripts$t) to ~/.pymolrc #"
echo "sys.path.append($t$pymolscripts$t)" >> ~/.pymolrc
fi
fi

Changes to Github repository

You can do it online, https://github.com/tlinnet/Pymol-script-repo

Make yourself a user on https://github.com/

Locate token at: Account settings -> Account admin -> API Token Configure git

git config --global user.name "Your Name"
git config --global user.email you@example.com
git config --global github.token 0123456789yourf0123456789token
cat ~/.gitconfig
git remote show origin
git remote set-url origin https://GITUSERNAME@github.com/GITUSERNAME/Pymol-script-repo.git
git remote show origin

And see cheat sheet here http://help.github.com/git-cheat-sheets/

Scheduling the editing or addition of all files to the next commit

git add .

Checking the status of your repository

git status

Committing files

git commit -m "First import"

Push the changes to remote repository

git push origin master

Read more here

http://learn.github.com/p/intro.html

http://gitref.org/branching/#merge

https://github.com/features/projects/codereview

Test to fetch script from github

ERROR in secure-include.php: URL https://github.com/tlinnet/Pymol-script-repo/blob/master/README not in allowed list.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox