[Sugar-devel] ObjectChooser() Issue?
nicestep at gmail.com
Tue Nov 9 13:37:01 EST 2010
I sent this answer to Art yesterday, but I didn't send it to the
group. I think this may be the answer to his problem.
On Mon, Nov 8, 2010 at 4:56 PM, James Simmons <nicestep at gmail.com> wrote:
> One thing I noted when I tried to read paths from Journal entries is
> that they don't stay valid forever. I think they are symbolic links
> to the actual file. If you read through a list of Journal objects
> only the current one will have a valid path, and the others get
> disconnected. Hard coding a value that worked before isn't going to
> I would guess that the object chooser will give you a valid jobject.
> Maybe try this:
> instead of jobject.file_path. It may be that using get_file_path()
> makes the datastore create the symbolic link, whereas just using
> .file_path just give the current value in the field, which might be
> stale. I use .get_file_path() in Sugar Commander and it seems to work
> James Simmons
> On Mon, Nov 8, 2010 at 4:36 PM, Art Hunkins <abhunkin at uncg.edu> wrote:
>> I tried the following variations of my "open" line:
>> open(jobject.file_path, "r").read()
>> open(jobject.file_path, "r")
>> self.read_file = open(jobject.file_path, "r")
>> self.read_file = open(jobject.file_path, "r").read()
>> open(self.filename, "r").read()
>> open(self.filename, "r")
>> self.read_file = open(self.filename, "r")
>> self.read_file = open(self.filename, "r").read()
>> Same result: Csound can't open the file.
>> Strangely, as well, I hardcoded the filepath of the file I was selecting
>> from the Journal into Csound - to see if one of the above would at least
>> enable the (same) file to be read. No luck; still can't open the file.
>> Passing the name works fine; Csound just can't open the file. And the only
>> files I seem to be able to *open* are the ones I place in the activity's
>> folder and hardcode in Csound.
>> Thanks so much for your help. Do you have any idea whether using *your*
>> Journal (and USB) methods (from your Using the Journal chapter) I'd have any
>> better luck opening soundfiles to play in Csound?
>> Art Hunkins
>> ----- Original Message ----- From: "James Simmons" <nicestep at gmail.com>
>> To: "Art Hunkins" <abhunkin at uncg.edu>
>> Sent: Monday, November 08, 2010 1:45 PM
>> Subject: Re: [Sugar-devel] ObjectChooser() Issue?
>> You probably want to put the "r" argument in your open statement like this:
>> self.read_file = open(fileName,"r")
>> What may be happening is that you are by default opening the file
>> read/write, which Sugar will not allow.
>> James Simmons
>> On Mon, Nov 8, 2010 at 12:01 PM, Art Hunkins <abhunkin at uncg.edu> 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) 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()
>>> if jobject and jobject.file_path:
>>> self.filename = str(jobject.file_path)
>>> # open(jobject.file_path).read()
>>> # open(self.filename).read()
>>> self.filename = "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
>>> 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
More information about the Sugar-devel