aboutsummaryrefslogtreecommitdiffstats
path: root/library/python/windows/__init__.py
diff options
context:
space:
mode:
authorDmitry Kopylov <kopylovd@gmail.com>2022-02-10 16:48:18 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:18 +0300
commitb2f5101486cc0de2e979c8ba9ada2109785bf5fd (patch)
treeaffe28b840816b505db0467f2285b01c89c04247 /library/python/windows/__init__.py
parente9b28b5aad71453a4637b70dde02e801e4147a2a (diff)
downloadydb-b2f5101486cc0de2e979c8ba9ada2109785bf5fd.tar.gz
Restoring authorship annotation for Dmitry Kopylov <kopylovd@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/python/windows/__init__.py')
-rw-r--r--library/python/windows/__init__.py42
1 files changed, 21 insertions, 21 deletions
diff --git a/library/python/windows/__init__.py b/library/python/windows/__init__.py
index 62861b3309..9966cb8c83 100644
--- a/library/python/windows/__init__.py
+++ b/library/python/windows/__init__.py
@@ -3,7 +3,7 @@
import os
import stat
import sys
-import shutil
+import shutil
import logging
from six import reraise
@@ -11,22 +11,22 @@ from six import reraise
import library.python.func
import library.python.strings
-logger = logging.getLogger(__name__)
-
+logger = logging.getLogger(__name__)
+
ERRORS = {
'SUCCESS': 0,
- 'PATH_NOT_FOUND': 3,
- 'ACCESS_DENIED': 5,
- 'SHARING_VIOLATION': 32,
+ 'PATH_NOT_FOUND': 3,
+ 'ACCESS_DENIED': 5,
+ 'SHARING_VIOLATION': 32,
'INSUFFICIENT_BUFFER': 122,
'DIR_NOT_EMPTY': 145,
}
-RETRIABLE_FILE_ERRORS = (ERRORS['ACCESS_DENIED'], ERRORS['SHARING_VIOLATION'])
-RETRIABLE_DIR_ERRORS = (ERRORS['ACCESS_DENIED'], ERRORS['DIR_NOT_EMPTY'], ERRORS['SHARING_VIOLATION'])
-
+RETRIABLE_FILE_ERRORS = (ERRORS['ACCESS_DENIED'], ERRORS['SHARING_VIOLATION'])
+RETRIABLE_DIR_ERRORS = (ERRORS['ACCESS_DENIED'], ERRORS['DIR_NOT_EMPTY'], ERRORS['SHARING_VIOLATION'])
+
# Check if on Windows
@library.python.func.lazy
def on_win():
@@ -145,7 +145,7 @@ if on_win():
ei = None
for t in xrange(tries):
if t:
- logger.debug('Diehard [errs %s]: try #%d in %s', ','.join(str(x) for x in winerrors), t, f)
+ logger.debug('Diehard [errs %s]: try #%d in %s', ','.join(str(x) for x in winerrors), t, f)
try:
return f(*args, **kwargs)
except WindowsError as e:
@@ -285,14 +285,14 @@ if on_win():
def set_error_mode(mode):
return ctypes.windll.kernel32.SetErrorMode(mode)
- @win_only
- def rmtree(path):
- def error_handler(func, handling_path, execinfo):
- e = execinfo[1]
- if e.winerror == ERRORS['PATH_NOT_FOUND']:
- handling_path = "\\\\?\\" + handling_path # handle path over 256 symbols
- if os.path.exists(path):
- return func(handling_path)
+ @win_only
+ def rmtree(path):
+ def error_handler(func, handling_path, execinfo):
+ e = execinfo[1]
+ if e.winerror == ERRORS['PATH_NOT_FOUND']:
+ handling_path = "\\\\?\\" + handling_path # handle path over 256 symbols
+ if os.path.exists(path):
+ return func(handling_path)
if e.winerror == ERRORS['ACCESS_DENIED']:
try:
# removing of r/w directory with read-only files in it yields ACCESS_DENIED
@@ -303,9 +303,9 @@ if on_win():
else:
# propagate true last error if this attempt fails
return func(handling_path)
- raise e
- shutil.rmtree(path, onerror=error_handler)
-
+ raise e
+ shutil.rmtree(path, onerror=error_handler)
+
# Don't display the Windows GPF dialog if the invoked program dies.
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms680621.aspx
@win_only