Exemplo n.º 1
0
 def _reply(self, args):
     self.dog.timeout = args.timeout
     handle = args.handle
     comment = args.comment
     id = args.comment_id
     format = args.format
     if comment is None:
         comment = sys.stdin.read()
     res = self.dog.comment(handle, comment, related_event_id=id)
     report_warnings(res)
     report_errors(res)
     if format == 'pretty':
         message = res['comment']['message']
         lines = message.split('\n')
         message = '\n'.join(['    ' + line for line in lines])
         print('id\t\t' + str(res['comment']['id']))
         print('url\t\t' + res['comment']['url'])
         print('resource\t' + res['comment']['resource'])
         print('handle\t\t' + res['comment']['handle'])
         print('message\n' + message)
     elif format == 'raw':
         print(json.dumps(res))
     else:
         print('id\t\t' + str(res['comment']['id']))
         print('url\t\t' + res['comment']['url'])
         print('resource\t' + res['comment']['resource'])
         print('handle\t\t' + res['comment']['handle'])
         print('message\t\t' + res['comment']['message'].__repr__())
Exemplo n.º 2
0
 def _post(self, args):
     self.dog.timeoue = args.timeout
     format = args.format
     message = args.message
     if message is None:
         message = sys.stdin.read()
     if args.tags is not None:
         tags = [t.strip() for t in args.tags.split(',')]
     else:
         tags = None
     res = self.dog.event_with_response(args.title,
                    message,
                    args.date_happened,
                    args.handle,
                    args.priority,
                    args.related_event_id,
                    tags,
                    args.host,
                    args.device,
                    args.aggregation_key,
                    args.type)
     report_warnings(res)
     report_errors(res)
     if format == 'pretty':
         prettyprint_event(res['event'])
     elif format == 'raw':
         print(json.dumps(res))
     else:
         print_event(res['event'])
Exemplo n.º 3
0
 def _show(self, args):
     self.dog.timeout = args.timeout
     format = args.format
     if args.host == 'all':
         res = self.dog.all_tags()
     else:
         res = self.dog.host_tags(args.host)
     report_warnings(res)
     report_errors(res)
     if args.host == 'all':
         if format == 'pretty':
             for tag, hosts in list(res['tags'].items()):
                 for host in hosts:
                     print(tag)
                     print('  ' + host)
                 print()
         elif format == 'raw':
             print(json.dumps(res))
         else:
             for tag, hosts in list(res['tags'].items()):
                 for host in hosts:
                     print(tag + '\t' + host)
     else:
         if format == 'pretty':
             for tag in res['tags']:
                 print(tag)
         elif format == 'raw':
             print(json.dumps(res))
         else:
             for tag in res['tags']:
                 print(tag)
Exemplo n.º 4
0
    def _push(self, args):
        self.dog.timeout = args.timeout
        for f in args.file:
            try:
                dash_obj = json.load(f)
            except Exception as err:
            # except simplejson.decoder.JSONDecodeError as err: # only works in simplejson 2.2.x
                raise Exception("Could not parse {0}: {1}".format(f.name, err))

            # Always convert to int, in case it was originally a string.
            dash_obj["id"] = int(dash_obj["id"])
            if args.append_auto_text:
                datetime_str = datetime.now().strftime('%x %X')
                auto_text = ("<br/>\nUpdated at {0} from {1} ({2}) on {3}"
                             .format(datetime_str, f.name, dash_obj["id"], platform.node()))
                dash_obj["description"] += auto_text
            tpl_vars = dash_obj.get("template_variables", [])
            res = self.dog.update_dashboard(dash_obj["id"], dash_obj["title"], dash_obj["description"],
                                            dash_obj["graphs"], template_variables=tpl_vars)
            print tpl_vars

            if 'errors' in res:
                print_err('Upload of dashboard {0} from file {1} failed.'.format(dash_obj["id"], f.name))

            report_warnings(res)
            report_errors(res)

            if args.format == 'pretty':
                print("Uploaded file {0} (dashboard {1})".format(f.name, dash_obj["id"]))
Exemplo n.º 5
0
 def _stream(self, args):
     self.dog.timeoue = args.timeout
     format = args.format
     if args.sources is not None:
         sources = [s.strip() for s in args.sources.split(',')]
     else:
         sources = None
     if args.tags is not None:
         tags = [t.strip() for t in args.tags.split(',')]
     else:
         tags = None
     start = parse_time(args.start)
     end = parse_time(args.end)
     res = self.dog.stream(start, end, args.priority, sources, tags)
     report_warnings(res)
     report_errors(res)
     if format == 'pretty':
         for event in res['events']:
             prettyprint_event(event)
             print()
     elif format == 'raw':
         print(json.dumps(res))
     else:
         for event in res['events']:
             print_event(event)
             print()
