Esempio n. 1
0
    def call(self, call_filename=None,
            update_details=None, label=None, category=None, example=None,
            update_sonogram=None, frequency_scale=FREQUENCY_SCALES[0],
            fft_step=DEFAULT_FFT_STEP,
            **ignored):
        if not call_filename:
            raise cherrypy.NotFound()

        fft_step = int(fft_step)

        if call_filename and update_details:
            self._storage.updateCall(call_filename, label, category, example)
            if ajax.isXmlHttpRequest():
                return # ajax update doesn't require a response

        call=self._storage.getCall(call_filename)
        if ajax.isXmlHttpRequest():
            # only sonogram updates are possible here
            assert(update_sonogram)
            return template.render('_sonogram.html', ajah=True,
                    sonogram_filename=self.getSonogram(call, frequency_scale,
                            fft_step), fft_step=fft_step,
                    frequency_scale=frequency_scale,
                    frequency_scales=FREQUENCY_SCALES)
        else:
            return template.render(station=self.getStationName(), call=call,
                    categories=",".join(self._storage.getCategoryNames()),
                    sonogram_filename=self.getSonogram(call, frequency_scale,
                            fft_step), fft_step=fft_step,
                    frequency_scale=frequency_scale,
                    frequency_scales=FREQUENCY_SCALES,
                    prev_next_files=self._storage.getPrevAndNextCalls(call))
Esempio n. 2
0
    def call(self,
             call_filename=None,
             update_details=None,
             label=None,
             category=None,
             example=None,
             update_sonogram=None,
             frequency_scale=FREQUENCY_SCALES[0],
             fft_step=DEFAULT_FFT_STEP,
             **ignored):
        if not call_filename:
            raise cherrypy.NotFound()

        fft_step = int(fft_step)

        if call_filename and update_details:
            self._storage.updateCall(call_filename, label, category, example)
            if ajax.isXmlHttpRequest():
                return  # ajax update doesn't require a response

        call = self._storage.getCall(call_filename)
        if ajax.isXmlHttpRequest():
            # only sonogram updates are possible here
            assert (update_sonogram)
            return template.render('_sonogram.html',
                                   ajah=True,
                                   sonogram_filename=self.getSonogram(
                                       call, frequency_scale, fft_step),
                                   fft_step=fft_step,
                                   frequency_scale=frequency_scale,
                                   frequency_scales=FREQUENCY_SCALES)
        else:
            return template.render(
                station=self.getStationName(),
                call=call,
                categories=",".join(self._storage.getCategoryNames()),
                sonogram_filename=self.getSonogram(call, frequency_scale,
                                                   fft_step),
                fft_step=fft_step,
                frequency_scale=frequency_scale,
                frequency_scales=FREQUENCY_SCALES,
                prev_next_files=self._storage.getPrevAndNextCalls(call))
Esempio n. 3
0
 def wrapper(*args, **kwargs):
     cherrypy.thread_data.template = loader.load(filename)
     opt = options.copy()
     if not ajax.isXmlHttpRequest() and method == 'html':
         opt.setdefault('doctype', 'html')
     serializer = get_serializer(method, **opt)
     stream = func(*args, **kwargs)
     if not isinstance(stream, Stream):
         return stream
     return encode(serializer(stream), method=serializer,
                   encoding=encoding)
Esempio n. 4
0
 def wrapper(*args, **kwargs):
     cherrypy.thread_data.template = loader.load(filename)
     opt = options.copy()
     if not ajax.isXmlHttpRequest() and method == 'html':
         opt.setdefault('doctype', 'html')
     serializer = get_serializer(method, **opt)
     stream = func(*args, **kwargs)
     if not isinstance(stream, Stream):
         return stream
     return encode(serializer(stream),
                   method=serializer,
                   encoding=encoding)