maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   [Python][Fremantle] How To Correctly Open The Browser (https://talk.maemo.org/showthread.php?t=33177)

BrentDC 2009-10-20 16:19

[Python][Fremantle] How To Correctly Open The Browser
 
I've asked this question a while back and received an answer of:

Code:

dbus-send --system --type=method_call --dest="com.nokia.osso_browser" --print-reply /com/nokia/osso_browser/request com.nokia.osso_browser.load_url string:"google.com"
But I've run into a problem with this; when I do that in on the SDK I get:

Code:

Error org.freedesktop.DBus.Error.ServiceUnknown: The name com.nokia.osso_browser was not provided by any .service files
But if I open the browser manually, then try that, it works as expected. Is this a problem were some sort of DBUS service is not correctly started on the SDK or is this also present on a real device? Additionally, if this is not the correct way to call the browser, I'm open to alternate solutions!

This is the last thing stopping me from promoting my app to extras-testing....Thanks!

qwerty12 2009-10-20 16:25

Re: [Python][Fremantle] How To Correctly Open The Browser
 
FWIW, that works on my N900. In the SDK, dbus-send commands must also be prefixed with run-standalone.sh.

And, unless you're using libosso to do the calling, you must prefix all URLs with http:// or the browser will refuse to open the URL given if there is already a browser window open.

BrentDC 2009-10-20 16:31

Re: [Python][Fremantle] How To Correctly Open The Browser
 
Then this is probably an SDK-only issue?:

Quote:

[sbox-FREMANTLE_X86: ~] > run-standalone.sh dbus-send --system --type=method_call --dest="com.nokia.osso_browser" --print-reply /com/nokia/osso_browser/request com.nokia.osso_browser.load_url string:"http://www.google.com"
Error org.freedesktop.DBus.Error.ServiceUnknown: The name com.nokia.osso_browser was not provided by any .service files

qwerty12 2009-10-20 16:34

Re: [Python][Fremantle] How To Correctly Open The Browser
 
Quote:

Originally Posted by BrentDC (Post 352797)
Then this is probably an SDK-only issue?:

Must be. DBus isn't my strong point... Someone was saying they had the same error with com.nokia.hildon-desktop, which is also on the system bus... :)

BrentDC 2009-10-20 17:33

Re: [Python][Fremantle] How To Correctly Open The Browser
 
Quote:

Originally Posted by qwerty12 (Post 352802)
Must be. DBus isn't my strong point... Someone was saying they had the same error with com.nokia.hildon-desktop, which is also on the system bus... :)

In that case, could you do me a huge favor?

On your N900:

1) Enable extras-devel*
2) Install TouchSearch (should be v1.1-4)**
3) Try searching something

If that works fine, reboot and repeat those three steps above before doing anything else.

Thanks!

* For others reading this thread, please don't do this. I do not want a bricked N900 on my conscious. Thank you :)
** This is a Python app, so it'll pull in a few megs in python libraries.

qwerty12 2009-10-20 18:47

Re: [Python][Fremantle] How To Correctly Open The Browser
 
I installed 1.1-4 and see nothing available in my "Select widget[s]" list.

OK, rebooted and now it shows up. Still doesn't work.

But, while I'm here:
- HildonEntry over GtkEntry is preferred;
- The GtkImage in the dialog would be nicer if it was a button with the image so that one can change search engine from there, if needed, without having to go back; and
- I'll look into it myself (the launching of the browser, that is)

qwerty12 2009-10-20 20:30

Re: [Python][Fremantle] How To Correctly Open The Browser
 
OK, sorry, it does turn out that it is working, but dbus-send is a really slow way of doing it. So I'll still work on a diff, anyway. :p

BrentDC 2009-10-20 20:44

Re: [Python][Fremantle] How To Correctly Open The Browser
 
Quote:

Originally Posted by qwerty12 (Post 353127)
OK, sorry, it does turn out that it is working...

