Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cc-node
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
cc-node
Commits
62e4e1ce
Commit
62e4e1ce
authored
9 years ago
by
Antoine Millet
Browse files
Options
Downloads
Patches
Plain Diff
Added stdin argument to execute_command
parent
415a9189
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cloudcontrol/node/host/__init__.py
+5
-3
5 additions, 3 deletions
cloudcontrol/node/host/__init__.py
with
5 additions
and
3 deletions
cloudcontrol/node/host/__init__.py
+
5
−
3
View file @
62e4e1ce
...
...
@@ -278,16 +278,18 @@ class Handler(BasePlugin):
logger
.
debug
(
'
Plugins state saved
'
)
@rpc_handler
def
execute_command
(
self
,
command
):
def
execute_command
(
self
,
command
,
stdin
=
None
):
"""
Execute an arbitrary shell command on the host.
:param string command: shell command to run
:param string stdin: string to use as stdin on command
"""
logger
.
debug
(
'
Executing command %s
'
,
command
)
try
:
remote_command
=
EvPopen
(
self
.
main
,
command
,
close_fds
=
True
,
shell
=
True
,
stdout
=
PIPE
,
stderr
=
STDOUT
)
shell
=
True
,
stdout
=
PIPE
,
stdin
=
PIPE
,
stderr
=
STDOUT
)
except
Exception
:
logger
.
exception
(
'
Error while starting subprocess for executing
'
'
command %s
'
,
command
)
...
...
@@ -296,7 +298,7 @@ class Handler(BasePlugin):
self
.
commands
.
add
(
remote_command
)
try
:
stdout
,
_
=
remote_command
.
communicate
()
stdout
,
_
=
remote_command
.
communicate
(
stdin
)
except
Exception
:
logger
.
exception
(
'
Error while communicating with subprocess for
'
'
command %s
'
,
command
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment