Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Carlos Ramos Carreño
slapos.core
Commits
edee0991
Commit
edee0991
authored
Jun 27, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'cliff'
parents
81a46850
0353c365
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
1 deletion
+72
-1
setup.py
setup.py
+2
-0
slapos/cli/console.py
slapos/cli/console.py
+70
-1
No files found.
setup.py
View file @
edee0991
...
@@ -47,6 +47,8 @@ setup(name=name,
...
@@ -47,6 +47,8 @@ setup(name=name,
'cliff'
,
'cliff'
,
'iniparse'
,
'iniparse'
,
'requests'
,
'requests'
,
'ipython'
,
'bpython'
,
]
+
additional_install_requires
,
]
+
additional_install_requires
,
extra_requires
=
{
'docs'
:
(
extra_requires
=
{
'docs'
:
(
'Sphinx'
,
'Sphinx'
,
...
...
slapos/cli/console.py
View file @
edee0991
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import
textwrap
from
slapos.cli.config
import
ClientConfigCommand
from
slapos.cli.config
import
ClientConfigCommand
from
slapos.client
import
init
,
do_console
,
ClientConfig
from
slapos.client
import
init
,
do_console
,
ClientConfig
class
ShellNotFound
(
Exception
):
pass
class
ConsoleCommand
(
ClientConfigCommand
):
class
ConsoleCommand
(
ClientConfigCommand
):
"""
"""
open python console with slap library imported
open python console with slap library imported
...
@@ -32,10 +38,73 @@ class ConsoleCommand(ClientConfigCommand):
...
@@ -32,10 +38,73 @@ class ConsoleCommand(ClientConfigCommand):
ap
.
add_argument
(
'-c'
,
'--cert_file'
,
ap
.
add_argument
(
'-c'
,
'--cert_file'
,
help
=
'SSL Authorisation certificate file'
)
help
=
'SSL Authorisation certificate file'
)
shell
=
ap
.
add_mutually_exclusive_group
()
shell
.
add_argument
(
'-b'
,
'--bpython'
,
action
=
'store_true'
,
help
=
'Use BPython shell if available (default)'
)
shell
.
add_argument
(
'-i'
,
'--ipython'
,
action
=
'store_true'
,
help
=
'Use IPython shell if available'
)
shell
.
add_argument
(
'-p'
,
'--python'
,
action
=
'store_true'
,
help
=
'Use plain Python shell'
)
return
ap
return
ap
def
take_action
(
self
,
args
):
def
take_action
(
self
,
args
):
configp
=
self
.
fetch_config
(
args
)
configp
=
self
.
fetch_config
(
args
)
conf
=
ClientConfig
(
args
,
configp
)
conf
=
ClientConfig
(
args
,
configp
)
local
=
init
(
conf
)
local
=
init
(
conf
)
if
not
any
([
args
.
python
,
args
.
ipython
,
args
.
bpython
]):
args
.
bpython
=
True
if
args
.
ipython
:
try
:
do_ipython_console
(
local
)
except
ShellNotFound
:
self
.
app
.
log
.
info
(
'IPython not available - using plain Python shell'
)
do_console
(
local
)
do_console
(
local
)
elif
args
.
bpython
:
try
:
do_bpython_console
(
local
)
except
ShellNotFound
:
self
.
app
.
log
.
info
(
'bpython not available - using plain Python shell'
)
do_console
(
local
)
else
:
do_console
(
local
)
console_banner
=
"""
\
slapos console allows you interact with slap API. You can play with the global
"slap" object and with the global request() and supply() methods.
examples :
>>> # Request instance
>>> request(kvm, "myuniquekvm")
>>> # Request software installation on owned computer
>>> supply(kvm, "mycomputer")
>>> # Fetch instance informations on already launched instance
>>> request(kvm, "myuniquekvm").getConnectionParameter("url")
"""
def
do_bpython_console
(
local
):
try
:
from
bpython
import
embed
except
ImportError
:
raise
ShellNotFound
embed
(
banner
=
console_banner
,
locals_
=
local
)
def
do_ipython_console
(
local
):
try
:
from
IPython
import
embed
except
ImportError
:
raise
ShellNotFound
embed
(
banner1
=
console_banner
,
user_ns
=
local
)
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