Beispiel #1
0
    def testOneRemoteHostToLocal(self):
        tempFolder = "oneRemoteHostToLocal"
        filePaths = {}
        checkPathList = []
        remoteSourceFilePathList2 = ft.getRemoteFolderFiles(
            self.remoteHostName2, self.remoteUserName2, self.remotePassword2,
            self.remoteSourceFolder2)
        for remoteSourceFilePath in remoteSourceFilePathList2:
            remoteSourceFileName = basename(remoteSourceFilePath)
            targetFilePath = join(self.localTargetFolder, tempFolder, "test2",
                                  remoteSourceFileName)
            filePaths[remoteSourceFilePath] = targetFilePath
            checkPathList.append(targetFilePath)

        self.fileTransfer.transferFilesFrom(filePaths,
                                            self.remoteHostName2,
                                            self.remoteUserName2,
                                            self.remotePassword2,
                                            gatewayHosts=self.gatewayHosts,
                                            numberTrials=self.numberTrials,
                                            forceOperation=self.forceOperation,
                                            operationId=self.operationId)
        passTest = len(
            self.fileTransfer.checkFiles(checkPathList,
                                         self.hostPasswords,
                                         gatewayHosts=self.gatewayHosts,
                                         numberTrials=self.numberTrials,
                                         forceOperation=self.forceOperation,
                                         operationId=self.operationId)) == 0
        cleanPath(join(self.localTargetFolder, tempFolder))
        self.assertTrue(passTest)
Beispiel #2
0
    def testSeveralRemoteHostsToLocal(self):
        tempFolder = "severalRemoteToLocal"
        filePaths = {}
        remoteSourceFilePathList1 = ft.getRemoteFolderFiles(self.remoteHostName1, self.remoteUserName1, self.remotePassword1, self.remoteSourceFolder1)
        remoteSourceFilePathList2 = ft.getRemoteFolderFiles(self.remoteHostName2, self.remoteUserName2, self.remotePassword2, self.remoteSourceFolder2)
        for remoteSourceFilePath in remoteSourceFilePathList1:
            targetFilePathList = []
            targetFilePathList.append(join(self.localTargetFolder, tempFolder, "test1", basename(remoteSourceFilePath)))
            filePaths[self.hostsRefs[0] + ":" + remoteSourceFilePath] = targetFilePathList
        for remoteSourceFilePath in remoteSourceFilePathList2:
            targetFilePathList = []
            targetFilePathList.append(join(self.localTargetFolder, tempFolder, "test2", basename(remoteSourceFilePath)))
            filePaths[self.hostsRefs[1] + ":" + remoteSourceFilePath] = targetFilePathList
        self.fileTransfer.transferFiles(filePaths, self.hostPasswords, gatewayHosts=self.gatewayHosts, numberTrials=self.numberTrials, forceOperation=self.forceOperation, operationId=self.operationId)
        checkPathList = ft.getFilePathList(filePaths)
        passTest = len(self.fileTransfer.checkFiles(checkPathList, self.hostPasswords, gatewayHosts=self.gatewayHosts, numberTrials=self.numberTrials, forceOperation=self.forceOperation, operationId=self.operationId)) == 0
#         self.fileTransfer.deleteFiles(checkPathList, self.hostPasswords, gatewayHosts=self.gatewayHosts, numberTrials=self.numberTrials, forceOperation=self.forceOperation, operationId=self.operationId)
        cleanPath(join(self.localTargetFolder, tempFolder))
        self.assertTrue(passTest)
