Replace print of warnings to stdout
Selected way of fix: sys.stderr All output of 'Warning" messages has been redirected to sys.stderr from default sys.stdout Change-Id: Id3854390718de75ee0b38cb42b6c2998b7b23118 Closes-bug: #1546444
This commit is contained in:
parent
c45bd4ebb9
commit
4dad6c890b
|
@ -11,6 +11,9 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import sys
|
||||
|
||||
import six
|
||||
|
||||
from fuelclient.cli.actions.base import Action
|
||||
from fuelclient.cli.actions.base import check_all
|
||||
|
@ -93,11 +96,9 @@ class EnvironmentAction(Action):
|
|||
"""
|
||||
|
||||
if params.nst == 'gre':
|
||||
self.serializer.print_to_output(
|
||||
{},
|
||||
six.print_(
|
||||
"WARNING: GRE network segmentation type is deprecated "
|
||||
"since 7.0 release."
|
||||
)
|
||||
"since 7.0 release.", file=sys.stderr)
|
||||
|
||||
env = Environment.create(
|
||||
params.name,
|
||||
|
|
|
@ -12,6 +12,10 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import sys
|
||||
|
||||
import six
|
||||
|
||||
from fuelclient.cli.actions.base import Action
|
||||
from fuelclient.cli.actions.base import check_all
|
||||
import fuelclient.cli.arguments as Args
|
||||
|
@ -113,7 +117,7 @@ class NetworkGroupAction(Action):
|
|||
if len(params.network) > 1:
|
||||
msg = ("Warning: Only first network with id={0}"
|
||||
" will be updated.".format(ng_id))
|
||||
self.serializer.print_to_output({}, msg)
|
||||
six.print_(msg, file=sys.stderr)
|
||||
|
||||
ng = NetworkGroup(ng_id)
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ class EnvCreate(EnvMixIn, base.BaseShowCommand):
|
|||
|
||||
def take_action(self, parsed_args):
|
||||
if parsed_args.nst == 'gre':
|
||||
self.app.stdout.write('WARNING: GRE network segmentation type is '
|
||||
self.app.stderr.write('WARNING: GRE network segmentation type is '
|
||||
'deprecated since 7.0 release')
|
||||
|
||||
new_env = self.client.create(name=parsed_args.name,
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
import os
|
||||
import pkg_resources
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
import six
|
||||
import yaml
|
||||
|
@ -114,8 +115,8 @@ class FuelClientSettings(object):
|
|||
deprecation = deprecation_tpl.format(old_option)
|
||||
replace = '' if new_option is None else replace_tpl.format(new_option)
|
||||
|
||||
six.print_(deprecation, end='')
|
||||
six.print_(replace)
|
||||
six.print_(deprecation, end='', file=sys.stderr)
|
||||
six.print_(replace, file=sys.stderr)
|
||||
|
||||
def _check_deprecated(self):
|
||||
"""Looks for deprecated options in user's configuration."""
|
||||
|
@ -134,7 +135,9 @@ class FuelClientSettings(object):
|
|||
six.print_('WARNING: configuration contains both {old} and '
|
||||
'{new} options set. Since {old} was deprecated, '
|
||||
'only the value of {new} '
|
||||
'will be used.'.format(old=opt, new=new_opt))
|
||||
'will be used.'.format(old=opt, new=new_opt),
|
||||
file=sys.stderr
|
||||
)
|
||||
|
||||
self._print_deprecation_warning(opt, new_opt)
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
# under the License.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
|
@ -78,9 +79,11 @@ class TestSettings(base.UnitTestCase):
|
|||
expected_warings = [mock.call('DEPRECATION WARNING: LISTEN_PORT '
|
||||
'parameter was deprecated and will not '
|
||||
'be supported in the next version of '
|
||||
'python-fuelclient.', end=''),
|
||||
'python-fuelclient.', end='',
|
||||
file=sys.stderr),
|
||||
mock.call(' Please replace this '
|
||||
'parameter with SERVER_PORT')]
|
||||
'parameter with SERVER_PORT',
|
||||
file=sys.stderr)]
|
||||
|
||||
m = mock.mock_open(read_data='LISTEN_PORT: 9000')
|
||||
with mock.patch('fuelclient.fuelclient_settings.open', m):
|
||||
|
@ -99,7 +102,7 @@ class TestSettings(base.UnitTestCase):
|
|||
with mock.patch('fuelclient.fuelclient_settings.open', m):
|
||||
fuelclient_settings.get_settings()
|
||||
|
||||
m_print.assert_has_calls([mock.call(expected_waring)])
|
||||
m_print.assert_has_calls([mock.call(expected_waring, file=sys.stderr)])
|
||||
|
||||
@mock.patch('six.print_')
|
||||
def test_set_deprecated_option_overwrites_unset_new_option(self, m_print):
|
||||
|
|
|
@ -50,7 +50,7 @@ class TestEnvironment(base.UnitTestCase):
|
|||
self.m_request.get('/api/v1/clusters/{0}/'.format(cluster_id),
|
||||
json=cluster_data)
|
||||
|
||||
with mock.patch('sys.stdout', new=moves.cStringIO()) as m_stdout:
|
||||
with mock.patch('sys.stderr', new=moves.cStringIO()) as m_stderr:
|
||||
self.execute(
|
||||
'fuel env create --name test --rel 1 --nst gre'
|
||||
.split()
|
||||
|
@ -58,7 +58,7 @@ class TestEnvironment(base.UnitTestCase):
|
|||
|
||||
self.assertIn("WARNING: GRE network segmentation type is "
|
||||
"deprecated since 7.0 release.",
|
||||
m_stdout.getvalue())
|
||||
m_stderr.getvalue())
|
||||
|
||||
|
||||
class TestEnvironmentOstf(base.UnitTestCase):
|
||||
|
|
|
@ -63,12 +63,12 @@ class TestEnvCommand(test_engine.BaseCLITest):
|
|||
def test_neutron_gre_deprecation_warning(self):
|
||||
args = 'env create -r 1 -nst gre env42'
|
||||
|
||||
with mock.patch('sys.stdout', new=moves.cStringIO()) as m_stdout:
|
||||
with mock.patch('sys.stderr', new=moves.cStringIO()) as m_stderr:
|
||||
self.exec_command(args)
|
||||
self.assertIn(
|
||||
"WARNING: GRE network segmentation type is deprecated "
|
||||
"since 7.0 release",
|
||||
m_stdout.getvalue()
|
||||
m_stderr.getvalue()
|
||||
)
|
||||
|
||||
def test_env_delete(self):
|
||||
|
|
Loading…
Reference in New Issue