Exemplo n.º 6
0
 def _reply(self, args):
     self.dog.timeout = args.timeout
     handle = args.handle
     comment = args.comment
     id = args.comment_id
     format = args.format
     if comment is None:
         comment = sys.stdin.read()
     res = self.dog.comment(handle, comment, related_event_id=id)
     report_warnings(res)
     report_errors(res)
     if format == 'pretty':
         message = res['comment']['message']
         lines = message.split('\n')
         message = '\n'.join(['    ' + line for line in lines])
         print('id\t\t' + str(res['comment']['id']))
         print('url\t\t' + res['comment']['url'])
         print('resource\t' + res['comment']['resource'])
         print('handle\t\t' + res['comment']['handle'])
         print('message\n' + message)
     elif format == 'raw':
         print(json.dumps(res))
     else:
         print('id\t\t' + str(res['comment']['id']))
         print('url\t\t' + res['comment']['url'])
         print('resource\t' + res['comment']['resource'])
         print('handle\t\t' + res['comment']['handle'])
         print('message\t\t' + res['comment']['message'].__repr__())
Exemplo n.º 7
0
 def _stream(self, args):
     self.dog.timeoue = args.timeout
     format = args.format
     if args.sources is not None:
         sources = [s.strip() for s in args.sources.split(',')]
     else:
         sources = None
     if args.tags is not None:
         tags = [t.strip() for t in args.tags.split(',')]
     else:
         tags = None
     start = parse_time(args.start)
     end = parse_time(args.end)
     res = self.dog.stream(start, end, args.priority, sources, tags)
     report_warnings(res)
     report_errors(res)
     if format == 'pretty':
         for event in res['events']:
             prettyprint_event(event)
             print()
     elif format == 'raw':
         print(json.dumps(res))
     else:
         for event in res['events']:
             print_event(event)
             print()
Exemplo n.º 8
0
    def _pull_all(self, args):
        self.dog.timeout = args.timeout

        def _title_to_filename(title):
            # Get a lowercased version with most punctuation stripped out...
            no_punct = ''.join([
                c for c in title.lower()
                if c.isalnum() or c in [" ", "_", "-"]
            ])
            # Now replace all -'s, _'s and spaces with "_", and strip trailing _
            return no_punct.replace(" ", "_").replace("-", "_").strip("_")

        format = args.format
        res = self.dog.dashboards()
        report_warnings(res)
        report_errors(res)

        if not os.path.exists(args.pull_dir):
            os.mkdir(args.pull_dir, 0o755)

        used_filenames = set()
        for dash_summary in res['dashes']:
            filename = _title_to_filename(dash_summary['title'])
            if filename in used_filenames:
                filename = filename + "-" + dash_summary['id']
            used_filenames.add(filename)

            self._write_dash_to_file(
                dash_summary['id'],
                os.path.join(args.pull_dir, filename + ".json"), args.timeout,
                format, args.string_ids)
        if format == 'pretty':
            print(("\n### Total: {0} dashboards to {1} ###".format(
                len(used_filenames), os.path.realpath(args.pull_dir))))
Exemplo n.º 9
0
    def _write_dash_to_file(self,
                            dash_id,
                            filename,
                            timeout,
                            format='raw',
                            string_ids=False):
        with open(filename, "w") as f:
            res = self.dog.dashboard(dash_id)
            report_warnings(res)
            report_errors(res)

            dash_obj = res["dash"]
            if "resource" in dash_obj:
                del dash_obj["resource"]
            if "url" in dash_obj:
                del dash_obj["url"]

            if string_ids:
                dash_obj["id"] = str(dash_obj["id"])

            json.dump(dash_obj, f, indent=2)

            if format == 'pretty':
                print("Downloaded dashboard {0} to file {1}".format(
                    dash_id, filename))
            else:
                print("{0} {1}".format(dash_id, filename))
