• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python util.isShellBuiltin函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mininet.util.isShellBuiltin函数的典型用法代码示例。如果您正苦于以下问题:Python isShellBuiltin函数的具体用法?Python isShellBuiltin怎么用?Python isShellBuiltin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了isShellBuiltin函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: sendCmd

 def sendCmd( self, *args, **kwargs ):
     """Send a command, followed by a command to echo a sentinel,
        and return without waiting for the command to complete.
        args: command and arguments, or string
        printPid: print command's PID?"""
     assert not self.waiting
     printPid = kwargs.get( 'printPid', True )
     # Allow sendCmd( [ list ] )
     if len( args ) == 1 and type( args[ 0 ] ) is list:
         cmd = args[ 0 ]
     # Allow sendCmd( cmd, arg1, arg2... )
     elif len( args ) > 0:
         cmd = args
     # Convert to string
     if not isinstance( cmd, str ):
         cmd = ' '.join( [ str( c ) for c in cmd ] )
     if not re.search( r'\w', cmd ):
         # Replace empty commands with something harmless
         cmd = 'echo -n'
     self.lastCmd = cmd
     printPid = printPid and not isShellBuiltin( cmd )
     if len( cmd ) > 0 and cmd[ -1 ] == '&':
         # print ^A{pid}\n{sentinel}
         cmd += ' printf "\\001%d\n\\177" $! \n'
     else:
         # print sentinel
         cmd += '; printf "\\177"'
         if printPid and not isShellBuiltin( cmd ):
             cmd = 'mnexec -p ' + cmd
     self.write( cmd + '\n' )
     self.lastPid = None
     self.waiting = True
开发者ID:RimHaw,项目名称:mn-ccnx,代码行数:32,代码来源:node.py


示例2: default

    def default( self, line ):
        """Called on an input line when the command prefix is not recognized.
        Overridden to run shell commands when a node is the first CLI argument.
        Past the first CLI argument, node names are automatically replaced with
        corresponding IP addrs."""

        first, args, line = self.parseline( line )

        if first in self.mn:
            if not args:
                print "*** Enter a command for node: %s <cmd>" % first
                return
            node = self.mn[ first ]
            rest = args.split( ' ' )
            # Substitute IP addresses for node names in command
            # If updateIP() returns None, then use node name
            rest = [ self.mn[ arg ].defaultIntf().updateIP() or arg
                     if arg in self.mn else arg
                     for arg in rest ]
            rest = ' '.join( rest )
            # Run cmd on node:
            builtin = isShellBuiltin( first )
            node.sendCmd( rest, printPid=( not builtin ) )
            self.waitForNode( node )
        else:
            error( '*** Unknown command: %s\n' % line )
开发者ID:ActiveCK,项目名称:mininet,代码行数:26,代码来源:cli.py


示例3: sendCmd

 def sendCmd( self, *args, **kwargs ):
     """Send a command, followed by a command to echo a sentinel,
        and return without waiting for the command to complete.
        args: command and arguments, or string
        printPid: print command's PID?"""
     assert not self.waiting
     printPid = kwargs.get( 'printPid', True )
     if len( args ) > 0:
         cmd = args
     if not isinstance( cmd, str ):
         cmd = ' '.join( cmd )
     if not re.search( r'\w', cmd ):
         # Replace empty commands with something harmless
         cmd = 'echo -n'
     if len( cmd ) > 0 and cmd[ -1 ] == '&':
         separator = '&'
         cmd = cmd[ :-1 ]
     else:
         separator = ';'
         if printPid and not isShellBuiltin( cmd ):
             cmd = 'mnexec -p ' + cmd
     self.write( cmd + separator + ' printf "\\177" \n' )
     self.lastCmd = cmd
     self.lastPid = None
     self.waiting = True
开发者ID:ssujoysaha,项目名称:myfiles,代码行数:25,代码来源:node.py


