當前位置: 首頁>>代碼示例>>Python>>正文


Python Profile.clone方法代碼示例

本文整理匯總了Python中mozprofile.profile.Profile.clone方法的典型用法代碼示例。如果您正苦於以下問題:Python Profile.clone方法的具體用法?Python Profile.clone怎麽用?Python Profile.clone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mozprofile.profile.Profile的用法示例。


在下文中一共展示了Profile.clone方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_cleanup_on_garbage_collected

# 需要導入模塊: from mozprofile.profile import Profile [as 別名]
# 或者: from mozprofile.profile.Profile import clone [as 別名]
 def test_cleanup_on_garbage_collected(self):
     clone = Profile.clone(self.profile.profile)
     profile_dir = clone.profile
     self.assertTrue(os.path.exists(profile_dir))
     del clone
     # clone should be deleted
     self.assertFalse(os.path.exists(profile_dir))
開發者ID:lgarner,項目名稱:mozilla-central,代碼行數:9,代碼來源:test_clone_cleanup.py

示例2: _init_profile

# 需要導入模塊: from mozprofile.profile import Profile [as 別名]
# 或者: from mozprofile.profile.Profile import clone [as 別名]
    def _init_profile(self):
        preferences = dict(self.browser_config['preferences'])
        if self.test_config.get('preferences'):
            test_prefs = dict(
                [(i, utils.parse_pref(j))
                 for i, j in self.test_config['preferences'].items()]
            )
            preferences.update(test_prefs)
        # interpolate webserver value in prefs
        webserver = self.browser_config['webserver']
        if '://' not in webserver:
            webserver = 'http://' + webserver
        for name, value in preferences.items():
            if type(value) is str:
                value = utils.interpolate(value, webserver=webserver)
                preferences[name] = value

        extensions = self.browser_config['extensions'][:]
        if self.test_config.get('extensions'):
            extensions.append(self.test_config['extensions'])

        profile = Profile.clone(
            os.path.normpath(self.test_config['profile_path']),
            self.profile_dir,
            restore=False)

        profile.set_preferences(preferences)
        profile.addon_manager.install_addons(extensions)
開發者ID:kleopatra999,項目名稱:system-addons,代碼行數:30,代碼來源:ffsetup.py

示例3: test_restore_false

# 需要導入模塊: from mozprofile.profile import Profile [as 別名]
# 或者: from mozprofile.profile.Profile import clone [as 別名]
    def test_restore_false(self):
        # make a clone of this profile with restore=False
        clone = Profile.clone(self.profile.profile, restore=False)

        clone.cleanup()

        # clone should still be around on the filesystem
        self.assertTrue(os.path.exists(clone.profile))
開發者ID:lgarner,項目名稱:mozilla-central,代碼行數:10,代碼來源:test_clone_cleanup.py

示例4: test_restore_true

# 需要導入模塊: from mozprofile.profile import Profile [as 別名]
# 或者: from mozprofile.profile.Profile import clone [as 別名]
    def test_restore_true(self):
        # make a clone of this profile with restore=True
        clone = Profile.clone(self.profile.profile, restore=True)

        clone.cleanup()

        # clone should be deleted
        self.assertFalse(os.path.exists(clone.profile))
開發者ID:lgarner,項目名稱:mozilla-central,代碼行數:10,代碼來源:test_clone_cleanup.py

示例5: test_restore_true

# 需要導入模塊: from mozprofile.profile import Profile [as 別名]
# 或者: from mozprofile.profile.Profile import clone [as 別名]
    def test_restore_true(self):
        counter = [0]

        def _feedback(dir, content):
            # Called by shutil.copytree on each visited directory.
            # Used here to display info.
            #
            # Returns the items that should be ignored by
            # shutil.copytree when copying the tree, so always returns
            # an empty list.
            counter[0] += 1
            return []

        # make a clone of this profile with restore=True
        clone = Profile.clone(self.profile.profile, restore=True,
                              ignore=_feedback)
        self.addCleanup(mozfile.remove, clone.profile)

        clone.cleanup()

        # clone should be deleted
        self.assertFalse(os.path.exists(clone.profile))
        self.assertTrue(counter[0] > 0)
開發者ID:luke-chang,項目名稱:gecko-1,代碼行數:25,代碼來源:test_clone_cleanup.py

示例6: _init_profile

# 需要導入模塊: from mozprofile.profile import Profile [as 別名]
# 或者: from mozprofile.profile.Profile import clone [as 別名]
    def _init_profile(self):
        preferences = dict(self.browser_config['preferences'])
        if self.test_config.get('preferences'):
            test_prefs = dict(
                [(i, utils.parse_pref(j))
                 for i, j in self.test_config['preferences'].items()]
            )
            preferences.update(test_prefs)
        # interpolate webserver value in prefs
        webserver = self.browser_config['webserver']
        if '://' not in webserver:
            webserver = 'http://' + webserver
        for name, value in preferences.items():
            if type(value) is str:
                value = utils.interpolate(value, webserver=webserver)
                preferences[name] = value

        extensions = self.browser_config['extensions'][:]
        if self.test_config.get('extensions'):
            extensions.append(self.test_config['extensions'])

        # downloading a profile instead of using the empty one
        if self.test_config['profile'] is not None:
            path = heavy.download_profile(self.test_config['profile'])
            self.test_config['profile_path'] = path

        profile_path = os.path.normpath(self.test_config['profile_path'])
        LOG.info("Cloning profile located at %s" % profile_path)

        def _feedback(directory, content):
            # Called by shutil.copytree on each visited directory.
            # Used here to display info.
            #
            # Returns the items that should be ignored by
            # shutil.copytree when copying the tree, so always returns
            # an empty list.
            sub = directory.split(profile_path)[-1].lstrip("/")
            if sub:
                LOG.info("=> %s" % sub)
            return []

        profile = Profile.clone(profile_path,
                                self.profile_dir,
                                ignore=_feedback,
                                restore=False)

        profile.set_preferences(preferences)

        # installing addons
        LOG.info("Installing Add-ons")
        profile.addon_manager.install_addons(extensions)

        # installing webextensions
        webextensions = self.test_config.get('webextensions', None)
        if isinstance(webextensions, basestring):
            webextensions = [webextensions]

        if webextensions is not None:
            LOG.info("Installing Webextensions")
            for webext in webextensions:
                filename = utils.interpolate(webext)
                if mozinfo.os == 'win':
                    filename = filename.replace('/', '\\')
                if not filename.endswith('.xpi'):
                    continue
                if not os.path.exists(filename):
                    continue

                profile.addon_manager.install_from_path(filename)
開發者ID:luke-chang,項目名稱:gecko-1,代碼行數:71,代碼來源:ffsetup.py


注:本文中的mozprofile.profile.Profile.clone方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。