root/trunk/umitCore/GetConfigFile.py @ 3177

Revision 3177, 1.5 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
23from os.path import exists, dirname
24from os import access, R_OK
25from tempfile import mktemp
26
27from umitCore.Paths import Path
28from umitCore.UmitLogging import log
29
30def get_config_file(filename, original_content):
31    config_file = mktemp()
32
33    try:
34        c = Path.__getattr__(filename)
35        if exists(c) and access(c, R_OK):
36            config_file = c
37        else:
38            raise Exception()
39    except:
40        # Using temporary file
41        cfile = open(config_file, "w")
42        cfile.write(original_content)
43        cfile.close()
44
45    log.debug(">>> Get config file %s: %s" % (filename, config_file))
46    return config_file
Note: See TracBrowser for help on using the browser.