当前位置: 首页>>代码示例>>Python>>正文


Python Folder.exists方法代码示例

本文整理汇总了Python中core.osutils.folder.Folder.exists方法的典型用法代码示例。如果您正苦于以下问题:Python Folder.exists方法的具体用法?Python Folder.exists怎么用?Python Folder.exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core.osutils.folder.Folder的用法示例。


在下文中一共展示了Folder.exists方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: build_android

# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import exists [as 别名]
    def build_android(attributes={}, assert_success=True, tns_path=None, log_trace=False, measureTime=False):
        output = Tns.run_tns_command("build android", attributes=attributes, tns_path=tns_path, log_trace=log_trace,
                                     measureTime=measureTime)
        if assert_success:
            # Verify output of build command
            assert "Project successfully built" in output, "Build failed!" + os.linesep + output
            assert "FAILURE" not in output
            assert "NOT FOUND" not in output  # Test for https://github.com/NativeScript/android-runtime/issues/390
            if log_trace:
                assert "BUILD SUCCESSFUL" in output, "Build failed!" + os.linesep + output
            else:
                assert "BUILD SUCCESSFUL" not in output, "Native build out is displayed even without --log trace"

            # Verify apk packages
            app_name = Tns.__get_app_name_from_attributes(attributes=attributes)
            Tns.__get_platform_string(platform=Platform.ANDROID)
            android_version_string = str(TnsAsserts.get_platform_version(app_name=app_name, platform='android'))
            android_major_version = int(android_version_string.split('-')[0].split('.')[0])
            if android_major_version > 3:
                apk_name = "app"
                debug_app_path = os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APK_DEBUG_PATH, apk_name)
                release_app_path = os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APK_RELEASE_PATH, apk_name)
            else:
                apk_name = Tns.__get_final_package_name(app_name, platform=Platform.ANDROID)
                debug_app_path = os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APK_PATH, apk_name)
                release_app_path = os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APK_PATH, apk_name)

            if "--release" in attributes.keys():
                apk_path = release_app_path + "-release.apk"
            else:
                apk_path = debug_app_path + "-debug.apk"
            apk_path = apk_path.replace("\"", "")  # Handle projects with space
            assert File.exists(apk_path), "Apk file does not exist at " + apk_path

            # Verify final package contains right modules (or verify bundle when it is used)
            if "--bundle" not in attributes.keys():
                assert "Webpack compilation complete" not in output
            else:
                assert "Webpack compilation complete" in output
                assert File.exists(os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH, "bundle.js"))
                assert File.exists(os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH, "package.json"))
                assert File.exists(os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH, "starter.js"))
                assert File.exists(os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH, "vendor.js"))
                assert not Folder.exists(os.path.join(app_name, TnsAsserts.PLATFORM_ANDROID_NPM_MODULES_PATH))

        return output
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:48,代码来源:tns.py

示例2: test_400_plugin_create_with_wrong_template

# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import exists [as 别名]
 def test_400_plugin_create_with_wrong_template(self):
     plugin_url = "https://github.com/NativeScript/nativescript-plugin-seed/"
     output = Tns.plugin_create(name=self.plugin_name, attributes={"--template": plugin_url}, assert_success=False)
     assert "successfully created" not in output, "It is expected plugin create to fail in this test case."
     assert not Folder.exists(self.plugin_name), "Plugin folder should not exists if create operation fails."
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:7,代码来源:plugin_create_tests.py


注:本文中的core.osutils.folder.Folder.exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。