root/branch/NetworkInventory/umitCore/BasePaths.py @ 3874

Revision 3874, 5.8 kB (checked in by gpolo, 4 years ago)

Removed unecessary imports to os.path

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 sys
25
26
27######################
28# Platform recognition
29PLATFORM = sys.platform
30HOME = os.path.expanduser("~")
31#HOME = os.environ.get('HOME', '')
32CURRENT_DIR = os.getcwd()
33
34# Look for files relative to the script path to allow running within the build
35# directory.
36main_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
37if hasattr(sys, "frozen"):
38    main_dir = os.path.dirname(sys.executable)
39
40CONFIG_DIR = os.path.join(main_dir, "share", "umit", "config")
41LOCALE_DIR = os.path.join(main_dir, "share", "locale")
42MISC_DIR = os.path.join(main_dir, "share", "umit", "misc")
43ICONS_DIR = os.path.join(main_dir, "share", "icons", "umit")
44PIXMAPS_DIR = os.path.join(main_dir, "share", "pixmaps", "umit")
45PLUGINS_DIR = os.path.join(main_dir, "share", "umit", "plugins")
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                  scripts_dir = os.path.join('share', 'scripts'),
60                  pixmaps_dir = PIXMAPS_DIR,
61                  plugins_dir = PLUGINS_DIR,
62                  i18n_dir = LOCALE_DIR,
63                  i18n_message_file = 'umit.mo',
64                  scan_results_extension = 'usr',  # comes from umit scan result
65                  scan_profile_extension = 'usp',  # comes from umit scan profile
66                  user_home = HOME,
67                  basic_search_sequence = [HOME, CURRENT_DIR],
68                  config_search_sequence = [HOME, CURRENT_DIR],
69                  pixmaps_search_sequence = [os.path.join(CURRENT_DIR, PIXMAPS_DIR),
70                                             HOME],
71                  i18n_search_sequence = [os.path.join(CURRENT_DIR, LOCALE_DIR), HOME],
72                  umitdb = "umit.db",
73
74                  # new generation database
75                  umitdb_ng = "umitng.db",
76
77                  # timeline configuration
78                  tl_conf = "timeline-settings.conf",
79                  tl_colors_std = "tl_colors_evt_std.conf",
80                 
81                  # scheduler
82                  sched_schemas = "scheduler-schemas.conf",
83                  sched_profiles = "scheduler-profiles.conf",
84                  sched_log = "scheduler.log",
85
86                  # smtp
87                  smtp_schemas = "smtp-schemas.conf",
88
89                  services = "nmap-services",
90                  services_dump = "services.dmp",
91                  os_db = "nmap-os-db",
92                  os_dump = "os_db.dmp",
93                  os_fingerprints = "nmap-os-fingerprints",
94                  umit_version = "umit_version",
95                  os_classification = "os_classification.dmp")
96
97
98if PLATFORM == 'linux2' or PLATFORM == 'linux1':
99    base_paths.update(dict(user_home = HOME,
100                           basic_search_sequence = [os.path.join(HOME, base_paths['config_dir']),
101                                                    '/opt/umit', HOME, CURRENT_DIR],
102                           config_search_sequence = [os.path.join(HOME, base_paths['config_dir']),
103                                                     CURRENT_DIR, '/etc'],
104                           pixmaps_search_sequence = [os.path.join(CURRENT_DIR, PIXMAPS_DIR),
105                                                      '/usr/share/pixmaps/umit',
106                                                      '/opt/umit', HOME],
107                           i18n_search_sequence = [os.path.join(CURRENT_DIR, LOCALE_DIR),
108                                                   '/usr/share/locale',
109                                                   HOME, CURRENT_DIR]))
110elif PLATFORM == 'win32':
111    PROGRAM_FILES = os.environ.get("PROGRAMFILES", "\\")
112    UMIT_DIR = os.path.join(PROGRAM_FILES, "Umit")
113    PIXMAPS_DIR = os.path.join(UMIT_DIR, PIXMAPS_DIR)
114   
115    base_paths.update(dict(\
116        basic_search_sequence = [UMIT_DIR, PROGRAM_FILES, HOME, CURRENT_DIR],
117        config_search_sequence = [UMIT_DIR, PROGRAM_FILES, HOME, CURRENT_DIR],
118        pixmaps_search_sequence = [PIXMAPS_DIR, PROGRAM_FILES,
119                                   os.path.join(CURRENT_DIR, PIXMAPS_DIR),
120                                   HOME],
121        i18n_search_sequence = [UMIT_DIR, PROGRAM_FILES,
122                                os.path.join(CURRENT_DIR, LOCALE_DIR), HOME],))
123
124elif PLATFORM == 'darwin':
125    base_paths.update(dict(user_home = HOME,
126                           basic_search_sequence = [os.path.join(HOME, 'Applications'),
127                                                    '/Local', '/Network',
128                                                    '/System/Library', HOME]))
129
Note: See TracBrowser for help on using the browser.