本文整理汇总了Python中core.osutils.file.File.copy方法的典型用法代码示例。如果您正苦于以下问题:Python File.copy方法的具体用法?Python File.copy怎么用?Python File.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.osutils.file.File
的用法示例。
在下文中一共展示了File.copy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_210_tns_run_ios_add_remove_files_and_folders
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import copy [as 别名]
def test_210_tns_run_ios_add_remove_files_and_folders(self):
"""
New files and folders should be synced properly.
"""
log = Tns.run_ios(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 = 'app2.css'
source_file = os.path.join(self.app_name, 'app', 'app.css')
destination_file = os.path.join(self.app_name, 'app', new_file_name)
File.copy(source_file, destination_file)
strings = ['Successfully transferred', new_file_name, 'Refreshing application']
Tns.wait_for_log(log_file=log, string_list=strings)
# Revert changes(rename file and delete file)
# File.copy(destination_file, source_file)
# File.remove(destination_file)
# strings = ['Successfully transferred', new_file_name]
# Tns.wait_for_log(log_file=log, string_list=strings)
# Add folder
new_folder_name = 'test2'
source_file = os.path.join(self.app_name, 'app', 'test')
destination_file = os.path.join(self.app_name, 'app', new_folder_name)
Folder.copy(source_file, destination_file)
strings = ['Successfully transferred test.txt', 'Successfully synced application']
Tns.wait_for_log(log_file=log, string_list=strings)
示例2: test_181_tns_run_ios_console_dir
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import copy [as 别名]
def test_181_tns_run_ios_console_dir(self):
"""
Test console.dir() of different objects.
"""
# Change main-page.js so it contains console logging
source_js = os.path.join('data', 'console-dir', 'main-page.js')
target_js = os.path.join(self.app_name, 'app', 'main-page.js')
File.copy(src=source_js, dest=target_js)
john_obj = "==== object dump start ====\n" \
"name: John\n" \
"age: 34\n" \
"==== object dump end ===="
log = Tns.run_ios(attributes={'--path': self.app_name, '--emulator': ''}, wait=False, assert_success=False)
strings = ['Project successfully built',
'Successfully installed on device with identifier', self.SIMULATOR_ID,
"true",
"false",
"null",
"undefined",
"-1",
"text",
self.max_long_string,
john_obj
]
Tns.wait_for_log(log_file=log, string_list=strings, timeout=150, check_interval=10)
assert self.very_long_string not in log
示例3: test_181_tns_run_android_console_dir
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import copy [as 别名]
def test_181_tns_run_android_console_dir(self):
"""
Test console.dir() of different objects.
"""
# Change main-page.js so it contains console logging
source_js = os.path.join('data', 'console-dir', 'main-page.js')
target_js = os.path.join(self.app_name, 'app', 'main-page.js')
File.copy(src=source_js, dest=target_js)
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',
"true",
"false",
"null",
"undefined",
"-1",
"text",
"==== object dump start ====",
"name: \"John\"",
"age: \"34\"",
"==== object dump end ====",
self.max_long_string
]
Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10)
assert self.very_long_string not in log
示例4: test_360_tns_run_android_with_jar_file_in_plugin
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import copy [as 别名]
def test_360_tns_run_android_with_jar_file_in_plugin(self):
"""
App should not crash when reference .jar file in some plugin
https://github.com/NativeScript/android-runtime/pull/905
"""
# Add .jar file in plugin and modify the app to reference it
custom_jar_file = os.path.join('data', 'issues', 'android-runtime-pr-905', 'customLib.jar')
modules_widgets = os.path.join(self.app_name, 'node_modules', 'tns-core-modules-widgets', 'platforms',
'android')
File.copy(src=custom_jar_file, dest=modules_widgets)
source = os.path.join('data', 'issues', 'android-runtime-pr-905', 'app.js')
target = os.path.join(self.app_name, 'app', 'app.js')
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)
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)
# Verify app looks correct inside emulator
Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID,
expected_image='livesync-hello-world_home')
示例5: test_280_tns_run_android_console_time
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import copy [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)
示例6: test_301_build_project_with_space_release
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import copy [as 别名]
def test_301_build_project_with_space_release(self):
Tns.create_app(self.app_name_space)
Tns.platform_add_android(
attributes={"--path": "\"" + self.app_name_space + "\"", "--frameworkPath": ANDROID_PACKAGE})
# Ensure ANDROID_KEYSTORE_PATH contain spaces (verification for CLI issue 2650)
Folder.create("with space")
base_path, file_name = os.path.split(ANDROID_KEYSTORE_PATH)
cert_with_space_path = os.path.join("with space", file_name)
File.copy(src=ANDROID_KEYSTORE_PATH, dest=cert_with_space_path)
# Verify project builds
Tns.build_android(attributes={"--path": "\"" + self.app_name_space + "\"",
"--keyStorePath": "\"" + cert_with_space_path + "\"",
"--keyStorePassword": ANDROID_KEYSTORE_PASS,
"--keyStoreAlias": ANDROID_KEYSTORE_ALIAS,
"--keyStoreAliasPassword": ANDROID_KEYSTORE_ALIAS_PASS,
"--release": ""
})
output = File.read(self.app_name_space + os.sep + "package.json")
assert app_identifier in output.lower()
output = File.read(
self.app_name_space + "/" + TnsAsserts.PLATFORM_ANDROID_SRC_MAIN_PATH + "AndroidManifest.xml")
assert app_identifier in output.lower()
示例7: test_210_tns_run_android_add_remove_files_and_folders
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import copy [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
示例8: pack
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import copy [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)
示例9: test_008_ios_run_hmr_console_log
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import copy [as 别名]
def test_008_ios_run_hmr_console_log(self):
source_js = os.path.join('data', "issues", 'console-log-hmr', 'main-view-model.js')
target_js = os.path.join(self.app_name, 'app', 'main-view-model.js')
File.copy(src=source_js, dest=target_js)
log = Tns.run_ios(attributes={'--path': self.app_name, '--emulator': '', '--hmr': ''}, wait=False,
assert_success=False)
strings = ['LOG Hello']
Tns.wait_for_log(log_file=log, string_list=strings)
Helpers.ios_screen_match(sim_id=self.SIMULATOR_ID, image=HelpersHMR.image_original, timeout=120)
示例10: test_205_build_android_app_bundle_env_snapshot
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import copy [as 别名]
def test_205_build_android_app_bundle_env_snapshot(self):
"""Build app with android app bundle option with --bundle and optimisations for snapshot.
Verify the output(app.aab) and use bundletool to deploy on device."""
# This test will not run on windows because env.snapshot option is not available on that OS
path_to_aab = os.path.join(self.app_name, "platforms", "android", "app", "build", "outputs", "bundle", "release", "app.aab")
#Configure app with snapshot optimisations
source = os.path.join('data', 'abdoid-app-bundle', 'app.gradle')
target = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'app.gradle' )
File.copy(src=source, dest=target)
source = os.path.join('data', 'abdoid-app-bundle', 'webpack.config.js')
target = os.path.join(self.app_name, 'webpack.config.js' )
File.copy(src=source, dest=target)
#env.snapshot is applicable only in release build
output = Tns.build_android(attributes={"--path": self.app_name,
"--keyStorePath": ANDROID_KEYSTORE_PATH,
"--keyStorePassword": ANDROID_KEYSTORE_PASS,
"--keyStoreAlias": ANDROID_KEYSTORE_ALIAS,
"--keyStoreAliasPassword": ANDROID_KEYSTORE_ALIAS_PASS,
"--release": "",
"--aab": "",
"--env.uglify": "",
"--env.snapshot": "",
"--bundle": ""
}, assert_success=False)
assert "The build result is located at:" in output
assert path_to_aab in output
assert File.exists(path_to_aab)
#Verify app can be deployed on emulator via bundletool
# Use bundletool to create the .apks file
self.bundletool_build(self.bundletool_path, path_to_aab, self.path_to_apks)
assert File.exists(self.path_to_apks)
# Verify that the correct .so file is included in the package
File.unzip(self.path_to_apks, os.path.join(self.app_name, 'apks'))
File.unzip(os.path.join(self.app_name, 'apks', 'splits', 'base-x86.apk'), os.path.join(self.app_name,'base_apk'))
assert File.exists(os.path.join(self.app_name, 'base_apk', 'lib', 'x86', 'libNativeScript.so'))
# Deploy on device
self.bundletool_deploy(self.bundletool_path, self.path_to_apks, device_id=EMULATOR_ID)
# Start the app on device
Adb.start_app(EMULATOR_ID, "org.nativescript.TestApp")
# Verify app looks correct inside emulator
app_started = Device.wait_for_text(device_id=EMULATOR_ID, text='TAP')
assert app_started, 'App is not started on device'
示例11: test_008_android_run_hmr_console_log
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import copy [as 别名]
def test_008_android_run_hmr_console_log(self):
source_js = os.path.join('data', "issues", 'console-log-hmr', 'main-view-model.js')
target_js = os.path.join(self.app_name, 'app', 'main-view-model.js')
File.copy(src=source_js, dest=target_js)
log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID, '--hmr': ''}, wait=False,
assert_success=False)
strings = ['LOG Hello']
Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10)
# Verify app looks correct inside emulator
Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID,
expected_image=HelpersHMR.image_original)
示例12: test_200_prepare_additional_appresources
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import copy [as 别名]
def test_200_prepare_additional_appresources(self):
# prepare project
output = Tns.prepare_ios(attributes={"--path": self.app_name})
TnsAsserts.prepared(self.app_name, platform=Platform.IOS, output=output, prepare=Prepare.FULL)
# Create new files in AppResources
File.copy(self.app_name + "/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png",
self.app_name + "/app/App_Resources/iOS/newDefault.png")
# prepare project
output = Tns.prepare_ios(attributes={"--path": self.app_name})
TnsAsserts.prepared(self.app_name, platform=Platform.IOS, output=output, prepare=Prepare.INCREMENTAL)
# Verify XCode Project include files from App Resources folder
output = run("cat " + self.app_name + "/platforms/ios/TestApp.xcodeproj/project.pbxproj | grep newDefault.png")
assert "newDefault.png" in output
示例13: test_220_build_ios_with_custom_plist
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import copy [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)
示例14: test_180_tns_run_android_console_logging
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import copy [as 别名]
def test_180_tns_run_android_console_logging(self):
"""
Test console info, warn, error, assert, trace, time and logging of different objects.
"""
# Change main-page.js so it contains console logging
source_js = os.path.join('data', 'console-log', 'main-page.js')
target_js = os.path.join(self.app_name, 'app', 'main-page.js')
File.copy(src=source_js, dest=target_js)
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',
"true",
"false",
"null",
"undefined",
"-1",
"text",
"\"name\": \"John\",",
"\"age\": 34",
"number: -1",
"string: text",
"text -1",
"info",
"warn",
"error",
"Assertion failed: false == true",
"Assertion failed: empty string evaluates to 'false'",
"Trace: console.trace() called",
"at pageLoaded",
"Button(8)",
"-1 text {",
"[1, 5, 12.5, {", "\"name\": \"John\",",
"\"age\": 34",
"}, text, 42]",
"Time:",
self.max_long_string,
"### TEST END ###"
]
Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10, clean_log=False)
assert "1 equals 1" not in log
assert self.very_long_string not in log
示例15: copy
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import copy [as 别名]
def copy(src, dst, only_files=False):
"""
Copy src folder in the dst folder.
:param only_files: If it's set to True - only the files from src folder are copied to dst folder.
If it's set to False - src folder with all files in it are copied.
"""
if only_files is True:
files = os.listdir(src)
for f in files:
f_path = os.path.join(src, f)
File.copy(f_path, dst)
else:
try:
shutil.copytree(src, dst, symlinks=True)
except OSError as exc: # python >2.5
if exc.errno == errno.ENOTDIR:
shutil.copy(src, dst)
else:
raise