source: trunk/packages/xen-3.1/xen-3.1/tools/python/xen/xend/server/params.py @ 34

Last change on this file since 34 was 34, checked in by hartmans, 18 years ago

Add xen and xen-common

File size: 1.8 KB
Line 
1#============================================================================
2# This library is free software; you can redistribute it and/or
3# modify it under the terms of version 2.1 of the GNU Lesser General Public
4# License as published by the Free Software Foundation.
5#
6# This library is distributed in the hope that it will be useful,
7# but WITHOUT ANY WARRANTY; without even the implied warranty of
8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
9# Lesser General Public License for more details.
10#
11# You should have received a copy of the GNU Lesser General Public
12# License along with this library; if not, write to the Free Software
13# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
14#============================================================================
15# Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com>
16#============================================================================
17
18import os
19
20def getenv(var, val, conv=None):
21    """Get a value from the environment, with optional conversion.
22
23    @param var  name of environment variable
24    @param val  default value
25    @param conv conversion function to apply to env value
26    @return converted value or default
27    """
28    try:
29        v = os.getenv(var)
30        if v is None:
31            v = val
32        else:
33            print var, '=', v
34        if conv:
35            v = conv(v)
36    except:
37        v = val
38    return v
39
40# The following parameters could be placed in a configuration file.
41XEND_PID_FILE      = '/var/run/xend.pid'
42XEND_TRACE_FILE    = '/var/log/xen/xend.trace'
43XEND_DEBUG_LOG     = '/var/log/xen/xend-debug.log'
44XEND_USER          = 'root'
45XEND_DEBUG         = getenv("XEND_DEBUG",     0, conv=int)
46XEND_DAEMONIZE     = getenv("XEND_DAEMONIZE", not XEND_DEBUG, conv=int)
Note: See TracBrowser for help on using the repository browser.