root/trunk/umitCore/BasePaths.py @ 3177

Revision 3177, 5.1 kB (checked in by luis, 5 years ago)

Update licence - FSF address

Command used:
find . -path '*/.svn' -prune -o -type f -print0 | xargs -0 sed -i -e 's/59 Temple Place, Suite 330/51 Franklin Street, Fifth Floor/;s/02111-1307/02110-1301/;'

Check licences: licensecheck -c -r trunk_directory/

Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#
4# Copyright (C) 2005-2006 Insecure.Com LLC.
5# Copyright (C) 2007-2008 Adriano Monteiro Marques
6#
7# Author: Adriano Monteiro Marques <adriano@umitproject.org>
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation; either version 2 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program; if not, write to the Free Software
21# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
23import os
24import os.path
25import sys
26
27
28######################
29# Platform recognition
30PLATFORM = sys.platform
31HOME = os.path.expanduser("~")
32#HOME = os.environ.get('HOME', '')
33CURRENT_DIR = os.getcwd()
34
35# Look for files relative to the script path to allow running within the build
36# directory.
37main_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
38if hasattr(sys, "frozen"):
39    main_dir = os.path.dirname(sys.executable)
40
41CONFIG_DIR = os.path.join(main_dir, "share", "umit", "config")
42LOCALE_DIR = os.path.join(main_dir, "share", "locale")
43MISC_DIR = os.path.join(main_dir, "share", "umit", "misc")
44ICONS_DIR = os.path.join(main_dir, "share", "icons", "umit")
45PIXMAPS_DIR = os.path.join(main_dir, "share", "pixmaps", "umit")
46DOCS_DIR = os.path.join(main_dir, "share", "doc", "umit")
47
48base_paths = dict(config_file = 'umit.conf',
49                  config_dir = '.umit',
50                  user_dir = os.path.join(HOME, '.umit'),
51                  scan_profile = 'scan_profile.usp',
52                  profile_editor = 'profile_editor.xml',
53                  recent_scans = 'recent_scans.txt',
54                  target_list = 'target_list.txt',
55                  wizard = 'wizard.xml',
56                  options = 'options.xml',
57                  umit_opf = 'umit.opf',
58                  umit_opt = 'umit.opt',
59                  pixmaps_dir = PIXMAPS_DIR,
60                  i18n_dir = LOCALE_DIR,
61                  i18n_message_file = 'umit.mo',
62                  scan_results_extension = 'usr',  # comes from umit scan result
63                  scan_profile_extension = 'usp',  # comes from umit scan profile
64                  user_home = HOME,
65                  basic_search_sequence = [HOME, CURRENT_DIR],
66                  config_search_sequence = [HOME, CURRENT_DIR],
67                  pixmaps_search_sequence = [os.path.join(CURRENT_DIR, PIXMAPS_DIR),
68                                             HOME],
69                  i18n_search_sequence = [os.path.join(CURRENT_DIR, LOCALE_DIR), HOME],
70                  umitdb = "umit.db",
71                  services = "nmap-services",
72                  services_dump = "services.dmp",
73                  os_db = "nmap-os-db",
74                  os_dump = "os_db.dmp",
75                  os_fingerprints = "nmap-os-fingerprints",
76                  umit_version = "umit_version",
77                  os_classification = "os_classification.dmp")
78
79
80if PLATFORM == 'linux2' or PLATFORM == 'linux1':
81    base_paths.update(dict(user_home = HOME,
82                           basic_search_sequence = [os.path.join(HOME, base_paths['config_dir']),
83                                                    '/opt/umit', HOME, CURRENT_DIR],
84                           config_search_sequence = [os.path.join(HOME, base_paths['config_dir']),
85                                                     CURRENT_DIR, '/etc'],
86                           pixmaps_search_sequence = [os.path.join(CURRENT_DIR, PIXMAPS_DIR),
87                                                      '/usr/share/pixmaps/umit',
88                                                      '/opt/umit', HOME],
89                           i18n_search_sequence = [os.path.join(CURRENT_DIR, LOCALE_DIR),
90                                                   '/usr/share/locale',
91                                                   HOME, CURRENT_DIR]))
92elif PLATFORM == 'win32':
93    PROGRAM_FILES = os.environ.get("PROGRAMFILES", "\\")
94    UMIT_DIR = os.path.join(PROGRAM_FILES, "Umit")
95    PIXMAPS_DIR = os.path.join(UMIT_DIR, PIXMAPS_DIR)
96   
97    base_paths.update(dict(\
98        basic_search_sequence = [UMIT_DIR, PROGRAM_FILES, HOME, CURRENT_DIR],
99        config_search_sequence = [UMIT_DIR, PROGRAM_FILES, HOME, CURRENT_DIR],
100        pixmaps_search_sequence = [PIXMAPS_DIR, PROGRAM_FILES,
101                                   os.path.join(CURRENT_DIR, PIXMAPS_DIR),
102                                   HOME],
103        i18n_search_sequence = [UMIT_DIR, PROGRAM_FILES,
104                                os.path.join(CURRENT_DIR, LOCALE_DIR), HOME],))
105
106elif PLATFORM == 'darwin':
107    base_paths.update(dict(user_home = HOME,
108                           basic_search_sequence = [os.path.join(HOME, 'Applications'),
109                                                    '/Local', '/Network',
110                                                    '/System/Library', HOME]))
111
Note: See TracBrowser for help on using the browser.