Exemplo n.º 10
0
    def _pull_all(self, args):
        self.dog.timeout = args.timeout

        def _title_to_filename(title):
            # Get a lowercased version with most punctuation stripped out...
            no_punct = ''.join([c for c in title.lower() if c.isalnum() or c in [" ", "_", "-"]])
            # Now replace all -'s, _'s and spaces with "_", and strip trailing _
            return no_punct.replace(" ", "_").replace("-", "_").strip("_")

        format = args.format
        res = self.dog.dashboards()
        report_warnings(res)
        report_errors(res)

        if not os.path.exists(args.pull_dir):
            os.mkdir(args.pull_dir, 0o755)

        used_filenames = set()
        for dash_summary in res['dashes']:
            filename = _title_to_filename(dash_summary['title'])
            if filename in used_filenames:
                filename = filename + "-" + dash_summary['id']
            used_filenames.add(filename)

            self._write_dash_to_file(dash_summary['id'],
                                     os.path.join(args.pull_dir, filename + ".json"),
                                     args.timeout,
                                     format,
                                     args.string_ids)
        if format == 'pretty':
            print(("\n### Total: {0} dashboards to {1} ###"
                  .format(len(used_filenames), os.path.realpath(args.pull_dir))))
Exemplo n.º 11
0
    def _push(self, args):
        self.dog.timeout = args.timeout
        for f in args.file:
            try:
                dash_obj = json.load(f)
            except Exception as err:
                # except simplejson.decoder.JSONDecodeError as err: # only works in simplejson 2.2.x
                raise Exception("Could not parse {0}: {1}".format(f.name, err))

            # Always convert to int, in case it was originally a string.
            dash_obj["id"] = int(dash_obj["id"])

            if args.append_auto_text:
                datetime_str = datetime.now().strftime('%x %X')
                auto_text = (
                    "<br/>\nUpdated at {0} from {1} ({2}) on {3}".format(
                        datetime_str, f.name, dash_obj["id"], platform.node()))
                dash_obj["description"] += auto_text

            res = self.dog.update_dashboard(dash_obj["id"], dash_obj["title"],
                                            dash_obj["description"],
                                            dash_obj["graphs"])

            if 'errors' in res:
                print_err(
                    'Upload of dashboard {0} from file {1} failed.'.format(
                        dash_obj["id"], f.name))

            report_warnings(res)
            report_errors(res)

            if args.format == 'pretty':
                print("Uploaded file {0} (dashboard {1})".format(
                    f.name, dash_obj["id"]))
Exemplo n.º 12
0
 def _detach(self, args):
     self.dog.timeout = args.timeout
     format = args.format
     res = self.dog.detach_tags(args.host)
     report_warnings(res)
     report_errors(res)
     if format == 'raw':
         print(json.dumps(res))
Exemplo n.º 13
0
 def _post(self, args):
     self.dog.timeout = args.timeout
     if args.localhostname:
         host = find_localhost()
     else:
         host = args.host
     res = self.dog.metric(args.name, args.value, host=host, device=args.device)
     report_warnings(res)
     report_errors(res)
Exemplo n.º 14
0
 def _post(self, args):
     self.dog.timeout = args.timeout
     if args.localhostname:
         # E0602: 25:MetricClient._post: Undefined variable 'find_localhost'
         host = find_localhost()
     else:
         host = args.host
     res = self.dog.metric(args.name, args.value, host=host, device=args.device)
     report_warnings(res)
     report_errors(res)
Exemplo n.º 15
0
 def _delete(self, args):
     self.dog.timeout = args.timeout
     format = args.format
     res = self.dog.delete_dashboard(args.dashboard_id)
     report_warnings(res)
     report_errors(res)
     if format == 'pretty':
         print(self._pretty_json(res))
     else:
         print(json.dumps(res))
Exemplo n.º 16
0
 def _delete(self, args):
     self.dog.timeout = args.timeout
     format = args.format
     res = self.dog.delete_dashboard(args.dashboard_id)
     report_warnings(res)
     report_errors(res)
     if format == 'pretty':
         print(self._pretty_json(res))
     else:
         print(json.dumps(res))
Exemplo n.º 17
0
 def _show(self, args):
     self.dog.timeoue = args.timeout
     format = args.format
     res = self.dog.get_event(args.event_id)
     report_warnings(res)
     report_errors(res)
     if format == 'pretty':
         prettyprint_event_details(res['event'])
     elif format == 'raw':
         print(json.dumps(res))
     else:
         print_event_details(res['event'])
