コード例 #1
0
ファイル: MTPdbSync.py プロジェクト: pablo-miselu/MTP
def transport(**kwargs):

    srcPath = os.path.dirname(kwargs["packetZeroPath"])
    baseFileName = os.path.basename(kwargs["packetZeroPath"])[:-2]

    def scpStr(index):
        s = "scp -P " + kwargs["port"] + " " + kwargs["user"] + "@" + kwargs["host"] + ":"
        s += os.path.join(srcPath, baseFileName + "." + str(index))
        s += " " + kwargs["dstPath"]
        return s

    if not os.path.exists(os.path.join(kwargs["dstPath"], baseFileName + ".0")):

        pUtils.createDirectory(kwargs["dstPath"])
        cmd = scpStr(0)
        t = pUtils.runProgram(cmd, True)
        if t["returnCode"] != 0:
            return {"retCode": 2, "errMsg": "Unable to retrieve packet zero", "debug": t, "cmd": cmd}

    fileFullPath = os.path.join(kwargs["dstPath"], baseFileName + ".0")
    manifestData = json.loads(pUtils.quickFileRead(fileFullPath))
    sliceAmount = manifestData["sliceAmount"]
    checksumDict = manifestData["checksumDict"]

    for i in range(1, sliceAmount + 1):
        fileFullPath = os.path.join(kwargs["dstPath"], baseFileName + "." + str(i))
        if os.path.exists(fileFullPath):
            fileSha1 = pUtils.getFileSha1(fileFullPath)
            if fileSha1 == checksumDict[baseFileName + "." + str(i)]:
                continue

        cmd = scpStr(i)
        t = None
        retryCounter = 0
        while True:
            retryCounter += 1
            if retryCounter > int(kwargs["try"]):
                return {"retCode": 1, "errMsg": "Max retry reached", "debug": t, "cmd": cmd}

            t = pUtils.runProgram(cmd, True)
            if t["returnCode"] != 0:
                continue

            fileSha1 = pUtils.getFileSha1(fileFullPath)
            if fileSha1 != checksumDict[baseFileName + "." + str(i)]:
                continue

            break

    return {"retCode": 0, "errMsg": None}
コード例 #2
0
ファイル: unitTest_pUtils.py プロジェクト: GawpAzrag/pUtils
 def test_runProgram_1(self):
     t = pUtils.runProgram('ls',shell=True)
     t['output']
     t['errorCode']
     self.assertEqual(t['returnCode'],0)
コード例 #3
0
ファイル: Sequencer.py プロジェクト: pablo-miselu/MTP
             if self.j == (self.wholeCycles-1) or self.isException:
                 
                 isDefaultResultWindowEnable = True
                 if self.customResultWindow!=None:
                     try:
                         exec('isDefaultResultWindowEnable = self.testSuite.'+self.customResultWindow+'(allTestResult=self.allTestResult)')
                     except:
                         isDefaultResultWindowEnable = True
                         print 'customResultWindow Exception'
                 
                 if isDefaultResultWindowEnable:
                     self.guiApi.sendMessage({'command':'pDialog',
                                              'buttonTextList':['OK','TestRunFolder'],
                                              'imageFileName':imageFileName})
                     if self.guiApi.waitForDialogReturn()[0]=='TestRunFolder':
                         pUtils.runProgram('pcmanfm '+self.testRunFolder,shell=True)
             
                 return
             
 def writeTestRunDataFiles(self):
     """
     | Writes all the test run data to drive.
     
     Args:
         None
     
     Returns:
         None
     """
     
     path = os.path.join(self.testRunFolder,'db')