Beispiel #3
0
    def testAll(self):
        tempFolder = "allTransfer"
        filePaths = {}

        sourceFilesPathList = getFiles(self.localSourceFolder)
        remoteSourceFilePathList1 = ft.getRemoteFolderFiles(self.remoteHostName1, self.remoteUserName1, self.remotePassword1, self.remoteSourceFolder1)
        remoteSourceFilePathList2 = ft.getRemoteFolderFiles(self.remoteHostName2, self.remoteUserName2, self.remotePassword2, self.remoteSourceFolder2)

        localUserName = getLocalUserName()
        localHostname = getLocalHostName()

        for sourceFilePath in sourceFilesPathList:
            sourceFileName = basename(sourceFilePath)
            targetFilePath1 = join(self.remoteTargetFolder1, tempFolder, sourceFileName)
            targetFilePath2 = join(self.remoteTargetFolder2, tempFolder, sourceFileName)
            targetFilePath3 = join (self.localTargetFolder, tempFolder, sourceFileName)
            targetFilePathList = []
            targetFilePathList.append(self.hostsRefs[0] + ":" + targetFilePath1)
            targetFilePathList.append(self.hostsRefs[1] + ":" + targetFilePath2)
            targetFilePathList.append(localUserName + "@" + localHostname + ":" + targetFilePath3)
            filePaths[sourceFilePath] = targetFilePathList

        for remoteSourceFilePath in remoteSourceFilePathList1:
            targetFilePathList = []
            targetFilePathList.append(join(self.localTargetFolder, tempFolder, "test1", basename(remoteSourceFilePath)))
            filePaths[self.hostsRefs[0] + ":" + remoteSourceFilePath] = targetFilePathList
        for remoteSourceFilePath in remoteSourceFilePathList2:
            targetFilePathList = []
            targetFilePathList.append(join(self.localTargetFolder, tempFolder, "test2", basename(remoteSourceFilePath)))
            filePaths[self.hostsRefs[1] + ":" + remoteSourceFilePath] = targetFilePathList

        self.fileTransfer.transferFiles(filePaths, self.hostPasswords, gatewayHosts=self.gatewayHosts, numberTrials=self.numberTrials, forceOperation=self.forceOperation, operationId=self.operationId)
        checkPathList = ft.getFilePathList(filePaths)
        passTest = len(self.fileTransfer.checkFiles(checkPathList, self.hostPasswords, gatewayHosts=self.gatewayHosts, numberTrials=self.numberTrials, forceOperation=self.forceOperation, operationId=self.operationId)) == 0
#         self.fileTransfer.deleteFiles(checkPathList, self.hostPasswords, gatewayHosts=self.gatewayHosts, numberTrials=self.numberTrials, forceOperation=self.forceOperation, operationId=self.operationId)
        cleanPath(join(self.localTargetFolder, tempFolder))
        ft.removeRemoteFolder(self.remoteHostName1, self.remoteUserName1, self.remotePassword1, join(self.remoteTargetFolder1, tempFolder))
        ft.removeRemoteFolder(self.remoteHostName2, self.remoteUserName2, self.remotePassword2, join(self.remoteTargetFolder2, tempFolder))
        self.assertTrue(passTest)
Beispiel #4
0
    def testOneRemoteHostToLocal(self):
        tempFolder = "oneRemoteHostToLocal"
        filePaths = {}
        checkPathList = []
        remoteSourceFilePathList2 = ft.getRemoteFolderFiles(self.remoteHostName2, self.remoteUserName2, self.remotePassword2, self.remoteSourceFolder2)
        for remoteSourceFilePath in remoteSourceFilePathList2:
            remoteSourceFileName = basename(remoteSourceFilePath)
            targetFilePath = join(self.localTargetFolder, tempFolder, "test2", remoteSourceFileName)
            filePaths[remoteSourceFilePath] = targetFilePath
            checkPathList.append(targetFilePath)

        self.fileTransfer.transferFilesFrom(filePaths, self.remoteHostName2, self.remoteUserName2, self.remotePassword2, gatewayHosts=self.gatewayHosts, numberTrials=self.numberTrials, forceOperation=self.forceOperation, operationId=self.operationId)
        passTest = len(self.fileTransfer.checkFiles(checkPathList, self.hostPasswords, gatewayHosts=self.gatewayHosts, numberTrials=self.numberTrials, forceOperation=self.forceOperation, operationId=self.operationId)) == 0
        cleanPath(join(self.localTargetFolder, tempFolder))
        self.assertTrue(passTest)