Mercurial > mozilla > hg > ProfileManager
annotate profilemanager/main.py @ 79:145e111903d2 default tip
add MPL license
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 10 May 2010 13:11:38 -0700 |
parents | 49d523a33c89 |
children |
rev | line source |
---|---|
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
2 |
79 | 3 # ***** BEGIN LICENSE BLOCK ***** |
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1 | |
5 # | |
6 # The contents of this file are subject to the Mozilla Public License Version | |
7 # 1.1 (the "License"); you may not use this file except in compliance with | |
8 # the License. You may obtain a copy of the License at | |
9 # http://www.mozilla.org/MPL/ | |
10 # | |
11 # Software distributed under the License is distributed on an "AS IS" basis, | |
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
13 # for the specific language governing rights and limitations under the | |
14 # License. | |
15 # | |
16 # The Original Code is mozilla.org code. | |
17 # | |
18 # The Initial Developer of the Original Code is | |
19 # Mozilla.org. | |
20 # Portions created by the Initial Developer are Copyright (C) 2010 | |
21 # the Initial Developer. All Rights Reserved. | |
22 # | |
23 # Contributor(s): | |
24 # Jeff Hammel <jhammel@mozilla.com> (Original author) | |
25 # | |
26 # Alternatively, the contents of this file may be used under the terms of | |
27 # either of the GNU General Public License Version 2 or later (the "GPL"), | |
28 # or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), | |
29 # in which case the provisions of the GPL or the LGPL are applicable instead | |
30 # of those above. If you wish to allow use of your version of this file only | |
31 # under the terms of either the GPL or the LGPL, and not to allow others to | |
32 # use your version of this file under the terms of the MPL, indicate your | |
33 # decision by deleting the provisions above and replace them with the notice | |
34 # and other provisions required by the GPL or the LGPL. If you do not delete | |
35 # the provisions above, a recipient may use your version of this file under | |
36 # the terms of any one of the MPL, the GPL or the LGPL. | |
37 # | |
38 # ***** END LICENSE BLOCK ***** | |
39 | |
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
40 import os |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
41 import sys |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
42 |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
43 from manager import ProfileManager |
1
979315ed0816
mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
44 from command import CommandParser |
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
45 |
1
979315ed0816
mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
46 def create_profilemanager(parser, options): |
979315ed0816
mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
47 """create the profile manager from parsed arguments""" |
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
48 if options.config is None: |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
49 # XXX unix-specific |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
50 options.config = os.path.join(os.environ['HOME'], '.mozilla/firefox/profiles.ini') |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
51 if not os.path.exists(options.config): |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
52 parser.error('%s does not exist' % options.config) |
1
979315ed0816
mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
53 return ProfileManager(options.config) |
979315ed0816
mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
54 |
979315ed0816
mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
55 def main(args=sys.argv[1:]): |
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
56 |
1
979315ed0816
mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
57 # global option parsing |
4
35dc297efa25
adding listing function and other cleanup
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
58 commands = [ ProfileManager.backup, |
10
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
4
diff
changeset
|
59 ProfileManager.backups, |
4
35dc297efa25
adding listing function and other cleanup
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
60 ProfileManager.clone, |
35dc297efa25
adding listing function and other cleanup
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
61 ProfileManager.list, |
10
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
4
diff
changeset
|
62 # ProfileManager.merge, |
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
4
diff
changeset
|
63 ProfileManager.new, |
20 | 64 ProfileManager.remove, |
1
979315ed0816
mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
65 ProfileManager.restore, |
10
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
4
diff
changeset
|
66 ] |
1
979315ed0816
mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
67 parser = CommandParser(commands, setup=create_profilemanager) |
979315ed0816
mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
68 parser.add_option('-c', '--config', dest='config', |
979315ed0816
mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
69 help="specify a profile.ini [default: $HOME/.mozilla/firefox/profiles.ini]") |
979315ed0816
mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
70 parser.invoke(args) |
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
71 |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
72 if __name__ == '__main__': |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
73 main() |