本文整理汇总了Python中mozprofile.Profile.create_new方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.create_new方法的具体用法?Python Profile.create_new怎么用?Python Profile.create_new使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozprofile.Profile
的用法示例。
在下文中一共展示了Profile.create_new方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _update_profile
# 需要导入模块: from mozprofile import Profile [as 别名]
# 或者: from mozprofile.Profile import create_new [as 别名]
def _update_profile(self, profile=None, profile_name=None):
"""Check if the profile has to be created, or replaced
:param profile: A Profile instance to be used.
:param name: Profile name to be used in the path.
"""
if self.runner and self.runner.is_running():
raise errors.MarionetteException("The current profile can only be updated "
"when the instance is not running")
if isinstance(profile, Profile):
# Only replace the profile if it is not the current one
if hasattr(self, "_profile") and profile is self._profile:
return
else:
profile_args = self.profile_args
profile_path = profile
# If a path to a profile is given then clone it
if isinstance(profile_path, basestring):
profile_args["path_from"] = profile_path
profile_args["path_to"] = tempfile.mkdtemp(
suffix=".{}".format(profile_name or os.path.basename(profile_path)),
dir=self.workspace)
# The target must not exist yet
os.rmdir(profile_args["path_to"])
profile = Profile.clone(**profile_args)
# Otherwise create a new profile
else:
profile_args["profile"] = tempfile.mkdtemp(
suffix=".{}".format(profile_name or "mozrunner"),
dir=self.workspace)
profile = Profile(**profile_args)
profile.create_new = True
if isinstance(self.profile, Profile):
self.profile.cleanup()
self._profile = profile