FAQ
Hi,

I am happy user of Nokia 770 tablett
and one application for Nokia 770 is maemo mapper (beta navigation
application).
And the following script should run under mm (for Debian).
Its developer told me it wans intended for other developers.
I have no idea how to write Python script
so please tell me how to learn how the following script works and how
to modify it to be fully working,
Frankly speaking I would prefer to pay for your kind assistance
as it may take me to much time to learn some Python and understand the
following script.

I would like to modify it to add 2 more columns to SQL (sqlite3) POI
database, to set proximity value and spead limit as in safety cam POI
in standard car navigation systems.

Please let me know your opinion.

Darius



#!/usr/bin/python2.5
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA

__author__ = "Henri Bergius <henri.bergius at iki.fi>"
__version__ = "0.0.1"
__date__ = "2007-03-06"
__copyright__ = "Copyright (c) 2007 %s. All rights reserved." %
__author__
__licence__ = "LGPL"

import sqlite3
import dbus
import httplib
import os
from xml.dom.minidom import parseString

# Start with getting position from GeoClue
bus = dbus.SessionBus()
# TODO: Get the GeoClue interface to use from /schemas/apps/geoclue/
position/defaultpath
# and /schemas/apps/geoclue/position/defaultserviceGConf keys
proxy_obj bus.get_object('org.foinse_project.geoclue.position.hostip', '/org/
foinse_project/geoclue/position/hostip')
geoclue_iface = dbus.Interface(proxy_obj,
'org.foinse_project.geoclue.position')

# Get the coordinates from the service
coordinates = geoclue_iface.current_position()
# We can also use hardcoded
#coordinates[0] = 60.158806494564
#coordinates[1] = 24.9426341056824

print "According to GeoClue you are in %s %s." % (coordinates[0],
coordinates[1])

# Make the HTTP request to the Geonames service
print "Pulling local Wikipedia pages from Geonames"
http_connection = httplib.HTTPConnection("ws.geonames.org")
http_connection.request("GET", "/findNearbyWikipedia?lat=%s" %
coordinates[0] + "&lng=%s" % coordinates[1] + "&maxRows0")
http_response = http_connection.getresponse()
# TODO: Error handling
xml = http_response.read()

def parse_entries(xml):
dom = parseString(xml)
entries = dom.getElementsByTagName('entry')
results = []
for entry in entries:
entry_dictionary = {}
entry_dictionary['title'] = entry.getElementsByTagName('title')
[0].firstChild.data
entry_dictionary['summary'] entry.getElementsByTagName('summary')[0].firstChild.data + " (source:
Wikipedia)"

if (entry.getElementsByTagName('feature')[0].firstChild):
entry_dictionary['feature'] entry.getElementsByTagName('feature')[0].firstChild.data

entry_dictionary['lat'] float(entry.getElementsByTagName('lat')[0].firstChild.data)
entry_dictionary['lon'] float(entry.getElementsByTagName('lng')[0].firstChild.data)
results.append(entry_dictionary)
return results

entries = parse_entries(xml)

