states.rb revision 29df54c6935a6dc6ebd194518adf1b1a2c19b876
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# * downloading
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# * processing
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen after_save :after_update_state, if: :change_applicable?
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen if (ind=lines.index("*** Error:")) and (out = lines[ind+1]).present?
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen while lines[i] and !lines[i].include?("hets: user error") do
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen msg << out.sub(URI.regexp,"...").sub(/ \/[A-Za-z0-9\/.]*/," ...")
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen elsif last_error.include?("exited with status")
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen msg << last_error[0,50]+" ... "+last_error.match("exited with status.*")[0]
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen msg << lines.first
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen msg.join(": ")
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen def after_update_state
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen ontology.state = state.to_s
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen ontology.save!
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen if ontology.distributed?
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen ontology.children.update_all state: ontology.state