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