Esempio n. 1
0
    def _write_dash_to_file(cls,
                            dash_id,
                            filename,
                            timeout,
                            format='raw',
                            string_ids=False):
        with open(filename, "w") as f:
            res = api.Timeboard.get(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(u"Downloaded dashboard {0} to file {1}".format(
                    dash_id, filename))
            else:
                print(u"{0} {1}".format(dash_id, filename))
Esempio n. 2
0
    def _write_screen_to_file(cls,
                              screenboard_id,
                              filename,
                              timeout,
                              format='raw',
                              string_ids=False):
        with open(filename, "w") as f:
            res = api.Screenboard.get(screenboard_id)
            report_warnings(res)
            report_errors(res)

            screen_obj = res
            if "resource" in screen_obj:
                del screen_obj["resource"]
            if "url" in screen_obj:
                del screen_obj["url"]

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

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

            if format == 'pretty':
                print("Downloaded screenboard {0} to file {1}".format(
                    screenboard_id, filename))
            else:
                print("{0} {1}".format(screenboard_id, filename))
Esempio n. 3
0
    def _write_dash_to_file(cls, dash_id, filename, timeout, format='raw', string_ids=False):
        with open(filename, "w") as f:
            res = api.Timeboard.get(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(u"Downloaded dashboard {0} to file {1}".format(dash_id, filename))
            else:
                print(u"{0} {1}".format(dash_id, filename))
Esempio n. 4
0
    def _write_screen_to_file(cls, screenboard_id, filename, timeout,
                              format='raw', string_ids=False):
        with open(filename, "w") as f:
            res = api.Screenboard.get(screenboard_id)
            report_warnings(res)
            report_errors(res)

            screen_obj = res
            if "resource" in screen_obj:
                del screen_obj["resource"]
            if "url" in screen_obj:
                del screen_obj["url"]

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

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

            if format == 'pretty':
                print("Downloaded screenboard {0} to file {1}".format(screenboard_id, filename))
            else:
                print("{0} {1}".format(screenboard_id, filename))