Merge "Fix the inconsistent use of printing errors"
This commit is contained in:
commit
076771462c
@ -560,7 +560,7 @@ def print_obj(datafile, check_etag=True, swift_dir='/etc/swift',
|
||||
if (policy_index is not None and
|
||||
policy_index_for_name is not None and
|
||||
policy_index != policy_index_for_name):
|
||||
print('Warning: Ring does not match policy!')
|
||||
print('WARNING: Ring does not match policy!')
|
||||
print('Double check your policy name!')
|
||||
if not ring and policy_index_for_name:
|
||||
ring = POLICIES.get_object_ring(policy_index_for_name,
|
||||
@ -652,9 +652,9 @@ def print_item_locations(ring, ring_name=None, account=None, container=None,
|
||||
policy = POLICIES.get_by_name(policy_name)
|
||||
if policy:
|
||||
if ring_name != policy.ring_name:
|
||||
print('Warning: mismatch between ring and policy name!')
|
||||
print('WARNING: mismatch between ring and policy name!')
|
||||
else:
|
||||
print('Warning: Policy %s is not valid' % policy_name)
|
||||
print('WARNING: Policy %s is not valid' % policy_name)
|
||||
|
||||
policy_index = None
|
||||
if ring is None and (obj or part):
|
||||
@ -698,7 +698,7 @@ def print_item_locations(ring, ring_name=None, account=None, container=None,
|
||||
ring = Ring(swift_dir, ring_name='container')
|
||||
else:
|
||||
if ring_name != 'container':
|
||||
print('Warning: account/container specified ' +
|
||||
print('WARNING: account/container specified ' +
|
||||
'but ring not named "container"')
|
||||
if account and not container and not obj:
|
||||
loc = 'accounts'
|
||||
@ -706,7 +706,7 @@ def print_item_locations(ring, ring_name=None, account=None, container=None,
|
||||
ring = Ring(swift_dir, ring_name='account')
|
||||
else:
|
||||
if ring_name != 'account':
|
||||
print('Warning: account specified ' +
|
||||
print('WARNING: account specified ' +
|
||||
'but ring not named "account"')
|
||||
|
||||
if account:
|
||||
@ -761,7 +761,7 @@ def run_print_info(db_type, args, opts):
|
||||
except (sqlite3.OperationalError, LockTimeout) as e:
|
||||
if not opts.get('stale_reads_ok'):
|
||||
opts['stale_reads_ok'] = True
|
||||
print('Warning: Possibly Stale Data')
|
||||
print('WARNING: Possibly Stale Data')
|
||||
run_print_info(db_type, args, opts)
|
||||
sys.exit(2)
|
||||
else:
|
||||
|
@ -736,7 +736,7 @@ def _fix_gaps(broker, args, paths_with_gaps):
|
||||
print(' gap can be fixed by expanding neighbor range:')
|
||||
_print_shard_range(expanding_range, 3)
|
||||
else:
|
||||
print('Warning: cannot fix gap: non-ACTIVE neighbors')
|
||||
print('WARNING: cannot fix gap: non-ACTIVE neighbors')
|
||||
|
||||
if args.max_expanding >= 0:
|
||||
solutions = solutions[:args.max_expanding]
|
||||
|
@ -22,7 +22,7 @@ from operator import itemgetter
|
||||
from os import mkdir
|
||||
from os.path import basename, abspath, dirname, exists, join as pathjoin
|
||||
import sys
|
||||
from sys import argv as sys_argv, exit, stderr, stdout
|
||||
from sys import argv as sys_argv, exit, stdout
|
||||
from textwrap import wrap
|
||||
from time import time
|
||||
import traceback
|
||||
@ -159,8 +159,8 @@ def _parse_add_values(argvish):
|
||||
dev_dict = parse_add_value(devstr)
|
||||
|
||||
if dev_dict['region'] is None:
|
||||
stderr.write('WARNING: No region specified for %s. '
|
||||
'Defaulting to region 1.\n' % devstr)
|
||||
print('WARNING: No region specified for %s. '
|
||||
'Defaulting to region 1.\n' % devstr, file=sys.stderr)
|
||||
dev_dict['region'] = 1
|
||||
|
||||
if dev_dict['replication_ip'] is None:
|
||||
@ -1300,9 +1300,9 @@ swift-ring-builder <builder_file> write_ring
|
||||
ring_data = builder.get_ring()
|
||||
if not ring_data._replica2part2dev_id:
|
||||
if ring_data.devs:
|
||||
print('Warning: Writing a ring with no partition '
|
||||
print('WARNING: Writing a ring with no partition '
|
||||
'assignments but with devices; did you forget to run '
|
||||
'"rebalance"?')
|
||||
'"rebalance"?', file=sys.stderr)
|
||||
ring_data.save(
|
||||
pathjoin(backup_dir, '%d.' % time() + basename(ring_file)))
|
||||
ring_data.save(ring_file)
|
||||
@ -1324,8 +1324,8 @@ swift-ring-builder <ring_file> write_builder [min_part_hours]
|
||||
if len(argv) > 3:
|
||||
min_part_hours = int(argv[3])
|
||||
else:
|
||||
stderr.write("WARNING: default min_part_hours may not match "
|
||||
"the value in the lost builder.\n")
|
||||
print("WARNING: default min_part_hours may not match "
|
||||
"the value in the lost builder.\n", file=sys.stderr)
|
||||
min_part_hours = 24
|
||||
ring = Ring(ring_file)
|
||||
for dev in ring.devs:
|
||||
|
@ -308,7 +308,7 @@ class RateLimitMiddleware(object):
|
||||
self.memcache_client = cache_from_env(env)
|
||||
if not self.memcache_client:
|
||||
self.logger.warning(
|
||||
'Warning: Cannot ratelimit without a memcached client')
|
||||
'Cannot ratelimit without a memcached client')
|
||||
return self.app(env, start_response)
|
||||
try:
|
||||
version, account, container, obj = req.split_path(1, 4, True)
|
||||
|
@ -550,7 +550,7 @@ Shard Ranges (3):
|
||||
# Test mismatch of ring and policy name (valid policy)
|
||||
self.assertRaises(InfoSystemExit, print_item_locations,
|
||||
objring, policy_name='zero')
|
||||
self.assertIn('Warning: mismatch between ring and policy name!',
|
||||
self.assertIn('WARNING: mismatch between ring and policy name!',
|
||||
out.getvalue())
|
||||
self.assertIn('No target specified', out.getvalue())
|
||||
|
||||
@ -561,7 +561,7 @@ Shard Ranges (3):
|
||||
objring = ring.Ring(self.testdir, ring_name='object')
|
||||
self.assertRaises(InfoSystemExit, print_item_locations,
|
||||
objring, policy_name=policy_name)
|
||||
exp_msg = 'Warning: Policy %s is not valid' % policy_name
|
||||
exp_msg = 'WARNING: Policy %s is not valid' % policy_name
|
||||
self.assertIn(exp_msg, out.getvalue())
|
||||
self.assertIn('No target specified', out.getvalue())
|
||||
|
||||
@ -598,7 +598,7 @@ Shard Ranges (3):
|
||||
print_item_locations(account_ring, account=account)
|
||||
exp_msg = 'Account \t%s' % account
|
||||
self.assertIn(exp_msg, out.getvalue())
|
||||
exp_warning = 'Warning: account specified ' + \
|
||||
exp_warning = 'WARNING: account specified ' + \
|
||||
'but ring not named "account"'
|
||||
self.assertIn(exp_warning, out.getvalue())
|
||||
exp_acct_msg = 'Account \t%s' % account
|
||||
@ -1385,7 +1385,7 @@ class TestPrintObjFullMeta(TestCliInfoBase):
|
||||
out = StringIO()
|
||||
with mock.patch('sys.stdout', out):
|
||||
print_obj(self.datafile, policy_name='two', swift_dir=self.testdir)
|
||||
ring_alert_msg = 'Warning: Ring does not match policy!'
|
||||
ring_alert_msg = 'WARNING: Ring does not match policy!'
|
||||
self.assertIn(ring_alert_msg, out.getvalue())
|
||||
|
||||
def test_valid_etag(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user