Exemplo n.º 18
0
 def _show(self, args):
     self.dog.timeoue = args.timeout
     format = args.format
     res = self.dog.get_event(args.event_id)
     report_warnings(res)
     report_errors(res)
     if format == 'pretty':
         prettyprint_event_details(res['event'])
     elif format == 'raw':
         print(json.dumps(res))
     else:
         print_event_details(res['event'])
Exemplo n.º 19
0
 def _post(self, args):
     self.dog.timeout = args.timeout
     if args.localhostname:
         host = find_localhost()
     else:
         host = args.host
     res = self.dog.metric(args.name,
                           args.value,
                           host=host,
                           device=args.device)
     report_warnings(res)
     report_errors(res)
Exemplo n.º 20
0
    def _new_file(self, args):
        self.dog.timeout = args.timeout
        format = args.format
        res = self.dog.create_dashboard(args.filename, "Description for {0}".format(args.filename), [])
        report_warnings(res)
        report_errors(res)

        self._write_dash_to_file(res["dash"]["id"], args.filename, args.timeout, format, args.string_ids)

        if format == "pretty":
            print(self._pretty_json(res))
        else:
            print(json.dumps(res))
Exemplo n.º 21
0
 def _delete(self, args):
     self.dog.timeout = args.timeout
     id = args.comment_id
     format = args.format
     res = self.dog.delete_comment(id)
     report_warnings(res)
     report_errors(res)
     if format == 'pretty':
         print('event %s deleted' % id)
     elif format == 'raw':
         print(json.dumps(res))
     else:
         pass
Exemplo n.º 22
0
 def _delete(self, args):
     self.dog.timeout = args.timeout
     id = args.comment_id
     format = args.format
     res = self.dog.delete_comment(id)
     report_warnings(res)
     report_errors(res)
     if format == 'pretty':
         print('event %s deleted' % id)
     elif format == 'raw':
         print(json.dumps(res))
     else:
         pass
Exemplo n.º 23
0
    def _new_file(self, args):
        self.dog.timeout = args.timeout
        format = args.format
        res = self.dog.create_dashboard(args.filename,
                         "Description for {0}".format(args.filename), [])
        report_warnings(res)
        report_errors(res)

        self._write_dash_to_file(res['dash']['id'], args.filename, args.timeout, format, args.string_ids)

        if format == 'pretty':
            print(self._pretty_json(res))
        else:
            print(json.dumps(res))
Exemplo n.º 24
0
    def _show(self, args):
        self.dog.timeout = args.timeout
        format = args.format
        res = self.dog.dashboard(args.dashboard_id)
        report_warnings(res)
        report_errors(res)

        if args.string_ids:
            res["dash"]["id"] = str(res["dash"]["id"])

        if format == 'pretty':
            print(self._pretty_json(res))
        else:
            print(json.dumps(res))
Exemplo n.º 25
0
    def _show(self, args):
        self.dog.timeout = args.timeout
        format = args.format
        res = self.dog.dashboard(args.dashboard_id)
        report_warnings(res)
        report_errors(res)

        if args.string_ids:
            res["dash"]["id"] = str(res["dash"]["id"])

        if format == 'pretty':
            print(self._pretty_json(res))
        else:
            print(json.dumps(res))
Exemplo n.º 26
0
 def _post(self, args):
     self.dog.timeout = args.timeout
     if args.localhostname:
         host = find_localhost()
     else:
         host = args.host
     if args.tags:
         tags = sorted(set([t.strip() for t in
                            args.tags.split(',') if t]))
     else:
         tags = None
     res = self.dog.metric(args.name, args.value, host=host,
         device=args.device, tags=tags)
     report_warnings(res)
     report_errors(res)
Exemplo n.º 27
0
 def _replace(self, args):
     self.dog.timeout = args.timeout
     format = args.format
     res = self.dog.change_tags(args.host, *args.tag)
     report_warnings(res)
     report_errors(res)
     if format == 'pretty':
         print("Tags for '%s':" % res['host'])
         for c in res['tags']:
             print('  ' + c)
     elif format == 'raw':
         print(json.dumps(res))
     else:
         for c in res['tags']:
             print(c)
Exemplo n.º 28
0
 def _update(self, args):
     self.dog.timeout = args.timeout
     format = args.format
     if args.graphs is None:
         graphs = sys.stdin.read()
     try:
         graphs = json.loads(graphs)
     except:
         raise Exception("bad json parameter")
     res = self.dog.update_dashboard(args.dashboard_id, args.title, args.description, graphs)
     report_warnings(res)
     report_errors(res)
     if format == "pretty":
         print(self._pretty_json(res))
     else:
         print(json.dumps(res))
