Esempio n. 1
0
    def output(self):
        log(self.type)
        if hasattr(self.content, 'read'):
            self.type = "file"
        if self.type == "plaintext":
            return [
                self.content,
            ]
        if self.type == "file":
            return self.content
        if self.type == "stream":

            def f(stream):
                for d in stream:
                    yield 'data: ' + pico.to_json(d) + '\n\n'

            return f(self.content)
        if self.type == "chunks":

            def f(response):
                yield (' ' * 1200) + '\n'
                yield '[\n'
                delimeter = ''
                for r in response:
                    yield delimeter + pico.to_json(r, self.json_dumpers) + '\n'
                    delimeter = ','
                yield "]\n"

            return f(self.content)
        else:
            s = pico.to_json(self.content, self.json_dumpers)
            if self.callback:
                s = self.callback + '(' + s + ')'
            return s
Esempio n. 2
0
 def output(self):
     if self._output:
         return self._output
     log(self.type)
     if hasattr(self.content, 'read'):
         self.type = "file"
     if self.type == "plaintext":
         return [self.content,]
     if self.type == "file":
         return self.content
     if self.type == "stream":
         def f(stream):
             for d in stream:
                 yield 'data: ' + pico.to_json(d) + '\n\n'
             yield 'data: "PICO_CLOSE_STREAM"\n\n'
         return f(self.content)
     if self.type == "chunks":
         log("chunks")
         def f(response):
             yield (' ' * 1200) + '\n'
             yield '[\n'
             delimeter = ''
             for r in response:
                 yield delimeter + pico.to_json(r, self.json_dumpers) + '\n'
                 delimeter = ','
             yield "]\n"
         return f(self.content)
     else:
         s = pico.to_json(self.content, self.json_dumpers)
         if self.callback:
             s = self.callback + '(' + s + ')'
         s = [s,]
         self._output = s
         return s
Esempio n. 3
0
 def f(response):
     yield (' ' * 1200) + '\n'
     yield '[\n'
     delimeter = ''
     for r in response:
         yield delimeter + pico.to_json(r, self.json_dumpers) + '\n'
         delimeter = ','
     yield "]\n"
Esempio n. 4
0
 def f(response):
     yield (' ' * 1200) + '\n'
     yield '[\n'
     delimeter = ''
     for r in response:
         yield delimeter + pico.to_json(r, self.json_dumpers) + '\n'
         delimeter = ','
     yield "]\n"
Esempio n. 5
0
 def json(self):
     properties = {}
     properties.update(self.ref.get('properties', None) or {})
     response = {}
     response['bbox'] = self.bbox #[l, b, r, t]
     response['shape'] = self.shape
     response['data'] = np.around(self.view(np.ndarray), decimals=2)
     response['properties'] = properties
     return pico.to_json(response)
Esempio n. 6
0
 def output(self):
     print(self.type)
     if hasattr(self.content, 'read'):
         self.type = "file"
     if self.type == "plaintext":
         return [self.content,]
     if self.type == "file":
         return self.content
     if self.type == "stream":
         def f(stream):
             for d in stream:
                 yield 'data: ' + pico.to_json(d) + '\n\n'
         return f(self.content)
     else:
         s = pico.to_json(self.content, self.json_dumpers)
         if self.callback:
             s = self.callback + '(' + s + ')'
         return s
Esempio n. 7
0
    def output(self):
        log(self.type)
        if hasattr(self.content, 'read'):
            self.type = "file"
        if self.type == "plaintext":
            return [
                self.content,
            ]
        if self.type == "file":
            return self.content
        if self.type == "stream":

            def f(stream):
                for d in stream:
                    yield 'data: ' + pico.to_json(d) + '\n\n'

            return f(self.content)
        else:
            s = pico.to_json(self.content, self.json_dumpers)
            if self.callback:
                s = self.callback + '(' + s + ')'
            return s
Esempio n. 8
0
 def f(stream):
     for d in stream:
         yield 'data: ' + pico.to_json(d) + '\n\n'
Esempio n. 9
0
 def f(stream):
     for d in stream:
         yield 'data: ' + pico.to_json(d) + '\n\n'
Esempio n. 10
0
def _call_function(module, function, args, stream=False):
    for k in args:
        args[k] = pico.to_json(args[k])
    # args['_function'] = function
    # args['_module'] = module
    return get(url + '%s/%s/' % (module, function), args, stream)
Esempio n. 11
0
def _call_function(module, function, args, stream=False): 
    for k in args:
        args[k] = pico.to_json(args[k])
    # args['_function'] = function
    # args['_module'] = module
    return get(url + '%s/%s/'%(module, function), args, stream)
Esempio n. 12
0
 def f(stream):
     for d in stream:
         yield 'data: ' + pico.to_json(d) + '\n\n'
     yield 'data: "PICO_CLOSE_STREAM"\n\n'