It's been my experience that dbus-send only works after you open the browser for the first time since a reboot (even if you close it right down).

Quote:

...but dbus-send is a really slow way of doing it. So I'll still work on a diff, anyway. :p
Thanks, man! :cool:

qwerty12 2009-10-21 15:42

Re: [Python][Fremantle] How To Correctly Open The Browser
 
Quote:

Originally Posted by BrentDC (Post 353147)
Thanks, man! :cool:

http://slexy.org/view/s20AYhGdzv

Hand on heart: It's way faster to open sites, and I do not need to open the browser first.

I hope that you can implement the other changes I suggested, and, perhaps, to make it like the original applet for Diablo, a history feature?

BrentDC 2009-10-21 15:51

Re: [Python][Fremantle] How To Correctly Open The Browser
 
Wow, thanks qwerty! That looks great! I tried using the osso stuff but couldn't figure out the API. This is waaaay cleaner than the kludge I was using. Thanks!

Concerning the other suggestions -- yes, I will definitely look into them. I think a history is also very doable. :)

fpp 2009-10-21 19:21

Re: [Python][Fremantle] How To Correctly Open The Browser
 
Maybe I misunderstand the original question, but why not use the "standard" Python way of doing this ? Is the webbrowser module not available in pymaemo ?...

http://docs.python.org/library/webbr...ule-webbrowser

Jaffa 2009-10-22 12:54

Re: [Python][Fremantle] How To Correctly Open The Browser
 
The webbrowser module is available. However, you need to hack around a broken gconf key. There's an internal bug for it and you can see it being overridden in Hermes' postinst.

fredrik_wendt 2010-04-25 15:30

Re: [Python][Fremantle] How To Correctly Open The Browser
 
Quote:

Originally Posted by Jaffa (Post 355300)
The webbrowser module is available. However, you need to hack around a broken gconf key. There's an internal bug for it and you can see it being overridden in Hermes' postinst.

Jaffa, doesn't the Hermes code just exit if it's incorrect?
Code:

if (gc.get_string('/desktop/gnome/url-handlers/http/command') == 'epiphany %s'):
        raise Exception('Browser in gconf invalid (see NB#136012). Installation error.')


Jaffa 2010-04-25 17:58

Re: [Python][Fremantle] How To Correctly Open The Browser
 
Quote:

Originally Posted by fredrik_wendt (Post 627068)
Jaffa, doesn't the Hermes code just exit if it's incorrect?
Code:

if (gc.get_string('/desktop/gnome/url-handlers/http/command') == 'epiphany %s'):
        raise Exception('Browser in gconf invalid (see NB#136012). Installation error.')


There's also this in hermes.postinst:

Code:

# Hacky fix for NB#136012
gconftool-2 -s /desktop/gnome/url-handlers/http/command 'dbus-send --system --type=method_call --dest="com.nokia.osso_browser" --print-reply /com/nokia/osso_browser/request com.nokia.osso_browser.load_url string:"%s"' --type string


lostinmirkwood 2010-06-10 04:56

Re: [Python][Fremantle] How To Correctly Open The Browser
 
I found Two alternatives:
Code:

import os
url='http://www.maemo.org'
os.system('browser --url=%s' %url)

Code:

import webbrowser
webbrowser.open_new('http://www.maemo.org')

Although both work the first solution tends to lock your code as described in browser-proxy.py (and above in this post), and the browser command isn't available on all os (obviously)

The second solution works in ubuntu as well as maemo5 without issue or the need for dbus or osso in your depends

http://docs.python.org/library/webbrowser.html
Quote:

The webbrowser module provides a high-level interface to allow displaying Web-based documents to users. Under most circumstances, simply calling the open() function from this module will do the right thing.

I love the will do the right thing. quote, it seems to just do that.


All times are GMT. The time now is 12:54.

vBulletin® Version 3.8.8