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


Python RemoteMachineShellConnection.file_ends_with方法代码示例

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


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

示例1: run

# 需要导入模块: from remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from remote.remote_util.RemoteMachineShellConnection import file_ends_with [as 别名]
 def run(self):
     remote = RemoteMachineShellConnection(self.server)
     server_type = 'membase'
     if remote.is_couchbase_installed():
         server_type = 'couchbase'
     stamp = time.strftime("%d_%m_%Y_%H_%M")
     try:
         info = remote.extract_remote_info()
         if info.type.lower() != 'windows':
             core_files = []
             print "looking for Erlang/Memcached crashes on {0} ... ".format(info.ip)
             core_files.extend(remote.file_starts_with("/opt/{0}/var/lib/{0}/".format(server_type), "erl_crash"))
             core_files.extend(remote.file_starts_with("/opt/{0}/var/lib/{0}/".format(server_type), "core"))
             core_files.extend(remote.file_starts_with("/tmp/", "core"))
             core_files.extend(remote.file_ends_with("/opt/{0}/var/lib/{0}/crash".format(server_type), ".dmp"))
             if core_files:
                 print "found dumps on {0}: {1}".format(info.ip, core_files)
                 command = "mkdir -p /tmp/backup_crash/{0};" \
                           "mv -f /tmp/core* /tmp/backup_crash/{0};" \
                           "mv -f /opt/{1}/var/lib/{1}/erl_crash.dump* /tmp/backup_crash/{0}; " \
                           "mv -f /opt/{1}/var/lib/{1}/crash/*.dmp /tmp/backup_crash/{0};".\
                     format(stamp, server_type)
                 print "Moved all dumps on {0} to backup folder: /tmp/backup_crash/{1}".format(self.server.ip, stamp)
                 remote.execute_command(command)
                 output, error = remote.execute_command("ls -la /tmp/backup_crash/{0}".format(stamp))
                 for o in output:
                     print o
                 for core_file in core_files:
                     remote_path, file_name = os.path.dirname(core_file), os.path.basename(core_file)
                     if remote.delete_file(remote_path, file_name):
                         print 'deleted core file : {0}'.format(core_file)
                 remote.disconnect()
             else:
                 print "dump files not found on {0}".format(info.ip)
                 if remote:
                     remote.disconnect()
     except Exception as ex:
         print ex
开发者ID:arod1987,项目名称:testrunner,代码行数:40,代码来源:getcoredumps.py


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