[Sugar-devel] ObjectChooser() Issue?
Aleksey Lim
alsroot at member.fsf.org
Tue Nov 9 13:55:56 EST 2010
On Tue, Nov 09, 2010 at 03:10:56PM -0300, Gonzalo Odiard wrote:
> On Tue, Nov 9, 2010 at 3:04 PM, Aleksey Lim <alsroot at member.fsf.org> wrote:
>
> > On Mon, Nov 08, 2010 at 01:01:02PM -0500, Art Hunkins wrote:
> > > At Sasha's suggestion, I've arrived at the following code to send the
> > > filepath of a soundfile to Csound via its reference in the Journal. The
> > > filename (self.filename[0]) is being correctly passed:
> > >
> > > def choose1(self, widget):
> > > chooser = ObjectChooser(parent=self,
> > what_filter=mime.GENERIC_TYPE_AUDIO)
> > > result = chooser.run()
> > > if result == gtk.RESPONSE_ACCEPT:
> > > jobject = chooser.get_selected_object()
> >
> > After destroying "jobject" object, you will lose
> > /home/olpc/.sugar/default/data/f70f03b1-fe40-44e6-9d75-5ef274cf0ad2.wav
> > file, so either keep this object or move/hard-link file somethere
> > for later usage (but remove it after using).
> >
> >
> Why is destroyed jobject ?
> Only curiosity, I have read the mail and don't understand what is the
> problem with the code.
The thing is that after creating sugar.datastore.datastore.DSObject
(here "jobject" variable) and calling "file_path", temporary file will be
created (in fact, hard link to the file stored in ds), after deleting
"jobject" this file will be removed.
Code tries to use "file_path" after deleting "jobject", thus file is
already deleted.
>
> Gonzalo
>
>
>
> > > if jobject and jobject.file_path:
> > > self.filename[0] = str(jobject.file_path)
> > > # open(jobject.file_path).read()
> > > # open(self.filename[0]).read()
> > > else:
> > > self.filename[0] = "0"
> > >
> > > The problem is that the file cannot be opened by Csound - either via the
> > > above function as it stands, or by the addition of either line that is
> > > commented out.
> > >
> > > I receive this error message (from Csound):
> > > diskinfo can't open
> > > /home/olpc/.sugar/default/data/f70f03b1-fe40-44e6-9d75-5ef274cf0ad2.wav
> > > The filepath and name are correct, and the file can be played fine with
> > > either Browse or Jukebox.
> > >
> > > What must I do to make the referenced soundfile readable?
> > >
> > > Art Hunkins
> > >
> > > _______________________________________________
> > > Sugar-devel mailing list
> > > Sugar-devel at lists.sugarlabs.org
> > > http://lists.sugarlabs.org/listinfo/sugar-devel
> > >
> >
> > --
> > Aleksey
> > _______________________________________________
> > Sugar-devel mailing list
> > Sugar-devel at lists.sugarlabs.org
> > http://lists.sugarlabs.org/listinfo/sugar-devel
> >
--
Aleksey
More information about the Sugar-devel
mailing list