Package flumotion :: Package configure :: Module configure
[hide private]

Source Code for Module flumotion.configure.configure

  1  # -*- Mode: Python; test-case-name: flumotion.test.test_configure -*- 
  2  # vi:si:et:sw=4:sts=4:ts=4 
  3   
  4  # Flumotion - a streaming media server 
  5  # Copyright (C) 2004,2005,2006,2007,2008,2009 Fluendo, S.L. 
  6  # Copyright (C) 2010,2011 Flumotion Services, S.A. 
  7  # All rights reserved. 
  8  # 
  9  # This file may be distributed and/or modified under the terms of 
 10  # the GNU Lesser General Public License version 2.1 as published by 
 11  # the Free Software Foundation. 
 12  # This file is distributed without any warranty; without even the implied 
 13  # warranty of merchantability or fitness for a particular purpose. 
 14  # See "LICENSE.LGPL" in the source distribution for more information. 
 15  # 
 16  # Headers in this file shall remain intact. 
 17   
 18  ''' 
 19  configure-time variables for installed or uninstalled operation 
 20   
 21  Code should run 
 22      >>> from flumotion.configure import configure 
 23   
 24  and then access the variables from the configure module.  For example: 
 25      >>> print configure.gladedir 
 26   
 27  The values are decided at ./configure time.  They can be overridden at startup 
 28  by programs based on environment or options.  This allows running with 
 29  different configdir, logdir and rundir. 
 30   
 31  @var  isinstalled: whether an installed version is being run 
 32  @type isinstalled: boolean 
 33   
 34  @var  cachedir:      directory where cached code is stored 
 35  @type cachedir:      stringed 
 36  @var  configdir:     directory where configuration files are stored 
 37  @type configdir:     string 
 38  @var  daemondir:     directory where daemonized programs should run 
 39  @type daemondir:     string 
 40  @var  datadir:       directory where data files are stored 
 41  @type datadir:       string 
 42  @var  gladedir:      directory where glade files are stored 
 43  @type gladedir:      string 
 44  @var  logdir:        directory where log files are stored 
 45  @type logdir:        string 
 46  @var  imagedir:      directory where image files are stored 
 47  @type imagedir:      string 
 48  @var  pythondir:     directory where the flumotion python files are stored 
 49  @type pythondir:     string 
 50  @var  registrydir:   directory where the registry files are stored 
 51  @type registrydir:   string 
 52  @var  rundir:        directory where the run/pid files are stored 
 53  @type rundir:        string 
 54  @var  bindir:        directory where the flumotion executables live 
 55  @type bindir:        string 
 56  @var  sbindir:       directory where the flumotion service program lives 
 57  @type sbindir:       string 
 58   
 59  @var  defaultTCPManagerPort:  the default manager port for TCP communication 
 60  @type defaultTCPManagerPort:  int 
 61  @var  defaultSSLManagerPort:  the default manager port for SSL communication 
 62  @type defaultSSLManagerPort:  int 
 63  @var  defaultHTTPStreamPort:  the default external http streaming port 
 64  @type defaultHTTPStreamPort:  int 
 65  @var  defaultGstPortRange:    the default range of internal GStreamer ports 
 66  @type defaultGstPortRange:    list of ints 
 67   
 68  @var  PACKAGE:      Flumotion package 
 69  @type PACKAGE:      string 
 70  @var  version:      Flumotion version number 
 71  @type version:      string 
 72  @var  versionTuple: Flumotion version number 
 73  @type versionTuple: 4-tuple of integers 
 74  @var  branchName:   Flumotion branch name 
 75  @type branchName:   string 
 76   
 77  # default values for service-related stuff 
 78   
 79  @var  processTermWait: how long to wait before timing out term signals 
 80  @type processTermWait int 
 81  @var  processKillWait: how long to wait before timing out kill signals 
 82  @type processKillWait int 
 83  @var  heartbeatInterval: component heartbeat interval, in seconds 
 84  @type heartbeatInterval: int 
 85  @var  pingTimeoutMultiplier: how long to wait before assuming a lost 
 86                               connection, specified as a multiple of the 
 87                               heartbeatInterval 
 88  @type pingTimeoutMultiplier: float 
 89  ''' 
 90   
 91  # Note: This module is loaded very early on, so 
 92  #       don't add any extra flumotion imports unless you 
 93  #       really know what you're doing 
 94   
 95  import os 
 96   
 97  __version__ = "$Rev$" 
 98   
 99  # where am I on the disk ? 
100  __thisdir = os.path.dirname(os.path.abspath(__file__)) 
101   
102  if os.path.exists(os.path.join(__thisdir, 'uninstalled.py')): 
103      from flumotion.configure import uninstalled 
104      _config = uninstalled.get() 
105  else: 
106      from flumotion.configure import installed 
107      _config = installed.get() 
108   
109   
110 -def _versionStringToTuple(versionString):
111 versionString = versionString.split('-')[0] 112 t = tuple(map(int, versionString.split('.'))) 113 if len(t) < 4: 114 t = t + (0, ) 115 return t
116 117 isinstalled = _config['isinstalled'] 118 119 cachedir = _config['cachedir'] 120 configdir = _config['configdir'] 121 daemondir = _config['daemondir'] 122 datadir = _config['datadir'] 123 gladedir = _config['gladedir'] 124 imagedir = _config['imagedir'] 125 logdir = _config['logdir'] 126 localedatadir = _config['localedatadir'] 127 pythondir = _config['pythondir'] 128 registrydir = _config['registrydir'] 129 rundir = _config['rundir'] 130 bindir = _config['bindir'] 131 sbindir = _config['sbindir'] 132 133 defaultTCPManagerPort = 8642 134 defaultSSLManagerPort = 7531 135 defaultHTTPStreamPort = 8800 136 defaultGstPortRange = range(8600, 8639 + 1) 137 138 PACKAGE = 'flumotion' 139 version = _config['version'] 140 versionTuple = _versionStringToTuple(version) 141 branchName = 'trunk' 142 143 processTermWait = 20 144 processKillWait = 10 145 heartbeatInterval = 5 146 # FIXME: bring pingTimeoutMultiplier back to 2.5 once the ping 147 # problems are fixed properly (possibly that value won't be needed at 148 # that point at all) 149 pingTimeoutMultiplier = 6.0 150