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


Python RemoteMachineShellConnection.file_starts_with方法代码示例

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


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

示例1: run

# 需要导入模块: from remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from remote.remote_util.RemoteMachineShellConnection import file_starts_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 crashes on {0} ... ".format(info.ip)
             print "erl_crash files under /opt/{0}/var/lib/{0}/".format(server_type)
             core_files.extend(remote.file_starts_with("/opt/{0}/var/lib/{0}/".format(server_type), "erl_crash"))
             print "core* files under /opt/{0}/var/lib/{0}/".format(server_type)
             core_files.extend(remote.file_starts_with("/opt/{0}/var/lib/{0}/".format(server_type), "core"))
             print "core* files under /tmp/"
             core_files.extend(remote.file_starts_with("/tmp/", "core"))
             if core_files:
                 print "found crashes on {0}: {1}".format(info.ip, core_files)
             else:
                 print "crashes not found on {0}".format(info.ip)
             i = 0
             for core_file in core_files:
                 if core_file.find('erl_crash.dump') != -1:
                     #let's just copy that file back
                     erl_crash_file_name = "erlang-{0}-{1}.log".format(self.server.ip, i)
                     remote_path, file_name = os.path.dirname(core_file), os.path.basename(core_file)
                     if remote.get_file(remote_path, file_name, os.path.join(self.path, erl_crash_file_name)):
                         print 'downloaded core file : {0}'.format(core_file)
                         i += 1
                 else:
                     command = "/opt/{0}/bin/tools/cbanalyze-core".format(server_type)
                     core_file_name = "core-{0}-{1}.log".format(self.server.ip, i)
                     core_log_output = "/tmp/{0}".format(core_file_name)
                     output, _ = remote.execute_command('{0} {1} -f {2}'.format(command, core_file, core_log_output))
                     print output
                     remote_path, file_name = os.path.dirname(core_log_output), os.path.basename(core_log_output)
                     if remote.get_file(remote_path, file_name, os.path.join(self.path, core_file_name)):
                         print 'downloaded core file : {0}'.format(core_log_output)
                         i += 1
             if i > 0:
                 command = "mkdir -p /tmp/backup_crash/{0};mv -f /tmp/core* /tmp/backup_crash/{0}; mv -f /opt/{0}/var/lib/{1}/erl_crash.dump* /tmp/backup_crash/{0}".\
                     format(stamp, server_type)
                 print "put all crashes on {0} in 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
                 remote.disconnect()
             if remote:
                 remote.disconnect()
     except Exception as ex:
         print ex
开发者ID:DavidAlphaFox,项目名称:couchbase,代码行数:55,代码来源:getcoredumps.py

示例2: run

# 需要导入模块: from remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from remote.remote_util.RemoteMachineShellConnection import file_starts_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

示例3: RemoteMachineShellConnection

# 需要导入模块: from remote.remote_util import RemoteMachineShellConnection [as 别名]
# 或者: from remote.remote_util.RemoteMachineShellConnection import file_starts_with [as 别名]
from TestInput import TestInputParser

if __name__ == "__main__":
    input = TestInputParser.get_test_input(sys.argv)
    remote = RemoteMachineShellConnection(input.servers[0])
    server_type = 'membase'
    if remote.is_couchbase_installed():
        server_type = 'couchbase'
    for serverInfo in input.servers:
        try:
            remote = RemoteMachineShellConnection(serverInfo)
            info = remote.extract_remote_info()
            if info.type.lower() != 'windows':
                core_files = []
                print "looking for erl_crash files under /opt/{0}/var/lib/{0}/".format(server_type)
                core_files.extend(remote.file_starts_with("/opt/{0}/var/lib/{0}/".format(server_type), "erl_crash"))
                print "looking for core* files under /opt/{0}/var/lib/{0}/".format(server_type)
                core_files.extend(remote.file_starts_with("/opt/{0}/var/lib/{0}/".format(server_type), "core"))
                print "looking for core* files under /tmp/"
                core_files.extend(remote.file_starts_with("/tmp/", "core"))
                i = 0
                for core_file in core_files:
                    if core_file.find('erl_crash.dump') != -1:
                        #let's just copy that file back
                        erl_crash_file_name = "erlang-{0}-{1}.log".format(serverInfo.ip, i)
                        erl_crash_path = "/opt/{0}/var/lib/{0}/{1}".format(server_type, erl_crash_file_name)
                        remote.execute_command('cp {0} {1}'.format(core_file, erl_crash_path))
                        destination = "{0}/{1}".format(os.getcwd(), erl_crash_file_name)
                        if remote.get_file(remotepath="/opt/{0}/var/lib/{0}/".format(server_type),
                                           filename=erl_crash_file_name,
                                           todir=destination):
开发者ID:Boggypop,项目名称:testrunner,代码行数:33,代码来源:getcoredumps.py


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