Beispiel #1
0
 def respond(self, code, headers=None, body=None, *pos_args):
     StdoutRequestHandler.respond(self, code, headers, body, *pos_args)
     if self.__output_path and body is not None:
         # pylint: disable=invalid-name
         with open(self.__output_path, 'w') as f:
             f.write(body)
         print 'Wrote {0}'.format(self.__output_path)
Beispiel #2
0
 def respond(self, code, headers=None, body=None, *pos_args):
   StdoutRequestHandler.respond(self, code, headers, body, *pos_args)
   if self.__output_path and body is not None:
     # pylint: disable=invalid-name
     with open(self.__output_path, 'w') as f:
       f.write(body)
     print 'Wrote {0}'.format(self.__output_path)
def process_command(command, spectator, stackdriver, options):
    request = StdoutRequestHandler()
    params = {}

    if command == 'clear':
        handlers.ClearCustomDescriptorsHandler(options,
                                               stackdriver)(request, '/clear',
                                                            params, None)
    elif command == 'dump':
        handlers.DumpMetricsHandler(options, spectator)(request, '/dump',
                                                        params, None)
    elif command == 'list':
        handlers.ListCustomDescriptorsHandler(options,
                                              stackdriver)(request, '/list',
                                                           params, None)
    elif command == 'explore':
        handlers.ExploreCustomDescriptorsHandler(options,
                                                 spectator)(request,
                                                            '/explore', params,
                                                            None)
    elif command == 'show':
        handlers.ShowCurrentMetricsHandler(options,
                                           spectator)(request, '/show', params,
                                                      None)
    else:
        raise ValueError('Unknown command "{0}".'.format(command))
Beispiel #4
0
 def __init__(self, content_type='text/plain', options=None):
     StdoutRequestHandler.__init__(self)
     self.__headers = {'accept': content_type}
     self.__output_path = (options or {}).get('output_path', None)
Beispiel #5
0
 def __init__(self, content_type='text/plain', options=None):
     StdoutRequestHandler.__init__(self)
     self.__headers = {'accept': content_type}
     self.__output_path = options.output_path if options is not None else None
Beispiel #6
0
 def __init__(self, content_type='text/plain', options=None):
   StdoutRequestHandler.__init__(self)
   self.__headers = {'accept': content_type}
   self.__output_path = (options or {}).get('output_path', None)