Skip to content

Commit

Permalink
Merge pull request #309 from RWTH-EBC/issue296_LinuxFolder
Browse files Browse the repository at this point in the history
#296 changed the OutputData path interactions to save all output in t…
  • Loading branch information
PRemmen authored Sep 21, 2016
2 parents f97b60b + 9736492 commit 2a46214
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion teaser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 5 additions & 4 deletions teaser/data/output/text_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
19 changes: 11 additions & 8 deletions teaser/logic/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def celsius_to_kelvin(value):
f_value = 0
return f_value+273.15


def create_path(path):
'''Create a folder.
Expand All @@ -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):
Expand All @@ -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
return full_path
7 changes: 4 additions & 3 deletions teaser/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 2a46214

Please sign in to comment.