Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mininet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Olaf Bergmann
mininet
Commits
e4c82e52
Commit
e4c82e52
authored
15 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Change Node.monitor() to just return output.
It seems easier to rely on node.waiting for the moment.
parent
a3d89912
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mininet/cli.py
+2
-4
2 additions, 4 deletions
mininet/cli.py
mininet/node.py
+7
-7
7 additions, 7 deletions
mininet/node.py
with
9 additions
and
11 deletions
mininet/cli.py
+
2
−
4
View file @
e4c82e52
...
@@ -209,12 +209,10 @@ def default( self, line ):
...
@@ -209,12 +209,10 @@ def default( self, line ):
rest
=
'
'
.
join
(
rest
)
rest
=
'
'
.
join
(
rest
)
# Run cmd on node:
# Run cmd on node:
node
.
sendCmd
(
rest
,
printPid
=
True
)
node
.
sendCmd
(
rest
,
printPid
=
True
)
while
True
:
while
node
.
waiting
:
try
:
try
:
done
,
data
=
node
.
monitor
()
data
=
node
.
monitor
()
info
(
'
%s
'
%
data
)
info
(
'
%s
'
%
data
)
if
done
:
break
except
KeyboardInterrupt
:
except
KeyboardInterrupt
:
node
.
sendInt
()
node
.
sendInt
()
else
:
else
:
...
...
This diff is collapsed.
Click to expand it.
mininet/node.py
+
7
−
7
View file @
e4c82e52
...
@@ -161,7 +161,8 @@ def sendInt( self ):
...
@@ -161,7 +161,8 @@ def sendInt( self ):
os
.
kill
(
self
.
lastPid
,
signal
.
SIGINT
)
os
.
kill
(
self
.
lastPid
,
signal
.
SIGINT
)
def
monitor
(
self
):
def
monitor
(
self
):
"
Monitor the output of a command, returning (done?, data).
"
"""
Monitor and return the output of a command.
Set self.waiting to False if command has completed.
"""
assert
self
.
waiting
assert
self
.
waiting
self
.
waitReadable
()
self
.
waitReadable
()
data
=
self
.
read
(
1024
)
data
=
self
.
read
(
1024
)
...
@@ -175,11 +176,11 @@ def monitor( self ):
...
@@ -175,11 +176,11 @@ def monitor( self ):
# Look for sentinel/EOF
# Look for sentinel/EOF
if
len
(
data
)
>
0
and
data
[
-
1
]
==
chr
(
127
):
if
len
(
data
)
>
0
and
data
[
-
1
]
==
chr
(
127
):
self
.
waiting
=
False
self
.
waiting
=
False
return
True
,
data
[
:
-
1
]
data
=
data
[
:
-
1
]
elif
chr
(
127
)
in
data
:
elif
chr
(
127
)
in
data
:
self
.
waiting
=
False
self
.
waiting
=
False
return
True
,
data
.
replace
(
chr
(
127
),
''
)
data
=
data
.
replace
(
chr
(
127
),
''
)
return
False
,
data
return
data
def
waitOutput
(
self
,
verbose
=
False
):
def
waitOutput
(
self
,
verbose
=
False
):
"""
Wait for a command to complete.
"""
Wait for a command to complete.
...
@@ -189,9 +190,8 @@ def waitOutput( self, verbose=False ):
...
@@ -189,9 +190,8 @@ def waitOutput( self, verbose=False ):
verbose: print output interactively
"""
verbose: print output interactively
"""
log
=
info
if
verbose
else
debug
log
=
info
if
verbose
else
debug
output
=
''
output
=
''
done
=
False
while
self
.
waiting
:
while
not
done
:
data
=
self
.
monitor
()
done
,
data
=
self
.
monitor
()
output
+=
data
output
+=
data
log
(
data
)
log
(
data
)
return
output
return
output
...
...
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