om@5
|
1 |
#!/bin/env python
|
om@5
|
2 |
# -*- coding: utf-8 -*-
|
om@5
|
3 |
|
om@5
|
4 |
# ------------------------------------------------------------
|
om@5
|
5 |
# new_firefox_profile_id
|
om@5
|
6 |
#
|
om@5
|
7 |
# pick the next firefox profile id
|
om@5
|
8 |
#
|
om@5
|
9 |
# Autor: Oliver Maurhart, <oliver.maurhart@ait.ac.at>
|
om@5
|
10 |
#
|
om@5
|
11 |
# Copyright (C) 2013 AIT Austrian Institute of Technology
|
om@5
|
12 |
# AIT Austrian Institute of Technology GmbH
|
om@5
|
13 |
# Donau-City-Strasse 1 | 1220 Vienna | Austria
|
om@5
|
14 |
# http://www.ait.ac.at
|
om@5
|
15 |
#
|
om@5
|
16 |
# This program is free software; you can redistribute it and/or
|
om@5
|
17 |
# modify it under the terms of the GNU General Public License
|
om@5
|
18 |
# as published by the Free Software Foundation version 2.
|
om@5
|
19 |
#
|
om@5
|
20 |
# This program is distributed in the hope that it will be useful,
|
om@5
|
21 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
om@5
|
22 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
om@5
|
23 |
# GNU General Public License for more details.
|
om@5
|
24 |
#
|
om@5
|
25 |
# You should have received a copy of the GNU General Public License
|
om@5
|
26 |
# along with this program; if not, write to the Free Software
|
om@5
|
27 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
om@5
|
28 |
# Boston, MA 02110-1301, USA.
|
om@5
|
29 |
# ------------------------------------------------------------
|
om@5
|
30 |
|
om@5
|
31 |
|
om@5
|
32 |
# ------------------------------------------------------------
|
om@5
|
33 |
# imports
|
om@5
|
34 |
|
om@5
|
35 |
import os
|
om@5
|
36 |
import os.path
|
om@5
|
37 |
import ConfigParser # in pythjon 3 this is lowercase
|
om@5
|
38 |
|
om@5
|
39 |
|
om@5
|
40 |
# ------------------------------------------------------------
|
om@5
|
41 |
# code
|
om@5
|
42 |
|
om@5
|
43 |
|
om@5
|
44 |
def main():
|
om@5
|
45 |
|
om@5
|
46 |
# grab the firefox profile ini (path may differ ...)
|
om@5
|
47 |
profiles_path = os.path.join(os.path.expanduser('~'), '.mozilla', 'firefox', 'profiles.ini')
|
om@5
|
48 |
cfg = ConfigParser.ConfigParser()
|
om@5
|
49 |
cfg.read(profiles_path)
|
om@5
|
50 |
profiles = [p for p in cfg.sections() if p.startswith('Profile')]
|
om@5
|
51 |
i = 0
|
om@5
|
52 |
for p in profiles:
|
om@5
|
53 |
p_number = p[len('Profile'):]
|
om@5
|
54 |
try:
|
om@5
|
55 |
i = max(int(p_number), i)
|
om@5
|
56 |
except:
|
om@5
|
57 |
pass
|
om@5
|
58 |
print i + 1
|
om@5
|
59 |
|
om@5
|
60 |
|
om@5
|
61 |
if __name__ == '__main__':
|
om@5
|
62 |
main()
|
om@5
|
63 |
|
om@5
|
64 |
|