本文整理汇总了Python中setuptools.sandbox.DirectorySandbox._violation方法的典型用法代码示例。如果您正苦于以下问题:Python DirectorySandbox._violation方法的具体用法?Python DirectorySandbox._violation怎么用?Python DirectorySandbox._violation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类setuptools.sandbox.DirectorySandbox
的用法示例。
在下文中一共展示了DirectorySandbox._violation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _no_sandbox
# 需要导入模块: from setuptools.sandbox import DirectorySandbox [as 别名]
# 或者: from setuptools.sandbox.DirectorySandbox import _violation [as 别名]
def _no_sandbox(function):
def __no_sandbox(*args, **kw):
try:
from setuptools.sandbox import DirectorySandbox
if not hasattr(DirectorySandbox, '_old'):
def violation(*args):
pass
DirectorySandbox._old = DirectorySandbox._violation
DirectorySandbox._violation = violation
patched = True
else:
patched = False
except ImportError:
patched = False
try:
return function(*args, **kw)
finally:
if patched:
DirectorySandbox._violation = DirectorySandbox._old
del DirectorySandbox._old
return __no_sandbox
示例2: disable_sandbox
# 需要导入模块: from setuptools.sandbox import DirectorySandbox [as 别名]
# 或者: from setuptools.sandbox.DirectorySandbox import _violation [as 别名]
def disable_sandbox():
"""
When capstone/keystone is installed as a dependency, setuptools
throws a SandboxViolation when it tries to create a
directory for its shared library. Just disable the
sandbox as a hacky workaround for now.
nb.
"""
try:
from setuptools.sandbox import DirectorySandbox
def violation(operation, *args, **_):
"""
Print stup for DirectorySandbox violation function.
"""
print("SandboxViolation (disabled): {} {}".format(operation, args))
# pylint: disable=W0212
DirectorySandbox._violation = violation
except ImportError:
pass
示例3: _rename_path
# 需要导入模块: from setuptools.sandbox import DirectorySandbox [as 别名]
# 或者: from setuptools.sandbox.DirectorySandbox import _violation [as 别名]
def _rename_path(path):
new_name = path + '.OLD.%s' % time.time()
log.warn('Renaming %s into %s', path, new_name)
try:
from setuptools.sandbox import DirectorySandbox
def _violation(*args):
pass
DirectorySandbox._violation = _violation
except ImportError:
pass
os.rename(path, new_name)
return new_name