VirtualBox

Changeset 82905 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jan 29, 2020 12:28:30 PM (5 years ago)
Author:
vboxsync
Message:

ValKit/txsclient.py: Increase the timeouts on file transfers, making them relative to the file/string size for uploads and providing a method for calculating it for downloads.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testdriver/txsclient.py

    r79662 r82905  
    16281628    #def "LIST    "
    16291629
     1630    @staticmethod
     1631    def calcFileXferTimeout(cbFile):
     1632        """
     1633        Calculates a reasonable timeout for an upload/download given the file size.
     1634
     1635        Returns timeout in milliseconds.
     1636        """
     1637        return 30000 + cbFile / 256; # 256 KiB/s (picked out of thin air)
     1638
     1639    @staticmethod
     1640    def calcUploadTimeout(sLocalFile):
     1641        """
     1642        Calculates a reasonable timeout for an upload given the file (will stat it).
     1643
     1644        Returns timeout in milliseconds.
     1645        """
     1646        try:    cbFile = os.path.getsize(sLocalFile);
     1647        except: cbFile = 1024*1024;
     1648        return Session.calcFileXferTimeout(cbFile);
     1649
    16301650    def asyncUploadFile(self, sLocalFile, sRemoteFile,
    16311651                        fMode = 0, fFallbackOkay = True, cMsTimeout = 30000, fIgnoreErrors = False):
     
    16401660                              self.taskUploadFile, (sLocalFile, sRemoteFile, fMode, fFallbackOkay));
    16411661
    1642     def syncUploadFile(self, sLocalFile, sRemoteFile, fMode = 0, fFallbackOkay = True, cMsTimeout = 30000, fIgnoreErrors = False):
     1662    def syncUploadFile(self, sLocalFile, sRemoteFile, fMode = 0, fFallbackOkay = True, cMsTimeout = 0, fIgnoreErrors = False):
    16431663        """Synchronous version."""
     1664        if cMsTimeout <= 0:
     1665            cMsTimeout = self.calcUploadTimeout(sLocalFile);
    16441666        return self.asyncToSync(self.asyncUploadFile, sLocalFile, sRemoteFile, fMode, fFallbackOkay, cMsTimeout, fIgnoreErrors);
    16451667
    16461668    def asyncUploadString(self, sContent, sRemoteFile,
    1647                           fMode = 0, fFallbackOkay = True, cMsTimeout = 30000, fIgnoreErrors = False):
     1669                          fMode = 0, fFallbackOkay = True, cMsTimeout = 0, fIgnoreErrors = False):
    16481670        """
    16491671        Initiates a upload string task.
     
    16531675        The task returns True on success, False on failure (logged).
    16541676        """
     1677        if cMsTimeout <= 0:
     1678            cMsTimeout = self.calcFileXferTimeout(len(sContent));
    16551679        return self.startTask(cMsTimeout, fIgnoreErrors, "uploadString",
    16561680                              self.taskUploadString, (sContent, sRemoteFile, fMode, fFallbackOkay));
    16571681
    1658     def syncUploadString(self, sContent, sRemoteFile, fMode = 0, fFallbackOkay = True, cMsTimeout = 30000, fIgnoreErrors = False):
     1682    def syncUploadString(self, sContent, sRemoteFile, fMode = 0, fFallbackOkay = True, cMsTimeout = 0, fIgnoreErrors = False):
    16591683        """Synchronous version."""
     1684        if cMsTimeout <= 0:
     1685            cMsTimeout = self.calcFileXferTimeout(len(sContent));
    16601686        return self.asyncToSync(self.asyncUploadString, sContent, sRemoteFile, fMode, fFallbackOkay, cMsTimeout, fIgnoreErrors);
    16611687
    1662     def asyncDownloadFile(self, sRemoteFile, sLocalFile, cMsTimeout = 30000, fIgnoreErrors = False):
     1688    def asyncDownloadFile(self, sRemoteFile, sLocalFile, cMsTimeout = 120000, fIgnoreErrors = False):
    16631689        """
    16641690        Initiates a download file task.
     
    16701696        return self.startTask(cMsTimeout, fIgnoreErrors, "downloadFile", self.taskDownloadFile, (sRemoteFile, sLocalFile));
    16711697
    1672     def syncDownloadFile(self, sRemoteFile, sLocalFile, cMsTimeout = 30000, fIgnoreErrors = False):
     1698    def syncDownloadFile(self, sRemoteFile, sLocalFile, cMsTimeout = 120000, fIgnoreErrors = False):
    16731699        """Synchronous version."""
    16741700        return self.asyncToSync(self.asyncDownloadFile, sRemoteFile, sLocalFile, cMsTimeout, fIgnoreErrors);
     
    16921718                                cMsTimeout, fIgnoreErrors);
    16931719
    1694     def asyncUnpackFile(self, sRemoteFile, sRemoteDir, cMsTimeout = 30000, fIgnoreErrors = False):
     1720    def asyncUnpackFile(self, sRemoteFile, sRemoteDir, cMsTimeout = 120000, fIgnoreErrors = False):
    16951721        """
    16961722        Initiates a unpack file task.
     
    17031729                              (sRemoteFile, sRemoteDir));
    17041730
    1705     def syncUnpackFile(self, sRemoteFile, sRemoteDir, cMsTimeout = 30000, fIgnoreErrors = False):
     1731    def syncUnpackFile(self, sRemoteFile, sRemoteDir, cMsTimeout = 120000, fIgnoreErrors = False):
    17061732        """Synchronous version."""
    17071733        return self.asyncToSync(self.asyncUnpackFile, sRemoteFile, sRemoteDir, cMsTimeout, fIgnoreErrors);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette