本文整理汇总了Python中core.osutils.folder.Folder.create方法的典型用法代码示例。如果您正苦于以下问题:Python Folder.create方法的具体用法?Python Folder.create怎么用?Python Folder.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.osutils.folder.Folder
的用法示例。
在下文中一共展示了Folder.create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_screen
# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import create [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
示例2: tearDown
# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import create [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 ""
示例3: test_370_tns_run_android_with_jar_and_aar_files_in_app_res
# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import create [as 别名]
def test_370_tns_run_android_with_jar_and_aar_files_in_app_res(self):
"""
App should not crash when reference .jar or/and .aar file in App_Resources/Android/libs
https://github.com/NativeScript/android-runtime/issues/899
"""
# Create libs/ in app/App_resources/, add .jar and .aar files in it and modify the app to reference them
curr_folder = os.getcwd()
Folder.navigate_to(os.path.join(self.app_name, 'app', 'App_Resources', 'Android'))
Folder.create("libs")
app_res_libs = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'libs')
Folder.navigate_to(curr_folder)
custom_jar_file = os.path.join('data', 'issues', 'android-runtime-pr-905', 'customLib.jar')
custom_aar_file = os.path.join('data', 'issues', 'android-runtime-899', 'mylibrary.aar')
File.copy(src=custom_jar_file, dest=app_res_libs)
File.copy(src=custom_aar_file, dest=app_res_libs)
source = os.path.join('data', 'issues', 'android-runtime-899', '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')
示例4: test_301_build_project_with_space_release
# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import create [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()
示例5: get_screen_text
# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import create [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
示例6: check_splashes
# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import create [as 别名]
def check_splashes(app_resources_android, app_resources_ios):
for folder in ResourcesGenerateTests.drawable_folders:
actual_logo = os.path.join(app_resources_android, folder, "logo.png")
expected_logo = os.path.join(ResourcesGenerateTests.expected_images_android, folder, "logo.png")
result = ImageUtils.image_match(actual_logo, expected_logo, 0.1)
if str(result[0]) is "False":
assert False, "Images: \n{0} and \n{1} \nhas diff: {2}".format(actual_logo, expected_logo,
str(result[1]))
actual_background = os.path.join(app_resources_android, folder, "background.png")
expected_background = os.path.join(ResourcesGenerateTests.expected_images_android, folder, "background.png")
result = ImageUtils.image_match(actual_background, expected_background, 0.1)
if str(result[0]) is "False":
assert False, "Images: \n{0} and \n{1} \nhas diff: {2}".format(actual_background, expected_background,
str(result[1]))
# iOS
if CURRENT_OS == OSType.OSX:
# Get all images to compare in one folder
src_1 = os.path.join(app_resources_ios, "LaunchImage.launchimage")
src_2 = os.path.join(app_resources_ios, "LaunchScreen.AspectFill.imageset")
src_3 = os.path.join(app_resources_ios, "LaunchScreen.Center.imageset")
Folder.create("temp_ios_resources")
dist = os.path.join(os.getcwd(), "temp_ios_resources")
Folder.copy(src_1, dist, only_files=True)
Folder.copy(src_2, dist, only_files=True)
Folder.copy(src_3, dist, only_files=True)
ios_images = ["[email protected]", "[email protected]", "[email protected]", "Default-1125h.png",
"Default-Landscape-X.png", "Default-Landscape.png", "[email protected]",
"[email protected]", "Default-Portrait.png", "[email protected]", "Default.png",
"[email protected]", "LaunchScreen-AspectFill.png", "LaunchScreen-Aspect[email protected]",
"LaunchScreen-Center.png", "[email protected]"]
for image in ios_images:
actual_image = os.path.join(os.getcwd(), "temp_ios_resources", image)
expected_image = os.path.join(ResourcesGenerateTests.expected_images_ios, image)
result = ImageUtils.image_match(actual_image, expected_image, 0.1)
if str(result[0]) is "False":
assert False, "Images: \n{0} and \n{1} \nhas diff: {2}".format(actual_image, expected_image,
str(result[1]))
示例7:
# 需要导入模块: from core.osutils.folder import Folder [as 别名]
# 或者: from core.osutils.folder.Folder import create [as 别名]
Git.clone_repo(repo_url='[email protected]:NativeScript/template-hello-world-ng.git',
local_folder=os.path.join(SUT_FOLDER, 'template-hello-world-ng'))
Npm.pack(folder=os.path.join(SUT_FOLDER, 'template-hello-world'),
output_file=os.path.join(SUT_FOLDER, 'tns-template-hello-world.tgz'))
Npm.pack(folder=os.path.join(SUT_FOLDER, 'template-hello-world-ts'),
output_file=os.path.join(SUT_FOLDER, 'tns-template-hello-world-ts.tgz'))
Npm.pack(folder=os.path.join(SUT_FOLDER, 'template-hello-world-ng'),
output_file=os.path.join(SUT_FOLDER, 'tns-template-hello-world-ng.tgz'))
if __name__ == '__main__':
# Cleanup files and folders created by the test execution
Folder.cleanup(OUTPUT_FOLDER)
Folder.create(OUTPUT_FOLDER)
Folder.cleanup(SUT_FOLDER)
Folder.cleanup("node_modules")
Npm.cache_clean()
Gradle.kill()
Gradle.cache_clean()
get_repos()
Emulator.stop() # Stop running emulators
# Copy test packages and cleanup
if CURRENT_OS == OSType.OSX:
Simulator.stop()
disable_crash_report()
get_test_packages(platform=Platform.BOTH)
Simulator.reset()