<commit_before>############################################################################
##
## Copyright (C) 2006-2009 University of Utah. All rights reserved.
##
## This file is part of VisTrails.
##
## This file may be used under the terms of the GNU General Public
## License version 2.0 as published by the Free Software Foundation
## and appearing in the file LICENSE.GPL included in the packaging of
## this file.  Please review the following to ensure GNU General Public
## Licensing requirements will be met:
## http://www.opensource.org/licenses/gpl-license.php
##
## If you are unsure which license is appropriate for your use (for
## instance, you are interested in developing a commercial derivative
## of VisTrails), please contact us at <EMAIL>.
##
## This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
## WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
##
############################################################################

"""Routines common to Linux and OSX."""
import os
import os.path
import stat
import subprocess
import sys
import core.utils
import re

def executable_is_in_path(filename):
    """executable_is_in_path(filename): string
    Tests if filename corresponds to an executable file on the path. Returns
the filename if true, or an empty string if false."""
    cmdline = ['which','%s' % filename]
    output = []
    result = execute_cmdline(cmdline, output)
    if result == 256:
        return ""
    if result != 0:
        msg = ("'%s' failed. Return code %s" %
               (cmdline, result))
        raise core.utils.VistrailsInternalError(msg)
    else:
        output = output[0][:-1]
        return output

def executable_is_in_pythonpath(filename):
    """executable_is_in_pythonpath(filename: str)
    Check if exename can be reached in the PYTHONPATH environment. Return
    the filename if true, or an empty string if false.
    
    """
    pathlist = sys.path
    for dir in pathlist:
        fullpath = os.path.join(dir, filename)
        try:
            st = os.stat(fullpath)
        except os.error:
            continue        <commit_msg><ticket>#351</ticket> <bugfix>core.system.executable_in_path now checks the correct error code from core.system.execute_cmdline()</bugfix><commit_after>############################################################################
##
## Copyright (C) 2006-2009 University of Utah. All rights reserved.
##
## This file is part of VisTrails.
##
## This file may be used under the terms of the GNU General Public
## License version 2.0 as published by the Free Software Foundation
## and appearing in the file LICENSE.GPL included in the packaging of
## this file.  Please review the following to ensure GNU General Public
## Licensing requirements will be met:
## http://www.opensource.org/licenses/gpl-license.php
##
## If you are unsure which license is appropriate for your use (for
## instance, you are interested in developing a commercial derivative
## of VisTrails), please contact us at <EMAIL>.
##
## This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
## WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
##
############################################################################

"""Routines common to Linux and OSX."""
import os
import os.path
import stat
import subprocess
import sys
import core.utils
import re

def executable_is_in_path(filename):
    """executable_is_in_path(filename): string
    Tests if filename corresponds to an executable file on the path. Returns
the filename if true, or an empty string if false."""
    cmdline = ['which','%s' % filename]
    output = []
    result = execute_cmdline(cmdline, output)
    if result == 1:
        return ""
    if result != 0:
        msg = ("'%s' failed. Return code %s" %
               (cmdline, result))
        raise core.utils.VistrailsInternalError(msg)
    else:
        output = output[0][:-1]
        return output

def executable_is_in_pythonpath(filename):
    """executable_is_in_pythonpath(filename: str)
    Check if exename can be reached in the PYTHONPATH environment. Return
    the filename if true, or an empty string if false.
    
    """
    pathlist = sys.path
    for dir in pathlist:
        fullpath = os.path.join(dir, filename)
        try:
            st = os.stat(fullpath)
        except os.error:
            continue        
{'fraction_non_alphanumeric': 0.1518844504626495, 'fraction_numerical': 0.007447528774542992, 'mean_word_length': 3.569072164948454, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6249280', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1134, 'n_words': 477}