Exemplo n.º 29
0
 def _post(self, args):
     self.dog.timeout = args.timeout
     format = args.format
     if args.graphs is None:
         graphs = sys.stdin.read()
     try:
         graphs = json.loads(graphs)
     except:
         raise Exception('bad json parameter')
     res = self.dog.create_dashboard(args.title, args.description, graphs)
     report_warnings(res)
     report_errors(res)
     if format == 'pretty':
         print(self._pretty_json(res))
     else:
         print(json.dumps(res))
Exemplo n.º 30
0
    def _show_all(self, args):
        self.dog.timeout = args.timeout
        format = args.format
        res = self.dog.dashboards()
        report_warnings(res)
        report_errors(res)

        if args.string_ids:
            for d in res["dashes"]:
                d["id"] = str(d["id"])

        if format == "pretty":
            print(self._pretty_json(res))
        elif format == "raw":
            print(json.dumps(res))
        else:
            for d in res["dashes"]:
                print("\t".join([(d["id"]), (d["resource"]), (d["title"]), self._escape(d["description"])]))
Exemplo n.º 31
0
 def _post(self, args):
     self.dog.timeout = args.timeout
     format = args.format
     graphs = args.graphs
     if args.graphs is None:
         graphs = sys.stdin.read()
     try:
         graphs = json.loads(graphs)
     except:
         raise Exception('bad json parameter')
     res = self.dog.create_dashboard(args.title, args.description, graphs,
                                     template_variables=args.template_variables)
     report_warnings(res)
     report_errors(res)
     if format == 'pretty':
         print(self._pretty_json(res))
     else:
         print(json.dumps(res))
Exemplo n.º 32
0
    def _show_all(self, args):
        self.dog.timeout = args.timeout
        format = args.format
        res = self.dog.dashboards()
        report_warnings(res)
        report_errors(res)

        if args.string_ids:
            for d in res["dashes"]:
                d["id"] = str(d["id"])

        if format == 'pretty':
            print(self._pretty_json(res))
        elif format == 'raw':
            print(json.dumps(res))
        else:
            for d in res["dashes"]:
                print("\t".join([(d["id"]), (d["resource"]), (d["title"]),
                                 self._escape(d["description"])]))
Exemplo n.º 33
0
 def _query(self, args):
     self.dog.timeout = args.timeout
     res = self.dog.search(args.query)
     report_warnings(res)
     report_errors(res)
     if format == 'pretty':
         for facet, results in list(res['results'].items()):
             for idx, result in enumerate(results):
                 if idx == 0:
                     print('\n')
                     print("%s\t%s" % (facet, result))
                 else:
                     print("%s\t%s" % (' ' * len(facet), result))
     elif format == 'raw':
         print(json.dumps(res))
     else:
         for facet, results in list(res['results'].items()):
             for result in results:
                 print("%s\t%s" % (facet, result))
Exemplo n.º 34
0
 def _query(self, args):
     self.dog.timeout = args.timeout
     res = self.dog.search(args.query)
     report_warnings(res)
     report_errors(res)
     if format == 'pretty':
         for facet, results in list(res['results'].items()):
             for idx, result in enumerate(results):
                 if idx == 0:
                     print('\n')
                     print("%s\t%s" % (facet, result))
                 else:
                     print("%s\t%s" % (' '*len(facet), result))
     elif format == 'raw':
         print(json.dumps(res))
     else:
         for facet, results in list(res['results'].items()):
             for result in results:
                 print("%s\t%s" % (facet, result))
Exemplo n.º 35
0
    def _post(self, args):
        self.dog.timeout = args.timeout
        if args.localhostname:
            host = find_localhost()
        else:
            host = args.host
        if args.tags:
            tags = sorted(set([t.strip() for t in
                               args.tags.split(',') if t]))
        else:
            tags = None

        # are we sending a counter?
        if args.counter:
            metric_type = MetricType.Counter
        else:
            metric_type = MetricType.Gauge
        res = self.dog.metric(args.name, args.value, host=host,
            device=args.device, tags=tags, metric_type=metric_type)
        report_warnings(res)
        report_errors(res)
