Setup deprecate msg for command.py

This could be a miss when we use osc_lib first in OSC.
command.py has been moved to osc_lib, and should reuse
it and print a deprecate msg if the old file is used.

Change-Id: Ibc35659f6f78b8f5e3c6026db2644a876ef7c549
This commit is contained in:
Tang Chen 2016-06-15 19:39:16 +08:00 committed by Steve Martinelli
parent 0ec711c640
commit ec630e033a

View File

@ -12,45 +12,15 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import abc # NOTE(dtroyer): This file is deprecated in Jun 2016, remove after 4.x release
import logging # or Jun 2017.
from cliff import command import sys
from cliff import lister
from cliff import show
from osc_lib import exceptions
import six
from openstackclient.i18n import _ from osc_lib.command import * # noqa
class CommandMeta(abc.ABCMeta): sys.stderr.write(
"WARNING: %s is deprecated and will be removed after Jun 2017. "
def __new__(mcs, name, bases, cls_dict): "Please use osc_lib.command\n" % __name__
if 'log' not in cls_dict: )
cls_dict['log'] = logging.getLogger(
cls_dict['__module__'] + '.' + name)
return super(CommandMeta, mcs).__new__(mcs, name, bases, cls_dict)
@six.add_metaclass(CommandMeta)
class Command(command.Command):
def run(self, parsed_args):
self.log.debug('run(%s)', parsed_args)
return super(Command, self).run(parsed_args)
def validate_os_beta_command_enabled(self):
if not self.app.options.os_beta_command:
msg = _('Caution: This is a beta command and subject to '
'change. Use global option --os-beta-command '
'to enable this command.')
raise exceptions.CommandError(msg)
class Lister(Command, lister.Lister):
pass
class ShowOne(Command, show.ShowOne):
pass