mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
dist/common/scripts: pass format variables to colorprint()
When we use str.format() to pass variables on the message it will always causes Exception like "KeyError: 'red'", since the message contains color variables but it's not passed to str.format(). To avoid the error we need to pass all format variables to colorprint() and run str.format() inside the function. Fixes #3649 Signed-off-by: Takuya ASADA <syuu@scylladb.com> Message-Id: <20180803015216.14328-1-syuu@scylladb.com>
This commit is contained in:
2
dist/common/scripts/scylla_ec2_check
vendored
2
dist/common/scripts/scylla_ec2_check
vendored
@@ -43,7 +43,7 @@ if __name__ == '__main__':
|
||||
driver = match.group(1)
|
||||
|
||||
if not en:
|
||||
colorprint('{red}{instance_class} doesn\'t support enahanced networking!{nocolor}'.format(instance_class))
|
||||
colorprint('{red}{instance_class} doesn\'t support enahanced networking!{nocolor}', instance_class=instance_class)
|
||||
print('''To enable enhanced networking, please use the instance type which supports it.
|
||||
More documentation available at:
|
||||
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking''')
|
||||
|
||||
2
dist/common/scripts/scylla_setup
vendored
2
dist/common/scripts/scylla_setup
vendored
@@ -102,7 +102,7 @@ def run_setup_script(name, script):
|
||||
res = run(script, exception=False)
|
||||
if res != 0:
|
||||
if interactive:
|
||||
colorprint('{red}{name} setup failed. Press any key to continue...{nocolor}'.format(name=name))
|
||||
colorprint('{red}{name} setup failed. Press any key to continue...{nocolor}', name=name)
|
||||
input()
|
||||
else:
|
||||
print('{} setup failed.'.format(name))
|
||||
|
||||
6
dist/common/scripts/scylla_util.py
vendored
6
dist/common/scripts/scylla_util.py
vendored
@@ -350,8 +350,10 @@ def is_unused_disk(dev):
|
||||
return False
|
||||
|
||||
CONCOLORS = {'green':'\033[1;32m', 'red':'\033[1;31m', 'nocolor':'\033[0m'}
|
||||
def colorprint(msg):
|
||||
print(msg.format(**CONCOLORS))
|
||||
def colorprint(msg, **kwargs):
|
||||
fmt = dict(CONCOLORS)
|
||||
fmt.update(kwargs)
|
||||
print(msg.format(**fmt))
|
||||
|
||||
def get_mode_cpuset(nic, mode):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user