<br><font size=3>Thank you all for your answers.</font>
<p><font size=3>What i am actually facing is a problem with a sugarizing.
I need to run the script, copy-to-Journal.py from a C program.</font>
<p><font size=3>1 - With "exec dbus-launch CActivity $args" in
the sugarActivity file, i can run multiple instances but i cant run the
script. It crashes throwing a python error. In olpc wiki says that the
scripts only works running with olpc user. I dont know if the dbus-launch
changes something in the way the scripts are called.</font>
<br>
<br><font size=2 face="Courier New">Error: org.freedesktop.DBus.Python.AttributeError:
Traceback (most recent call last):</font>
<br><font size=2 face="Courier New"> File "/usr/lib/python2.5/site-packages/dbus/service.py",
line 692, in _message_cb</font>
<br><font size=2 face="Courier New"> retval = candidate_method(self,
*args, **keywords)</font>
<br><font size=2 face="Courier New"> File "/usr/lib/python2.5/site-packages/olpc/datastore/datastore.py",
line 215, in create</font>
<br><font size=2 face="Courier New"> mp.create_async(props,
filelike, can_move=transfer_ownership,</font>
<br><font size=2 face="Courier New">AttributeError: 'NoneType' object has
no attribute 'create_async'</font>
<p><font size=3>2 - But changing it to "exec CActivity $args"
the scripts run perfect, but the second instance of the activity throws
an "error when trying to load or save configuration... "<br>
</font><font size=2 face="Courier New"> </font><font size=3>Configuration
server couldn't be contacted: D-BUS error: Method "LookupExtended"
<br>
with signature "ssb" on interface
"org.gnome.GConf.Database" doesn't exist </font>
<p><font size=3>***********<br>
SugarActivity file: sugarPlanilla<br>
***********<br>
</font><font size=2 face="Courier New">#!/bin/sh</font>
<br><font size=2 face="Courier New">args=""</font>
<br><font size=2 face="Courier New">while [ -n "$2" ] ; do</font>
<br><font size=2 face="Courier New"> case "$1"
in</font>
<br><font size=2 face="Courier New"> -b
| --bundle-id) export SUGAR_BUNDLE_ID="$2" ;;</font>
<br><font size=2 face="Courier New"> -a
| --activity-id) export SUGAR_ACTIVITY_ID="$2" ;;</font>
<br><font size=2 face="Courier New"> -o
| --object-id) export SUGAR_OBJECT_ID="$2" ; echo
"o $2"; args="$args -o $2" ;;</font>
<br><font size=2 face="Courier New"> -u
| --uri) export SUGAR_URI="$2"
;;</font>
<br><font size=2 face="Courier New"> *)
echo unknown argument $1 $2 ;;</font>
<br><font size=2 face="Courier New"> esac</font>
<br><font size=2 face="Courier New"> shift;shift</font>
<br><font size=2 face="Courier New">done</font>
<br><font size=2 face="Courier New">echo $args</font>
<br><font size=2 face="Courier New">export LD_PRELOAD="$SUGAR_BUNDLE_PATH/lib/libsugarize.so"</font>
<br><font size=2 face="Courier New">export NET_WM_NAME="Planilla"</font>
<br><font size=2 face="Courier New"><b>exec gnumeric $args</b></font>
<br>
<br><font size=3>and the Activity.info runs the sugarActivity file.</font>
<br><font size=2 face="Courier New">exec = sugarPlanilla</font>
<p><font size=3>Thanks,<br>
Pablo Posada<br>
____________________________________________ </font>
<p>
<table width=100%>
<tr valign=top>
<td width=23% rowspan=5 bgcolor=#e1e1e1>
<div align=center>
<br><font size=1><b>Bert Freudenberg <bert@freudenbergs.de></b></font><font size=3>
</font>
<p><font size=1>12/10/2008 11:17 AM CET</font></div>
<td width=10% bgcolor=#e1e1e1>
<div align=right>
<br><font size=1>To</font><font size=3> </font></div>
<td width=66% bgcolor=#e1e1e1><font size=1><br>
david@lang.hm</font>
<tr valign=top>
<td bgcolor=#e1e1e1>
<div align=right>
<br><font size=1>cc</font><font size=3> </font></div>
<td bgcolor=#e1e1e1><font size=1><br>
Pablo Posada <pablo.posada@tcs.com>, OLPC Development <devel@lists.laptop.org>,
Sugar Devel <sugar-devel@lists.sugarlabs.org></font>
<tr valign=top>
<td bgcolor=#e1e1e1>
<div align=right>
<br><font size=1>bcc</font><font size=3> </font></div>
<td bgcolor=#e1e1e1>
<tr valign=top>
<td bgcolor=#e1e1e1>
<div align=right>
<br><font size=1>Subject</font><font size=3> </font></div>
<td bgcolor=#e1e1e1><font size=1><br>
Re: [Sugar-devel] One instance activity</font>
<tr valign=top>
<td bgcolor=#e1e1e1>
<td bgcolor=#e1e1e1></table>
<br>
<br><tt><font size=3><br>
On 10.12.2008, at 11:56, david@lang.hm wrote:</font></tt><font size=3><br>
</font><tt><font size=3><br>
> On Wed, 10 Dec 2008, Bert Freudenberg wrote:<br>
><br>
>> On 10.12.2008, at 03:57, david@lang.hm wrote:<br>
>><br>
>>> On Tue, 9 Dec 2008, Bert Freudenberg wrote:<br>
>>>> On 09.12.2008, at 18:55, Eben Eliason wrote:<br>
>>>>> Are you sure? Browse makes use of shared code,
but still<br>
>>>>> presents the<br>
>>>>> user with the appearance of multiple instances.<br>
>>>> Right.<br>
>>>> The way to do it would be to create a unique D-Bus service
in your<br>
>>>> activity. When the second instance tries to create that
service it<br>
>>>> will notice that it already exists. It could then notify
its first<br>
>>>> instance via said D-Bus service.<br>
>>> you don't need to use D-Bus for this, it can be done by X
without<br>
>>> any other communication channels.<br>
>>> I don't know the details for how to do this, but I've seen
mozilla/<br>
>>> firefox do this for a few years. to see this start firefox
on one<br>
>>> machine, connect to another machine and point the display
back to<br>
>>> the first one. then try and start firefox on that second machine.<br>
>>> the end result will be a new window opening up, but running
on the<br>
>>> first machine (if you have trouble seeing the difference,
make the<br>
>>> two machines have different bookmarks, or give one network
access<br>
>>> that the other doesn't have)<br>
>>> please don't develop new mechanisms to do things that already
exist.<br>
>><br>
>><br>
>> It's not a new mechanism. The usage of a named D-Bus service to<br>
>> ensure unique program instances is documented and not my invention<br>
>> (though I cannot remember where I saw it first).<br>
>><br>
>> I should have written "One way to do this would be ...",
I give you<br>
>> that.<br>
>><br>
>> But you cannot know which way would be preferable for a given<br>
>> activity. And since it is private to the activity and does not<br>
>> affect other activities, no harm is done either way.<br>
>><br>
>> E.g., twiddling X properties is hard in various high-level<br>
>> languages, in particular when using higher-level UI toolkits.
Sugar<br>
>> currently requires two custom X properties and this is causing<br>
>> activity authors considerable pain. Even Sugar itself had to resort<br>
>> to C code, adding a custom native library to manipulate these<br>
>> properties, it was not easy in pure Python. This is in stark<br>
>> contrast to the nicely general and easy-to-use Python D-Bus<br>
>> bindings, which are similarly available in other high-level<br>
>> languages.<br>
>><br>
>> So please consider that not all people like having to go down
into<br>
>> the machine room to make new plumbing with a C compiler. Having<br>
>> done too much of that myself I can relate to them.<br>
><br>
> my initial reaction to this is that this sounds like a gap in the<br>
> python libraries that would be very useful to fill. getting someone<br>
> to write a python library to better access the X properties would<br>
> help many areas.<br>
><br>
> any idea why nobody has written one yet? Python is much better than<br>
> many languages at letting you write a library in C and then use it<br>
> cleanly, so if doing this in python is as hard as you are<br>
> indicating, why hasn't it been addressed?</font></tt><font size=3><br>
<br>
</font><tt><font size=3><br>
I don't know. And this is diverging from the subject at hand.</font></tt><font size=3><br>
</font><tt><font size=3><br>
Even if it was simple to set and read an X property then implementing<br>
single-instance apps via X properties still would be considerable more<br>
complex than using D-Bus. You would have to learn a whole lot about<br>
how X works first, and then design that mechanism on top of it. Having<br>
done a fair bit of X programming myself (the Squeak VM talks to Xlib<br>
directly, no toolkit) I would not exactly rate this as trivial. X can<br>
be abused to do IPC, sure, but it still is abuse. D-Bus is made to do<br>
that.</font></tt><font size=3><br>
</font><tt><font size=3><br>
- Bert -</font></tt><font size=3><br>
<br>
</font><font size=1 color=white><br>
ForwardSourceID:NT00005F1E </font><pre>=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
</pre>