Class: RunPostprocess
- Inherits:
-
Object
- Object
- RunPostprocess
- Includes:
- OpenStudio::Workflow::ApplyMeasures
- Defined in:
- lib/openstudio/workflow/jobs/run_postprocess/run_postprocess.rb
Constant Summary
Constants included from OpenStudio::Workflow::ApplyMeasures
OpenStudio::Workflow::ApplyMeasures::MEASURE_TYPES
Instance Method Summary collapse
- #cleanup ⇒ Object
-
#initialize(directory, logger, time_logger, adapter, options = {}) ⇒ RunPostprocess
constructor
A new instance of RunPostprocess.
- #perform ⇒ Object
Methods included from OpenStudio::Workflow::ApplyMeasures
#apply_arguments, #apply_measure, #apply_measures, #apply_variables
Constructor Details
#initialize(directory, logger, time_logger, adapter, options = {}) ⇒ RunPostprocess
Returns a new instance of RunPostprocess.
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/openstudio/workflow/jobs/run_postprocess/run_postprocess.rb', line 30 def initialize(directory, logger, time_logger, adapter, = {}) defaults = {} @options = defaults.merge() @directory = directory @run_directory = "#{@directory}/run" @adapter = adapter @logger = logger @time_logger = time_logger @results = {} @output_attributes = {} @logger.info "#{self.class} passed the following options #{@options}" end |
Instance Method Details
#cleanup ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/openstudio/workflow/jobs/run_postprocess/run_postprocess.rb', line 59 def cleanup # move any of the reporting file to the 'reports' directory for serverside access eplus_search_path = nil FileUtils.mkdir_p "#{@directory}/reports" # try to find the energyplus result file eplus_html = "#{@run_directory}/eplustbl.htm" unless File.exist? eplus_html eplus_html = Dir["#{@directory}/*EnergyPlus*/eplustbl.htm"].last || nil end if eplus_html if File.exist? eplus_html # do some encoding on the html if possible html = File.read(eplus_html) html = html.force_encoding('ISO-8859-1').encode('utf-8', replace: nil) File.open("#{@directory}/reports/eplustbl.html", 'w') { |f| f << html } end end # Also, find any "report.html" files Dir["#{@run_directory}/*/report*.*"].each do |report| # get the parent directory of the file and snake case it # do i need to force encoding on this as well? measure_class_name = File.basename(File.dirname(report)).snake_case file_ext = File.extname(report) append_str = File.basename(report, '.*').gsub('report', '') new_file_name = "#{@directory}/reports/#{measure_class_name}#{append_str}#{file_ext}" FileUtils.copy report, new_file_name end # Remove empty directories in run folder Dir["#{@run_directory}/*"].select { |d| File.directory? d }.select { |d| (Dir.entries(d) - %w(. ..)).empty? }.each do |d| @logger.info "Removing empty directory #{d}" Dir.rmdir d end paths_to_rm = [] # paths_to_rm << Pathname.glob("#{@run_directory}/*.osm") # paths_to_rm << Pathname.glob("#{@run_directory}/*.idf") # keep the idfs # paths_to_rm << Pathname.glob("*.audit") # paths_to_rm << Pathname.glob("*.bnd") paths_to_rm << Pathname.glob("#{@run_directory}/*.eso") paths_to_rm << Pathname.glob("#{@run_directory}/*.mtr") paths_to_rm << Pathname.glob("#{@run_directory}/*.epw") paths_to_rm << Pathname.glob("#{@run_directory}/*.mtd") paths_to_rm << Pathname.glob("#{@run_directory}/*.rdd") paths_to_rm.each { |p| FileUtils.rm_rf(p) } end |
#perform ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/openstudio/workflow/jobs/run_postprocess/run_postprocess.rb', line 44 def perform @logger.info "Calling #{__method__} in the #{self.class} class" @logger.info 'RunPostProcess Retrieving datapoint and problem' begin cleanup rescue => e = "Runner error #{__FILE__} failed with #{e.}, #{e.backtrace.join("\n")}" @logger.error # raise log_message end @results end |