- Timestamp:
- Jul 5, 2016 1:50:26 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 108487
- Location:
- trunk/src/VBox/ValidationKit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/common/utils.py
r61988 r62025 378 378 time.strftime('%Y-%m-%d %H:%M', time.localtime(oStat.st_mtime)), ); 379 379 380 ## Good buffer for file operations. 381 g_cbGoodBufferSize = 256*1024; 382 383 ## The original shutil.copyfileobj. 384 g_fnOriginalShCopyFileObj = None; 385 386 def __myshutilcopyfileobj(fsrc, fdst, length = g_cbGoodBufferSize): 387 """ shutil.copyfileobj with different length default value (16384 is slow with python 2.7 on windows). """ 388 return g_fnOriginalShCopyFileObj(fsrc, fdst, length); 389 390 def __installShUtilHacks(shutil): 391 """ Installs the shutil buffer size hacks. """ 392 global g_fnOriginalShCopyFileObj; 393 if g_fnOriginalShCopyFileObj is None: 394 g_fnOriginalShCopyFileObj = shutil.copyfileobj; 395 shutil.copyfileobj = __myshutilcopyfileobj; 396 return True; 397 398 399 def copyFileSimple(sFileSrc, sFileDst): 400 """ 401 Wrapper around shutil.copyfile that simply copies the data of a regular file. 402 Raises exception on failure. 403 Return True for show. 404 """ 405 import shutil; 406 __installShUtilHacks(shutil); 407 return shutil.copyfile(sFileSrc, sFileDst); 380 408 381 409 # … … 1559 1587 1560 1588 1561 ## Good buffer for file operations.1562 g_cbGoodBufferSize = 256*1024;1563 1564 ## The original shutil.copyfileobj.1565 g_fnOriginalShCopyFileObj = None;1566 1567 def __myshutilcopyfileobj(fsrc, fdst, length = g_cbGoodBufferSize):1568 """ shutil.copyfileobj with different length default value (16384 is slow with python 2.7 on windows). """1569 return g_fnOriginalShCopyFileObj(fsrc, fdst, length);1570 1571 1589 ## Set if we've replaced tarfile.copyfileobj with __mytarfilecopyfileobj already. 1572 1590 g_fTarCopyFileObjOverriddend = False; … … 1608 1626 # 1609 1627 if True is True: 1610 global g_fnOriginalShCopyFileObj; 1611 if g_fnOriginalShCopyFileObj is None: 1612 g_fnOriginalShCopyFileObj = shutil.copyfileobj; 1613 shutil.copyfileobj = __myshutilcopyfileobj; 1628 __installShUtilHacks(shutil); 1614 1629 global g_fTarCopyFileObjOverriddend; 1615 1630 if g_fTarCopyFileObjOverriddend is False: -
trunk/src/VBox/ValidationKit/common/webutils.py
r61834 r62025 31 31 # Standard Python imports. 32 32 import os; 33 import shutil;34 33 import sys; 35 34 import unittest; … … 177 176 fnLog('Copying "%s" to "%s"...' % (sSrcPath, sDstFile)); 178 177 try: 179 shutil.copyfile(sSrcPath, sDstFile);178 utils.copyFileSimple(sSrcPath, sDstFile); 180 179 except Exception, oXcpt: 181 180 fnError('Error copying "%s" to "%s": %s' % (sSrcPath, sDstFile, oXcpt)); -
trunk/src/VBox/ValidationKit/tests/unittests/tdUnitTest1.py
r61840 r62025 36 36 import re 37 37 import subprocess 38 import shutil39 38 40 39 … … 515 514 reporter.log('_hardenedCopyFile: %s -> %s (mode: %o)' % (sSrc, sDst, iMode,)); 516 515 if utils.getHostOs() in [ 'win', 'os2' ]: 517 shutil.copyfile(sSrc, sDst);516 utils.copyFileSimple(sSrc, sDst); 518 517 os.chmod(sDst, iMode); 519 518 else:
Note:
See TracChangeset
for help on using the changeset viewer.