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
134a75ef
Commit
134a75ef
authored
13 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Fix pylint complaint and add natural sort key function.
parent
e6d8e974
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
mininet/util.py
+10
-4
10 additions, 4 deletions
mininet/util.py
with
10 additions
and
4 deletions
mininet/util.py
+
10
−
4
View file @
134a75ef
...
...
@@ -3,9 +3,9 @@
from
time
import
sleep
from
resource
import
setrlimit
,
RLIMIT_NPROC
,
RLIMIT_NOFILE
from
select
import
poll
,
POLLIN
from
os
import
read
from
subprocess
import
call
,
check_call
,
Popen
,
PIPE
,
STDOUT
from
mininet.log
import
output
,
error
import
re
# Command execution support
...
...
@@ -33,7 +33,7 @@ def oldQuietRun( *cmd ):
# We can't use Popen.communicate() because it uses
# select(), which can't handle
# high file descriptor numbers! poll() can, however.
out
put
=
''
out
=
''
readable
=
poll
()
readable
.
register
(
popen
.
stdout
)
while
True
:
...
...
@@ -41,11 +41,11 @@ def oldQuietRun( *cmd ):
data
=
popen
.
stdout
.
read
(
1024
)
if
len
(
data
)
==
0
:
break
out
put
+=
data
out
+=
data
popen
.
poll
()
if
popen
.
returncode
!=
None
:
break
return
out
put
return
out
# This is a bit complicated, but it enables us to
# monitor commount output as it is happening
...
...
@@ -254,3 +254,9 @@ def fixLimits():
"
Fix ridiculously small resource limits.
"
setrlimit
(
RLIMIT_NPROC
,
(
4096
,
8192
)
)
setrlimit
(
RLIMIT_NOFILE
,
(
16384
,
32768
)
)
def
natural
(
text
):
"
To sort sanely/alphabetically: sorted( l, key=natural )
"
def
num
(
s
):
return
int
(
s
)
if
s
.
isdigit
()
else
text
return
[
num
(
s
)
for
s
in
re
.
split
(
r
'
(\d+)
'
,
text
)
]
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