snoopycrimecop/snoopycrimecop — pull request #2 by joshmoore (2012-12-07 14:20:26+00:00)
Title: Handle virtualenv activation from within script

The jenkins script to run `ome_merge.py` is currently:

```
import urllib
import sys
import os

# In the jobs that have a "src/" directory, we must chdir
if os.path.exists('src'):
os.chdir('src')

# Turn on virtualenv
activate = os.path.join(os.path.expanduser("~"), "sphinx-2.6", "bin", "activate_this.py")
execfile(activate, dict(__file__=activate))

# Download the gist
url = urllib.urlopen(os.environ["SCRIPT_URL"])
script = url.read()
url.close()

# Execute it with our labels
sys.argv.append("--reset")
base = os.environ["BASE"]
sys.argv.append(base)
if os.environ.has_key("EXCLUDE"):
sys.argv.append("--exclude")
exclude_args = os.environ["EXCLUDE"].split()
sys.argv.extend(exclude_args)

exec script
```

We could shorten this by adding an option to pass the venv directly a la:
``
--venv=~/sphinx-2.6
``

Similarly, the chdir to src and the parsing of `SNOOPYCRIMECOP_ARGS` could all be done internally in order to reduce this down to:

``
exec urllib.urlopen(...)
``