示例4: default

    def default( self, line ):
        """Called on an input line when the command prefix is not recognized.
        Overridden to run shell commands when a node is the first CLI argument.
        Past the first CLI argument, node names are automatically replaced with
        corresponding IP addrs."""

        first, args, line = self.parseline( line )
        if args and len(args) > 0 and args[ -1 ] == '\n':
            args = args[ :-1 ]
        rest = args.split( ' ' )

        if first in self.nodemap:
            node = self.nodemap[ first ]
            # Substitute IP addresses for node names in command
            for index in range(len(rest)):
                arg = rest[index]
                if arg in self.nodemap:
                    ip = self.nodemap[arg].IP()
                    if not ip:
                        error('%s is an unreachable, detached host\n' % arg)
                        return
                    rest[index] = ip
            #rest = [ self.nodemap[ arg ].IP()
            #        if arg in self.nodemap else arg
            #        for arg in rest ]
            rest = ' '.join( rest )
            # Run cmd on node:
            builtin = isShellBuiltin( first )
            node.sendCmd( rest, printPid=( not builtin ) )
            self.waitForNode( node )
        else:
            error( '*** Unknown command: %s\n' % first )
开发者ID:sandeephebbani,项目名称:mininet,代码行数:32,代码来源:cli.py


示例5: default

    def default( self, line ):
        """Called on an input line when the command prefix is not recognized.
        Overridden to run shell commands when a component is the first CLI
        argument. Past the first CLI argument, component names are then
        automatically replaced with corresponding node IP addrs."""

        first, args, line = self.parseline( line )
        if not args:
            return
        if args and len(args) > 0 and args[ -1 ] == '\n':
            args = args[ :-1 ]
        rest = args.split( ' ' )

        if first in self.cn:
            comp = self.cn[ first ]
            # Substitute IP addresses for node names in command
            rest = [ self.cn[ arg ].node.defaultIntf().updateIP()
                     if arg in self.cn else arg
                     for arg in rest ]
            rest = ' '.join( rest )
            # Run cmd on node:
            builtin = isShellBuiltin( first )
            comp.node.sendCmd( rest, printPid=( not builtin ) )
            self.waitForNode( comp.node )
        else:
            error( '*** Unknown command: %s\n' % first )
开发者ID:eternia478,项目名称:mininetcetera_public,代码行数:26,代码来源:cms_cli.py


示例6: sendCmd

 def sendCmd(self, *args, **kwargs):
     """Send a command, followed by a command to echo a sentinel,
        and return without waiting for the command to complete.
        args: command and arguments, or string
        printPid: print command's PID? (False)"""
     assert self.shell and not self.waiting
     printPid = kwargs.get('printPid', False)
     # Allow sendCmd( [ list ] )
     if len(args) == 1 and isinstance(args[ 0 ], list):
         cmd = args[ 0 ]
     # Allow sendCmd( cmd, arg1, arg2... )
     elif len(args) > 0:
         cmd = args
     # Convert to string
     if not isinstance(cmd, str):
         cmd = ' '.join([ str(c) for c in cmd ])
     if not re.search(r'\w', cmd):
         # Replace empty commands with something harmless
         cmd = 'echo -n'
     self.lastCmd = cmd
     # if a builtin command is backgrounded, it still yields a PID
     if len(cmd) > 0 and cmd[ -1 ] == '&':
         # print ^A{pid}\n so monitor() can set lastPid
         cmd += ' printf "\\001%d\\012" $! '
     elif printPid and not isShellBuiltin(cmd):
         cmd = 'mnexec -p ' + cmd
     self.write(cmd + '\n')
     self.lastPid = None
     self.waiting = True
开发者ID:intrig-unicamp,项目名称:mininet-wifi,代码行数:29,代码来源:node.py


示例7: sendCmd

 def sendCmd( self, *args, **kwargs ):
     assert self.shell and not self.waiting
     printPid = kwargs.get( 'printPid', True )
     # Allow sendCmd( [ list ] )
     if len( args ) == 1 and isinstance( args[ 0 ], list ):
         cmd = args[ 0 ]
     # Allow sendCmd( cmd, arg1, arg2... )
     elif len( args ) > 0:
         cmd = args
     # Convert to string
     if not isinstance( cmd, str ):
         cmd = ' '.join( [ str( c ) for c in cmd ] )
     if not re.search( r'\w', cmd ):
         # Replace empty commands with something harmless
         cmd = 'echo -n'
     self.lastCmd = cmd
     printPid = printPid and not isShellBuiltin( cmd )
     if len( cmd ) > 0 and cmd[ -1 ] == '&':
         # print ^A{pid}\n{sentinel}
         cmd += ' printf "\\001%d\\012" $! '
     else:
         pass
     self.write( cmd + '\n' )
     self.lastPid = None
     self.waiting = True
