本文整理汇总了Python中umake.tools.remove_framework_envs_from_user函数的典型用法代码示例。如果您正苦于以下问题:Python remove_framework_envs_from_user函数的具体用法?Python remove_framework_envs_from_user怎么用?Python remove_framework_envs_from_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了remove_framework_envs_from_user函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_remove_user_env_no_file
def test_remove_user_env_no_file(self, expanderusermock):
"""Remove an env from a user setup with no profile file"""
expanderusermock.return_value = self.local_dir
profile_file = os.path.join(self.local_dir, ".profile")
tools.remove_framework_envs_from_user("framework A")
self.assertRaises(FileNotFoundError, open, profile_file)
示例2: test_remove_user_env_not_found
def test_remove_user_env_not_found(self, expanderusermock):
"""Remove an env from a user setup with no matching content found"""
expanderusermock.return_value = self.local_dir
profile_file = os.path.join(self.local_dir, ".profile")
open(profile_file, 'w').write("Foo\nBar\nexport BAR=baz")
tools.remove_framework_envs_from_user("framework A")
profile_content = open(profile_file).read()
self.assertEqual(profile_content, "Foo\nBar\nexport BAR=baz")
示例3: test_remove_user_env_end
def test_remove_user_env_end(self, expanderusermock):
"""Remove an env from a user setup being at the end of profile file"""
expanderusermock.return_value = self.local_dir
profile_file = os.path.join(self.local_dir, ".profile")
open(profile_file, "w").write("Foo\nBar\n# Ubuntu make installation of framework A" "\nexport FOO=bar\n\n")
tools.remove_framework_envs_from_user("framework A")
profile_content = open(profile_file).read()
self.assertEqual(profile_content, "Foo\nBar\n")
示例4: test_remove_user_multiple_same_framework
def test_remove_user_multiple_same_framework(self, expanderusermock):
"""Remove an env from a user setup, same framework being repeated multiple times"""
expanderusermock.return_value = self.local_dir
profile_file = os.path.join(self.local_dir, ".profile")
open(profile_file, 'w').write("Foo\nBar\n# Ubuntu make installation of framework A\nexport BAR=bar\n\n"
"# Ubuntu make installation of framework A\nexport FOO=bar\n\nexport BAR=baz")
tools.remove_framework_envs_from_user("framework A")
profile_content = open(profile_file).read()
self.assertEqual(profile_content, "Foo\nBar\nexport BAR=baz")
示例5: test_remove_user_env_multiple_frameworks
def test_remove_user_env_multiple_frameworks(self, expanderusermock):
"""Remove an env from a user setup restraining to the correct framework"""
expanderusermock.return_value = self.local_dir
profile_file = os.path.join(self.local_dir, ".profile")
open(profile_file, 'w').write("Foo\nBar\n# Ubuntu make installation of framework B\nexport BAR=bar\n\n"
"# Ubuntu make installation of framework A\nexport FOO=bar\n\nexport BAR=baz")
tools.remove_framework_envs_from_user("framework A")
profile_content = open(profile_file).read()
self.assertEquals(profile_content, "Foo\nBar\n# Ubuntu make installation of framework B\nexport BAR=bar\n\n"
"export BAR=baz")
示例6: test_remove_user_env_zsh
def test_remove_user_env_zsh(self, expanderusermock):
"""Remove an env from a user setup using zsh"""
os.environ['SHELL'] = '/bin/zsh'
expanderusermock.return_value = self.local_dir
profile_file = os.path.join(self.local_dir, ".zprofile")
open(profile_file, 'w').write("Foo\nBar\n# Ubuntu make installation of framework A"
"\nexport FOO=bar\n\nexport BAR=baz")
tools.remove_framework_envs_from_user("framework A")
profile_content = open(profile_file).read()
self.assertEqual(profile_content, "Foo\nBar\nexport BAR=baz")
示例7: tearDown
def tearDown(self):
# don't remove on machine paths if running within a container
if not self.in_container:
with suppress(FileNotFoundError):
shutil.rmtree(self.installed_path)
# TODO: need to be finer grain in the future
with suppress(FileNotFoundError):
os.remove(self.conf_path)
if self.desktop_filename:
with suppress(FileNotFoundError):
os.remove(get_launcher_path(self.desktop_filename))
remove_framework_envs_from_user(self.framework_name_for_profile)
for dir in self.additional_dirs:
with suppress(OSError):
shutil.rmtree(dir)
super().tearDown()
示例8: tearDown
def tearDown(self):
# don't remove on machine paths if running within a container
if not self.in_container:
with suppress(FileNotFoundError):
shutil.rmtree(self.installed_path)
# TODO: need to be finer grain in the future
with suppress(FileNotFoundError):
os.remove(self.conf_path)
if self.desktop_filename:
with suppress(FileNotFoundError):
os.remove(get_launcher_path(self.desktop_filename))
remove_framework_envs_from_user(self.framework_name_for_profile)
for dir in self.additional_dirs:
with suppress(OSError):
shutil.rmtree(dir)
# restore original environment. Do not use the dict copy which erases the object and doesn't have the magical
# _Environ which setenv() for subprocess
os.environ.clear()
os.environ.update(self.original_env)
super().tearDown()
示例9: remove
def remove(self):
"""Remove current framework if installed
Not that we only remove desktop file, launcher icon and dir content, we do not remove
packages as they might be in used for other framework"""
# check if it's installed and so on.
super().remove()
UI.display(DisplayMessage("Removing {}".format(self.name)))
if self.desktop_filename:
with suppress(FileNotFoundError):
os.remove(get_launcher_path(self.desktop_filename))
if self.icon_filename:
with suppress(FileNotFoundError):
os.remove(get_icon_path(self.icon_filename))
with suppress(FileNotFoundError):
shutil.rmtree(self.install_path)
remove_framework_envs_from_user(self.name)
self.remove_from_config()
UI.delayed_display(DisplayMessage("Suppression done"))
UI.return_main_screen()
示例10: reinstall
def reinstall(self):
logger.debug("Mark previous installation path for cleaning.")
self._paths_to_clean.add(self.install_path) # remove previous installation path
self.confirm_path(self.arg_install_path)
remove_framework_envs_from_user(self.name)