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
108
109
110
111
112
113
114
115
116
|
# File 'lib/origen/site_config/config.rb', line 64
def fetch
def inform_user_of_cached_file
if cached?
puts yellow('Origen: Site Config: Found previously cached site config. Using the older site config.')
else
puts yellow('Origen: Site Config: No cached file found. An empty site config will be used in its place.')
end
puts
end
if centralized?
puts "Pulling centralized site config from: #{path}"
begin
text = HTTParty.get(path, verify: parent.find_val('centralized_site_config_verify_ssl'))
puts "Caching centralized site config to: #{cached_file}"
unless Dir.exist?(cached_file.dirname)
FileUtils.mkdir_p(cached_file.dirname)
end
File.open(cached_file, 'w+') do |f|
f.write(text)
end
rescue SocketError => e
puts red("Origen: Site Config: Unable to connect to #{path}")
puts red('Origen: Site Config: Failed to retrieve centralized site config!')
puts red("Error from exception: #{e.message}")
inform_user_of_cached_file
rescue OpenSSL::SSL::SSLError => e
puts red("Origen: Site Config: Unable to connect to #{path}")
puts red('Origen: Site Config: Failed to retrieve centralized site config!')
puts red("Error from exception: #{e.message}")
puts red('It looks like the error is related to SSL certification. If this is a trusted server, you can use')
puts red("the site config setting 'centralized_site_config_verify_ssl' to disable verifying the SSL certificate.")
inform_user_of_cached_file
rescue Exception => e
puts red("Origen: Site Config: Unexpected exception ocurred trying to either retrieve or cache the site config at #{path}")
puts red('Origen: Site Config: Failed to retrieve centralized site config!')
puts red("Class of exception: #{e.class}")
puts red("Error from exception: #{e.message}")
inform_user_of_cached_file
end
text
end
end
|