1
[Mozprofile](https://github.com/mozilla/mozbase/tree/master/mozprofile)
2
is a python tool for creating and managing profiles for Mozilla's
3
applications (Firefox, Thunderbird, etc.). In addition to creating profiles,
4
mozprofile can install [addons](https://developer.mozilla.org/en/addons)
6
[preferences](https://developer.mozilla.org/En/A_Brief_Guide_to_Mozilla_Preferences).
7
Mozprofile can be utilized from the command line or as an API.
12
mozprofile may be used to create profiles, set preferences in
13
profiles, or install addons into profiles.
15
The profile to be operated on may be specified with the `--profile`
16
switch. If a profile is not specified, one will be created in a
17
temporary directory which will be echoed to the terminal:
20
/tmp/tmp4q1iEU.mozrunner
21
(mozmill)> ls /tmp/tmp4q1iEU.mozrunner
24
To run mozprofile from the command line enter:
25
`mozprofile --help` for a list of options.
30
To use mozprofile as an API you can import
31
[mozprofile.profile](https://github.com/mozilla/mozbase/tree/master/mozprofile/mozprofile/profile.py)
33
[AddonManager](https://github.com/mozilla/mozbase/tree/master/mozprofile/mozprofile/addons.py).
35
`mozprofile.profile` features a generic `Profile` class. In addition,
36
subclasses `FirefoxProfile` and `ThundebirdProfile` are available
37
with preset preferences for those applications.
39
`mozprofile.profile:Profile`:
42
profile=None, # Path to the profile
43
addons=None, # String of one or list of addons to install
44
addon_manifests=None, # Manifest for addons, see http://ahal.ca/blog/2011/bulk-installing-fx-addons/
45
preferences=None, # Dictionary or class of preferences
46
locations=None, # locations to proxy
47
proxy=False, # setup a proxy
48
restore=True # If true remove all installed addons preferences when cleaning up
52
"""reset the profile to the beginning state"""
54
def set_preferences(self, preferences, filename='user.js'):
55
"""Adds preferences dict to profile preferences"""
57
def clean_preferences(self):
58
"""Removed preferences added by mozrunner."""
61
"""Cleanup operations for the profile."""
64
`mozprofile.addons:AddonManager`:
66
def __init__(self, profile):
67
"""profile - the path to the profile for which we install addons"""
69
def install_addons(self, addons=None, manifests=None):
71
Installs all types of addons
72
addons - a list of addon paths to install
73
manifest - a list of addon manifests to install
77
def get_amo_install_path(self, query):
79
Return the addon xpi install path for the specified AMO query.
80
See: https://developer.mozilla.org/en/addons.mozilla.org_%28AMO%29_API_Developers%27_Guide/The_generic_AMO_API
81
for query documentation.
85
def addon_details(cls, addon_path):
87
returns a dictionary of details about the addon
88
- addon_path : path to the addon directory
90
{'id': u'rainbow@colors.org', # id of the addon
91
'version': u'1.4', # version of the addon
92
'name': u'Rainbow', # name of the addon
93
'unpack': False } # whether to unpack the addon
96
def clean_addons(self):
97
"""Cleans up addons in the profile."""
102
Addons may be installed individually or from a manifest.
106
from mozprofile import FirefoxProfile
108
# create new profile to pass to mozmill/mozrunner
109
profile = FirefoxProfile(addons=["adblock.xpi"])
112
# Setting Preferences
114
Preferences can be set in several ways:
116
- using the API: You can pass preferences in to the Profile class's
117
constructor: `obj = FirefoxProfile(preferences=[("accessibility.typeaheadfind.flashBar", 0)])`
118
- using a JSON blob file: `mozprofile --preferences myprefs.json`
119
- using a `.ini` file: `mozprofile --preferences myprefs.ini`
120
- via the command line: `mozprofile --pref key:value --pref key:value [...]`
122
When setting preferences from an `.ini` file or the `--pref` switch,
123
the value will be interpolated as an integer or a boolean
124
(`true`/`false`) if possible.
126
# Setting Permissions
128
mozprofile also takes care of adding permissions to the profile.
129
See https://github.com/mozilla/mozbase/blob/master/mozprofile/mozprofile/permissions.py
134
Other Mozilla programs offer additional and overlapping functionality
135
for profiles. There is also substantive documentation on profiles and
138
- [ProfileManager](https://developer.mozilla.org/en/Profile_Manager) :
139
XULRunner application for managing profiles. Has a GUI and CLI.
140
- [python-profilemanager](http://k0s.org/mozilla/hg/profilemanager/) : python CLI interface similar to ProfileManager
141
- profile documentation : http://support.mozilla.com/en-US/kb/Profiles