Exemplo n.º 1
0
 def testLocalToLocal(self):
     tempFolder = "localToLocal"
     filePaths = {}
     sourceFilesPathList = getFiles(self.localSourceFolder)
     for sourceFilePath in sourceFilesPathList:
         sourceFileName = basename(sourceFilePath)
         targetFilePath = join(self.localTargetFolder, tempFolder,
                               sourceFileName)
         targetFilePathList = []
         targetFilePathList.append(targetFilePath)
         filePaths[sourceFilePath] = 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)
Exemplo n.º 2
0
    def testLocalToLocal(self):
        tempFolder = "localToLocal"
        filePaths = {}
        sourceFilesPathList = getFiles(self.localSourceFolder)
        for sourceFilePath in sourceFilesPathList:
            sourceFileName = basename(sourceFilePath)
            targetFilePath = join(self.localTargetFolder, tempFolder, sourceFileName)
            targetFilePathList = []
            targetFilePathList.append(targetFilePath)
            filePaths[sourceFilePath] = 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)
Exemplo n.º 3
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)
Exemplo n.º 4
0
    def testLocalToSeveralRemoteHosts(self):
        tempFolder = "localToSeveralRemote"
        filePaths = {}
        sourceFilesPathList = getFiles(self.localSourceFolder)
        for sourceFilePath in sourceFilesPathList:
            sourceFileName = basename(sourceFilePath)
            targetFilePath1 = join(self.remoteTargetFolder1, tempFolder, sourceFileName)
            targetFilePath2 = join(self.remoteTargetFolder2, tempFolder, sourceFileName)
            targetFilePathList = []
            targetFilePathList.append(self.hostsRefs[0] + ":" + targetFilePath1)
            targetFilePathList.append(self.hostsRefs[1] + ":" + targetFilePath2)
            filePaths[sourceFilePath] = 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)
        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)
Exemplo n.º 5
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)