Find Lat/Long from python using Google - python

I'm coming up just a little short on this. I know google has a python client library, and it also has Client Location. However, i'm at a loss on how to access Client Location via the API.
What I'm trying to do is make a desktop app Location Aware.

Is it a desktop app running in a browser ? If so, then use the W3C GeoLocation API - see https://stackoverflow.com/a/8973377/156477 and many other questions on SO.
If not, then you need a service that determines location via WiFi MAC address or an IP geolocation lookup. For the WiFi MAC address lookup, check out http://code.google.com/p/maclocate/. For an IP based lookup, MaxMind provide a service (there is a free service accurate to a city, or a paid for service if you need more accuracy). There is also a Python library http://www.maxmind.com/app/python.
Note, I haven't tried either library so I can't vouch for them. I have used the MaxMind service and it works well, with the exception of users who are on a corporate network. These users will always be reported as being located where the corporate network hub is.

Related

My Flask python web application is not accessible from a domain name

I have programmed in python a web application using flask. I decided to deploy it from my home with a raspberry pi which runs the code continuously. I would like it to be accessible from a web browser and for that I have thought to configure my router to redirect the requests to my server. I also took care to configure my firewall accordingly. It turns out that the application works well and is perfectly accessible by typing its public IP in my URL bar. The problem is that I can't access it using a domain name. I have rented a new one and I have configured the DNS records so that it points to my server. I tested the DNS servers and it seems that the pointing is effective. However, when I enter the domain name I don't get my web application but the page of hostinger, the hosting company where I rented the domain name. I have contacted the technical department and they assure me that the problem is not in the DNS but in the hosting, so in my python code. This leaves me perplexed because my web application is accessible from its public IP. So the code should be good.
Please do not hesitate to ask me for additional details, either on the level of my python program or on the level of my server.
Thanks in advance for your help

Can't see sonos devices on Spotify connect

I am trying to connect my Spotify to my sonos. I am using the Tekore library to consume the Spotify API. When I try to list all devices on Spotify Connect, i.e. spotify.playback_devices(), I get only some of the available devices. Especially, the Sonos devices are not listed. Does anybody know why?
The documentation for the Spotify Connect Web API is pretty clear about this type of scenario:
Devices not Appearing on Device List
Connect Web API relies on local network connections to discover and interact with some devices.
For example, when:
A new device is added to the network
A device is in “sleep” mode
A device on the local network is currently tied to another user account, or
Other reasons specific to the device
As a result, some devices that appear in the Connect picker within the
Spotify application may not always be visible or available on the
Connect Web API
Endpoints.
Translation: if it doesn't appear in the API, there's likely a reason for that. You might be able to get further guidance from the development team if you tweet at them #SpotifyPlatform.

Is it possible to migrate a google VM instance from one account to another keeping its external IP?

I am working in a python project that interacts both with the cloud and with an USB port. I hardcoded the VM IP in my python code, but I need to migrate the server from my personal account to the company's account. Because I deployed this python project as a .exe I have to build it again (with pyinstaller) in case I change the server IP. Is it possible to keep this IP after migrating?
It looks like Bring your own ip is possible
Best security practice, don't always keep public IP.
Internal/external IP identified with DNS server. Understand the objective and decide accordingly.
No, you can't keep the same IP from one project to another one (or you are very lucky). However, in this case, I recommend you to perform that:
Replace your billing account with the company billing account
Migrate the project from your organization to the company organization
Instead of recreate your project, simply change the ownership.
In the future, follow subbu recommendation: use domain name instead of IP!
I would first like to address that, for transferring and/or keeping public IP addresses from VM instances, you will need to then review the following documentation on reserving static external IP addresses, as an external IP address is the public IP address.
In your case, since you have public IP’s assigned to the VMs, you will need to then promote an ephemeral external IP address to a static external IP address; here you’ll find the documentation that demonstrates how to do this as well. This is how you can keep a public IP address for your instances.
Please keep in mind that, to preserve the same IPs after copying your VMs, you can do that if the instance is created in the same zone, so the new instance in the new project should be created in the same zone.
Moreover, in terms of moving VMs from one project to another, it is not possible, as VMs are binded to the project that they are located in. If you would like to move VMs from one organization to another, you will need to move the entire project to the end organization. You can follow this documentation to learn more about migration.

Google Onhub API?

I'm trying to create an API for the Google Onhub router, but when I sniff my phone's network traffic it doesn't send to the router but to a google server IP and when I try to connect to the IP I timeout, any ideas on how I could do this?
An API already exists for the Google OnHub. Documentation is sparse, but the known URLs at present are as follows:
http://onhub.here/api/v1/status
http://onhub.here/api/v1/diagnostic-report
http://onhub.here/api/v1/welcome-mat
http://onhub.here/api/v1/connected-devices
http://onhub.here/api/v1/get-attestation-information
http://onhub.here/api/v1/get-endorsement-information
I am actually working on something that describes exactly what you said.
What you are looking for is the 'Google Home Foyer' API. It's a private service that's only used by Google's apps.
I am documenting it here. It's still in beta, however. I'm also working on an actual desktop client for it here.

How do I find out what the IP address is for a domain name on Google App Engine?

I need to figure out which IP address my application is actually connecting to when it makes a urlfetch to a provided domain. My application on the production server is having problems connecting to a domain but connecting works perfectly fine using the SDK on my computer. I am trying to debug this problem and it occurred to me that Google App Engine may be resolving the domain to a different IP address than my local computer is.
If I had access to the socket library this would be as simple as socket.gethostbyname('thedomainiwant.com') but unfortunately Google does not allow the socket library on App Engine.
Any ideas?
If there is a solution that requires Java or Go on App Engine I am willing to try that too.
Update June 26, 2011:
I changed the production code to use the IP directly right away just to get this working (and it did) but this is not a good long term solution as I don't control the server I am making urlfetches to so the IP may change on me without warning.
Returned headers would not be helpful in this case because whatever IP address the production instance is resolving the domain to is not responding at all and the request times out.
If the server I am doing urlfetches to was blocking App Engine then doing an urlfetch by IP would not work either...but it does work. Also, I talked to the team managing the server and they confirmed they are not blocking App Engine. I am still pestering them for more info but it does not seem to be a problem on that end.
Update July 7, 2011:
Google has confirmed that there was a problem on their end that affected my application. They have applied a work around and are working on a fix. See here:
http://code.google.com/p/googleappengine/issues/detail?id=5244
There's currently no way to do name resolution on App Engine. You'll have to call an external service over HTTP if you want to do that.
Take a look at the response headers, you might get a HOST header back with exactly this info.
Otherwise, why not just use the raw IP's for your connections while you're diagnosing this?
You can use web services that perform DNS lookup. You can embed the address in the URL, like this:
http://www.dnswatch.info/dns/dnslookup?la=en&host=HOST_HERE&type=A&submit=Resolve
(replace the HOST_HERE) and then parse the result. Unfortunately it is HTML, but even simple regex should make it. You can also try find some service, which allows some XML output or so - there are a lot of such services, just type "dnslookup" in Google, someone might have it.

Categories