How to recognize current location in python?

My client has two offices in Germany and the USA, and python should recognize the location of the office. What would be the most elegant way to implement this? He only needs to recognize the country. In addition, it can also happen that there will be no permanent Internet connection. The program works with windows, but the solution must be independent of the OS.

Any suggestions? Thanks

+3
source share
1 answer

AFAIK, there is no elegant solution. You can make reasonable guesses, but then take this example: I disconnect my laptop in Germany and travel to the USA. I plug it into the US office - the regional settings are the same, the time zone has not changed, now what?

Things you can make a guess from:

  • regional and language settings (but German in the USA can use de_DE)
  • (but we are in New York or Brazil, the same TZ offset, in your case (PDT / EDT) and CET, are quite different).
  • internal IP address (provided that your offices have different internal addresses (for example, "10.5.20.0/24 - Germany, 192.168.4.0/24 - USA", regarding VPN, and what about unconnected devices?)
  • IP- ( /, , , VPN- , , ).
  • , ( )
  • ,
  • , ( )

, , . , .

; , .

+5
source

Source: https://habr.com/ru/post/1752459/


All Articles