当前位置: 首页>>代码示例>>Python>>正文


Python Shell.cat方法代码示例

本文整理汇总了Python中cloudmesh_client.common.Shell.Shell.cat方法的典型用法代码示例。如果您正苦于以下问题:Python Shell.cat方法的具体用法?Python Shell.cat怎么用?Python Shell.cat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cloudmesh_client.common.Shell.Shell的用法示例。


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

示例1: _grep

# 需要导入模块: from cloudmesh_client.common.Shell import Shell [as 别名]
# 或者: from cloudmesh_client.common.Shell.Shell import cat [as 别名]
 def _grep(self, search, platform):
   if not search:
       search = "'OS_PASSWORD': '[a-zA-Z0-9]+'"
   cmd = "egrep -ri \"{0}\" * | cut -d\":\" -f1 > a.tmp".format(search)
   print("[{0}]:{1}".format(platform, cmd))
   os.system(cmd)
   res = Shell.cat("a.tmp")
   if res:
       print ('[{0}]: [ERROR] PASSWORD(OR SECRET KEY) DETECTED, SEE FILES '
              'BELOW'.format(platform))
       print ("")
       print (res)
   else:
       print ("[{0}]: NO PASSWORD DETECTED".format(platform))
   Shell.rm("a.tmp")
   print ("")
开发者ID:alistairking,项目名称:client,代码行数:18,代码来源:setup-old.py

示例2: do_vbox

# 需要导入模块: from cloudmesh_client.common.Shell import Shell [as 别名]
# 或者: from cloudmesh_client.common.Shell.Shell import cat [as 别名]
def do_vbox(argv):
    """
    ::

      Usage:
        vbox version [--format=FORMAT]
        vbox image list [--format=FORMAT]
        vbox image find NAME
        vbox image add NAME
        vbox vm list [--format=FORMAT] [-v]
        vbox vm delete NAME
        vbox vm config NAME
        vbox vm ip NAME [--all]
        vbox create NAME ([--memory=MEMORY]
                          [--image=IMAGE]
                          [--script=SCRIPT] | list)
        vbox vm boot NAME ([--memory=MEMORY]
                           [--image=IMAGE]
                           [--port=PORT]
                           [--script=SCRIPT] | list)
        vbox vm ssh NAME [-e COMMAND]
    """
    arg = dotdict(docopt(do_vbox.__doc__, argv))
    arg.format = arg["--format"] or "table"
    arg.verbose = arg["-v"]
    arg.all = arg["--all"]

    if arg.version:
        versions = {
            "vagrant": {
               "attribute": "Vagrant Version",
                "version": vagrant.version(),
            },
            "cloudmesh-vbox": {
                "attribute":"cloudmesh vbox Version",
                "version": __version__
            }
        }
        _LIST_PRINT(versions, arg.format)

    elif arg.image and arg.list:
        l = vagrant.image.list(verbose=arg.verbose)
        _LIST_PRINT(l, arg.format, order=["name", "provider", "date"])

    elif arg.image and arg.add:
        l = vagrant.image.add(arg.NAME)
        print(l)

    elif arg.image and arg.find:
        l = vagrant.image.find(arg.NAME)
        print(l)

    elif arg.vm and arg.list:
        l = vagrant.vm.list()
        _LIST_PRINT(l,
                   arg.format,
                   order=["name", "state", "id", "provider", "directory"])

    elif arg.create and arg.list:

        result = Shell.cat("{NAME}/Vagrantfile".format(**arg))
        print (result)

    elif arg.create:

        d = defaults()

        arg.memory = arg["--memory"] or d.memory
        arg.image = arg["--image"] or d.image
        arg.script = arg["--script"] or d.script

        vagrant.vm.create(
            name=arg.NAME,
            memory=arg.memory,
            image=arg.image,
            script=arg.script)

    elif arg.config:

        # arg.NAME
        d = vagrant.vm.info(name=arg.NAME)

        result = Printer.attribute(d, output=arg.format)

        print (result)

    elif arg.ip:

        data = []
        result = vagrant.vm.execute(arg.NAME, "ifconfig")
        if result is not None:
            lines = result.splitlines()[:-1]
            for line in lines:
                if "inet addr" in line:
                    line = line.replace("inet addr", "ip")
                    line = ' '.join(line.split())
                    _adresses = line.split(" ")
                    address = {}
                    for element in _adresses:
                        attribute, value = element.split(":")
#.........这里部分代码省略.........
开发者ID:cloudmesh,项目名称:vagrant,代码行数:103,代码来源:cm_vbox.py


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