RemoteFileUtil

public class RemoteFileUtil
extends Object

java.lang.Object
   ↳ com.android.tradefed.util.RemoteFileUtil


用來處理遠端執行個體檔案的公用程式類別

摘要

公用建構函式

RemoteFileUtil()

公用方法

static boolean doesRemoteFileExist(String host, String user, File sshPrivateKey, IRunUtil runUtil, long timeout, String remotePath)

檢查遠端執行個體上是否有檔案 (或目錄)

static boolean doesRemoteFileExist(String host, String user, File sshPrivateKey, IRunUtil runUtil, long timeout, String remotePath, String sshPortNumber)

檢查遠端執行個體上是否有檔案 (或目錄)

static boolean fetchRemoteDir(String host, String user, File sshPrivateKey, IRunUtil runUtil, long timeout, String remoteDirPath, File localDir)

從遠端主機擷取遠端目錄。

static File fetchRemoteDir(String host, String user, File sshPrivateKey, IRunUtil runUtil, long timeout, String remoteDirPath)

從遠端主機擷取遠端目錄。

static File fetchRemoteDir(String host, String user, File sshPrivateKey, List<String> scpArgs, IRunUtil runUtil, long timeout, String remoteDirPath)

從遠端主機擷取遠端目錄。

static boolean fetchRemoteDir(String host, String user, File sshPrivateKey, List<String> scpArgs, IRunUtil runUtil, long timeout, String remoteDirPath, File localDir)

從遠端主機擷取遠端目錄。

static File fetchRemoteFile(String host, String user, File sshPrivateKey, List<String> scpArgs, IRunUtil runUtil, long timeout, String remoteFilePath)

在容器執行個體中擷取遠端檔案。

static File fetchRemoteFile(String host, String user, File sshPrivateKey, IRunUtil runUtil, long timeout, String remoteFilePath)

在容器執行個體中擷取遠端檔案。

static boolean fetchRemoteFile(String host, String user, File sshPrivateKey, List<String> scpArgs, IRunUtil runUtil, long timeout, String remoteFilePath, File localFile)

在裝置或容器例項中擷取遠端檔案。

static boolean fetchRemoteFile(String host, String user, File sshPrivateKey, IRunUtil runUtil, long timeout, String remoteFilePath, File localFile)

在裝置或容器例項中擷取遠端檔案。

static boolean pushFileToRemote(String host, String user, File sshPrivateKey, List<String> scpArgs, IRunUtil runUtil, long timeout, String remoteFilePath, File localFile)

將本機主機的 File 推送至遠端執行個體

公用建構函式

RemoteFileUtil

public RemoteFileUtil ()

公用方法

doesRemoteFileExist

public static boolean doesRemoteFileExist (String host, 
                String user, 
                File sshPrivateKey, 
                IRunUtil runUtil, 
                long timeout, 
                String remotePath)

檢查遠端執行個體上是否有檔案 (或目錄)

參數
host String:遠端主機。

user String:遠端主機上的使用者

sshPrivateKey File:包含要使用的 SSH 金鑰的檔案。

runUtil IRunUtil:執行指令的 IRunUtil

timeout long:擷取完成所需的時間 (以毫秒為單位)

remotePath String:檔案的遠端路徑。

傳回
boolean 檔案是否存在

doesRemoteFileExist

public static boolean doesRemoteFileExist (String host, 
                String user, 
                File sshPrivateKey, 
                IRunUtil runUtil, 
                long timeout, 
                String remotePath, 
                String sshPortNumber)

檢查遠端執行個體上是否有檔案 (或目錄)

參數
host String:遠端主機。

user String:遠端主機上的使用者

sshPrivateKey File:包含要使用的 SSH 金鑰的檔案。

runUtil IRunUtil:執行指令的 IRunUtil

timeout long:擷取完成所需的時間 (以毫秒為單位)

remotePath String:檔案的遠端路徑。

sshPortNumber String:SSH 的通訊埠編號。

傳回
boolean 檔案是否存在

fetchRemoteDir

public static boolean fetchRemoteDir (String host, 
                String user, 
                File sshPrivateKey, 
                IRunUtil runUtil, 
                long timeout, 
                String remoteDirPath, 
                File localDir)

從遠端主機擷取遠端目錄。

參數
host String:遠端主機。

user String:遠端主機上的使用者

sshPrivateKey File:包含要使用的 SSH 金鑰的檔案。

runUtil IRunUtil:執行指令的 IRunUtil

timeout long:擷取完成所需的時間 (以毫秒為單位)

remoteDirPath String:目錄所在的遠端路徑。

localDir File:要放置所提取檔案的本機目錄。

傳回
boolean 成功時傳回 True,否則傳回 False

fetchRemoteDir

public static File fetchRemoteDir (String host, 
                String user, 
                File sshPrivateKey, 
                IRunUtil runUtil, 
                long timeout, 
                String remoteDirPath)

從遠端主機擷取遠端目錄。

參數
host String:遠端主機。

user String:遠端主機上的使用者

sshPrivateKey File:包含要使用的 SSH 金鑰的檔案。

runUtil IRunUtil:執行指令的 IRunUtil

timeout long:擷取完成所需的時間 (以毫秒為單位)

remoteDirPath String:目錄所在的遠端路徑。