# Open SQLite connection
#sqlite_connection = sqlite3.connect(os.path.expanduser("~/
MyDocs/.documents/poi.db"))
sqlite_connection = sqlite3.connect(os.path.expanduser("/home/user/
MyDocs/.documents/poi.db"))
sqlite_cursor = sqlite_connection.cursor()
for entry in entries:
# Check if the entry is already in database
sql_variables = (entry["title"],)
sqlite_cursor.execute('select poi_id from poi where label=?',
sql_variables)
existing_entry_id = sqlite_cursor.fetchall()
if (existing_entry_id):
print "%s is already in database, skipping" % entry["title"]
# TODO: Update
else:
print "Inserting %s (%s, %s) into POI database" %
(entry["title"], entry["lat"], entry["lon"])
# TODO: Be smarter about POI categories
sql_variables = (entry["lat"], entry["lon"], entry["title"],
entry["summary"], 10)
sqlite_cursor.execute("insert into poi (lat, lon, label, desc,
cat_id) values (?, ?, ?, ?, ?)", sql_variables)

sqlite_connection.commit()
sqlite_cursor.close()
sqlite_connection.close()

Search Discussions

  • Http://members.lycos.co.uk/dariusjack/ at Sep 21, 2007 at 11:00 am

    On Sep 21, 2:33 am, "http://members.lycos.co.uk/dariusjack/" wrote:
    Hi,

    I am happy user of Nokia 770 tablett
    and one application for Nokia 770 is maemo mapper (beta navigation
    application).
    And the following script should run under mm (for Debian).
    Its developer told me it wans intended for other developers.
    I have no idea how to write Python script
    so please tell me how to learn how the following script works and how
    to modify it to be fully working,
    Frankly speaking I would prefer to pay for your kind assistance
    as it may take me to much time to learn some Python and understand the
    following script.

    I would like to modify it to add 2 more columns to SQL (sqlite3) POI
    database, to set proximity value and spead limit as in safety cam POI
    in standard car navigation systems.

    Please let me know your opinion.

    Darius

    #!/usr/bin/python2.5
    #
    # This library is free software; you can redistribute it and/or
    # modify it under the terms of the GNU Lesser General Public
    # License as published by the Free Software Foundation; either
    # version 2.1 of the License, or (at your option) any later version.
    #
    # This library is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    # Lesser General Public License for more details.
    #
    # You should have received a copy of the GNU Lesser General Public
    # License along with this library; if not, write to the Free Software
    # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301 USA

    __author__ = "Henri Bergius <henri.berg... at iki.fi>"
    __version__ = "0.0.1"
    __date__ = "2007-03-06"
    __copyright__ = "Copyright (c) 2007 %s. All rights reserved." %
    __author__
    __licence__ = "LGPL"

    import sqlite3
    import dbus
    import httplib
    import os
    from xml.dom.minidom import parseString

    # Start with getting position from GeoClue
    bus = dbus.SessionBus()
    # TODO: Get the GeoClue interface to use from /schemas/apps/geoclue/
    position/defaultpath
    # and /schemas/apps/geoclue/position/defaultserviceGConf keys
    proxy_obj > bus.get_object('org.foinse_project.geoclue.position.hostip', '/org/
    foinse_project/geoclue/position/hostip')
    geoclue_iface = dbus.Interface(proxy_obj,
    'org.foinse_project.geoclue.position')

    # Get the coordinates from the service
    coordinates = geoclue_iface.current_position()
    # We can also use hardcoded
    #coordinates[0] = 60.158806494564
    #coordinates[1] = 24.9426341056824

    print "According to GeoClue you are in %s %s." % (coordinates[0],
    coordinates[1])

    # Make the HTTP request to the Geonames service
    print "Pulling local Wikipedia pages from Geonames"
    http_connection = httplib.HTTPConnection("ws.geonames.org")
    http_connection.request("GET", "/findNearbyWikipedia?lat=%s" %
    coordinates[0] + "&lng=%s" % coordinates[1] + "&maxRows0")
    http_response = http_connection.getresponse()
    # TODO: Error handling
    xml = http_response.read()

    def parse_entries(xml):
    dom = parseString(xml)
    entries = dom.getElementsByTagName('entry')
    results = []
    for entry in entries:
    entry_dictionary = {}
    entry_dictionary['title'] = entry.getElementsByTagName('title')
    [0].firstChild.data
    entry_dictionary['summary'] > entry.getElementsByTagName('summary')[0].firstChild.data + " (source:
    Wikipedia)"

    if (entry.getElementsByTagName('feature')[0].firstChild):
    entry_dictionary['feature'] > entry.getElementsByTagName('feature')[0].firstChild.data

    entry_dictionary['lat'] > float(entry.getElementsByTagName('lat')[0].firstChild.data)
    entry_dictionary['lon'] > float(entry.getElementsByTagName('lng')[0].firstChild.data)
    results.append(entry_dictionary)
    return results

    entries = parse_entries(xml)

    # Open SQLite connection
    #sqlite_connection = sqlite3.connect(os.path.expanduser("~/
    MyDocs/.documents/poi.db"))
    sqlite_connection = sqlite3.connect(os.path.expanduser("/home/user/
    MyDocs/.documents/poi.db"))
    sqlite_cursor = sqlite_connection.cursor()
    for entry in entries:
    # Check if the entry is already in database
    sql_variables = (entry["title"],)
    sqlite_cursor.execute('select poi_id from poi where label=?',
    sql_variables)
    existing_entry_id = sqlite_cursor.fetchall()
    if (existing_entry_id):
    print "%s is already in database, skipping" % entry["title"]
    # TODO: Update
    else:
    print "Inserting %s (%s, %s) into POI database" %
    (entry["title"], entry["lat"], entry["lon"])
    # TODO: Be smarter about POI categories
    sql_variables = (entry["lat"], entry["lon"], entry["title"],
    entry["summary"], 10)
    sqlite_cursor.execute("insert into poi (lat, lon, label, desc,
    cat_id) values (?, ?, ?, ?, ?)", sql_variables)

    sqlite_connection.commit()
    sqlite_cursor.close()
    sqlite_connection.close()
    Please help and let me know your terms.

    Darius
  • Diez B. Roggisch at Sep 21, 2007 at 11:26 am
    <snip/>
    Please help and let me know your terms.
    There are websites dedicated to this - like e.g.

    http://www.guru.com/

    Make an offer there.

    Diez
  • Http://members.lycos.co.uk/dariusjack/ at Sep 22, 2007 at 12:09 am

    On Sep 21, 1:26 pm, "Diez B. Roggisch" wrote:
    <snip/>
    Please help and let me know your terms.
    There are websites dedicated to this - like e.g.

    http://www.guru.com/

    Make an offer there.

    Diez
    Ok Diez,

    Do you really think only Gurus from Guru.com can help me ?
    Do really need a middle-man ?
    As you see, I am not developer of that code.
    Henri responded to me, code was intended for developers.
    It doesn't really look complicated or high-tech.
    Script should connect to a remote web site and get xml formatted data
    as a response to a query string http request, read data and inject
    into SQL database.
    Is Python not fit to a task of this kind ?
    Is there no a library of Python free scripts to accomplish the above
    like many for javascripts ?
    I am asking just of curosity, as an author of this script didn't
    respond to my second request to tell me how complicated is the
    problem and what made him not to write that script as a fully working
    version.

    Is Python so difficult, complicated, even for experienced developers ?

    Thanks for any comments.

    Darius
  • Marc 'BlackJack' Rintsch at Sep 22, 2007 at 6:35 am

    On Fri, 21 Sep 2007 17:09:04 -0700, http://members.lycos.co.uk/dariusjack/ wrote:
    On Sep 21, 1:26 pm, "Diez B. Roggisch" wrote:
    <snip/>
    Is Python not fit to a task of this kind ?
    It is, and it should be quite simple.
    Is there no a library of Python free scripts to accomplish the above
    like many for javascripts ?
    I am asking just of curosity, as an author of this script didn't
    respond to my second request to tell me how complicated is the
    problem and what made him not to write that script as a fully working
    version.

    Is Python so difficult, complicated, even for experienced developers ?
    What makes you think it is?

    This group is about the Python programming language, discussing it and
    helping people to learn it. It seems that people here don't like fixing
    code for free for people who are not interested in the language
    themselves. There are platforms like guru.com or rentacoder.com for such
    assignments.

    Ciao,
    Marc 'BlackJack' Rintsch

    From http Sat Sep 22 08:38:38 2007
    From: http (Paul Rubin)
    Date: 21 Sep 2007 23:38:38 -0700
    Subject: Would Anonymous Functions Help in Learning Programming/Python?
    References: <1190410638.211343.241690@y42g2000hsy.googlegroups.com>
    <46f45f02$0$15350$4c368faf@roadrunner.com>
    Message-ID: <7xps0bgq6p.fsf@ruckus.brouhaha.com>

    Carl Banks <pavlovevidence at gmail.com> writes:
    Especially someone like an
    engineer (in the classical sense), who isn't building versatile software
    packages, won't need to resort to functional programming much.
    http://www.math.chalmers.se/~rjmh/Papers/whyfp.html
  • Diez B. Roggisch at Sep 22, 2007 at 10:34 am

    http://members.lycos.co.uk/dariusjack/ schrieb:
    On Sep 21, 1:26 pm, "Diez B. Roggisch" wrote:
    <snip/>
    Please help and let me know your terms.
    There are websites dedicated to this - like e.g.

    http://www.guru.com/

    Make an offer there.

    Diez
    Ok Diez,

    Do you really think only Gurus from Guru.com can help me ?
    Do really need a middle-man ?
    What middle-man?
    As you see, I am not developer of that code.
    Henri responded to me, code was intended for developers.
    It doesn't really look complicated or high-tech.
    Script should connect to a remote web site and get xml formatted data
    as a response to a query string http request, read data and inject
    into SQL database.
    Is Python not fit to a task of this kind ?
    Is there no a library of Python free scripts to accomplish the above
    like many for javascripts ?
    I am asking just of curosity, as an author of this script didn't
    respond to my second request to tell me how complicated is the
    problem and what made him not to write that script as a fully working
    version.

    Is Python so difficult, complicated, even for experienced developers ?
    No, it's neither complicated nor difficult. And you know what? Not only
    for expierenced, but also for inexperienced developers it's an easy
    language.

    And this community here is an extremely helpful and kind one.

    But what it isn't is a forum to ask other to do your work FOR FREE. And
    get kinky about it if they refuse to do so...

    And as you said yourself:

    """
    Frankly speaking I would prefer to pay for your kind assistance
    as it may take me to much time to learn some Python and understand the
    following script.
    """

    Now, again: http://www.guru.com/ There you can get devlopers for money.
    So what again is your problem?

    Diez
  • Andrey Khavryuchenko at Sep 22, 2007 at 2:25 pm
    DBR> And as you said yourself:

    DBR> """
    DBR> Frankly speaking I would prefer to pay for your kind assistance
    DBR> as it may take me to much time to learn some Python and understand the
    DBR> following script.
    DBR> """

    DBR> Now, again: http://www.guru.com/ There you can get devlopers for
    DBR> money. So what again is your problem?

    Actually, I am a python (and django) developer, looking for a contract,
    owning Nokia 770 and contacted original poster with no response.

    --
    Andrey V Khavryuchenko http://a.khavr.com/
    Chytach - unflood your feeds http://www.chytach.com/
    Software Development Company http://www.kds.com.ua/
  • Http://members.lycos.co.uk/dariusjack/ at Sep 22, 2007 at 5:53 pm

    On Sep 22, 4:25 pm, Andrey Khavryuchenko wrote:
    DBR> And as you said yourself:

    DBR> """
    DBR> Frankly speaking I would prefer to pay for your kind assistance
    DBR> as it may take me to much time to learn some Python and understand the
    DBR> following script.
    DBR> """

    DBR> Now, again:http://www.guru.com/There you can get devlopers for
    DBR> money. So what again is your problem?

    Actually, I am a python (and django) developer, looking for a contract,
    owning Nokia 770 and contacted original poster with no response.

    --
    Andrey V Khavryuchenko http://a.khavr.com/
    Chytach - unflood your feedshttp://www.chytach.com/
    Software Development Companyhttp://www.kds.com.ua/
    Thanks Andrey,

    if you mean having emailed me before.
    I really sorry having to tell that I haven't got any email from you.
    Don't use
    Reply to author
    feature by Google Groups
    as any such email is not sent from your mailbox and you don't have a
    copy of it.
    Just read my e-mail and email me directly from your mailbox not Google
    Groups.
    At some groups Google diabled this option to contact original poster
    personally
    and even poster's email adresss is not avaliable.

    Thanks for your interest.
    Darius
  • Diez B. Roggisch at Sep 22, 2007 at 5:56 pm

    Andrey Khavryuchenko schrieb:
    DBR> And as you said yourself:

    DBR> """
    DBR> Frankly speaking I would prefer to pay for your kind assistance
    DBR> as it may take me to much time to learn some Python and understand the
    DBR> following script.
    DBR> """

    DBR> Now, again: http://www.guru.com/ There you can get devlopers for
    DBR> money. So what again is your problem?

    Actually, I am a python (and django) developer, looking for a contract,
    owning Nokia 770 and contacted original poster with no response.
    Well, I presume the above quoted wasn't exactly true - in the end, the
    whole attitude of the OP smelled after "I want you to do work for me for
    free that I'm unwilling to bother myself with - as it would mean putting
    effort into it."

    Diez
  • Tobiah at Sep 25, 2007 at 7:40 pm

    Diez B. Roggisch wrote:
    Andrey Khavryuchenko schrieb:
    DBR> And as you said yourself:

    DBR> """
    DBR> Frankly speaking I would prefer to pay for your kind assistance
    DBR> as it may take me to much time to learn some Python and
    understand the
    DBR> following script.
    DBR> """

    DBR> Now, again: http://www.guru.com/ There you can get devlopers for
    DBR> money. So what again is your problem?

    Actually, I am a python (and django) developer, looking for a contract,
    owning Nokia 770 and contacted original poster with no response.
    Well, I presume the above quoted wasn't exactly true - in the end, the
    whole attitude of the OP smelled after "I want you to do work for me for
    free that I'm unwilling to bother myself with - as it would mean putting
    effort into it."

    Diez
    Jeepers - It says right there in the quote that he is willing to pay.
    I don't see why the OP is getting so much flack for his question, even
    if it is thought to be a little off topic.


    --
    Posted via a free Usenet account from http://www.teranews.com

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedSep 21, '07 at 12:33a
activeSep 25, '07 at 7:40p
posts10
users5
websitepython.org

People

Translate

site design / logo © 2022 Grokbase