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


Python File.remove方法代码示例

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


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

示例1: get_screen

# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import remove [as 别名]
    def get_screen(device_id, file_path):
        """
        Save screen of mobile device.
        :param device_id: Device identifier (example: `emulator-5554`).
        :param file_path: Path to image that will be saved.
        """

        File.remove(file_path)
        base_path, file_name = os.path.split(file_path)
        Folder.create(base_path)

        device_type = Device.__get_device_type(device_id)
        if (device_type == DeviceType.EMULATOR) or (device_type == DeviceType.ANDROID):
            Adb.get_screen(device_id=device_id, file_path=file_path)
        if device_type == DeviceType.SIMULATOR:
            Simulator.get_screen(device_id=device_id, file_path=file_path)
        if device_type == DeviceType.IOS:
            IDevice.get_screen(device_id=device_id, file_path=file_path)

        image_saved = False
        if File.exists(file_path):
            size = os.path.getsize(file_path)
            if size > 10:
                image_saved = True
        return image_saved
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:27,代码来源:device.py

示例2: setUpClass

# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import remove [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

示例3: test_301_prepare_android_platform_specific_files

# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import remove [as 别名]
    def test_301_prepare_android_platform_specific_files(self):
        Tns.prepare_android(attributes={"--path": self.app_name})

        # Add set of platform specific files
        File.copy(self.app_name + "/app/app.js", self.app_name + "/app/app.ios.js")
        File.copy(self.app_name + "/app/app.js", self.app_name + "/app/app.android.js")
        File.copy(self.app_name + "/app/app.js", self.app_name + "/app/appios.js")
        File.copy(self.app_name + "/app/app.js", self.app_name + "/app/appandroid.js")
        File.copy(self.app_name + "/app/app.js", self.app_name + "/app/ios.js")
        File.copy(self.app_name + "/app/app.js", self.app_name + "/app/android.js")

        File.copy(self.app_name + "/app/app.css", self.app_name + "/app/app.ios.css")
        File.copy(self.app_name + "/app/app.css", self.app_name + "/app/app.android.css")
        File.copy(self.app_name + "/app/app.js", self.app_name + "/app/appNew.js")
        File.copy(self.app_name + "/app/app.css", self.app_name + "/app/appNew.css")
        File.remove(self.app_name + "/app/app.js")
        File.remove(self.app_name + "/app/app.css")

        Tns.prepare_android(attributes={"--path": self.app_name})

        # Verify new files are in available in platforms folder
        app_path = os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH)
        assert File.exists(os.path.join(app_path, 'app.css'))
        assert File.exists(os.path.join(app_path, 'app.js'))
        assert File.exists(os.path.join(app_path, 'appandroid.js'))
        assert File.exists(os.path.join(app_path, 'appios.js'))
        assert File.exists(os.path.join(app_path, 'android.js'))
        assert File.exists(os.path.join(app_path, 'ios.js'))
        assert not File.exists(os.path.join(app_path, 'app.ios.css'))
        assert not File.exists(os.path.join(app_path, 'app.android.css'))
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:32,代码来源:prepare_android_tests.py

示例4: test_210_tns_run_android_add_remove_files_and_folders

# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import remove [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

示例5: pack

# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import remove [as 别名]
 def pack(folder, output_file):
     try:
         Folder.navigate_to(folder)
         run('npm pack', log_level=CommandLogLevel.SILENT)
         src_file = File.find_by_extension('tgz')[0]
         File.copy(src=src_file, dest=output_file)
         File.remove(src_file)
     except:
         print 'Failed to pack {0}'.format(folder)
     Folder.navigate_to(TEST_RUN_HOME, relative_from_current_folder=False)
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:12,代码来源:npm.py

示例6: test_009_android_run_hmr_delete_file

# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import remove [as 别名]
    def test_009_android_run_hmr_delete_file(self):
        log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID, '--hmr': ''}, wait=False,
                        assert_success=False)

        Tns.wait_for_log(log_file=log, string_list=HelpersHMR.wp_run, not_existing_string_list=HelpersHMR.wp_errors,
                         timeout=240)
        HelpersHMR.android_screen_match(image=self.image_original, timeout=120)
        File.remove(self.app_name + 'app', 'main-view-model.js')

        self.apply_changes(app_name=self.app_name, log=log, platform=Platform.ANDROID)
        self.revert_changes(app_name=self.app_name, log=log, platform=Platform.ANDROID)
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:13,代码来源:hello_world_js_hmr_android.py

示例7: test_321_build_with_copy_to_option

# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import remove [as 别名]
    def test_321_build_with_copy_to_option(self):
        # TODO: Remove those lines after https://github.com/NativeScript/nativescript-cli/issues/2547 is fixed.
        # 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})

        File.remove(self.debug_apk)
        Tns.build_android(attributes={"--path": self.app_name, "--copy-to": "./"})
        assert File.exists(self.debug_apk)
        File.remove(self.debug_apk)
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:13,代码来源:build_android_tests.py

示例8: get_screen_text

# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import remove [as 别名]
 def get_screen_text(device_id):
     """
     Get text of current screen on mobile device.
     :param device_id: Device identifier (example: `emulator-5554`).
     :return: All the text visible on screen as string
     """
     img_name = "actual_{0}_{1}.png".format(device_id, time.time())
     actual_image_path = os.path.join(OUTPUT_FOLDER, "images", device_id, img_name)
     if File.exists(actual_image_path):
         File.remove(actual_image_path)
     Device.get_screen(device_id=device_id, file_path=actual_image_path)
     image = Image.open(actual_image_path).convert('LA')
     text = pytesseract.image_to_string(image)
     return text
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:16,代码来源:device.py

