本文整理汇总了Python中core.osutils.file.File.read方法的典型用法代码示例。如果您正苦于以下问题:Python File.read方法的具体用法?Python File.read怎么用?Python File.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.osutils.file.File
的用法示例。
在下文中一共展示了File.read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import read [as 别名]
def start(emulator_name=EMULATOR_NAME, port=EMULATOR_PORT, timeout=300, wipe_data=True):
"""
Start emulator.
:param wipe_data: If true it will wipe emulator date.
:param emulator_name: Name of android emulator image (avd).
:param port: Port for Android emulator.
:param timeout: Time to wait until emulator boot.
"""
print 'Starting emulator {0}'.format(emulator_name)
if CURRENT_OS == OSType.WINDOWS:
start_command = 'START /B ' + EMULATOR_PATH + ' -avd ' + emulator_name + ' -port ' + port
else:
start_command = EMULATOR_PATH + ' -avd ' + emulator_name + ' -port ' + port
if wipe_data:
start_command += ' -wipe-data'
log_file = run(start_command, timeout=timeout, wait=False, log_level=CommandLogLevel.COMMAND_ONLY)
# Check if emulator is running
device_name = 'emulator-' + port
if Emulator.wait(device_name, timeout):
print 'Emulator started successfully.'
else:
print 'Emulator failed to boot!'
print File.read(log_file)
raise Exception('Wait for emulator failed!')
示例2: test_301_build_project_with_space_release
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import read [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()
示例3: test_301_platform_update_ios
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import read [as 别名]
def test_301_platform_update_ios(self):
Tns.platform_add_ios(version="2.2.0", attributes={"--path": self.app_name})
output = File.read(self.app_name + os.sep + "package.json")
assert "\"version\": \"2.2.0\"" in output
Tns.platform_update("[email protected]", attributes={"--path": self.app_name, " < data/keys/enter_key.txt": ""})
output = File.read(self.app_name + os.sep + "package.json")
assert "\"version\": \"2.3.0\"" in output
Tns.build_ios(attributes={"--path": self.app_name})
示例4: test_002_usage_reporting_disable
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import read [as 别名]
def test_002_usage_reporting_disable(self):
output = Tns.run_tns_command("usage-reporting disable")
assert disabled.format(usage_reporting, "now ") in output
assert "GA_TRACKING_ID" in File.read(self.config)
assert "UA-111455-44" in File.read(self.config)
# Check there is no any message for tracking in Google Analytics
output = Tns.run_tns_command("doctor", timeout=180, log_trace=True)
assert "Will send the following information to Google Analytics" not in output
output = Tns.run_tns_command("usage-reporting status")
assert disabled.format(usage_reporting, "") in output
示例5: test_100_plugin_add_sandbox_pod_can_write_in_app_folder
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import read [as 别名]
def test_100_plugin_add_sandbox_pod_can_write_in_app_folder(self):
Tns.create_app(self.app_name)
Tns.platform_add_ios(attributes={"--path": self.app_name,
"--frameworkPath": IOS_PACKAGE})
plugin = os.path.join(TEST_RUN_HOME, "data", "CocoaPods", "nativescript-ios-working-with-sandbox-plugin.tgz")
output = Tns.plugin_add(plugin, attributes={"--path": self.app_name}, assert_success=False)
assert "Successfully installed plugin nativescript-ios-working-with-sandbox-plugin." in output
assert "nativescript-ios-working-with-sandbox-plugin" in File.read(self.app_name + "/package.json")
output = Tns.prepare_ios(attributes={"--path": self.app_name})
assert "Successfully prepared plugin " + \
"nativescript-ios-working-with-sandbox-plugin for ios." in output
assert "content" in File.read(self.app_name + "/platforms/ios/TestApp/app/I_MADE_THIS_FILE.txt")
示例6: test_320_platform_add_ios_custom_bundle_id
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import read [as 别名]
def test_320_platform_add_ios_custom_bundle_id(self):
# Create project with different appId
Folder.cleanup(self.app_name)
output = Tns.create_app(self.app_name, attributes={"--appid": "org.nativescript.MyApp"}, assert_success=False)
TnsAsserts.created(self.app_name, output=output, full_check=False)
output = File.read(self.app_name + os.sep + "package.json")
assert "\"id\": \"org.nativescript.MyApp\"" in output
# Add iOS platform
Tns.platform_add_ios(attributes={"--path": self.app_name, "--frameworkPath": IOS_PACKAGE})
# Verify plist file in native project (after prepare)
Tns.prepare_ios(attributes={"--path": self.app_name})
output = File.read(self.app_name + "/platforms/ios/TestApp/TestApp-Info.plist")
assert "org.nativescript.MyApp" in output
示例7: create_app_ng
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import read [as 别名]
def create_app_ng(app_name, attributes={}, log_trace=False, assert_success=True, update_modules=True,
template_version=None):
if template_version is not None:
template = "[email protected]" + template_version
attr = {"--template": template}
else:
if BRANCH is "master":
attr = {"--template": SUT_FOLDER + os.path.sep + "tns-template-hello-world-ng.tgz"}
else:
attr = {"--template": "tns-template-hello-world-ng"}
attributes.update(attr)
output = Tns.create_app(app_name=app_name, attributes=attributes, log_trace=log_trace,
assert_success=assert_success,
update_modules=update_modules)
if update_modules:
Tns.update_angular(path=app_name)
Tns.update_typescript(path=app_name)
if assert_success:
if USE_YARN != "True":
if Npm.version() < 5:
assert "nativescript-angular" in output
assert File.exists(os.path.join(app_name, 'node_modules', 'nativescript-theme-core'))
package_json = File.read(os.path.join(app_name, 'package.json'))
assert "tns-core-modules" in package_json
assert "nativescript-angular" in package_json
assert "nativescript-dev-typescript" in package_json
return output
示例8: wait_for_log
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import read [as 别名]
def wait_for_log(log_file, string_list, not_existing_string_list=None, timeout=45, check_interval=3,
clean_log=True):
"""
Wait until log file contains list of string.
:param log_file: Path to log file.
:param string_list: List of strings.
:param not_existing_string_list: List of string that should not be in logs.
:param timeout: Timeout.
:param check_interval: Check interval.
:param clean_log: Specify if content of log file should be delete after check.
"""
t_end = time.time() + timeout
all_items_found = False
not_found_list = []
log = ""
while time.time() < t_end:
not_found_list = []
log = File.read(log_file)
log = str(log.decode('utf8').encode('utf8')).strip()
for item in string_list:
if item in log:
print "'{0}' found.".format(item)
else:
not_found_list.append(item)
if not_found_list == []:
all_items_found = True
print "Log contains: {0}".format(string_list)
break
else:
print "'{0}' NOT found. Wait...".format(not_found_list)
time.sleep(check_interval)
if 'BUILD FAILED' in log:
print 'BUILD FAILED. No need to wait more time!'
break
if 'Unable to sync files' in log:
print 'Sync process failed. No need to wait more time!'
break
if '????????????????????????????' in log:
print 'Log seems to be corrupted. No need to wait more time!'
break
if 'errors were thrown' in log:
print 'Multiple errors were thrown. No need to wait more time!'
break
if clean_log and (CURRENT_OS is not OSType.WINDOWS) and all_items_found:
File.write(file_path=log_file, text="")
if all_items_found:
if not_existing_string_list is None:
pass
else:
for item in not_existing_string_list:
assert item not in log, "{0} found! It should not be in logs.\nLog:\n{1}".format(item, log)
else:
print "##### OUTPUT BEGIN #####\n"
print log
print "##### OUTPUT END #####\n"
print ""
assert False, "Output does not contain {0}".format(not_found_list)
示例9: test_220_build_ios_with_custom_plist
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import read [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)
示例10: test_300_build_project_with_dash_and_ios_inspector_added
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import read [as 别名]
def test_300_build_project_with_dash_and_ios_inspector_added(self):
"""
Verify we can build projects with dashes.
Verify we can build android when inspector is added (test for CLI issue 2467)
"""
Tns.create_app(self.app_name_dash)
Tns.platform_add_android(attributes={"--path": self.app_name_dash, "--frameworkPath": ANDROID_PACKAGE})
if USE_YARN == "True":
Npm.install(package="tns-ios-inspector", option='--dev', folder=self.app_name_dash)
else:
Npm.install(package="tns-ios-inspector", option='--save-dev', folder=self.app_name_dash)
Tns.build_android(attributes={"--path": self.app_name_dash})
# Verify project id
output = File.read(self.app_name_dash + "/package.json")
assert app_identifier in output.lower()
# Verify AndroidManifest.xml
output = File.read(self.app_name_dash + "/" + TnsAsserts.PLATFORM_ANDROID_SRC_MAIN_PATH + "AndroidManifest.xml")
assert app_identifier in output.lower()
示例11: test_202_plugin_add_xcconfig_after_platform_add_ios
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import read [as 别名]
def test_202_plugin_add_xcconfig_after_platform_add_ios(self):
Tns.platform_add_ios(attributes={"--path": self.app_name, "--frameworkPath": IOS_PACKAGE})
plugin_path = TEST_RUN_HOME + "/data/CocoaPods/xcconfig-plugin.tgz"
output = Tns.plugin_add(plugin_path, attributes={"--path": self.app_name}, assert_success=False)
assert "Successfully installed plugin xcconfig-plugin." in output
assert File.exists(self.app_name + "/node_modules/xcconfig-plugin/package.json")
assert File.exists(self.app_name + "/node_modules/xcconfig-plugin/platforms/ios/build.xcconfig")
assert File.exists(self.app_name + "/node_modules/xcconfig-plugin/platforms/ios/module.modulemap")
assert File.exists(self.app_name + "/node_modules/xcconfig-plugin/platforms/ios/XcconfigPlugin.h")
assert "xcconfig-plugin" in File.read(self.app_name + "/package.json")
output = Tns.build_ios(attributes={"--path": self.app_name})
assert "Successfully prepared plugin xcconfig-plugin for ios." in output
output = File.read(self.app_name + "/platforms/ios/plugins-debug.xcconfig")
assert "OTHER_LDFLAGS = $(inherited) -l\"sqlite3\"" in output
output = File.read(self.app_name + "/platforms/ios/TestApp/build-debug.xcconfig")
assert "#include \"../plugins-debug.xcconfig\"" in output
示例12: test_001_usage_reporting_enable
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import read [as 别名]
def test_001_usage_reporting_enable(self):
output = Tns.run_tns_command("usage-reporting enable")
assert enabled.format(usage_reporting, "now ") in output
assert "GA_TRACKING_ID" in File.read(self.config)
assert "UA-111455-44" in File.read(self.config)
# Check there is message for tracking in Google Analytics
output = Tns.run_tns_command("doctor", timeout=180, log_trace=True)
assert "Will send the following information to Google Analytics" in output
output = Tns.run_tns_command("usage-reporting status")
assert enabled.format(usage_reporting, "") in output
# https://github.com/NativeScript/nativescript-cli/issues/3595
output = Tns.create_app(self.app_name,
attributes={'--template': os.path.join('data', 'apps', 'livesync-hello-world.tgz')},
log_trace=True,
force_clean=False, update_modules=True)
assert "label: 'data/apps/livesync-hello-world.tgz'" not in output
assert "label: 'localTemplate_tns-template-hello-world'" in output
示例13: test_002_build_android_release
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import read [as 别名]
def test_002_build_android_release(self):
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": ""
}, log_trace=True)
# Configs are respected
assert 'release' in File.read(os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH, 'config.json'))
assert File.exists(os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APK_RELEASE_PATH, self.release_apk))
示例14: __verify_debugger_attach
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import read [as 别名]
def __verify_debugger_attach(log, app_started=True):
strings = ["Frontend client connected", "Backend socket created", "NativeScript debugger attached"]
Tns.wait_for_log(log_file=log, string_list=strings, timeout=90, check_interval=10, clean_log=False)
time.sleep(10)
output = File.read(log)
assert "Frontend socket closed" not in output
assert "Backend socket closed" not in output
assert "NativeScript debugger detached" not in output
assert Process.is_running('NativeScript Inspector')
if app_started:
assert "Page loaded 1 time" in output, "Page not reloaded, this is bug!"
else:
assert "Page loaded 1 time" not in output, "Page reloaded, this is bug!"
示例15: package_json_contains
# 需要导入模块: from core.osutils.file import File [as 别名]
# 或者: from core.osutils.file.File import read [as 别名]
def package_json_contains(app_name, string_list=None):
"""
Assert package.json contains list of strings.
:param app_name: Application name.
:param string_list: List of strings.
"""
package_json_path = os.path.join(app_name, 'package.json')
output = File.read(package_json_path)
for item in string_list:
if item in output:
print '{0} found in {1}.'.format(item, str(package_json_path))
else:
print 'package.json:'
print output
assert False, '{0} NOT found in {1}.'.format(item, str(package_json_path))