mirror of
https://github.com/certbot/certbot.git
synced 2026-06-06 15:22:38 -04:00
Use a try/except import approach similar to lock
This commit is contained in:
parent
0b6c5d6003
commit
7e1f284d36
1 changed files with 5 additions and 6 deletions
|
|
@ -6,12 +6,11 @@ import stat
|
|||
|
||||
try:
|
||||
import ntsecuritycon # pylint: disable=import-error
|
||||
except ImportError: # pragma: no cover
|
||||
ntsecuritycon = None # type: ignore
|
||||
try:
|
||||
import win32security # pylint: disable=import-error
|
||||
except ImportError: # pragma: no cover
|
||||
win32security = None # type: ignore
|
||||
except ImportError:
|
||||
POSIX_MODE = True
|
||||
else:
|
||||
POSIX_MODE = False
|
||||
|
||||
|
||||
def chmod(file_path, mode):
|
||||
|
|
@ -24,7 +23,7 @@ def chmod(file_path, mode):
|
|||
:param str file_path: Path of the file
|
||||
:param int mode: POSIX mode to apply
|
||||
"""
|
||||
if not win32security:
|
||||
if POSIX_MODE:
|
||||
os.chmod(file_path, mode)
|
||||
else:
|
||||
_apply_win_mode(file_path, mode)
|
||||
|
|
|
|||
Loading…
Reference in a new issue