def test_json_formatter(self): """Should return a JSON representation of the TObject.""" rep = response_formatters.json_formatter(self.th1) self.assertIsInstance(rep, str)
# Format the plot name with the sensor number # str.format will work even with no format specifiers in the string plot = plot.format(sensor) # Try to the get the plot object try: plot_obj = plots.get_run_plot(plot, run, reference=reference) except KeyError, e: sys.stderr.write("Invalid plot name provided: {0}".format(plot)) sys.stderr.write("Exception caught: {0}".format(e)) sys.exit(1) # Try to format the object in to JSON try: response = response_formatters.json_formatter(plot_obj) except TypeError, e: sys.stderr.write("Cannot handle plot type for plot {0}".format(plot)) sys.stderr.write("Exception caught: {0}".format(e)) sys.stdout.write(response) def main(): parser = create_parser() args = parser.parse_args() retrieve_run_view_plot(args.run, args.plot, args.sensor, args.reference) if __name__ == "__main__": main()