Merge "Python 3 using builtins instead of __builtin__, rename raw_input() to input() from six.moves"
This commit is contained in:
commit
647e97e63b
@ -27,6 +27,7 @@ from textwrap import wrap
|
||||
from time import time
|
||||
import optparse
|
||||
import math
|
||||
from six.moves import input
|
||||
|
||||
from swift.common import exceptions
|
||||
from swift.common.ring import RingBuilder, Ring
|
||||
@ -188,8 +189,8 @@ def _set_weight_values(devs, weight):
|
||||
print('Matched more than one device:')
|
||||
for dev in devs:
|
||||
print(' %s' % format_device(dev))
|
||||
if raw_input('Are you sure you want to update the weight for '
|
||||
'these %s devices? (y/N) ' % len(devs)) != 'y':
|
||||
if input('Are you sure you want to update the weight for '
|
||||
'these %s devices? (y/N) ' % len(devs)) != 'y':
|
||||
print('Aborting device modifications')
|
||||
exit(EXIT_ERROR)
|
||||
|
||||
@ -245,8 +246,8 @@ def _set_info_values(devs, change):
|
||||
print('Matched more than one device:')
|
||||
for dev in devs:
|
||||
print(' %s' % format_device(dev))
|
||||
if raw_input('Are you sure you want to update the info for '
|
||||
'these %s devices? (y/N) ' % len(devs)) != 'y':
|
||||
if input('Are you sure you want to update the info for '
|
||||
'these %s devices? (y/N) ' % len(devs)) != 'y':
|
||||
print('Aborting device modifications')
|
||||
exit(EXIT_ERROR)
|
||||
|
||||
@ -732,8 +733,8 @@ swift-ring-builder <builder_file> search
|
||||
print('Matched more than one device:')
|
||||
for dev in devs:
|
||||
print(' %s' % format_device(dev))
|
||||
if raw_input('Are you sure you want to remove these %s '
|
||||
'devices? (y/N) ' % len(devs)) != 'y':
|
||||
if input('Are you sure you want to remove these %s '
|
||||
'devices? (y/N) ' % len(devs)) != 'y':
|
||||
print('Aborting device removals')
|
||||
exit(EXIT_ERROR)
|
||||
|
||||
|
@ -554,11 +554,11 @@ class TestReconCommands(unittest.TestCase):
|
||||
mock.call('=' * 79),
|
||||
]
|
||||
|
||||
with mock.patch('__builtin__.print') as mock_print:
|
||||
with mock.patch('six.moves.builtins.print') as mock_print:
|
||||
cli.disk_usage([('127.0.0.1', 6010)])
|
||||
mock_print.assert_has_calls(default_calls)
|
||||
|
||||
with mock.patch('__builtin__.print') as mock_print:
|
||||
with mock.patch('six.moves.builtins.print') as mock_print:
|
||||
expected_calls = default_calls + [
|
||||
mock.call('LOWEST 5'),
|
||||
mock.call('85.00% 127.0.0.1 sdc1'),
|
||||
@ -568,7 +568,7 @@ class TestReconCommands(unittest.TestCase):
|
||||
cli.disk_usage([('127.0.0.1', 6010)], 0, 5)
|
||||
mock_print.assert_has_calls(expected_calls)
|
||||
|
||||
with mock.patch('__builtin__.print') as mock_print:
|
||||
with mock.patch('six.moves.builtins.print') as mock_print:
|
||||
expected_calls = default_calls + [
|
||||
mock.call('TOP 5'),
|
||||
mock.call('90.00% 127.0.0.1 sdb1'),
|
||||
@ -578,7 +578,7 @@ class TestReconCommands(unittest.TestCase):
|
||||
cli.disk_usage([('127.0.0.1', 6010)], 5, 0)
|
||||
mock_print.assert_has_calls(expected_calls)
|
||||
|
||||
@mock.patch('__builtin__.print')
|
||||
@mock.patch('six.moves.builtins.print')
|
||||
@mock.patch('time.time')
|
||||
def test_replication_check(self, mock_now, mock_print):
|
||||
now = 1430000000.0
|
||||
@ -633,7 +633,7 @@ class TestReconCommands(unittest.TestCase):
|
||||
# that is returned from the recon middleware, thus can't rely on it
|
||||
mock_print.assert_has_calls(default_calls, any_order=True)
|
||||
|
||||
@mock.patch('__builtin__.print')
|
||||
@mock.patch('six.moves.builtins.print')
|
||||
@mock.patch('time.time')
|
||||
def test_load_check(self, mock_now, mock_print):
|
||||
now = 1430000000.0
|
||||
@ -672,7 +672,7 @@ class TestReconCommands(unittest.TestCase):
|
||||
# that is returned from the recon middleware, thus can't rely on it
|
||||
mock_print.assert_has_calls(default_calls, any_order=True)
|
||||
|
||||
@mock.patch('__builtin__.print')
|
||||
@mock.patch('six.moves.builtins.print')
|
||||
@mock.patch('time.time')
|
||||
def test_time_check(self, mock_now, mock_print):
|
||||
now = 1430000000.0
|
||||
@ -704,7 +704,7 @@ class TestReconCommands(unittest.TestCase):
|
||||
# that is returned from the recon middleware, thus can't rely on it
|
||||
mock_print.assert_has_calls(default_calls, any_order=True)
|
||||
|
||||
@mock.patch('__builtin__.print')
|
||||
@mock.patch('six.moves.builtins.print')
|
||||
@mock.patch('time.time')
|
||||
def test_time_check_mismatch(self, mock_now, mock_print):
|
||||
now = 1430000000.0
|
||||
|
@ -1552,7 +1552,7 @@ class TestRingBuilder(unittest.TestCase):
|
||||
self.assertEquals(loaded_rb.to_dict(), rb.to_dict())
|
||||
self.assertEquals(loaded_rb.overload, 3.14159)
|
||||
|
||||
@mock.patch('__builtin__.open', autospec=True)
|
||||
@mock.patch('six.moves.builtins.open', autospec=True)
|
||||
@mock.patch('swift.common.ring.builder.pickle.dump', autospec=True)
|
||||
def test_save(self, mock_pickle_dump, mock_open):
|
||||
mock_open.return_value = mock_fh = mock.MagicMock()
|
||||
|
@ -3446,7 +3446,7 @@ class TestECDiskFile(DiskFileMixin, unittest.TestCase):
|
||||
'Content-Length': '0',
|
||||
}
|
||||
writer.put(metadata)
|
||||
with mock.patch('__builtin__.open', mock_open):
|
||||
with mock.patch('six.moves.builtins.open', mock_open):
|
||||
self.assertRaises(expected_exception,
|
||||
writer.commit,
|
||||
timestamp)
|
||||
@ -3493,7 +3493,7 @@ class TestECDiskFile(DiskFileMixin, unittest.TestCase):
|
||||
'Content-Length': '0',
|
||||
}
|
||||
writer.put(metadata)
|
||||
with mock.patch('__builtin__.open', mock_open):
|
||||
with mock.patch('six.moves.builtins.open', mock_open):
|
||||
self.assertRaises(expected_exception,
|
||||
writer.commit,
|
||||
timestamp)
|
||||
|
Loading…
x
Reference in New Issue
Block a user