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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
3 # ***** BEGIN LICENSE BLOCK *****
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
5 #
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
6 # The contents of this file are subject to the Mozilla Public License Version
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
7 # 1.1 (the "License"); you may not use this file except in compliance with
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
8 # the License. You may obtain a copy of the License at
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
9 # http://www.mozilla.org/MPL/
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
10 #
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
11 # Software distributed under the License is distributed on an "AS IS" basis,
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
13 # for the specific language governing rights and limitations under the
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
14 # License.
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
15 #
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
16 # The Original Code is mozilla.org code.
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
17 #
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
18 # The Initial Developer of the Original Code is
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
19 # Mozilla.org.
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
20 # Portions created by the Initial Developer are Copyright (C) 2010
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
21 # the Initial Developer. All Rights Reserved.
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
22 #
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
23 # Contributor(s):
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
24 # Jeff Hammel <jhammel@mozilla.com> (Original author)
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
25 #
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
26 # Alternatively, the contents of this file may be used under the terms of
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
27 # either of the GNU General Public License Version 2 or later (the "GPL"),
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
28 # or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
29 # in which case the provisions of the GPL or the LGPL are applicable instead
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
30 # of those above. If you wish to allow use of your version of this file only
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
31 # under the terms of either the GPL or the LGPL, and not to allow others to
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
32 # use your version of this file under the terms of the MPL, indicate your
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
33 # decision by deleting the provisions above and replace them with the notice
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
34 # and other provisions required by the GPL or the LGPL. If you do not delete
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
35 # the provisions above, a recipient may use your version of this file under
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
36 # the terms of any one of the MPL, the GPL or the LGPL.
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
37 #
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
38 # ***** END LICENSE BLOCK *****
145e111903d2 add MPL license
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
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
49d523a33c89 more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 10
diff changeset
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()