src/cm/utils/system.py
author gibus
Thu, 03 Jan 2013 11:42:46 +0100
changeset 480 b9b802261109
parent 0 40c8f766c9b8
permissions -rw-r--r--
Replace pre_edit stage by an input checkbox to increase performances (compute_new_comment_positions run once).

# taken from plone

import os

bin_search_path = [
    '/usr/bin',
    '/usr/local/bin',
    ]

class MissingBinary(Exception): pass

def bin_search(binary):
    """search the bin_search_path  for a given binary
    returning its fullname or None"""
    result = None
    mode   = os.R_OK | os.X_OK
    for p in bin_search_path:
        path = os.path.join(p, binary)
        if os.access(path, mode) == 1:
            result = path
            break
    else:
        raise MissingBinary('Unable to find binary "%s"' % binary)
    return result