Commit ed658c90 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Merge branch 'feature-starting-points' into develop

parents 17cfc2f0 c22183b9
......@@ -13,6 +13,8 @@ Changes:
New scheme for ALL <object> <verb> [object id] [--arguments]
e.g., file modidy --metadata-add=revier='Mr. Reviewer' /pithos/myfile.txt
6. Deprecate (with note) server stats/console/addr (move to server info)
7. A vanilla kamaki call now shows only the available commands instead of
loading a shell [#4612]
Features:
......@@ -27,4 +29,5 @@ Features:
network info/list/create/delete/set
subnet info/list/create/set
port info/list/create/delete/set
5. Create a kamaki-shell for kamaki shell [#4612]
......@@ -485,20 +485,58 @@ def set_command_params(parameters):
# CLI Choice:
def run_one_cmd(exe_string, parser, cloud):
global _history
try:
token = parser.arguments['config'].get_cloud(cloud, 'token').split()[0]
except Exception:
token = None
_history = History(
parser.arguments['config'].get('global', 'history_file'), token=token)
_history.add(' '.join([exe_string] + argv[1:]))
from kamaki.cli import one_command
one_command.run(cloud, parser, _help)
def is_non_API(parser):
nonAPIs = ('history', 'config')
for term in parser.unparsed:
if not term.startswith('-'):
if term in nonAPIs:
return True
return False
return False
def main(foo):
def wrap():
try:
exe = basename(argv[0])
parser = ArgumentParseManager(exe)
if parser.arguments['version'].value:
exit(0)
_cnf = parser.arguments['config']
log_file = _cnf.get('global', 'log_file')
if log_file:
logger.set_log_filename(log_file)
global filelog
filelog = logger.add_file_logger(__name__.split('.')[0])
filelog.info('* Initial Call *\n%s\n- - -' % ' '.join(argv))
from kamaki.cli.utils import suggest_missing
global _colors
exclude = ['ansicolors'] if not _colors == 'on' else []
suggest_missing(exclude=exclude)
foo(exe, parser)
except CLIError as err:
print_error_message(err)
if _debug:
raise err
exit(1)
except KeyboardInterrupt:
print('Canceled by user')
exit(1)
except Exception as er:
print('Unknown Error: %s' % er)
if _debug:
raise
exit(1)
return wrap
def run_shell(exe_string, parser, cloud):
@main
def run_shell(exe, parser):
parser.arguments['help'].value = False
cloud = _init_session(parser.arguments)
from command_shell import _init_shell
global kloger
_cnf = parser.arguments['config']
......@@ -508,61 +546,28 @@ def run_shell(exe_string, parser, cloud):
auth_base.user_term('name'), auth_base.user_term('id'))
except Exception:
username, userid = '', ''
shell = _init_shell(exe_string, parser, username, userid)
shell = _init_shell(exe, parser, username, userid)
_load_all_commands(shell.cmd_tree, parser.arguments)
shell.run(auth_base, cloud, parser)
def is_non_API(parser):
nonAPIs = ('history', 'config')
for term in parser.unparsed:
if not term.startswith('-'):
if term in nonAPIs:
return True
return False
return False
def main():
try:
exe = basename(argv[0])
parser = ArgumentParseManager(exe)
if parser.arguments['version'].value:
exit(0)
_cnf = parser.arguments['config']
log_file = _cnf.get('global', 'log_file')
if log_file:
logger.set_log_filename(log_file)
global filelog
filelog = logger.add_file_logger(__name__.split('.')[0])
filelog.info('* Initial Call *\n%s\n- - -' % ' '.join(argv))
cloud = _init_session(parser.arguments, is_non_API(parser))
from kamaki.cli.utils import suggest_missing
global _colors
exclude = ['ansicolors'] if not _colors == 'on' else []
suggest_missing(exclude=exclude)
if parser.unparsed:
run_one_cmd(exe, parser, cloud)
elif _help:
#parser.parser.print_help()
parser.print_help()
_groups_help(parser.arguments)
else:
run_shell(exe, parser, cloud)
except CLIError as err:
print_error_message(err)
if _debug:
raise err
exit(1)
except KeyboardInterrupt:
print('Canceled by user')
exit(1)
except Exception as er:
print('Unknown Error: %s' % er)
if _debug:
raise
exit(1)
@main
def run_one_cmd(exe, parser):
cloud = _init_session(parser.arguments, is_non_API(parser))
if parser.unparsed:
global _history
try:
token = parser.arguments['config'].get_cloud(
cloud, 'token').split()[0]
except Exception:
token = None
_history = History(
parser.arguments['config'].get('global', 'history_file'),
token=token)
_history.add(' '.join([exe] + argv[1:]))
from kamaki.cli import one_command
one_command.run(cloud, parser, _help)
else:
parser.print_help()
_groups_help(parser.arguments)
print('kamaki-shell: An interactive command line shell')
......@@ -103,7 +103,7 @@ class ConfigArgument(Argument):
@property
def value(self):
return super(ConfigArgument, self).value
return getattr(self, '_value', None)
@value.setter
def value(self, config_file):
......
......@@ -291,7 +291,7 @@ class Config(RawConfigParser):
:raises KeyError: if cloud or cloud's option does not exist
"""
r = self.get(CLOUD_PREFIX, cloud)
r = self.get(CLOUD_PREFIX, cloud) if cloud else None
if not r:
raise KeyError('Cloud "%s" does not exist' % cloud)
return r[option]
......
......@@ -62,21 +62,21 @@ setup(
packages=[
'kamaki',
'kamaki.cli',
'kamaki.cli.command_tree',
'kamaki.cli.argument',
'kamaki.cli.config',
'kamaki.cli.utils',
'kamaki.cli.config',
'kamaki.cli.argument',
'kamaki.cli.commands',
'kamaki.cli.command_tree',
'kamaki.clients',
'kamaki.clients.utils',
'kamaki.clients.livetest',
'kamaki.clients.astakos',
'kamaki.clients.image',
'kamaki.clients.storage',
'kamaki.clients.pithos',
'kamaki.clients.astakos',
'kamaki.clients.compute',
'kamaki.clients.network',
'kamaki.clients.cyclades',
'kamaki.clients.network'
'kamaki.clients.livetest',
],
classifiers=[
'Operating System :: OS Independent',
......@@ -93,7 +93,10 @@ setup(
],
include_package_data=True,
entry_points={
'console_scripts': ['kamaki = kamaki.cli:main']
'console_scripts': [
'kamaki = kamaki.cli:run_one_cmd',
'kamaki-shell = kamaki.cli:run_shell'
]
},
install_requires=requires
)
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