[Sugar-devel] ObjectChooser() Issue?
Art Hunkins
abhunkin at uncg.edu
Sun Nov 14 17:20:49 EST 2010
Aleksey / Sasha / James,
Despite all your valued feedback, I remain stymied.
My current jobject code:
#Declarations
self.file = [0, 0, 0, 0]
self.fileflag = ["0", "0", "0", "0"]
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()
if jobject and jobject.file_path:
self.file[0] = jobject.get_file_path()
open(self.file[0], "r")
self.fileflag[0] = "1"
else:
self.fileflag[0] = "0"
close(self.file[0])
# Later, variables sent to my Csound code via:
self.w.set_channel("fileflag1", self.fileflag[0])
self.w.set_filechannel("file1", str(self.file[0]))
Comments:
The jobject is being selected just fine; the problem is, it is still being
deleted, even though I'm trying to store its path. So Csound never finds the
passed filename (self.file[0]). (The str() conversion is apparently required
by Csound, as the path is otherwise some sort of DS string, which it does
not recognize.)
Please note that there are up to *4* of these choosers (the reason why
self.file is a list); obviously the various jobjects may well
replace/interfere with each other.
So, what needs to be saved ( - from deletion), and what form of data
(filename) needs to be sent to Csound to correctly locate the still-existent
"jobjects"?
The above code sends a reasonable filename, I get "DSobject was deleted", or
some such error message.
Hopefully, with your help, I can get this thorny issue behind me soon.
Art Hunkins
----- Original Message -----
From: "Aleksey Lim" <alsroot at member.fsf.org>
To: "Gonzalo Odiard" <gonzalo at laptop.org>
Cc: "Art Hunkins" <abhunkin at uncg.edu>; <sugar-devel at lists.sugarlabs.org>
Sent: Tuesday, November 09, 2010 1:55 PM
Subject: Re: [Sugar-devel] ObjectChooser() Issue?
> 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