本文整理汇总了Python中nuitka.Utils.deleteFile方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.deleteFile方法的具体用法?Python Utils.deleteFile怎么用?Python Utils.deleteFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nuitka.Utils
的用法示例。
在下文中一共展示了Utils.deleteFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getDependsExePath
# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import deleteFile [as 别名]
def getDependsExePath():
""" Return the path of depends.exe (for Windows).
Will prompt the user to download if not already cached in AppData
directory for Nuitka.
"""
if Utils.getArchitecture() == "x86":
depends_url = "http://dependencywalker.com/depends22_x86.zip"
else:
depends_url = "http://dependencywalker.com/depends22_x64.zip"
if "APPDATA" not in os.environ:
sys.exit("Error, standalone mode cannot find 'APPDATA' environment.")
nuitka_app_dir = os.path.join(os.environ["APPDATA"], "nuitka")
if not Utils.isDir(nuitka_app_dir):
os.makedirs(nuitka_app_dir)
nuitka_depends_zip = os.path.join(
nuitka_app_dir,
os.path.basename(depends_url)
)
if not Utils.isFile(nuitka_depends_zip):
Tracing.printLine("""\
Nuitka will make use of Dependency Walker (http://dependencywalker.com) tool
to analyze the dependencies of Python extension modules. Is it OK to download
and put it in APPDATA (no installer needed, cached, one time question).""")
reply = raw_input("Proceed and download? [Yes]/No ")
if reply.lower() in ("no", "n"):
sys.exit("Nuitka does not work in --standalone on Windows without.")
info("Downloading '%s'" % depends_url)
urlretrieve(
depends_url,
nuitka_depends_zip
)
nuitka_depends_dir = os.path.join(
nuitka_app_dir,
Utils.getArchitecture()
)
if not Utils.isDir(nuitka_depends_dir):
os.makedirs(nuitka_depends_dir)
depends_exe = os.path.join(
nuitka_depends_dir,
"depends.exe"
)
if not Utils.isFile(depends_exe):
info("Extracting to '%s'" % depends_exe)
import zipfile
try:
depends_zip = zipfile.ZipFile(nuitka_depends_zip)
depends_zip.extractall(nuitka_depends_dir)
except Exception: # Catching anything zip throws, pylint:disable=W0703
info("Problem with the downloaded zip file, deleting it.")
Utils.deleteFile(depends_exe, must_exist = False)
Utils.deleteFile(nuitka_depends_zip, must_exist = True)
sys.exit(
"Error, need '%s' as extracted from '%s'." % (
depends_exe,
depends_url
)
)
assert Utils.isFile(depends_exe)
return depends_exe