傳回
File 如果成功,則為已擷取的目錄 File,否則為空值

fetchRemoteDir

public static File fetchRemoteDir (String host, 
                String user, 
                File sshPrivateKey, 
                List<String> scpArgs, 
                IRunUtil runUtil, 
                long timeout, 
                String remoteDirPath)

從遠端主機擷取遠端目錄。

參數
host String:遠端主機。

user String:遠端主機上的使用者

sshPrivateKey File:包含要使用的 SSH 金鑰的檔案。

scpArgs List:要傳遞至 scp 指令的額外引數

runUtil IRunUtil:執行指令的 IRunUtil

timeout long:擷取完成所需的時間 (以毫秒為單位)

remoteDirPath String:目錄所在的遠端路徑。

傳回
File 如果成功,則為已擷取的目錄 File,否則為空值

fetchRemoteDir

public static boolean fetchRemoteDir (String host, 
                String user, 
                File sshPrivateKey, 
                List<String> scpArgs, 
                IRunUtil runUtil, 
                long timeout, 
                String remoteDirPath, 
                File localDir)

從遠端主機擷取遠端目錄。

參數
host String:遠端主機。

user String:遠端主機上的使用者

sshPrivateKey File:包含要使用的 SSH 金鑰的檔案。

scpArgs List:要傳遞至 scp 指令的額外引數

runUtil IRunUtil:執行指令的 IRunUtil

timeout long:擷取完成所需的時間 (以毫秒為單位)

remoteDirPath String:目錄所在的遠端路徑。

localDir File:要放置所提取檔案的本機目錄。

傳回
boolean 成功時傳回 True,否則傳回 False

fetchRemoteFile

public static File fetchRemoteFile (String host, 
                String user, 
                File sshPrivateKey, 
                List<String> scpArgs, 
                IRunUtil runUtil, 
                long timeout, 
                String remoteFilePath)

在容器執行個體中擷取遠端檔案。

參數
host String:遠端主機。

user String:遠端主機上的使用者

sshPrivateKey File:包含要使用的 SSH 金鑰的檔案。

scpArgs List:要傳遞至 scp 指令的額外引數

runUtil IRunUtil:執行指令的 IRunUtil

timeout long:擷取完成所需的時間 (以毫秒為單位)

remoteFilePath String:檔案的遠端路徑。

傳回
File 如果成功,則為擷取的欄位,否則為空值

fetchRemoteFile

public static File fetchRemoteFile (String host, 
                String user, 
                File sshPrivateKey, 
                IRunUtil runUtil, 
                long timeout, 
                String remoteFilePath)

在容器執行個體中擷取遠端檔案。

參數
host String:遠端主機。

user String:遠端主機上的使用者

sshPrivateKey File:包含要使用的 SSH 金鑰的檔案。

runUtil IRunUtil:執行指令的 IRunUtil

timeout long:擷取完成所需的時間 (以毫秒為單位)

remoteFilePath String:檔案的遠端路徑。

傳回
File 如果成功,則為擷取的欄位,否則為空值

fetchRemoteFile

public static boolean fetchRemoteFile (String host, 
                String user, 
                File sshPrivateKey, 
                List<String> scpArgs, 
                IRunUtil runUtil, 
                long timeout, 
                String remoteFilePath, 
                File localFile)

在裝置或容器例項中擷取遠端檔案。

參數
host String:遠端主機。

user String:遠端主機上的使用者

sshPrivateKey File:包含要使用的 SSH 金鑰的檔案。

scpArgs List:要傳遞至 scp 指令的額外引數

runUtil IRunUtil:執行指令的 IRunUtil

timeout long:擷取完成所需的時間 (以毫秒為單位)

remoteFilePath String:檔案的遠端路徑。

localFile File:要從中提取遠端檔案的本機 File

傳回
boolean 成功時傳回 True,否則傳回 False

fetchRemoteFile

public static boolean fetchRemoteFile (String host, 
                String user, 
                File sshPrivateKey, 
                IRunUtil runUtil, 
                long timeout, 
                String remoteFilePath, 
                File localFile)

在裝置或容器例項中擷取遠端檔案。

參數
host String:遠端主機。

user String:遠端主機上的使用者

sshPrivateKey File:包含要使用的 SSH 金鑰的檔案。

runUtil IRunUtil:執行指令的 IRunUtil

timeout long:擷取完成所需的時間 (以毫秒為單位)

remoteFilePath String:檔案的遠端路徑。

localFile File:要從中提取遠端檔案的本機 File

傳回
boolean 成功時傳回 True,否則傳回 False

pushFileToRemote

public static boolean pushFileToRemote (String host, 
                String user, 
                File sshPrivateKey, 
                List<String> scpArgs, 
                IRunUtil runUtil, 
                long timeout, 
                String remoteFilePath, 
                File localFile)

將本機主機的 File 推送至遠端執行個體

參數
host String:遠端主機。

user String:遠端主機上的使用者

sshPrivateKey File

scpArgs List:要傳遞至 scp 指令的額外引數

runUtil IRunUtil:執行指令的 IRunUtil

timeout long:擷取完成所需的時間 (以毫秒為單位)

remoteFilePath String:檔案的遠端路徑。

localFile File:要從中提取遠端檔案的本機 File

傳回
boolean 成功時傳回 True,否則傳回 False