Skip to content
Snippets Groups Projects
Commit 134a75ef authored by Bob Lantz's avatar Bob Lantz
Browse files

Fix pylint complaint and add natural sort key function.

parent e6d8e974
No related branches found
No related tags found
No related merge requests found
......@@ -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.
output = ''
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
output += data
out += data
popen.poll()
if popen.returncode != None:
break
return output
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 ) ]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment