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

Source Code for Module PyFoam.Infrastructure.Hardcoded

 1  #  ICE Revision: $Id: /local/openfoam/Python/PyFoam/PyFoam/Infrastructure/Hardcoded.py 6471 2010-04-16T19:46:47.669328Z 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 globalConfigDir():
19 """@return: The name of the global configuration directory where .cfg-files can be placed""" 20 return globalConfigFile()+".d"
21
22 -def userDirectory():
23 """@return: the user directory""" 24 return path.expanduser(path.join("~","."+_pyFoamDirName))
25
26 -def userConfigFile():
27 """@return: The name of the user configuration File""" 28 return path.join(userDirectory(),_pyFoamConfigName)
29
30 -def userConfigDir():
31 """@return: The name of the user configuration directory where .cfg-files can be placed""" 32 return userConfigFile()+".d"
33
34 -def userName():
35 """@return: name of the current user""" 36 user="" 37 if environ.has_key("USER"): 38 user=environ["USER"] 39 return user
40
41 -def logDirectory():
42 """Path to the log directory that this user may write to. 43 /var/log/pyFoam for root, ~/.pyFoam/log for all others 44 @return: path to the log directory.""" 45 if userName()=="root": 46 return path.join("/var/log","pyFoam") 47 else: 48 return path.join(userDirectory(),"log")
49
50 -def assertDirectory(name):
51 """Makes sure that the directory exists 52 @param name: the directory""" 53 if path.exists(name): 54 return 55 else: 56 makedirs(name,mode=0755)
57