diff --git a/teaser/__init__.py b/teaser/__init__.py index 95151dc37..13cf88a93 100644 --- a/teaser/__init__.py +++ b/teaser/__init__.py @@ -18,7 +18,7 @@ else: raise Exception('This software runs on python versions 2.7 or >=3.3 only!') -new_path = utilitis.get_full_path("OutputData") +new_path = os.path.join(os.path.expanduser('~'), ("TEASEROutput")) if not os.path.exists(new_path): os.makedirs(new_path) diff --git a/teaser/data/output/text_output.py b/teaser/data/output/text_output.py index 074a5f50e..4842cf126 100644 --- a/teaser/data/output/text_output.py +++ b/teaser/data/output/text_output.py @@ -7,6 +7,8 @@ """ import teaser.logic.utilities as utilitis from mako.template import Template +import os + def export_parameters_txt(prj, path): '''Exports parameters of all buildings in a readable text file @@ -19,19 +21,18 @@ def export_parameters_txt(prj, path): can be specified ''' if path is None: - path = "OutputData/"+prj.name + path = os.path.join(os.path.expanduser('~'), "TEASEROutput/", prj.name) else: path = path+"/"+prj.name for bldg in prj.buildings: bldg_path = path + "/" + bldg.name + "/" - utilitis.create_path(utilitis.get_full_path(bldg_path)) + utilitis.create_path(bldg_path) readable_template = Template( filename=utilitis.get_full_path( "data/output/texttemplate/ReadableBuilding")) - out_file = open(utilitis.get_full_path - (bldg_path+"ReadableOutput.txt"), 'w') + out_file = open((bldg_path + "ReadableOutput.txt"), 'w') out_file.write(readable_template.render_unicode (bldg=bldg, prj=prj)) out_file.close() diff --git a/teaser/logic/utilities.py b/teaser/logic/utilities.py index 58b4a7c31..5df332101 100644 --- a/teaser/logic/utilities.py +++ b/teaser/logic/utilities.py @@ -15,6 +15,7 @@ def celsius_to_kelvin(value): f_value = 0 return f_value+273.15 + def create_path(path): '''Create a folder. @@ -35,23 +36,25 @@ def create_path(path): os.makedirs(path) os.chdir(path) - return path + def get_default_path(): '''Function to construct default path to OutputData folder - This function constructs the default path to the OutputData folder ''' - directory = os.path.dirname(__file__) - src = "teaser" - last_index = directory.rfind(src) - default_path = os.path.join(directory[:last_index], "teaser", "OutputData") + home_path = os.path.expanduser('~') + + teaser_default_path = os.path.join(home_path, 'TEASEROutput') + # directory = os.path.dirname(__file__) + # src = "teaser" + # last_index = directory.rfind(src) + # teaser_default_path = os.path.join(directory[:last_index], "teaser", "OutputData") - return default_path + return teaser_default_path def get_full_path(rel_path): @@ -75,4 +78,4 @@ def get_full_path(rel_path): first_path = os.path.join(directory[:last_index], "teaser") full_path = os.path.join(first_path, rel_path) - return full_path \ No newline at end of file + return full_path diff --git a/teaser/project.py b/teaser/project.py index 33ccc64e9..861aa998f 100644 --- a/teaser/project.py +++ b/teaser/project.py @@ -6,6 +6,7 @@ import warnings +import os import teaser.logic.utilities as utilitis import teaser.data.input.teaserxml_input as txml_in import teaser.data.output.teaserxml_output as txml_out @@ -837,7 +838,7 @@ def save_project(self, file_name=None, path=None): name = file_name if path is None: - new_path = utilitis.get_full_path("OutputData") + "/" + name + new_path = os.path.join(utilitis.get_default_path(), name) else: new_path = path + "/" + name utilitis.create_path(utilitis.get_full_path(path)) @@ -882,7 +883,7 @@ def save_citygml(self, file_name=None, path=None): name = file_name if path is None: - new_path = utilitis.get_full_path("OutputData") + "/" + name + new_path = os.path.join(utilitis.get_default_path(), name) else: new_path = path + "/" + name utilitis.create_path(utilitis.get_full_path(path)) @@ -1004,7 +1005,7 @@ def export_parameters_txt(self, path=None): ''' if path is None: - path = "OutputData/"+self.name + path = os.path.join(utilitis.get_default_path(), self.name) else: path = path+"/"+self.name