rad-invoke.py revision 3185
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen# CDDL HEADER START
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen# The contents of this file are subject to the terms of the
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen# Common Development and Distribution License (the "License").
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen# You may not use this file except in compliance with the License.
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen# See the License for the specific language governing permissions
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen# and limitations under the License.
b3254619187a08d0ecbdfaf4d251468158287c40Timo Sirainen# When distributing Covered Code, include this CDDL HEADER in each
b3254619187a08d0ecbdfaf4d251468158287c40Timo Sirainen# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b3254619187a08d0ecbdfaf4d251468158287c40Timo Sirainen# If applicable, add the following below this CDDL HEADER, with the
b3254619187a08d0ecbdfaf4d251468158287c40Timo Sirainen# fields enclosed by brackets "[]" replaced with your own identifying
b3254619187a08d0ecbdfaf4d251468158287c40Timo Sirainen# information: Portions Copyright [yyyy] [name of copyright owner]
b3254619187a08d0ecbdfaf4d251468158287c40Timo Sirainen# CDDL HEADER END
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen# progress delay.
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen """Simple subclass to ignore exceptions raised during logging output."""
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen # Ignore exceptions raised during output to stdout/stderr.
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen """Create error message."""
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen if os.getenv("__IPS_INVOKE_IN_RAD") == "true":
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen return {"status": 1, "errors": [{"reason": text}]}
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen """Initialize logger."""
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen # This logger is for delivering JSON result. Use stderr to distinguish
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen # it with progress output.
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen # If this script is used in RAD, only retrieve log levels <= INFO.
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen if os.getenv("__IPS_INVOKE_IN_RAD") == "true":
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen if os.getenv("__IPS_INVOKE_IN_RAD") != "true":
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen return error(_("This script can only be invoked by RAD"))
cbd6cad82e1c9ad60869ad71ae6c42e1af8b10a8Timo Sirainen "hR:?", ["help", "pargs=", "opts=", "prog-delay="])
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen return error(_("illegal global option -- {0} in file: {1}"
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen return error(_("invalid option argument: {0} in file: {1}"
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen return error(_("missing argument in file: {0}").format(
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen return entry.rad_pkg(pargs[0], pargs_json=pargs_json,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen # Ignore python's spurious pipe problems.