Exemplo n.º 36
0
    def _write_dash_to_file(self, dash_id, filename, timeout, format='raw', string_ids=False):
        with open(filename, "w") as f:
            res = self.dog.dashboard(dash_id)
            report_warnings(res)
            report_errors(res)

            dash_obj = res["dash"]
            if "resource" in dash_obj:
                del dash_obj["resource"]
            if "url" in dash_obj:
                del dash_obj["url"]

            if string_ids:
                dash_obj["id"] = str(dash_obj["id"])

            json.dump(dash_obj, f, indent=2)

            if format == 'pretty':
                print("Downloaded dashboard {0} to file {1}".format(dash_id, filename))
            else:
                print("{0} {1}".format(dash_id, filename))
Exemplo n.º 37
0
 def _update(self, args):
     self.dog.timeout = args.timeout
     format = args.format
     graphs = args.graphs
     if args.graphs is None:
         graphs = sys.stdin.read()
     try:
         graphs = json.loads(graphs)
     except:
         raise Exception('bad json parameter')
     if args.template_variables:
         tpl_vars = [v.strip() for v in args.template_variables.split(',')]
     else:
         tpl_vars = []
     res = self.dog.update_dashboard(args.dashboard_id, args.title, args.description,
                                     graphs, template_variables=tpl_vars)
     report_warnings(res)
     report_errors(res)
     if format == 'pretty':
         print(self._pretty_json(res))
     else:
         print(json.dumps(res))
Exemplo n.º 38
0
 def _post(self, args):
     self.dog.timeoue = args.timeout
     format = args.format
     message = args.message
     if message is None:
         message = sys.stdin.read()
     if args.tags is not None:
         tags = [t.strip() for t in args.tags.split(',')]
     else:
         tags = None
     res = self.dog.event_with_response(args.title, message,
                                        args.date_happened, args.handle,
                                        args.priority,
                                        args.related_event_id, tags,
                                        args.host, args.device)
     report_warnings(res)
     report_errors(res)
     if format == 'pretty':
         prettyprint_event(res['event'])
     elif format == 'raw':
         print(json.dumps(res))
     else:
         print_event(res['event'])
Exemplo n.º 39
0
    def _post(self, args):
        self.dog.timeout = args.timeout
        if args.localhostname:
            host = find_localhost()
        else:
            host = args.host
        if args.tags:
            tags = sorted(set([t.strip() for t in args.tags.split(',') if t]))
        else:
            tags = None

        # are we sending a counter?
        if args.counter:
            metric_type = MetricType.Counter
        else:
            metric_type = MetricType.Gauge
        res = self.dog.metric(args.name,
                              args.value,
                              host=host,
                              device=args.device,
                              tags=tags,
                              metric_type=metric_type)
        report_warnings(res)
        report_errors(res)
Exemplo n.º 40
0
 def _show(self, args):
     self.dog.timeout = args.timeout
     id = args.comment_id
     format = args.format
     res = self.dog.get_event(id)
     report_warnings(res)
     report_errors(res)
     if format == 'pretty':
         message = res['event']['text']
         lines = message.split('\n')
         message = '\n'.join(['    ' + line for line in lines])
         print('id\t\t' + str(res['event']['id']))
         print('url\t\t' + res['event']['url'])
         print('resource\t' + res['event']['resource'])
         # print 'handle\t\t' + res['event']['handle']
         print('message\n' + message)
     elif format == 'raw':
         print(json.dumps(res))
     else:
         print('id\t\t' + str(res['event']['id']))
         print('url\t\t' + res['event']['url'])
         print('resource\t' + res['event']['resource'])
         # print 'handle\t\t' + res['event']['handle']
         print('message\t\t' + res['event']['text'].__repr__())
Exemplo n.º 41
0
 def _show(self, args):
     self.dog.timeout = args.timeout
     id = args.comment_id
     format = args.format
     res = self.dog.get_event(id)
     report_warnings(res)
     report_errors(res)
     if format == 'pretty':
         message = res['event']['text']
         lines = message.split('\n')
         message = '\n'.join(['    ' + line for line in lines])
         print('id\t\t' + str(res['event']['id']))
         print('url\t\t' + res['event']['url'])
         print('resource\t' + res['event']['resource'])
         #print 'handle\t\t' + res['event']['handle']
         print('message\n' + message)
     elif format == 'raw':
         print(json.dumps(res))
     else:
         print('id\t\t' + str(res['event']['id']))
         print('url\t\t' + res['event']['url'])
         print('resource\t' + res['event']['resource'])
         #print 'handle\t\t' + res['event']['handle']
         print('message\t\t' + res['event']['text'].__repr__())