Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dogshell: remove Exception wrapping #477

Merged
merged 1 commit into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 2 additions & 8 deletions datadog/dogshell/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ def _post(cls, args):
widgets = args.widgets
if args.widgets is None:
widgets = sys.stdin.read()
try:
widgets = json.loads(widgets)
except Exception:
raise Exception('bad json parameter')
widgets = json.loads(widgets)

# Required arguments
payload = {
Expand Down Expand Up @@ -115,10 +112,7 @@ def _update(cls, args):
widgets = args.widgets
if args.widgets is None:
widgets = sys.stdin.read()
try:
widgets = json.loads(widgets)
except Exception:
raise Exception('bad json parameter')
widgets = json.loads(widgets)

# Required arguments
payload = {
Expand Down
10 changes: 2 additions & 8 deletions datadog/dogshell/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ def _post(cls, args):
format = args.format
options = None
if args.options is not None:
try:
options = json.loads(args.options)
except Exception:
raise Exception('bad json parameter')
options = json.loads(args.options)

if args.tags:
tags = sorted(set([t.strip() for t in args.tags.split(',') if t.strip()]))
Expand Down Expand Up @@ -190,10 +187,7 @@ def _update(cls, args):
to_update['query'] = args.query_opt

if args.options is not None:
try:
to_update['options'] = json.loads(args.options)
except Exception:
raise Exception('bad json parameter')
to_update['options'] = json.loads(args.options)

res = api.Monitor.update(args.monitor_id, **to_update)

Expand Down
20 changes: 4 additions & 16 deletions datadog/dogshell/screenboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ def _pull(cls, args):
def _push(cls, args):
api._timeout = args.timeout
for f in args.file:
try:
screen_obj = json.load(f)
except Exception as err:
raise Exception("Could not parse {0}: {1}".format(f.name, err))
screen_obj = json.load(f)

if args.append_auto_text:
datetime_str = datetime.now().strftime('%x %X')
Expand Down Expand Up @@ -172,10 +169,7 @@ def _post(cls, args):
graphs = args.graphs
if args.graphs is None:
graphs = sys.stdin.read()
try:
graphs = json.loads(graphs)
except Exception:
raise Exception('bad json parameter')
graphs = json.loads(graphs)
res = api.Screenboard.create(
title=args.title, description=args.description, graphs=[graphs],
template_variables=args.template_variables, width=args.width, height=args.height)
Expand All @@ -193,10 +187,7 @@ def _update(cls, args):
graphs = args.graphs
if args.graphs is None:
graphs = sys.stdin.read()
try:
graphs = json.loads(graphs)
except Exception:
raise Exception('bad json parameter')
graphs = json.loads(graphs)

res = api.Screenboard.update(
args.screenboard_id, board_title=args.title, description=args.description,
Expand Down Expand Up @@ -269,10 +260,7 @@ def _new_file(cls, args):
graphs = args.graphs
if args.graphs is None:
graphs = sys.stdin.read()
try:
graphs = json.loads(graphs)
except Exception:
raise Exception('bad json parameter')
graphs = json.loads(graphs)
res = api.Screenboard.create(board_title=args.filename,
description="Description for {0}".format(args.filename),
widgets=[graphs])
Expand Down
15 changes: 3 additions & 12 deletions datadog/dogshell/timeboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,7 @@ def _new_file(cls, args):
graphs = args.graphs
if args.graphs is None:
graphs = sys.stdin.read()
try:
graphs = json.loads(graphs)
except Exception:
raise Exception('bad json parameter')
graphs = json.loads(graphs)
res = api.Timeboard.create(
title=args.filename,
description="Description for {0}".format(args.filename),
Expand Down Expand Up @@ -234,10 +231,7 @@ def _post(cls, args):
graphs = args.graphs
if args.graphs is None:
graphs = sys.stdin.read()
try:
graphs = json.loads(graphs)
except Exception:
raise Exception('bad json parameter')
graphs = json.loads(graphs)
res = api.Timeboard.create(title=args.title, description=args.description, graphs=[graphs],
template_variables=args.template_variables)
report_warnings(res)
Expand All @@ -254,10 +248,7 @@ def _update(cls, args):
graphs = args.graphs
if args.graphs is None:
graphs = sys.stdin.read()
try:
graphs = json.loads(graphs)
except Exception:
raise Exception('bad json parameter')
graphs = json.loads(graphs)

res = api.Timeboard.update(args.timeboard_id, title=args.title,
description=args.description, graphs=graphs,
Expand Down