1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/OpenSecurity/vm/usr/local/bin/new_firefox_profile_id.py Mon Dec 02 16:02:00 2013 +0100
1.3 @@ -0,0 +1,64 @@
1.4 +#!/bin/env python
1.5 +# -*- coding: utf-8 -*-
1.6 +
1.7 +# ------------------------------------------------------------
1.8 +# new_firefox_profile_id
1.9 +#
1.10 +# pick the next firefox profile id
1.11 +#
1.12 +# Autor: Oliver Maurhart, <oliver.maurhart@ait.ac.at>
1.13 +#
1.14 +# Copyright (C) 2013 AIT Austrian Institute of Technology
1.15 +# AIT Austrian Institute of Technology GmbH
1.16 +# Donau-City-Strasse 1 | 1220 Vienna | Austria
1.17 +# http://www.ait.ac.at
1.18 +#
1.19 +# This program is free software; you can redistribute it and/or
1.20 +# modify it under the terms of the GNU General Public License
1.21 +# as published by the Free Software Foundation version 2.
1.22 +#
1.23 +# This program is distributed in the hope that it will be useful,
1.24 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1.25 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.26 +# GNU General Public License for more details.
1.27 +#
1.28 +# You should have received a copy of the GNU General Public License
1.29 +# along with this program; if not, write to the Free Software
1.30 +# Foundation, Inc., 51 Franklin Street, Fifth Floor,
1.31 +# Boston, MA 02110-1301, USA.
1.32 +# ------------------------------------------------------------
1.33 +
1.34 +
1.35 +# ------------------------------------------------------------
1.36 +# imports
1.37 +
1.38 +import os
1.39 +import os.path
1.40 +import ConfigParser # in pythjon 3 this is lowercase
1.41 +
1.42 +
1.43 +# ------------------------------------------------------------
1.44 +# code
1.45 +
1.46 +
1.47 +def main():
1.48 +
1.49 + # grab the firefox profile ini (path may differ ...)
1.50 + profiles_path = os.path.join(os.path.expanduser('~'), '.mozilla', 'firefox', 'profiles.ini')
1.51 + cfg = ConfigParser.ConfigParser()
1.52 + cfg.read(profiles_path)
1.53 + profiles = [p for p in cfg.sections() if p.startswith('Profile')]
1.54 + i = 0
1.55 + for p in profiles:
1.56 + p_number = p[len('Profile'):]
1.57 + try:
1.58 + i = max(int(p_number), i)
1.59 + except:
1.60 + pass
1.61 + print i + 1
1.62 +
1.63 +
1.64 +if __name__ == '__main__':
1.65 + main()
1.66 +
1.67 +