开发者ID:25dedezembro,项目名称:p4factory,代码行数:25,代码来源:docker_node.py


示例8: sendCmd

 def sendCmd( self, *args, **kwargs ):
     assert not self.waiting
     printPid = kwargs.get( 'printPid', True )
     if len( args ) == 1 and type( args[ 0 ] ) is list:
         cmd = args[ 0 ]
     elif len( args ) > 0:
         cmd = args
     if not isinstance( cmd, str ):
         cmd = ' '.join( [ str( c ) for c in cmd ] )
     if not re.search( r'\w', cmd ):
         cmd = 'echo -n'
     self.lastCmd = cmd
     printPid = printPid and not isShellBuiltin( cmd )
     if len( cmd ) > 0 and cmd[ -1 ] == '&':
         cmd += ' printf "\\001%d\n\\177" $! \n'
     else:
         cmd += '; printf "\\177"'
     self.write( cmd + '\n' )
     self.lastPid = None
     self.waiting = True
开发者ID:thomasameisel,项目名称:cloud-computing,代码行数:20,代码来源:networking_application.py


示例9: sendCmd

 def sendCmd( self, *args, **kwargs ):
     """Send a command, and return without waiting for the command
        to complete.
        args: command and arguments, or string
        printPid: print command's PID?"""
     assert not self.waiting
     self.serial += 1
     self.write( 'echo __   %s   __\n' % self.serial )
     match = '__ %s __' % self.serial
     buf = ''
     while True:
         i = buf.find( match )
         if i >= 0:
             buf = buf[ i + len( match ): ]
             break
         buf += self.read( 1024 )
     while True:
         if chr( 127 ) in buf:
             break
         buf += self.read( 1024 )
     printPid = kwargs.get( 'printPid', True )
     if len( args ) > 0:
         cmd = args
     if not isinstance( cmd, str ):
         cmd = ' '.join( cmd )
     if not re.search( r'\w', cmd ):
         # Replace empty commands with something harmless
         cmd = 'echo -n'
     if printPid and not isShellBuiltin( cmd ):
         use_mnexec = kwargs.get( 'mn_use_mnexec', True)
         if use_mnexec:
             cmd = 'mnexec -p ' + cmd
         disable_io_buf = kwargs.get( 'mn_disable_io_buf', False)
         if disable_io_buf:
             cmd = 'stdbuf -i0 -o0 -e0 ' + cmd
     self.write( cmd + '\n' )
     wait_flag = kwargs.get( 'mn_wait', True)
     if wait_flag:
         self.lastCmd = cmd
         self.lastPid = None
         self.waiting = True
开发者ID:sandeephebbani,项目名称:mininet,代码行数:41,代码来源:node.py


示例10: default

    def default(self, line):
        """Called on an input line when the command prefix is not recognized.
        Overridden to run shell commands when a node is the first CLI argument.
        Past the first CLI argument, node names are automatically replaced with
        corresponding IP addrs."""

        first, args, line = self.parseline(line)
        if args and len(args) > 0 and args[-1] == "\n":
            args = args[:-1]
        rest = args.split(" ")

        if first in self.nodemap:
            node = self.nodemap[first]
            # Substitute IP addresses for node names in command
            rest = [self.nodemap[arg].IP() if arg in self.nodemap else arg for arg in rest]
            rest = " ".join(rest)
            # Run cmd on node:
            builtin = isShellBuiltin(first)
            node.sendCmd(rest, printPid=(not builtin))
            self.waitForNode(node)
        else:
            error("*** Unknown command: %s\n" % first)
开发者ID:09zwcbupt,项目名称:mininet,代码行数:22,代码来源:cli.py



注:本文中的mininet.util.isShellBuiltin函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.macColonHex函数代码示例发布时间:2022-05-27
下一篇:
Python util.irange函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap