Example #1
0
def proof(path, is_bundle, debug):
    path = os.path.abspath(path)
    home_path = utils.get_home()
    if not home_path:  # expansion failed
        return ['Could not determine home directory'], 200
    if not path.startswith(home_path):
        return [
            'For security reasons, only paths under '
            'your home directory can be accessed'
        ], 200
    if not is_bundle:
        try:
            c = Charm(path)
        except:
            try:
                c = Bundle(path, debug)
            except Exception as e:
                return [
                    "FATAL: No bundle.yaml (Bundle) or metadata.yaml "
                    "(Charm) found, cannot proof"
                ], 200
    else:
        try:
            c = Bundle(path, debug)
        except Exception as e:
            return ["FATAL: %s" % e.message], 200

    lint, err_code = c.proof()
    return lint, err_code
Example #2
0
def proof(path, is_bundle=False, with_remote=True, debug=False):
    path = os.path.abspath(path)
    if not is_bundle:
        try:
            c = Charm(path)
        except:
            try:
                c = Bundle(path, debug)
            except Exception as e:
                return ["FATAL: Not a Bundle or a Charm, can not proof"], 200
    else:
        try:
            c = Bundle(path, debug)
        except Exception as e:
            return ["FATAL: %s" % e.strerror], 200

    lint, err_code = c.proof(with_remote)
    return lint, err_code
Example #3
0
def proof(path, is_bundle, debug):
    path = os.path.abspath(path)
    if not is_bundle:
        try:
            c = Charm(path)
        except:
            try:
                c = Bundle(path, debug)
            except Exception as e:
                return ["FATAL: Not a Bundle or a Charm, can not proof"], 200
    else:
        try:
            c = Bundle(path, debug)
        except Exception as e:
            return ["FATAL: %s" % e.message], 200

    lint, err_code = c.proof()
    return lint, err_code
Example #4
0
def proof(path, is_bundle, debug):
    path = os.path.abspath(path)
    if not is_bundle:
        try:
            c = Charm(path)
        except:
            try:
                c = Bundle(path, debug)
            except Exception as e:
                return ["FATAL: No bundle.yaml (Bundle) or metadata.yaml "
                        "(Charm) found, cannot proof"], 200
    else:
        try:
            c = Bundle(path, debug)
        except Exception as e:
            return ["FATAL: %s" % e.message], 200

    lint, err_code = c.proof()
    return lint, err_code
Example #5
0
def proof(path, is_bundle, with_remote, debug, server, port, secure):
    path = os.path.abspath(path)
    if not is_bundle:
        try:
            c = Charm(path)
        except:
            try:
                c = Bundle(path, debug)
            except Exception as e:
                return ["FATAL: Not a Bundle or a Charm, can not proof"], 200
    else:
        try:
            c = Bundle(path, debug)
        except Exception as e:
            return ["FATAL: %s" % e.message], 200

    lint, err_code = c.proof(
        remote=with_remote, server=server, port=port, secure=secure)
    return lint, err_code
Example #6
0
def proof(path, is_bundle, debug):
    messages = []
    exit_code = 0
    path = os.path.abspath(path)
    home_path = utils.get_home()
    home_msg = ('For security reasons, only paths under '
                'your home directory can be accessed')
    if not home_path:  # expansion failed
        messages.append('Could not determine home directory')
        messages.append(home_msg)
    elif not path.startswith(home_path):
        messages.append('The path {} is not under your '
                        'home directory'.format(path))
        messages.append(home_msg)
    if not os.access(path, os.R_OK):
        messages.append('Unable to read from {}'.format(path))
        exit_code = 200
        return messages, exit_code
    if not is_bundle:
        try:
            c = Charm(path)
        except:
            try:
                c = Bundle(path, debug)
            except Exception as e:
                return [
                    "FATAL: No bundle.yaml (Bundle) or metadata.yaml "
                    "(Charm) found, cannot proof"
                ], 200
    else:
        try:
            c = Bundle(path, debug)
        except Exception as e:
            return ["FATAL: %s" % e.message], 200

    lint, err_code = c.proof()
    return lint, err_code