Mercurial > mozilla > hg > ProfileManager
annotate profilemanager/manager.py @ 47:420becb84df7
* move exception string to the exception itself
* further stubbing on backup
* stub on temporary profile function
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 07 May 2010 09:06:16 -0700 |
parents | df1b2e48dddb |
children | 09a2666999fa |
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 """ |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
2 manage Mozilla/Firefox profiles |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
3 """ |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
4 |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
5 import os |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
6 import shutil |
15
543d08958b67
actually sample 8 random lowercase letters and numbers for the profile hash
Jeff Hammel <jhammel@mozilla.com>
parents:
10
diff
changeset
|
7 import string |
9
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
8 import ConfigParser |
15
543d08958b67
actually sample 8 random lowercase letters and numbers for the profile hash
Jeff Hammel <jhammel@mozilla.com>
parents:
10
diff
changeset
|
9 from random import Random |
5
ca57920aa223
adding better formatting for list
Jeff Hammel <jhammel@mozilla.com>
parents:
4
diff
changeset
|
10 from utils import format_tabular |
ca57920aa223
adding better formatting for list
Jeff Hammel <jhammel@mozilla.com>
parents:
4
diff
changeset
|
11 from ConfigParser import SafeConfigParser as ConfigParser |
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
12 |
10
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
13 # Changes to profiles.ini: |
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
14 # - add a ``backups`` field for each profile: |
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
15 # Backups = /path/to/backup:1273104310 /path/to/other/backup:1273104355 |
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
16 |
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
17 class ProfileNotFound(Exception): |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
18 """ |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
19 exception when a profile is specified but is not present in a given |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
20 .ini file |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
21 """ |
47
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
22 def __init__(self, profile, config): |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
23 self.profile = profile |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
24 self.config = config |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
25 Exception.__init__('Profile %s not found in %s' % (profile, config)) |
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
26 |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
27 class ProfileManager(object): |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
28 |
47
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
29 backups_dir = 'backups' # directory for backups relative to profile_dir |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
30 |
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
31 def __init__(self, profiles): |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
32 """ |
4
35dc297efa25
adding listing function and other cleanup
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
33 - profiles: filesystem path to profiles.ini file |
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
34 """ |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
35 self.profiles = profiles |
4
35dc297efa25
adding listing function and other cleanup
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
36 self.profile_dir = os.path.abspath(os.path.dirname(profiles)) |
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
37 |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
38 ### (public) API |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
39 |
16 | 40 def new(self, name, directory=None, hash=True): |
9
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
41 """ |
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
42 generate a new clean profile |
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
43 - name: name of the profile to generate |
16 | 44 - directory: where to create the profile [DEFAULT: relative to profiles.ini] |
45 - hash: whether to generate a a random hash tag | |
9
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
46 """ |
16 | 47 |
48 # path to the profile directory | |
20 | 49 dirname = name |
50 relative = False | |
16 | 51 if hash: |
18
8e651dd8e9ad
fix two things about hash() usage
Jeff Hammel <jhammel@mozilla.com>
parents:
16
diff
changeset
|
52 dirname = '%s.%s' % (self.hash(), dirname) |
16 | 53 if not directory: |
54 directory = self.profile_dir | |
20 | 55 relative = True |
56 path = os.path.join(directory, dirname) | |
16 | 57 |
58 # create directory | |
40
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
59 # TODO: (optionally) pre-populate the directory a la Firefox |
20 | 60 os.mkdir(path) |
16 | 61 |
19
4a1815f8d146
* stub adding new profile to configuration
Jeff Hammel <jhammel@mozilla.com>
parents:
18
diff
changeset
|
62 # update profiles.ini |
40
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
63 self.add(name, relative and dirname or path, relative) |
19
4a1815f8d146
* stub adding new profile to configuration
Jeff Hammel <jhammel@mozilla.com>
parents:
18
diff
changeset
|
64 |
16 | 65 # return the directory name |
36
a6222b71aab6
return the right thing, finally
Jeff Hammel <jhammel@mozilla.com>
parents:
31
diff
changeset
|
66 return path |
9
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
67 |
19
4a1815f8d146
* stub adding new profile to configuration
Jeff Hammel <jhammel@mozilla.com>
parents:
18
diff
changeset
|
68 def remove(self, name, delete=True): |
4a1815f8d146
* stub adding new profile to configuration
Jeff Hammel <jhammel@mozilla.com>
parents:
18
diff
changeset
|
69 """ |
4a1815f8d146
* stub adding new profile to configuration
Jeff Hammel <jhammel@mozilla.com>
parents:
18
diff
changeset
|
70 remove a profile from profiles.ini |
20 | 71 - delete: delete the profile directory as well |
19
4a1815f8d146
* stub adding new profile to configuration
Jeff Hammel <jhammel@mozilla.com>
parents:
18
diff
changeset
|
72 """ |
37 | 73 parser = self.parser() |
74 section = self.section(name, parser) | |
21
15484adb9758
note what section a a profile is in
Jeff Hammel <jhammel@mozilla.com>
parents:
20
diff
changeset
|
75 if section is None: |
47
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
76 raise ProfileNotFound(profile, self.profiles) |
22
956f5a4c589a
* restructure utility functions to do less more efficiently
Jeff Hammel <jhammel@mozilla.com>
parents:
21
diff
changeset
|
77 if delete: # remove the profile from disk |
956f5a4c589a
* restructure utility functions to do less more efficiently
Jeff Hammel <jhammel@mozilla.com>
parents:
21
diff
changeset
|
78 shutil.rmtree(self.path(name)) |
956f5a4c589a
* restructure utility functions to do less more efficiently
Jeff Hammel <jhammel@mozilla.com>
parents:
21
diff
changeset
|
79 parser.remove_section(section) |
29 | 80 parser.write(file(self.profiles, 'w')) |
19
4a1815f8d146
* stub adding new profile to configuration
Jeff Hammel <jhammel@mozilla.com>
parents:
18
diff
changeset
|
81 |
4
35dc297efa25
adding listing function and other cleanup
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
82 def list(self, directories=False): |
35dc297efa25
adding listing function and other cleanup
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
83 """ |
35dc297efa25
adding listing function and other cleanup
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
84 lists the profiles available in the config file |
6
2a3f5cdfd60c
flush out helper functions and list directories
Jeff Hammel <jhammel@mozilla.com>
parents:
5
diff
changeset
|
85 - directories : display the directories |
4
35dc297efa25
adding listing function and other cleanup
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
86 """ |
9
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
87 profiles = self.profiles_dict() |
38 | 88 if not directories: |
89 return sorted(profiles.keys()) | |
90 return dict([(name, self.path(name)) for name in profiles.keys()]) | |
4
35dc297efa25
adding listing function and other cleanup
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
91 |
40
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
92 def clone(self, source, dest, add=True): |
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
93 """ |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
94 clones the profile `source` and output to `dest` |
40
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
95 - add: add the profile to the profiles.ini file |
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
96 """ |
45 | 97 |
98 # filesystem path of the `from` profile | |
99 source_path = self.path(source) | |
7
d3b22d086934
comments for what to do next
Jeff Hammel <jhammel@mozilla.com>
parents:
6
diff
changeset
|
100 |
8
7205cb6f5530
various flushing out, deleting old TODOs and making new ones
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
101 # dest: fs path to back up to |
7205cb6f5530
various flushing out, deleting old TODOs and making new ones
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
102 relative = False |
40
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
103 if os.path.sep in dest: |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
104 if not os.path.isabs(dest): |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
105 dest = os.path.abspath(dest) |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
106 dirname = dest |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
107 name = os.path.basename(dest) |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
108 else: |
46
df1b2e48dddb
handle hashing for clones only if they are added to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
45
diff
changeset
|
109 name = dest |
8
7205cb6f5530
various flushing out, deleting old TODOs and making new ones
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
110 relative = True |
46
df1b2e48dddb
handle hashing for clones only if they are added to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
45
diff
changeset
|
111 if add: |
df1b2e48dddb
handle hashing for clones only if they are added to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
45
diff
changeset
|
112 dirname = '%s.%s' % (self.hash(), name) |
8
7205cb6f5530
various flushing out, deleting old TODOs and making new ones
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
113 dest = os.path.join(self.profile_dir, dest) |
7
d3b22d086934
comments for what to do next
Jeff Hammel <jhammel@mozilla.com>
parents:
6
diff
changeset
|
114 |
40
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
115 # update profiles.ini |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
116 if add: |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
117 self.add(name, dirname, relative) |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
118 |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
119 # copy the files |
8
7205cb6f5530
various flushing out, deleting old TODOs and making new ones
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
120 shutil.copytree(source_path, dest, symlinks=False) |
43 | 121 |
122 return dest | |
1
979315ed0816
mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
123 |
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
124 def backup(self, profile, dest=None): |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
125 """ |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
126 backup the profile |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
127 - profile: name of the profile to be backed up |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
128 - dest: name of the destination (optional) |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
129 """ |
47
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
130 |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
131 # get the profile section |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
132 parser = self.parser() |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
133 section = self.section(profile) |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
134 if profile is None: |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
135 raise ProfileNotFound(profile, self.profiles) |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
136 |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
137 # determine destination directory |
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
138 if dest is None: |
8
7205cb6f5530
various flushing out, deleting old TODOs and making new ones
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
139 dest = '%s.%d.bak' % (profile, int(time.time())) |
47
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
140 name = dest |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
141 backups_dir = os.path.join(self.profile_dir, self.backups_dir) |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
142 if not os.path.exists(backups_dir): |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
143 os.mkdir(backups_dir) |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
144 dest = os.path.join(backups_dir, dest) |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
145 else: |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
146 if not os.path.isabs(dest): |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
147 dest = os.path.abspath(dest) |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
148 name = dest |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
149 |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
150 # copy the files |
45 | 151 self.clone(profile, dest, add=False) |
47
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
152 |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
153 |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
154 # add backup entry to profiles.ini: |
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
155 # `Backup=$(profile)s.$(datestamp)s.bak` |
47
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
156 raise NotImplementedError |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
157 |
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
158 |
10
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
159 def backups(self, profile=None): |
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
160 """ |
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
161 list backups for a given profile, or all profiles if the |
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
162 profile is not given; returns a list of backups if |
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
163 profile is given or a dictionary of lists otherwise |
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
164 """ |
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
165 if profile is None: |
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
166 # all profiles |
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
167 retval = {} |
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
168 return retval |
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
169 # TODO |
47
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
170 raise NotImplementedError |
10
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
171 |
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
172 def restore(self, profile, date=None, delete=False): |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
173 """ |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
174 restore the profile from a backup |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
175 the most recent backup is used unless `date` is given |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
176 - date : date to restore from |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
177 - delete : delete the backup after restoration |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
178 """ |
8
7205cb6f5530
various flushing out, deleting old TODOs and making new ones
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
179 |
7205cb6f5530
various flushing out, deleting old TODOs and making new ones
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
180 # get the possible backups |
10
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
181 backups = self.backups(profile) |
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
182 # TODO: check to see if these all exist (print warnings if not) |
8
7205cb6f5530
various flushing out, deleting old TODOs and making new ones
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
183 |
7205cb6f5530
various flushing out, deleting old TODOs and making new ones
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
184 # restore the backup over ``profile`` |
7205cb6f5530
various flushing out, deleting old TODOs and making new ones
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
185 |
7205cb6f5530
various flushing out, deleting old TODOs and making new ones
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
186 if delete: # delete the backup |
10
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
187 # delete the directory |
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
188 # delete the entry from ``profiles.ini`` |
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
189 # if there are no backups, delete the ``backups`` line |
c77e9bef78d6
* update list of public API functions
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
190 pass #TODO |
47
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
191 |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
192 def temporary(self): |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
193 """make a temporary profile""" |
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
194 raise NotImplementedError |
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
195 |
5
ca57920aa223
adding better formatting for list
Jeff Hammel <jhammel@mozilla.com>
parents:
4
diff
changeset
|
196 def merge(self, output, *profiles): |
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
197 """merge a set of profiles (not trivial!)""" |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
198 raise NotImplementedError |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
199 |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
200 ### internal functions |
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
201 |
40
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
202 def add(self, profile, path, relative=True): |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
203 """ |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
204 add a profile entry to profiles.ini |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
205 """ |
41 | 206 |
207 # ensure name is not already present | |
208 assert profile not in self.profiles_dict(), 'Profile "%s" already in %s' % (name, self.profiles) | |
40
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
209 parser = self.parser() |
41 | 210 |
211 # find and add the section | |
40
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
212 ctr = 0 |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
213 section = 'Profile%d' % ctr # unsure of this naming convention |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
214 while section in parser.sections(): |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
215 ctr += 1 |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
216 section = 'Profile%d' % ctr |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
217 parser.add_section(section) |
41 | 218 |
219 # add metadata | |
40
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
220 parser.set(section, 'Name', profile) |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
221 parser.set(section, 'IsRelative', '%d' % int(relative)) |
42 | 222 parser.set(section, 'Path', path) |
40
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
223 if not ctr: |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
224 parser.set(section, 'Default', '1') |
41 | 225 |
226 # write the file | |
40
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
227 parser.write(file(self.profiles, 'w')) |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
228 |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
229 |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
230 def path(self, profile): |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
231 """returns the path to the profile""" |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
232 profile = self.profile_dict(profile) |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
233 if profile.get('isrelative', None) == '1': |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
234 return os.path.join(self.profile_dir, profile['path']) |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
235 return profile['path'] |
34c740d1962d
abstract out adding an entry to profiles.ini
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
236 |
22
956f5a4c589a
* restructure utility functions to do less more efficiently
Jeff Hammel <jhammel@mozilla.com>
parents:
21
diff
changeset
|
237 def parser(self): |
956f5a4c589a
* restructure utility functions to do less more efficiently
Jeff Hammel <jhammel@mozilla.com>
parents:
21
diff
changeset
|
238 """ |
956f5a4c589a
* restructure utility functions to do less more efficiently
Jeff Hammel <jhammel@mozilla.com>
parents:
21
diff
changeset
|
239 return a ConfigParser instance appropriate to profiles.ini |
956f5a4c589a
* restructure utility functions to do less more efficiently
Jeff Hammel <jhammel@mozilla.com>
parents:
21
diff
changeset
|
240 """ |
25
fc31d3f26755
i seriously need to learn to code
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
241 parser = ConfigParser() |
fc31d3f26755
i seriously need to learn to code
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
242 parser.read(self.profiles) |
fc31d3f26755
i seriously need to learn to code
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
243 return parser |
22
956f5a4c589a
* restructure utility functions to do less more efficiently
Jeff Hammel <jhammel@mozilla.com>
parents:
21
diff
changeset
|
244 |
0
7301d534bc6c
initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
245 |
22
956f5a4c589a
* restructure utility functions to do less more efficiently
Jeff Hammel <jhammel@mozilla.com>
parents:
21
diff
changeset
|
246 def section(self, profile, parser=None): |
20 | 247 """ |
21
15484adb9758
note what section a a profile is in
Jeff Hammel <jhammel@mozilla.com>
parents:
20
diff
changeset
|
248 returns the name of the section that a profile is in or None |
15484adb9758
note what section a a profile is in
Jeff Hammel <jhammel@mozilla.com>
parents:
20
diff
changeset
|
249 if not found |
20 | 250 """ |
22
956f5a4c589a
* restructure utility functions to do less more efficiently
Jeff Hammel <jhammel@mozilla.com>
parents:
21
diff
changeset
|
251 if parser is None: |
29 | 252 parser = self.parser() |
31 | 253 for section in parser.sections(): |
21
15484adb9758
note what section a a profile is in
Jeff Hammel <jhammel@mozilla.com>
parents:
20
diff
changeset
|
254 if not parser.has_option(section, 'name'): |
15484adb9758
note what section a a profile is in
Jeff Hammel <jhammel@mozilla.com>
parents:
20
diff
changeset
|
255 continue # not a profile |
15484adb9758
note what section a a profile is in
Jeff Hammel <jhammel@mozilla.com>
parents:
20
diff
changeset
|
256 if parser.get(section, 'name') == profile: |
15484adb9758
note what section a a profile is in
Jeff Hammel <jhammel@mozilla.com>
parents:
20
diff
changeset
|
257 return section |
20 | 258 |
27
5988a15da3b4
things are being awful; checking in anyway
Jeff Hammel <jhammel@mozilla.com>
parents:
26
diff
changeset
|
259 def profile_dict(self, profile): |
5988a15da3b4
things are being awful; checking in anyway
Jeff Hammel <jhammel@mozilla.com>
parents:
26
diff
changeset
|
260 """ |
5988a15da3b4
things are being awful; checking in anyway
Jeff Hammel <jhammel@mozilla.com>
parents:
26
diff
changeset
|
261 return option dictionary for a single profile |
5988a15da3b4
things are being awful; checking in anyway
Jeff Hammel <jhammel@mozilla.com>
parents:
26
diff
changeset
|
262 """ |
5988a15da3b4
things are being awful; checking in anyway
Jeff Hammel <jhammel@mozilla.com>
parents:
26
diff
changeset
|
263 parser = self.parser() |
5988a15da3b4
things are being awful; checking in anyway
Jeff Hammel <jhammel@mozilla.com>
parents:
26
diff
changeset
|
264 section = self.section(profile, parser) |
5988a15da3b4
things are being awful; checking in anyway
Jeff Hammel <jhammel@mozilla.com>
parents:
26
diff
changeset
|
265 if section is None: |
47
420becb84df7
* move exception string to the exception itself
Jeff Hammel <jhammel@mozilla.com>
parents:
46
diff
changeset
|
266 raise ProfileNotFound(profile, self.profiles) |
27
5988a15da3b4
things are being awful; checking in anyway
Jeff Hammel <jhammel@mozilla.com>
parents:
26
diff
changeset
|
267 return dict(parser.items(section)) |
5988a15da3b4
things are being awful; checking in anyway
Jeff Hammel <jhammel@mozilla.com>
parents:
26
diff
changeset
|
268 |
9
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
269 def profiles_dict(self): |
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
270 """ |
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
271 return nested dict of all profiles |
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
272 """ |
22
956f5a4c589a
* restructure utility functions to do less more efficiently
Jeff Hammel <jhammel@mozilla.com>
parents:
21
diff
changeset
|
273 # assumes profiles have unique names |
956f5a4c589a
* restructure utility functions to do less more efficiently
Jeff Hammel <jhammel@mozilla.com>
parents:
21
diff
changeset
|
274 parser = self.parser() |
9
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
275 retval = {} |
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
276 for section in parser.sections(): |
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
277 if section == 'General': |
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
278 continue |
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
279 try: |
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
280 name = parser.get(section, 'name') |
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
281 except ConfigParser.NoOptionError: |
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
282 continue |
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
283 retval[name] = self.profile_dict(name) |
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
284 return retval |
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
285 |
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
286 |
8
7205cb6f5530
various flushing out, deleting old TODOs and making new ones
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
287 def hash(self): |
7205cb6f5530
various flushing out, deleting old TODOs and making new ones
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
288 """ |
7205cb6f5530
various flushing out, deleting old TODOs and making new ones
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
289 generate a random hash for a new profile |
7205cb6f5530
various flushing out, deleting old TODOs and making new ones
Jeff Hammel <jhammel@mozilla.com>
parents:
7
diff
changeset
|
290 """ |
15
543d08958b67
actually sample 8 random lowercase letters and numbers for the profile hash
Jeff Hammel <jhammel@mozilla.com>
parents:
10
diff
changeset
|
291 population = string.lowercase + string.digits |
18
8e651dd8e9ad
fix two things about hash() usage
Jeff Hammel <jhammel@mozilla.com>
parents:
16
diff
changeset
|
292 return ''.join(Random().sample(population, 8)) |
9
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
293 |
b1274abd1206
rework API a bit; the "public" methods are becoming a bit specialized to the command line, which was my fear, so I should probably inherit from ProfileManager to do the interface like I should
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
294 |