Package PyFoam :: Package Infrastructure :: Module Hardcoded
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.Infrastructure.Hardcoded

 1  #  ICE Revision: $Id: Hardcoded.py 7581 2007-06-27 15:29:14Z bgschaid $  
 2  """Hardcoded values""" 
 3   
 4  from os import path,makedirs,environ 
 5   
 6  _pyFoamDirName="pyFoam" 
 7   
 8  _pyFoamConfigName="pyfoamrc" 
 9   
10 -def globalDirectory():
11 """@return: the global directory""" 12 return path.join("/etc",_pyFoamDirName)
13
14 -def globalConfigFile():
15 """@return: The name of the global configuration File""" 16 return path.join(globalDirectory(),_pyFoamConfigName)
17
18 -def userDirectory():
19 """@return: the user directory""" 20 return path.expanduser(path.join("~","."+_pyFoamDirName))
21
22 -def userConfigFile():
23 """@return: The name of the user configuration File""" 24 return path.join(userDirectory(),_pyFoamConfigName)
25
26 -def userName():
27 """@return: name of the current user""" 28 user="" 29 if environ.has_key("USER"): 30 user=environ["USER"] 31 return user
32
33 -def logDirectory():
34 """Path to the log directory that this user may write to. 35 /var/log/pyFoam for root, ~/.pyFoam/log for all others 36 @return: path to the log directory.""" 37 if userName()=="root": 38 return path.join("/var/log","pyFoam") 39 else: 40 return path.join(userDirectory(),"log")
41
42 -def assertDirectory(name):
43 """Makes sure that the directory exists 44 @param name: the directory""" 45 if path.exists(name): 46 return 47 else: 48 makedirs(name,mode=0755)
49