mirror of https://github.com/MISP/PyMISP
Properly display deprecation warning
parent
142566df4d
commit
f6dc991751
|
@ -50,14 +50,14 @@ def deprecated(func):
|
||||||
@functools.wraps(func)
|
@functools.wraps(func)
|
||||||
def new_func(*args, **kwargs):
|
def new_func(*args, **kwargs):
|
||||||
if sys.version_info < (3, 0):
|
if sys.version_info < (3, 0):
|
||||||
warnings.warn_explicit(
|
warnings.showwarning(
|
||||||
"Call to deprecated function {}.".format(func.__name__),
|
"Call to deprecated function {}.".format(func.__name__),
|
||||||
category=DeprecationWarning,
|
category=DeprecationWarning,
|
||||||
filename=func.func_code.co_filename,
|
filename=func.func_code.co_filename,
|
||||||
lineno=func.func_code.co_firstlineno + 1
|
lineno=func.func_code.co_firstlineno + 1
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
warnings.warn_explicit(
|
warnings.showwarning(
|
||||||
"Call to deprecated function {}.".format(func.__name__),
|
"Call to deprecated function {}.".format(func.__name__),
|
||||||
category=DeprecationWarning,
|
category=DeprecationWarning,
|
||||||
filename=func.__code__.co_filename,
|
filename=func.__code__.co_filename,
|
||||||
|
@ -1441,7 +1441,6 @@ class PyMISP(object):
|
||||||
|
|
||||||
@deprecated
|
@deprecated
|
||||||
def add_tag(self, event, tag, attribute=False):
|
def add_tag(self, event, tag, attribute=False):
|
||||||
# FIXME: this is dirty, this function needs to be deprecated with something tagging a UUID
|
|
||||||
session = self.__prepare_session()
|
session = self.__prepare_session()
|
||||||
if attribute:
|
if attribute:
|
||||||
to_post = {'request': {'Attribute': {'id': event['id'], 'tag': tag}}}
|
to_post = {'request': {'Attribute': {'id': event['id'], 'tag': tag}}}
|
||||||
|
@ -1457,13 +1456,12 @@ class PyMISP(object):
|
||||||
|
|
||||||
@deprecated
|
@deprecated
|
||||||
def remove_tag(self, event, tag, attribute=False):
|
def remove_tag(self, event, tag, attribute=False):
|
||||||
# FIXME: this is dirty, this function needs to be deprecated with something removing the tag to a UUID
|
|
||||||
session = self.__prepare_session()
|
session = self.__prepare_session()
|
||||||
if attribute:
|
if attribute:
|
||||||
to_post = {'request': {'Attribute': {'id': event['id'], 'tag': tag}}}
|
to_post = {'request': {'Attribute': {'id': event['id'], 'tag': tag}}}
|
||||||
path = 'attributes/addTag'
|
path = 'attributes/removeTag'
|
||||||
else:
|
else:
|
||||||
to_post = {'request': {'Event': {'id': event['Event']['id'], 'tag': tag}}}
|
to_post = {'request': {'Event': {'id': event['Event']['id'], 'tag': tag}}}
|
||||||
path = 'events/addTag'
|
path = 'events/removeTag'
|
||||||
response = session.post(urljoin(self.root_url, path), data=json.dumps(to_post))
|
response = session.post(urljoin(self.root_url, path), data=json.dumps(to_post))
|
||||||
return self._check_response(response)
|
return self._check_response(response)
|
||||||
|
|
Loading…
Reference in New Issue