示例9: get_screen

# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import remove [as 别名]
    def get_screen(device_id, file_path):
        """
        Save screen of mobile device.
        :param device_id: Device identifier (example: `emulator-5554`).
        :param file_path: Name of image that will be saved.
        """

        base_path, file_name = os.path.split(file_path)
        file_name = file_name.rsplit('.', 1)[0]

        run(command="idevicescreenshot -u {0} {1}.tiff".format(device_id, file_name), log_level=CommandLogLevel.SILENT)
        run(command="sips -s format png {0}.tiff --out {1}".format(file_name, file_path),
            log_level=CommandLogLevel.SILENT)
        File.remove("{0}.tiff".format(file_name))
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:16,代码来源:libimobiledevice.py

示例10: get_screen_text

# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import remove [as 别名]
 def get_screen_text():
     """
     Get text of current screen of host machine.
     :return: All the text visible on screen as string
     """
     base_path = os.path.join(OUTPUT_FOLDER, "images", "host")
     if not File.exists(base_path):
         Folder.create(base_path)
     actual_image_path = os.path.join(base_path, "host_{0}.png".format(time.time()))
     if File.exists(actual_image_path):
         File.remove(actual_image_path)
     Screen.save_screen(path=actual_image_path)
     image = Image.open(actual_image_path)
     text = pytesseract.image_to_string(image.convert('L'))
     return text
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:17,代码来源:screen.py

示例11: test_220_build_ios_with_custom_plist

# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import remove [as 别名]
    def test_220_build_ios_with_custom_plist(self):
        # Update Info.plist
        src_file = os.path.join(TEST_RUN_HOME, 'data', 'Info.plist')
        target_file = os.path.join(TEST_RUN_HOME, self.app_name, 'app', 'App_Resources', 'iOS', 'Info.plist')
        File.remove(target_file)
        File.copy(src=src_file, dest=target_file)

        # Prepare in debug
        final_plist = os.path.join(TEST_RUN_HOME, self.app_name, 'platforms', 'ios', 'TestApp', 'TestApp-Info.plist')
        Tns.prepare_ios(attributes={"--path": self.app_name})
        assert "<string>fbXXXXXXXXX</string>" in File.read(final_plist)
        assert "<string>orgnativescriptTestApp</string>" in File.read(final_plist)

        # Prepare in release
        Tns.prepare_ios(attributes={"--path": self.app_name, '--release': ''})
        assert "<string>fbXXXXXXXXX</string>" in File.read(final_plist)
        assert "<string>orgnativescriptTestApp</string>" not in File.read(final_plist)
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:19,代码来源:prepare_ios_tests.py

示例12: setUpClass

# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import remove [as 别名]
    def setUpClass(cls):
        BaseClass.setUpClass(cls.__name__)

        Folder.cleanup(cls.app_no_platform)

        File.remove(cls.debug_apk)
        File.remove(cls.release_apk)
        Folder.cleanup('temp')

        Tns.create_app(cls.app_name)
        Tns.platform_add_android(attributes={"--path": cls.app_name, "--frameworkPath": ANDROID_PACKAGE})

        # Add release and debug configs
        debug = os.path.join(cls.app_name, 'app', 'config.debug.json')
        release = os.path.join(cls.app_name, 'app', 'config.release.json')
        File.write(file_path=debug, text='{"config":"debug"}')
        File.write(file_path=release, text='{"config":"release"}')
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:19,代码来源:build_android_tests.py

示例13: test_300_prepare_android_remove_old_files

# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import remove [as 别名]
    def test_300_prepare_android_remove_old_files(self):
        Tns.prepare_android(attributes={"--path": self.app_name})

        # Add new files and delete old files
        time.sleep(1)
        File.copy(self.app_name + "/app/app.js", self.app_name + "/app/app-new.js")
        File.copy(self.app_name + "/app/app.css", self.app_name + "/app/app-new.css")
        File.copy(self.app_name + "/app/main-page.xml", self.app_name + "/app/main-page-new.xml")
        File.remove(self.app_name + "/app/app.js")
        File.remove(self.app_name + "/app/app.css")
        File.remove(self.app_name + "/app/main-page.xml")

        Tns.prepare_android(attributes={"--path": self.app_name})

        # Verify new files are in available in platforms folder
        app_path = os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH)
        assert File.exists(os.path.join(app_path, 'app-new.js'))
        assert File.exists(os.path.join(app_path, 'app-new.css'))
        assert File.exists(os.path.join(app_path, 'main-page-new.xml'))

        # Verify old files are removed from folder
        assert not File.exists(os.path.join(app_path, 'app.js'))
        assert not File.exists(os.path.join(app_path, 'app.css'))
        assert not File.exists(os.path.join(app_path, 'main-page.xml'))
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:26,代码来源:prepare_android_tests.py

示例14: test_001_redirect_strerr_output_to_file

# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import remove [as 别名]
 def test_001_redirect_strerr_output_to_file(self):
     File.remove('./stderr.txt')
     output = Tns.run_tns_command("run invalidEntry", attributes={" 2> stderr.txt ": ""})
     assert "The input is not valid sub-command for 'run' command" in output
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:6,代码来源:stderr_output_tests.py

示例15: tearDownClass

# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import remove [as 别名]
 def tearDownClass(cls):
     File.remove(cls.debug_apk)
     File.remove(cls.release_apk)
     Folder.cleanup('temp')
     pass
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:7,代码来源:build_android_tests.py


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