Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
kamaki
Commits
6a2a28bd
Commit
6a2a28bd
authored
Jun 28, 2013
by
Stavros Sachtouris
Browse files
Add name and uuid of session user to shell greet
Refs: 3632
parent
f42bcc2d
Changes
2
Hide whitespace changes
Inline
Side-by-side
kamaki/cli/__init__.py
View file @
6a2a28bd
...
...
@@ -473,7 +473,12 @@ def run_one_cmd(exe_string, parser, auth_base, cloud):
def
run_shell
(
exe_string
,
parser
,
auth_base
,
cloud
):
from
command_shell
import
_init_shell
shell
=
_init_shell
(
exe_string
,
parser
)
try
:
username
,
userid
=
(
auth_base
.
user_term
(
'name'
),
auth_base
.
user_term
(
'id'
))
except
Exception
:
username
,
userid
=
''
,
''
shell
=
_init_shell
(
exe_string
,
parser
,
username
,
userid
)
_load_all_commands
(
shell
.
cmd_tree
,
parser
.
arguments
)
shell
.
run
(
auth_base
,
cloud
,
parser
)
...
...
kamaki/cli/command_shell.py
View file @
6a2a28bd
...
...
@@ -46,12 +46,12 @@ from kamaki.cli.logger import add_file_logger
log
=
add_file_logger
(
__name__
)
def
_init_shell
(
exe_string
,
parser
):
def
_init_shell
(
exe_string
,
parser
,
username
=
''
,
userid
=
''
):
parser
.
arguments
.
pop
(
'version'
,
None
)
shell
=
Shell
()
shell
.
set_prompt
(
exe_string
)
from
kamaki
import
__version__
as
version
shell
.
greet
(
version
)
shell
.
greet
(
version
,
username
,
userid
)
shell
.
do_EOF
=
shell
.
do_exit
from
kamaki.cli.command_tree
import
CommandTree
shell
.
cmd_tree
=
CommandTree
(
...
...
@@ -98,7 +98,7 @@ class Shell(Cmd):
return
line
[
1
:]
return
line
def
greet
(
self
,
version
):
def
greet
(
self
,
version
,
username
=
''
,
userid
=
''
):
print
(
'kamaki v%s - Interactive Shell
\n
'
%
version
)
print
(
'
\t
/exit
\t
terminate kamaki'
)
print
(
'
\t
exit or ^D
\t
exit context'
)
...
...
@@ -106,6 +106,8 @@ class Shell(Cmd):
print
(
'
\t
?command
\t
help on command'
)
print
(
'
\t
!<command>
\t
execute OS shell command'
)
print
(
''
)
if
username
or
userid
:
print
(
'Session user is %s (uuid: %s)'
%
(
username
,
userid
))
def
set_prompt
(
self
,
new_prompt
):
self
.
prompt
=
'%s%s%s'
%
(
self
.
_prefix
,
new_prompt
,
self
.
_suffix
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment