Commit d22fde73 authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾 Committed by GitHub

Run: print raised exception on stdout (#7)

- Run : Print on stdout the exception that occured to explicitely aware the user
that a command failed.
- Main : Add membership interface creation failure to error message when an
exception is raised in `add_membership_interface` method
parent 8f7bf840
...@@ -38,10 +38,17 @@ def add_membership_interface(interface_name, ipv4=True, ipv6=False): ...@@ -38,10 +38,17 @@ def add_membership_interface(interface_name, ipv4=True, ipv6=False):
add_membership_interface(interface_name, ipv4, ipv6) add_membership_interface(interface_name, ipv4, ipv6)
return return
if ipv4 and kernel is not None: try:
kernel.create_membership_interface(interface_name=interface_name) if ipv4 and kernel is not None:
if ipv6 and kernel_v6 is not None: kernel.create_membership_interface(interface_name=interface_name)
kernel_v6.create_membership_interface(interface_name=interface_name) if ipv6 and kernel_v6 is not None:
kernel_v6.create_membership_interface(interface_name=interface_name)
except Exception as e:
e.args = (
'Failed to create membership interface for %s\n%s' % (interface_name, e.args[0]),
*e.args[1:],
)
raise e
def remove_interface(interface_name, pim=False, membership=False, ipv4=True, ipv6=False): def remove_interface(interface_name, pim=False, membership=False, ipv4=True, ipv6=False):
......
...@@ -115,7 +115,8 @@ class MyDaemon(Daemon): ...@@ -115,7 +115,8 @@ class MyDaemon(Daemon):
connection.sendall(pickle.dumps(Main.get_config())) connection.sendall(pickle.dumps(Main.get_config()))
elif 'drop' in args and args.drop: elif 'drop' in args and args.drop:
Main.drop(args.drop[0], int(args.drop[1])) Main.drop(args.drop[0], int(args.drop[1]))
except Exception: except Exception as e:
connection.sendall(pickle.dumps(e))
connection.shutdown(socket.SHUT_RDWR) connection.shutdown(socket.SHUT_RDWR)
traceback.print_exc() traceback.print_exc()
finally: finally:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment