mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 20:30:05 +00:00
Disable HTTP request for region
This commit is contained in:
parent
e69f9a8008
commit
17ebfd609d
4 changed files with 52 additions and 2 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#include <scwx/provider/aws_nexrad_data_provider.hpp>
|
||||
#include <scwx/util/environment.hpp>
|
||||
#include <scwx/util/logger.hpp>
|
||||
#include <scwx/util/map.hpp>
|
||||
#include <scwx/util/time.hpp>
|
||||
|
|
@ -51,6 +52,9 @@ public:
|
|||
lastModified_ {},
|
||||
updatePeriod_ {}
|
||||
{
|
||||
// Disable HTTP request for region
|
||||
util::SetEnvironment("AWS_EC2_METADATA_DISABLED", "true");
|
||||
|
||||
Aws::Client::ClientConfiguration config;
|
||||
config.region = region_;
|
||||
|
||||
|
|
|
|||
31
wxdata/source/scwx/util/environment.cpp
Normal file
31
wxdata/source/scwx/util/environment.cpp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include <scwx/util/environment.hpp>
|
||||
#include <scwx/util/logger.hpp>
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <cstdlib>
|
||||
#endif
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
static const std::string logPrefix_ {"scwx::util::environment"};
|
||||
static const auto logger_ = util::Logger::Create(logPrefix_);
|
||||
|
||||
void SetEnvironment(const std::string& name, const std::string& value)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
errno_t error = _putenv_s(name.c_str(), value.c_str());
|
||||
#else
|
||||
int error = setenv(name.c_str(), value.c_str(), 1);
|
||||
#endif
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
logger_->warn("Could not set environment variable: {}={}", name, value);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace scwx
|
||||
Loading…
Add table
Add a link
Reference in a new issue