[Suggestion] Auto detect location on first run
I suggest to add a new feature:
the auto detection of the current location on the first run.
One implementation can be (only for the first run or if there are no settings yet) :
/usr/bin/
1) Check for internet connection, skip to (4) if none;
2) Run a script for retrieve necessary informations (my version at the bottom of the page);
3) If (2), store informations in the program database, else, skip to (4);
4) Run program
POSSIBLE SCRIPT:
#! /usr/bin/env python
import urllib, urllib2
def TryConnection(
try:
response = urllib2.
except urllib2.HTTPError, e: # No internet connection
print 'The server couldn\'t fulfill the request.\nError code: ', e.code
return -1
except urllib2.URLError, e: # No internet connection
print 'We failed to reach the server.\nReason: ', e.reason
return -1
else: # Internet connection available
temp = response.read()
return temp
url = "http://
req = urllib2.
pageBuffer = TryConnection(req) # Validate request
if not pageBuffer == -1:
var = []
for line in pageBuffer.
if 'content-td2' in line:
temp = line.split(
if ' <' in temp:
else:
#print var # Test
print "%s, %s" % (var[1], var[9]) # City, Country
else:
print 'Couldn\' retrieve webpage'
Question information
- Language:
- English Edit question
- Status:
- Answered
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Alessio L. for more information if necessary.