Files
deb-python-dcos/cli/dcoscli/util.py
Cody Maloney 1e2627ba3c Add some missing newlines between import sections (#841)
Builtin, third party, and first party are all supposed to have a newline between
them. Most of the codebase was doing this, but some had snuck through. This
updates those ones to follow the coding style. These are caught by recent
changes in the code style checking plugin making it more strict / accurate.
2016-11-21 21:51:36 -08:00

29 lines
581 B
Python

from functools import wraps
import docopt
from dcos import emitting
emitter = emitting.FlatEmitter()
def decorate_docopt_usage(func):
"""Handle DocoptExit exception
:param func: function
:type func: function
:return: wrapped function
:rtype: function
"""
@wraps(func)
def wrapper(*args, **kwargs):
try:
result = func(*args, **kwargs)
except docopt.DocoptExit as e:
emitter.publish("Command not recognized\n")
emitter.publish(e)
return 1
return result
return wrapper