MCPcopy Create free account
hub / github.com/mininet/mininet / popen

Method popen

mininet/node.py:397–423  ·  view source on GitHub ↗

Return a Popen() object in our namespace args: Popen() args, single list, or string kwargs: Popen() keyword args

( self, *args, **kwargs )

Source from the content-addressed store, hash-verified

395 return self.cmd( *args, **{ 'verbose': True } )
396
397 def popen( self, *args, **kwargs ):
398 """Return a Popen() object in our namespace
399 args: Popen() args, single list, or string
400 kwargs: Popen() keyword args"""
401 defaults = { 'stdout': PIPE, 'stderr': PIPE,
402 'mncmd':
403 [ 'mnexec', '-da', str( self.pid ) ] }
404 defaults.update( kwargs )
405 shell = defaults.pop( 'shell', False )
406 if len( args ) == 1:
407 if isinstance( args[ 0 ], list ):
408 # popen([cmd, arg1, arg2...])
409 cmd = args[ 0 ]
410 elif isinstance( args[ 0 ], BaseString ):
411 # popen("cmd arg1 arg2...")
412 cmd = [ args[ 0 ] ] if shell else args[ 0 ].split()
413 else:
414 raise Exception( 'popen() requires a string or list' )
415 elif len( args ) > 0:
416 # popen( cmd, arg1, arg2... )
417 cmd = list( args )
418 if shell:
419 cmd = [ os.environ[ 'SHELL' ], '-c' ] + [ ' '.join( cmd ) ]
420 # Attach to our namespace using mnexec -a
421 cmd = defaults.pop( 'mncmd' ) + cmd
422 popen = self._popen( cmd, **defaults )
423 return popen
424
425 def pexec( self, *args, **kwargs ):
426 """Execute a command using popen

Callers 5

pexecMethod · 0.95
tunnelX11Function · 0.45
makeTermFunction · 0.45
runX11Function · 0.45
popenMethod · 0.45

Calls 1

_popenMethod · 0.95

Tested by

no test coverage detected