Commit 534e7bbb authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Remove reference to Config.get/set_global

parent 8fb0acd2
......@@ -244,7 +244,7 @@ def _init_session(arguments, is_non_API=False):
_check_config_version(_cnf.value)
global _colors
_colors = _cnf.value.get_global('colors')
_colors = _cnf.value.get('global', 'colors')
if not (stdout.isatty() and _colors == 'on'):
from kamaki.cli.utils import remove_colors
remove_colors()
......@@ -473,7 +473,7 @@ def set_command_params(parameters):
def run_one_cmd(exe_string, parser, cloud):
global _history
_history = History(parser.arguments['config'].get_global('history_file'))
_history = History(parser.arguments['config'].get('global', 'history_file'))
_history.add(' '.join([exe_string] + argv[1:]))
from kamaki.cli import one_command
one_command.run(cloud, parser, _help)
......@@ -515,7 +515,7 @@ def main():
exit(0)
_cnf = parser.arguments['config']
log_file = _cnf.get_global('log_file')
log_file = _cnf.get('global', 'log_file')
if log_file:
logger.set_log_filename(log_file)
global filelog
......
......@@ -126,7 +126,7 @@ class ConfigArgument(Argument):
k.endswith(suffix))]
def get_global(self, option):
return self.value.get_global(option)
return self.value.get('global', option)
def get_cloud(self, cloud, option):
return self.value.get_cloud(cloud, option)
......
......@@ -152,9 +152,9 @@ class ConfigArgument(TestCase):
('config_cli', 'config'),
('image_cli', 'image'),
('history_cli', 'history')):
with patch('%s.get_global' % cnf_path, return_value=v) as gg:
with patch('%s.get' % cnf_path, return_value=v) as gg:
self.assertEqual(c.get_global(k), v)
self.assertEqual(gg.mock_calls[-1], call(k))
self.assertEqual(gg.mock_calls[-1], call('global', k))
def test_get_cloud(self):
c = argument._config_arg
......
......@@ -305,7 +305,7 @@ class Shell(Cmd):
self.cloud = cloud
self._parser = parser
self._history = History(
parser.arguments['config'].get_global('history_file'))
parser.arguments['config'].get('global', 'history_file'))
if path:
cmd = self.cmd_tree.get_command(path)
intro = cmd.path.replace('_', ' ')
......
......@@ -155,26 +155,26 @@ class _command_init(object):
def _set_log_params(self):
try:
self.client.LOG_TOKEN = (
self['config'].get_global('log_token').lower() == 'on')
self['config'].get('global', 'log_token').lower() == 'on')
except Exception as e:
log.debug('Failed to read custom log_token setting:'
'%s\n default for log_token is off' % e)
try:
self.client.LOG_DATA = (
self['config'].get_global('log_data').lower() == 'on')
self['config'].get('global', 'log_data').lower() == 'on')
except Exception as e:
log.debug('Failed to read custom log_data setting:'
'%s\n default for log_data is off' % e)
try:
self.client.LOG_PID = (
self['config'].get_global('log_pid').lower() == 'on')
self['config'].get('global', 'log_pid').lower() == 'on')
except Exception as e:
log.debug('Failed to read custom log_pid setting:'
'%s\n default for log_pid is off' % e)
def _update_max_threads(self):
if getattr(self, 'client', None):
max_threads = int(self['config'].get_global('max_threads'))
max_threads = int(self['config'].get('global', 'max_threads'))
assert max_threads > 0, 'invalid max_threads config option'
self.client.MAX_THREADS = max_threads
......
......@@ -75,7 +75,7 @@ class _init_history(_command_init):
@errors.generic.all
@errors.history.init
def _run(self):
self.history = History(self.config.get_global('history_file'))
self.history = History(self.config.get('global', 'history_file'))
def main(self):
self._run()
......
......@@ -292,9 +292,6 @@ class Config(RawConfigParser):
raise KeyError('Cloud "%s" does not exist' % cloud)
return r[option]
def get_global(self, option):
return self.get('global', option)
def set_cloud(self, cloud, option, value):
try:
d = self.get(CLOUD_PREFIX, cloud) or dict()
......@@ -303,9 +300,6 @@ class Config(RawConfigParser):
d[option] = value
self.set(CLOUD_PREFIX, cloud, d)
def set_global(self, option, value):
self.set('global', option, value)
def _load_defaults(self):
for section, options in DEFAULTS.items():
for option, val in options.items():
......
......@@ -300,14 +300,6 @@ class Config(TestCase):
with patch('kamaki.cli.config.Config.get', return_value=0) as get:
self.assertRaises(KeyError, _cnf.get_cloud, 'mycloud', 'opt1')
def test_get_global(self):
from kamaki.cli.config import Config
_cnf = Config(path=self.f.name)
with patch('kamaki.cli.config.Config.get', return_value='val') as get:
self.assertEqual('val', _cnf.get_global('opt'))
get.assert_called_once_with('global', 'opt')
@patch('kamaki.cli.config.Config.set')
def test_set_cloud(self, c_set):
from kamaki.cli.config import Config, CLOUD_PREFIX
......@@ -336,14 +328,6 @@ class Config(TestCase):
self.assertEqual(
c_set.mock_calls[-1], call(CLOUD_PREFIX, 'mycloud', d))
def test_set_global(self):
from kamaki.cli.config import Config
_cnf = Config(path=self.f.name)
with patch('kamaki.cli.config.Config.set') as c_set:
_cnf.set_global('opt', 'val')
c_set.assert_called_once_with('global', 'opt', 'val')
def test__load_defaults(self):
from kamaki.cli.config import Config, DEFAULTS
_cnf = Config(path=self.f.name)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment