本文整理汇总了Python中core.osutils.folder.Folder类的典型用法代码示例。如果您正苦于以下问题:Python Folder类的具体用法?Python Folder怎么用?Python Folder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Folder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_401_prepare_project_with_many_dependencies
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)
示例2: test_391_platform_list
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
示例3: create_app
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
示例4: test_311_build_android_with_custom_compile_sdk_old
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})
示例5: test_301_build_project_with_space_release
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()
示例6: setUpClass
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)
示例7: get_screen
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
示例8: tearDown
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 ""
示例9: test_200_tns_run_android_extending_class_inside_file_containing_dots
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)
示例10: setUp
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'))
示例11: __run_yarn_command
def __run_yarn_command(command, folder=None, log_level=CommandLogLevel.FULL):
if folder is not None:
Folder.navigate_to(folder=folder, relative_from_current_folder=True)
output = run('yarn {0}'.format(command), log_level=log_level)
if folder is not None:
Folder.navigate_to(TEST_RUN_HOME, relative_from_current_folder=False)
return output
示例12: test_280_tns_run_android_console_time
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)
示例13: test_210_tns_run_ios_add_remove_files_and_folders
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)
示例14: update_webpack
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
示例15: setUp
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)