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


Python Folder.cleanup方法代码示例

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


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

示例1: create_app

# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import cleanup [as 别名]
    def create_app(app_name, attributes={}, log_trace=False, assert_success=True, update_modules=True,
                   force_clean=True, measureTime=False):

        if force_clean:
            if File.exists(app_name):
                Folder.cleanup(app_name)

        path = app_name
        attributes_to_string = ""
        for k, v in attributes.iteritems():
            if "--path" in k:
                path = v
            attributes_to_string = "".join("{0} {1}".format(k, v))
        attr = {}
        if not any(s in attributes_to_string for s in ("--ng", "--template", "--tsc", "--vue")):
            if BRANCH == "master":
                attr = {"--template": SUT_FOLDER + os.path.sep + "tns-template-hello-world.tgz"}
            else:
                attr = {"--template": "tns-template-hello-world"}
        attr.update(attributes)
        if app_name is None:
            output = Tns.run_tns_command("create ", attributes=attr, log_trace=log_trace, measureTime=measureTime)
        else:
            output = Tns.run_tns_command("create \"" + app_name + "\"", attributes=attr, log_trace=log_trace,
                                         measureTime=measureTime)
        if assert_success:
            TnsAsserts.created(app_name=app_name, output=output)
        if update_modules:
            Tns.update_modules(path)
        # Tns.ensure_app_resources(path)
        return output
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:33,代码来源:tns.py

示例2: test_200_tns_run_android_extending_class_inside_file_containing_dots

# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import cleanup [as 别名]
    def test_200_tns_run_android_extending_class_inside_file_containing_dots(self):
        """Test for https://github.com/NativeScript/android-runtime/issues/761"""

        # Copy the app folder (app is modified in order to get some console logs on loaded)
        source = os.path.join('data', 'apps', 'livesync-hello-world-ng', 'src')
        target = os.path.join(self.app_name, 'src')
        Folder.cleanup(target)
        Folder.copy(src=source, dst=target)
        
        source_html = os.path.join('data', 'issues', 'android-runtime-761', 'items.component.html')
        target_html = os.path.join(self.app_name, 'src', 'app', 'item', 'items.component.html')
        File.copy(src=source_html, dest=target_html)

        source_ts = os.path.join('data', 'issues', 'android-runtime-761', 'items.component.ts')
        target_ts = os.path.join(self.app_name, 'src', 'app', 'item', 'items.component.ts')
        File.copy(src=source_ts, dest=target_ts)

        source_xml = os.path.join('data', 'issues', 'android-runtime-761', 'AndroidManifest.xml')
        target_xml = os.path.join(self.app_name, 'App_Resources', 'Android', 'src', 'main', 'AndroidManifest.xml')
        File.copy(src=source_xml, dest=target_xml)

        # Verify the app is running
        log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID}, wait=False,
                              assert_success=False)
        strings = ['Project successfully built',
                   'Successfully installed on device with identifier', EMULATOR_ID,
                   'Successfully synced application']
        Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10)
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:30,代码来源:run_android_ng_tests.py

示例3: update_webpack

# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import cleanup [as 别名]
    def update_webpack(path):
        """
        Update modules for {N} project
        :param path: Path to {N} project
        :return: Output of command that update nativescript-dev-webpack plugin.
        """

        # Escape path with spaces
        if " " in path:
            path = "\"" + path + "\""

        if USE_YARN == "True":
            Npm.uninstall(package="nativescript-dev-webpack", option="--dev", folder=path)
            output = Npm.install(package=WEBPACK_PACKAGE, option="--dev", folder=path)
        else:
            Npm.uninstall(package="nativescript-dev-webpack", option="--save-dev", folder=path)
            output = Npm.install(package=WEBPACK_PACKAGE, option="--save-dev", folder=path)
            if Npm.version() > 3:
                assert "ERR" not in output, "Something went wrong when webpack are installed."

        # Update webpack dependencies
        update_script = os.path.join(TEST_RUN_HOME, path,
                                     "node_modules", ".bin", "update-ns-webpack --deps --configs")
        run(update_script)
        if USE_YARN == "True":
            Folder.cleanup(folder=os.path.join(TEST_RUN_HOME, path, "node_modules"))
            Npm.yarn_install(folder=path)
        else:
            Npm.install(folder=path)
        return output
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:32,代码来源:tns.py

示例4: test_280_tns_run_android_console_time

# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import cleanup [as 别名]
    def test_280_tns_run_android_console_time(self):
        # Copy the app folder (app is modified in order to get some console logs on loaded)
        source = os.path.join('data', 'apps', 'livesync-hello-world-ng', 'src')
        target = os.path.join(self.app_name, 'src')
        Folder.cleanup(target)
        Folder.copy(src=source, dst=target)

        # Replace app.component.ts to use console.time() and console.timeEnd()
        source = os.path.join('data', 'issues', 'ios-runtime-843', 'app.component.ts')
        target = os.path.join(self.app_name, 'src', 'app', 'app.component.ts')
        File.copy(src=source, dest=target)

        # `tns run android` and wait until app is deployed
        log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID}, wait=False,
                              assert_success=False)

        # Verify the app is running
        strings = ['Successfully synced application',
                   'Application loaded!',
                   'Home page loaded!']

        Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10, clean_log=False)

        # Verify initial state of the app
        Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID,
                            expected_image='ng-hello-world-home-white', tolerance=5.0)

        # Verify console.time() works
        console_time = ['JS: startup:']
        Tns.wait_for_log(log_file=log, string_list=console_time)
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:32,代码来源:run_android_ng_tests.py

示例5: tearDown

# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import cleanup [as 别名]
    def tearDown(self):
        # Logic executed only on test failure
        test_name = self._testMethodName
        artifacts_folder = os.path.join(OUTPUT_FOLDER, self.__class__.__name__ + "_" + test_name)
        outcome = "PASSED"
        if self.IsFailed(self._resultForDoCleanups) is True:
            outcome = "FAILED"

            # Ensure `artifacts_folder` exists and it is clean
            if File.exists(artifacts_folder):
                Folder.cleanup(artifacts_folder)
            else:
                Folder.create(artifacts_folder)

            # Collect artifacts on test failure
            self.__copy_images(artifacts_folder=artifacts_folder)
            self.__copy_project_folder(artifacts_folder=artifacts_folder)
            self.__save_host_screen(artifacts_folder=artifacts_folder, test_method_name=test_name)

        print ""
        print "Test Method: {0}".format(self._testMethodName)
        print "End Time:    {0}".format(time.strftime("%X"))
        print "Outcome:     {0}".format(outcome)
        print "_________________________________TEST END_______________________________________"
        print ""
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:27,代码来源:BaseClass.py

示例6: setUpClass

# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import cleanup [as 别名]
    def setUpClass(cls, class_name):

        print ""
        print "_________________________________CLASS START_______________________________________"
        print "Class Name: {0}".format(class_name)
        print "Start Time:  {0}".format(time.strftime("%X"))
        print ""

        Tns.kill()
        Gradle.kill()
        Process.kill('node')
        Process.kill('adb')
        if CURRENT_OS == OSType.OSX:
            Process.kill('NativeScript Inspector')
            Process.kill('Safari')
            Process.kill('Xcode')

        if class_name is not None:
            logfile = os.path.join('out', class_name + '.txt')
        else:
            logfile = os.path.join(OUTPUT_FOLDER, cls.__name__ + ".txt")

        File.remove(logfile)
        sys.stdout = sys.stderr = Logger.Logger(logfile)

        Folder.cleanup(cls.app_name)
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:28,代码来源:BaseClass.py

示例7: test_391_platform_list

# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import cleanup [as 别名]
    def test_391_platform_list(self):
        """Platform list command should list installed platforms and if app is prepared for those platforms"""
        Folder.cleanup(self.app_name)
        Tns.create_app(self.app_name, update_modules=False)

        # `tns platform list` on brand new project
        output = Tns.platform_list(attributes={"--path": self.app_name})
        TnsAsserts.platform_list_status(output=output, prepared=Platform.NONE, added=Platform.NONE)

        # `tns platform list` when iOS is added
        Tns.platform_add_ios(attributes={"--path": self.app_name, "--frameworkPath": IOS_PACKAGE})
        output = Tns.platform_list(attributes={"--path": self.app_name})
        TnsAsserts.platform_list_status(output=output, prepared=Platform.NONE, added=Platform.IOS)

        # `tns platform list` when iOS is prepared
        Tns.prepare_ios(attributes={"--path": self.app_name})
        output = Tns.platform_list(attributes={"--path": self.app_name})
        TnsAsserts.platform_list_status(output=output, prepared=Platform.IOS, added=Platform.IOS)

        # `tns platform list` when android is added (iOS already prepared)
        Tns.platform_add_android(attributes={"--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE})
        output = Tns.platform_list(attributes={"--path": self.app_name})
        TnsAsserts.platform_list_status(output=output, prepared=Platform.IOS, added=Platform.BOTH)

        # `tns platform list` when android is prepared (iOS already prepared)
        Tns.prepare_android(attributes={"--path": self.app_name})
        output = Tns.platform_list(attributes={"--path": self.app_name})
        TnsAsserts.platform_list_status(output=output, prepared=Platform.BOTH, added=Platform.BOTH)

        # Verify build both platforms is not allowed
        # Test for https://github.com/NativeScript/nativescript-cli/pull/3425
        output = Tns.run_tns_command(command="build", attributes={"--path": self.app_name})
        assert "The input is not valid sub-command for 'build' command" in output
        assert "<Platform> is the target mobile platform for which you want to build your project" in output
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:36,代码来源:platform_ios_tests.py

示例8: setUp

# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import cleanup [as 别名]
 def setUp(self):
     print ""
     print "_________________________________TEST START_______________________________________"
     print "Test Method: {0}".format(self._testMethodName)
     print "Start Time:  {0}".format(time.strftime("%X"))
     print ""
     Folder.cleanup(os.path.join(TEST_RUN_HOME, 'out', 'images'))
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:9,代码来源:BaseClass.py

示例9: test_311_build_android_with_custom_compile_sdk_old

# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import cleanup [as 别名]
 def test_311_build_android_with_custom_compile_sdk_old(self):
     #https://github.com/NativeScript/nativescript-cli/issues/4052
     # This is required when build with different SDK
     Folder.cleanup(self.app_name)
     Tns.create_app(self.app_name)
     Tns.platform_add_android(attributes={"--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE})
     Tns.build_android(attributes={"--compileSdk": "27", "--path": self.app_name})
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:9,代码来源:build_android_tests.py

示例10: test_401_prepare_project_with_many_dependencies

# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import cleanup [as 别名]
 def test_401_prepare_project_with_many_dependencies(self):
     """
     Test for https://github.com/NativeScript/nativescript-cli/issues/2561
     """
     Folder.cleanup(self.app_name)
     Tns.create_app_ng(app_name=self.app_name, template_version="4", update_modules=False)
     if USE_YARN == "True":
         Npm.install(package="lodash", folder=self.app_name)
         Npm.install(package="moment", folder=self.app_name)
         Npm.install(package="nativescript-cardview", folder=self.app_name)
         Npm.install(package="nativescript-sqlite", folder=self.app_name)
         Npm.install(package="nativescript-statusbar", folder=self.app_name)
         Npm.install(package="nativescript-websockets", folder=self.app_name)
         Npm.install(package="number-generator", folder=self.app_name)
         Npm.install(package="eslint", folder=self.app_name)
         Npm.install(package="eslint-plugin-compat", folder=self.app_name)
     else:
         Npm.install(package="lodash", option="--save", folder=self.app_name)
         Npm.install(package="moment", option="--save", folder=self.app_name)
         Npm.install(package="nativescript-cardview", option="--save", folder=self.app_name)
         Npm.install(package="nativescript-sqlite", option="--save", folder=self.app_name)
         Npm.install(package="nativescript-statusbar", option="--save", folder=self.app_name)
         Npm.install(package="nativescript-websockets", option="--save", folder=self.app_name)
         Npm.install(package="number-generator", option="--save", folder=self.app_name)
         Npm.install(package="eslint", option="--save", folder=self.app_name)
         Npm.install(package="eslint-plugin-compat", option="--save", folder=self.app_name)
     Tns.platform_add_android(version="4", attributes={"--path": self.app_name})
     Tns.prepare_android(attributes={"--path": self.app_name}, log_trace=True)
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:30,代码来源:prepare_android_tests.py

示例11: setUp

# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import cleanup [as 别名]
    def setUp(self):
        BaseClass.setUp(self)
        Tns.kill()

        # Replace app folder between tests.
        app_folder = os.path.join(self.app_name, 'app')
        Folder.cleanup(app_folder)
        Folder.copy(src=self.TEMP_FOLDER, dst=app_folder)
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:10,代码来源:run_ios_device_tests.py

示例12: test_210_tns_run_android_add_remove_files_and_folders

# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import cleanup [as 别名]
    def test_210_tns_run_android_add_remove_files_and_folders(self):
        """
        New files and folders should be synced properly.
        """

        log = Tns.run_android(attributes={'--path': self.app_name, '--device': self.DEVICE_ID}, wait=False,
                              assert_success=False)
        strings = ['Successfully synced application', self.DEVICE_ID]
        Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10)

        # Add new files
        new_file_name = 'main-page2.xml'
        source_file = os.path.join(self.app_name, 'app', 'main-page.xml')
        destination_file = os.path.join(self.app_name, 'app', new_file_name)
        File.copy(source_file, destination_file)
        strings = ['Successfully transferred main-page2.xml', 'Successfully synced application', self.DEVICE_ID]
        Tns.wait_for_log(log_file=log, string_list=strings)

        # Verify new file is synced and available on device.
        error_message = 'Newly created file {0} not found on {1}'.format(new_file_name, self.DEVICE_ID)
        app_id = Tns.get_app_id(app_name=self.app_name)
        path = 'app/{0}'.format(new_file_name)
        assert Adb.path_exists(device_id=self.DEVICE_ID, package_id=app_id, path=path), error_message

        # Revert changes(rename file and delete file)
        File.copy(destination_file, source_file)
        File.remove(destination_file)
        strings = ['Successfully transferred main-page.xml', 'Successfully synced application', self.DEVICE_ID]
        Tns.wait_for_log(log_file=log, string_list=strings)

        # Verify new file is synced and available on device.
        error_message = '{0} was deleted, but still available on {1}'.format(new_file_name, self.DEVICE_ID)
        assert Adb.path_does_not_exist(device_id=self.DEVICE_ID, package_id=app_id, path=path), error_message

        # Add folder
        new_folder_name = 'feature2'
        source_file = os.path.join(self.app_name, 'app', 'feature1')
        destination_file = os.path.join(self.app_name, 'app', new_folder_name)
        Folder.copy(source_file, destination_file)
        strings = ['Successfully transferred', 'Successfully transferred', 'feature1.js', self.DEVICE_ID]
        Tns.wait_for_log(log_file=log, string_list=strings)

        # Verify new folder is synced and available on device.
        error_message = 'Newly created folder {0} not found on {1}'.format(new_folder_name, self.DEVICE_ID)
        path = 'app/{0}'.format(new_folder_name)
        assert Adb.path_exists(device_id=self.DEVICE_ID, package_id=app_id, path=path, timeout=20), error_message
        path = 'app/{0}/{1}'.format(new_folder_name, 'feature1.js')
        assert Adb.path_exists(device_id=self.DEVICE_ID, package_id=app_id, path=path, timeout=20), error_message

        # Delete folder
        Folder.cleanup(destination_file)
        strings = ['Successfully synced application', self.DEVICE_ID]
        Tns.wait_for_log(log_file=log, string_list=strings)

        # Verify new folder is deleted from device.
        error_message = 'Deleted folder {0} is still available on {1}'.format(new_folder_name, self.DEVICE_ID)
        assert Adb.path_does_not_exist(device_id=self.DEVICE_ID, package_id=app_id, path=path), error_message
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:59,代码来源:run_android_device_tests.py

示例13: test_313_build_android_with_invalid_compile_sdk

# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import cleanup [as 别名]
    def test_313_build_android_with_invalid_compile_sdk(self):
        # This is required when build with different SDK
        Folder.cleanup(self.app_name)
        Tns.create_app(self.app_name)
        Tns.platform_add_android(attributes={"--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE})

        output = Tns.build_android(attributes={"--compileSdk": "99", "--path": self.app_name},
                                   assert_success=False)
        assert "You have specified '99' for compile sdk, but it is not installed on your system." in output
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:11,代码来源:build_android_tests.py

示例14: test_330_prepare_android_next

# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import cleanup [as 别名]
 def test_330_prepare_android_next(self):
     Tns.platform_remove(platform=Platform.ANDROID, attributes={"--path": self.app_name}, assert_success=False)
     Tns.platform_add_android(attributes={"--path": self.app_name}, version="next")
     Folder.cleanup(os.path.join(self.app_name, "node_modules"))
     Folder.cleanup(os.path.join(self.app_name, "platforms"))
     android_version = Npm.get_version("[email protected]")
     File.replace(file_path=os.path.join(self.app_name, "package.json"), str1=android_version, str2="next")
     output = Tns.prepare_android(attributes={"--path": self.app_name})
     TnsAsserts.prepared(self.app_name, platform=Platform.ANDROID, output=output, prepare=Prepare.FIRST_TIME)
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:11,代码来源:prepare_android_tests.py


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