本文整理汇总了Python中mininet.node.Host.popen方法的典型用法代码示例。如果您正苦于以下问题:Python Host.popen方法的具体用法?Python Host.popen怎么用?Python Host.popen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.node.Host
的用法示例。
在下文中一共展示了Host.popen方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: popen
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import popen [as 别名]
def popen( self, *args, **kwargs ):
"""Return a Popen() object in node's namespace
args: Popen() args, single list, or string
kwargs: Popen() keyword args"""
# Tell mnexec to execute command in our cgroup
mncmd = [ 'docker', 'attach', "mininet-"+self.name ]
return Host.popen( self, *args, mncmd=mncmd, **kwargs )
示例2: popen
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import popen [as 别名]
def popen( self, *args, **kwargs ):
"Popen with chroot support"
chroot = kwargs.pop( 'chroot', True )
mncmd = kwargs.get( 'mncmd',
[ 'mnexec', '-a', str( self.pid ) ] )
if chroot:
mncmd = [ 'chroot', self.root ] + mncmd
kwargs[ 'mncmd' ] = mncmd
return Host.popen( self, *args, **kwargs )
示例3: popen
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import popen [as 别名]
def popen(self, *args, **params):
if len(args) == 1:
if isinstance(args[0], list):
# popen([cmd, arg1, arg2...])
cmd = args[0]
elif isinstance(args[0], basestring):
# popen("cmd arg1 arg2...")
cmd = args[0].split()
else:
raise TypeError('popen() requires a string or list')
elif len(args) > 0:
# popen( cmd, arg1, arg2... )
cmd = list(args)
if cmd[0][0] != '/' and cmd[0] != 'which':
cmdPath, _, whichExit = self.pexec('which', cmd[0])
if whichExit == 0:
cmd[0] = cmdPath.rstrip()
env = self.env
env.update(params.get('env', {}))
env['HOME'] = '/root'
params['env'] = env
return Host.popen(self, cmd, **params)
示例4: popen
# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import popen [as 别名]
def popen( self, *args, **kwargs ):
mncmd = [ 'docker', 'attach', ""+self.name ]
return Host.popen( self, *args, mncmd=mncmd, **kwargs )