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


Python RemoteMachineShellConnection.execute_cbcollect_info方法代码示例

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


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

示例1: run

# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import execute_cbcollect_info [as 别名]
    def run(self):
        file_name = "%s-%s-diag.zip" % (self.server.ip, time_stamp())
        if not self.local:
            from lib.remote.remote_util import RemoteMachineShellConnection

            remote_client = RemoteMachineShellConnection(self.server)
            print "Collecting logs from %s\n" % self.server.ip
            output, error = remote_client.execute_cbcollect_info(file_name)
            print "\n".join(output)
            print "\n".join(error)

            user_path = "/home/"
            if remote_client.info.distribution_type.lower() == "mac":
                user_path = "/Users/"
            else:
                if self.server.ssh_username == "root":
                    user_path = "/"

            remote_path = "%s%s" % (user_path, self.server.ssh_username)
            status = remote_client.file_exists(remote_path, file_name)
            if not status:
                raise Exception("%s doesn't exists on server" % file_name)
            status = remote_client.get_file(remote_path, file_name, "%s/%s" % (self.path, file_name))
            if status:
                print "Downloading zipped logs from %s" % self.server.ip
            else:
                raise Exception("Fail to download zipped logs from %s" % self.server.ip)
            remote_client.execute_command("rm -f %s" % os.path.join(remote_path, file_name))
            remote_client.disconnect()
开发者ID:pkdevboxy,项目名称:testrunner,代码行数:31,代码来源:collect_server_info.py

示例2: run

# 需要导入模块: from lib.remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from lib.remote.remote_util.RemoteMachineShellConnection import execute_cbcollect_info [as 别名]
    def run(self):
        remote_client = RemoteMachineShellConnection(self.server)
        now = datetime.now()
        day = now.day
        month = now.month
        year = now.year
        hour = now.timetuple().tm_hour
        min = now.timetuple().tm_min
        file_name = "%s-%s%s%s-%s%s-diag.zip" % (self.server.ip,
                                                 month, day, year, hour, min)
        print "Collecting logs from %s\n" % self.server.ip
        output, error = remote_client.execute_cbcollect_info(file_name)
        print "\n".join(output)
        print "\n".join(error)

        user_path = "/home/"
        if self.server.ssh_username == "root":
            user_path = "/"
        remote_path = "%s%s" % (user_path, self.server.ssh_username)
        status = remote_client.file_exists(remote_path, file_name)
        if not status:
            raise Exception("%s doesn't exists on server" % file_name)
        status = remote_client.get_file(remote_path, file_name,
                                        "%s/%s" % (self.path, file_name))
        if status:
            print "Downloading zipped logs from %s" % self.server.ip
        else:
            raise Exception("Fail to download zipped logs from %s"
                            % self.server.ip)
        remote_client.disconnect()
开发者ID:Boggypop,项目名称:testrunner,代码行数:32,代码来源:collect_server_info.py


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