Files
python-tripleoclient/tripleoclient/command.py
Cédric Jeanneret 88d3dfd5e7 Ensure created symlink is in $PATH
With "sudo", the $PATH is overriden an really basic:
PATH=/sbin:/bin:/usr/sbin:/usr/bin
It doesn't list the /usr/local/(s)bin, hence the created
symlink wasn't seen by the script.

It also push that symlink creation in the __new__ special
method in order to make it cleaner.

Finaly, it takes care of lint/pep8 failures, not related to
this change (how is that even possible?!)

Co-Authored-By: Natal Ngétal <hobbestigrou@erakis.eu>
Closes-Bug: 1817365
Partial-Bug: 1816446

Change-Id: If09eb32f43b2c26c8cd8a89f2e862db1dd91dfed
2019-02-27 01:33:51 +00:00

57 lines
1.9 KiB
Python

# Copyright 2017 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from argparse import _StoreAction
import logging
from osc_lib.command import command
from tripleoclient import utils
class Command(command.Command):
log = logging.getLogger(__name__ + ".Command")
def run(self, parsed_args):
utils.store_cli_param(self.cmd_name, parsed_args)
try:
super(Command, self).run(parsed_args)
except Exception:
self.log.exception("Exception occured while running the command")
raise
class Lister(Command, command.Lister):
pass
class DeprecatedActionStore(_StoreAction):
"""To deprecated an option an store the value"""
log = logging.getLogger(__name__)
def __call__(self, parser, namespace, values, option_string=None):
"""Display the warning message"""
if len(self.option_strings) == 1:
message = 'The option {option} is deprecated, it will be removed'\
' in a future version'.format(
option=self.option_strings[0])
else:
option = ', '.join(self.option_strings)
message = 'The options {option} is deprecated, it will be removed'\
' in a future version'.format(option=option)
self.log.warning(message)
super(DeprecatedActionStore, self).__call__(
parser, namespace, values, option_string)