Commit be95821184f9cfc5e5591c905d6e1aaec85aa0e5

Authored by Jürgen Knödlseder
1 parent e943ca09

Allow forcing of host country code query (#3319)

include/GTools.hpp
... ... @@ -164,7 +164,7 @@ namespace gammalib {
164 164 const double& tol);
165 165 std::string http_query(const std::string& host,
166 166 const std::string& query);
167   - std::string host_country(void);
  167 + std::string host_country(const bool& force_query = false);
168 168 GFilename gamma_filename(const std::string& name);
169 169 }
170 170  
... ...
pyext/GTools.i
... ... @@ -117,6 +117,6 @@ namespace gammalib {
117 117 const double& tol);
118 118 std::string http_query(const std::string& host,
119 119 const std::string& query);
120   - std::string host_country(void);
  120 + std::string host_country(const bool& force_query = false);
121 121 GFilename gamma_filename(const std::string& name);
122 122 }
... ...
src/support/GDaemon.cpp
... ... @@ -679,8 +679,8 @@ void GDaemon::update_statistics(void)
679 679 ***************************************************************************/
680 680 void GDaemon::update_host_country(void)
681 681 {
682   - // Get host country code
683   - std::string country = gammalib::host_country();
  682 + // Get host country code by forcing a query
  683 + std::string country = gammalib::host_country(true);
684 684  
685 685 // Continue only if host country is a two-digit code
686 686 if (country.length() == 2) {
... ...
src/support/GTools.cpp
... ... @@ -2259,6 +2259,7 @@ std::string gammalib::http_query(const std::string& host, const std::string& que
2259 2259 /***********************************************************************//**
2260 2260 * @brief Return two-digit host country code
2261 2261 *
  2262 + * @param[in] force_query Force query of host country code?
2262 2263 * @return Host two-digit host country code.
2263 2264 *
2264 2265 * Returns two-digit host country code, either by reading the code from the
... ... @@ -2278,6 +2279,7 @@ std::string gammalib::http_query(const std::string& host, const std::string& que
2278 2279 /***********************************************************************//**
2279 2280 * @brief Return two-digit host country code
2280 2281 *
  2282 + * @param[in] force_query Force query of host country code?
2281 2283 * @return Host two-digit host country code.
2282 2284 *
2283 2285 * Returns two-digit host country code, either by reading the code from the
... ... @@ -2294,7 +2296,7 @@ std::string gammalib::http_query(const std::string& host, const std::string& que
2294 2296 * country code it will write the results into a host-country file.
2295 2297 ***************************************************************************/
2296 2298 #endif
2297   -std::string gammalib::host_country(void)
  2299 +std::string gammalib::host_country(const bool& force_query)
2298 2300 {
2299 2301 // Initialise country as static variable
2300 2302 static std::string country;
... ... @@ -2306,7 +2308,7 @@ std::string gammalib::host_country(void)
2306 2308 GFilename filename = gammalib::gamma_filename("host-country");
2307 2309  
2308 2310 // Continue only if file exists
2309   - if (access(filename.url().c_str(), R_OK) == 0) {
  2311 + if ((!force_query) && (access(filename.url().c_str(), R_OK) == 0)) {
2310 2312  
2311 2313 // OpenMP critical zone to read host-country file
2312 2314 #pragma omp critical(GammaLib_host_country)
... ...