[5101] | 1 | """Common filenames and locations for topographic data, meshes and outputs. |
---|
| 2 | Also includes origin for slump scenario. |
---|
| 3 | """ |
---|
| 4 | |
---|
| 5 | from os import sep, environ, getenv, getcwd |
---|
| 6 | import sys |
---|
| 7 | from time import localtime, strftime |
---|
| 8 | from os import mkdir, access, F_OK |
---|
| 9 | from anuga.abstract_2d_finite_volumes.util import add_directories, \ |
---|
| 10 | copy_code_files |
---|
| 11 | |
---|
| 12 | from anuga.utilities.system_tools import get_user_name |
---|
| 13 | |
---|
| 14 | boundary_file = 'boundary.tsm' |
---|
| 15 | |
---|
| 16 | class Project: |
---|
| 17 | def __init__(self, |
---|
| 18 | trunk, |
---|
| 19 | outputdir_name = None, |
---|
| 20 | home = None): |
---|
| 21 | |
---|
| 22 | self.user = get_user_name() |
---|
| 23 | if home is None: |
---|
| 24 | home = getenv('INUNDATIONHOME') #Sandpit's parent dir |
---|
| 25 | self.home = home |
---|
| 26 | # Create the structure of where the output directories will go |
---|
| 27 | scenariodir=add_directories(home, trunk) |
---|
| 28 | |
---|
| 29 | #Derive subdirectories and filenames |
---|
| 30 | if outputdir_name is None: |
---|
| 31 | #gets time for dir |
---|
| 32 | outputdir_name = strftime('%Y%m%d_%H%M%S',localtime()) |
---|
| 33 | general_outputdir = scenariodir+sep+'output'+sep |
---|
| 34 | self.outputdir = general_outputdir+outputdir_name+sep |
---|
| 35 | self.meshdir = scenariodir+sep+'meshes'+sep |
---|
| 36 | |
---|
| 37 | # creates copy of output dir structure, if it doesn't exist |
---|
| 38 | if not access(self.meshdir,F_OK): |
---|
| 39 | mkdir (self.meshdir) |
---|
| 40 | if not access(general_outputdir,F_OK): |
---|
| 41 | mkdir (general_outputdir) |
---|
| 42 | if not access(self.outputdir,F_OK): |
---|
| 43 | mkdir (self.outputdir) |
---|
| 44 | |
---|
| 45 | self.codedir = getcwd()+sep |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | #------------------------------------------------------------- |
---|
| 49 | if __name__ == "__main__": |
---|
| 50 | p = Project(['eagle'], 'lego','.') |
---|
| 51 | print p.outputdir |
---|
| 52 | print p.meshdir |
---|