<commit_before>"""Perform in-place updates of geminicassandra and databases when installed into virtualenv.
"""
import os
import shutil
import subprocess
import sys

import geminicassandra.config

def release(parser, args):
    """Update geminicassandra to the latest release, along with associated data files.
    """
    url = "https://github.com/bgossele/geminicassandra/master/requirements.txt"
    repo = "https://github.com/bgossele/geminicassandra"
    cbl_repo = "https://github.com/chapmanb/cloudbiolinux.git"
    # update locally isolated python
    base = os.path.dirname(os.path.realpath(sys.executable))
    gemini_cmd = os.path.join(base, "geminicassandra")
    pip_bin = os.path.join(base, "pip")
    fab_cmd = os.path.join(base, "fab")
    activate_bin = os.path.join(base, "activate")
    conda_bin = os.path.join(base, "conda")
    if not args.dataonly:
        if os.path.exists(conda_bin):
            pkgs = ["bx-python", "conda", "cython", "ipython", "jinja2", "nose", "numpy",
                    "pip", "pycrypto", "pyparsing", "pysam", "pyyaml",
                    "pyzmq", "pandas", "scipy", "cassandra-driver", "blist"]
            channels = ["-c", "https://conda.binstar.org/bcbio"]
            subprocess.check_call([conda_bin, "install", "--yes", "numpy"])
            subprocess.check_call([conda_bin, "install", "--yes"] + channels + pkgs)
        elif os.path.exists(activate_bin):
            pass
        else:
            raise NotImplementedError("Can only upgrade geminicassandra installed in anaconda or virtualenv")
        # allow downloads excluded in recent pip (1.5 or greater) versions
        try:
            p = subprocess.Popen([pip_bin, "--version"], stdout=subprocess.PIPE)
            pip_version = p.communicate()[0].split()[1]
        except:
            pip_version = ""
        pip_compat = []
        if pip_version >= "1.5":
            for req in ["python-graph-core", "python-graph-dot"]:
                pip_compat += ["--allow-external", req, "--allow-unverified", req]
        # update libraries
        subprocess.check_call([pip_bin, "install"] + pip_compat + ["-r", url])
        if args.devel:
            print("Installing latest GEMINI development version")
            subprocess.check_call([pip_bin, "install", "--upgrade", "--no-deps",
                                   "git+%s" % repo])
        print "Gemini upgraded to latest version"
    if args.tooldir:
        print "Upgrading associated tools..."
        cbl = get_cloudbiolinux(cbl_repo)
        fabricrc = write_fabricrc(cbl["fabricrc"], args.tooldir, args.sudo)<commit_msg>checkcall fix in gemini_update<commit_after>"""Perform in-place updates of geminicassandra and databases when installed into virtualenv.
"""
import os
import shutil
import subprocess
import sys

import geminicassandra.config

def release(parser, args):
    """Update geminicassandra to the latest release, along with associated data files.
    """
    url = "https://github.com/bgossele/geminicassandra/master/requirements.txt"
    repo = "https://github.com/bgossele/geminicassandra"
    cbl_repo = "https://github.com/chapmanb/cloudbiolinux.git"
    # update locally isolated python
    base = os.path.dirname(os.path.realpath(sys.executable))
    gemini_cmd = os.path.join(base, "geminicassandra")
    pip_bin = os.path.join(base, "pip")
    fab_cmd = os.path.join(base, "fab")
    activate_bin = os.path.join(base, "activate")
    conda_bin = os.path.join(base, "conda")
    if not args.dataonly:
        if os.path.exists(conda_bin):
            pkgs = ["bx-python", "conda", "cython", "ipython", "jinja2", "nose", "numpy",
                    "pip", "pycrypto", "pyparsing", "pysam", "pyyaml",
                    "pyzmq", "pandas", "scipy", "cassandra-driver", "blist"]
            channels = ["-c", "https://conda.binstar.org/bcbio"]
            subprocess.check_call([conda_bin, "install", "--yes", "numpy"])
            subprocess.check_call([conda_bin, "install", "--yes"] + channels + pkgs)
        elif os.path.exists(activate_bin):
            pass
        else:
            raise NotImplementedError("Can only upgrade geminicassandra installed in anaconda or virtualenv")
        # allow downloads excluded in recent pip (1.5 or greater) versions
        try:
            p = subprocess.Popen([pip_bin, "--version"], stdout=subprocess.PIPE)
            pip_version = p.communicate()[0].split()[1]
        except:
            pip_version = ""
        pip_compat = []
        if pip_version >= "1.5":
            for req in ["python-graph-core", "python-graph-dot", "geminicassandra"]:
                pip_compat += ["--allow-external", req, "--allow-unverified", req]
        # update libraries
        subprocess.check_call([pip_bin, "install"] + pip_compat + ["-r", url])
        if args.devel:
            print("Installing latest GEMINI development version")
            subprocess.check_call([pip_bin, "install", "--upgrade", "--no-deps",
                                   "git+%s" % repo])
        print "Gemini upgraded to latest version"
    if args.tooldir:
        print "Upgrading associated tools..."
        cbl = get_cloudbiolinux(cbl_repo)
        fabricrc = write_fabricrc(cbl["fabricrc"], args.tooldir, args.sudo)
{'fraction_non_alphanumeric': 0.1402740768937952, 'fraction_numerical': 0.0026646364674533687, 'mean_word_length': 2.662020905923345, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '499919', 'n_tokens_mistral': 1687, 'n_tokens_neox': 1620, 'n_words': 367}