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 | from anuga.abstract_2d_finite_volumes.generic_boundary_conditions\ |
---|
15 | import File_boundary_time |
---|
16 | boundary_file = 'boundary.tms' |
---|
17 | #boundary_file = 'boundary_mellow.tms' |
---|
18 | |
---|
19 | class Project: |
---|
20 | def __init__(self, |
---|
21 | trunk, |
---|
22 | outputdir_name = None, |
---|
23 | home = None): |
---|
24 | |
---|
25 | self.user = get_user_name() |
---|
26 | if home is None: |
---|
27 | home = getenv('INUNDATIONHOME') #Sandpit's parent dir |
---|
28 | self.home = home |
---|
29 | # Create the structure of where the output directories will go |
---|
30 | scenariodir=add_directories(home, trunk) |
---|
31 | |
---|
32 | #Derive subdirectories and filenames |
---|
33 | if outputdir_name is None: |
---|
34 | #gets time for dir |
---|
35 | outputdir_name = strftime('%Y%m%d_%H%M%S',localtime()) |
---|
36 | general_outputdir = scenariodir+sep+'output'+sep |
---|
37 | self.outputdir = general_outputdir+outputdir_name+sep |
---|
38 | self.meshdir = scenariodir+sep+'meshes'+sep |
---|
39 | |
---|
40 | # creates copy of output dir structure, if it doesn't exist |
---|
41 | if not access(self.meshdir,F_OK): |
---|
42 | mkdir (self.meshdir) |
---|
43 | if not access(general_outputdir,F_OK): |
---|
44 | mkdir (general_outputdir) |
---|
45 | if not access(self.outputdir,F_OK): |
---|
46 | mkdir (self.outputdir) |
---|
47 | |
---|
48 | self.codedir = getcwd()+sep |
---|
49 | |
---|
50 | |
---|
51 | #------------------------------------------------------------- |
---|
52 | if __name__ == "__main__": |
---|
53 | p = Project(['eagle'], 'lego','.') |
---|
54 | print p.outputdir |
---|
55 | print p.meshdir |
---|