當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。