[Sugar-devel] datastore.write problem

Walter Bender walter.bender at gmail.com
Wed Apr 25 13:30:44 EDT 2012


On Wed, Apr 25, 2012 at 1:24 PM, Manuel Kaufmann <humitos at gmail.com> wrote:
> On Wed, Apr 25, 2012 at 14:18, Walter Bender <walter.bender at gmail.com> wrote:
>> But it seems
>> that sometimes the data in the audio file at the time of the call to
>> write is not the same as the data that ends up in the datastore. Is
>> there some way to make sure that the write has completed?
>
> Can you share the relevant part of code with us?


def _save_recording_cb(self, button=None):
        if os.path.exists(os.path.join(self.datapath, 'output.ogg')):
            _logger.debug('Saving recording to Journal...')
            obj_id = self.dsobjects[self.i].object_id
            dsobject = self._search_for_audio_note(obj_id)
            if dsobject is None:
                dsobject = datastore.create()
            if dsobject is not None:
                _logger.debug(self.dsobjects[self.i].metadata['title'])
                dsobject.metadata['title'] = _('audio note for %s') % \
                    (self.dsobjects[self.i].metadata['title'])
                dsobject.metadata['icon-color'] = \
                    profile.get_color().to_string()
                dsobject.metadata['tags'] = obj_id
                dsobject.metadata['mime_type'] = 'audio/ogg'
                dsobject.set_file_path(
                    os.path.join(self.datapath, 'output.ogg'))
                datastore.write(dsobject)
                dsobject.destroy()
        else:
            _logger.debug('Nothing to save...')
        return

>
> --
> Kaufmann Manuel
> Blog: http://humitos.wordpress.com/
> Porfolio: http://fotos.mkaufmann.com.ar/
> PyAr: http://www.python.com.ar/



-- 
Walter Bender
Sugar Labs
http://www.sugarlabs.org


More information about the Sugar-devel mailing list