src/cm/utils/system.py
author Production Moz <dev@sopinspace.com>
Wed, 26 Jun 2013 23:43:08 +0200
changeset 515 0be906e586e6
parent 0 40c8f766c9b8
permissions -rw-r--r--
Fix south migration problem caused by 0003_update_keys_to_textversion using TextVersion model which is updated only in 0010_auto__add_field_textversion_category_1__add_field_textversion_category, same with 0007_populate_id_key_in_comments using Comment model updated in 0011_auto__add_field_comment_category.

# 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