From 6661f6b605968a3ceb6336e7796169aed635f882 Mon Sep 17 00:00:00 2001
From: NGUYEN Do Duc Anh <do-duc-anh.nguyen@imt-atlantique.fr>
Date: Thu, 17 Oct 2024 20:48:12 +0200
Subject: [PATCH] check error code

---
 ubuntu_base/opportunistic_node.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/ubuntu_base/opportunistic_node.py b/ubuntu_base/opportunistic_node.py
index 044509b..2e2018a 100644
--- a/ubuntu_base/opportunistic_node.py
+++ b/ubuntu_base/opportunistic_node.py
@@ -15,9 +15,16 @@ map_firewall = {}
 
 
 def setup_firewall(inter_num):
-    subprocess.run(
-        [f'{DIR}/ubuntu_base/configure_bridge_firewall', f"public{inter_num}", f"private{inter_num}", f"ens{inter_num}", f"br{inter_num}", f"{inter_num}", DIR],
-        check=True)
+    try:
+        subprocess.run(
+            [f'{DIR}/ubuntu_base/configure_bridge_firewall', f"public{inter_num}", f"private{inter_num}", f"ens{inter_num}", f"br{inter_num}", f"{inter_num}", DIR],
+            check=True)
+    except subprocess.CalledProcessError as e:
+        # This will run if the command returns a non-zero exit code (i.e., an error)
+        print(f"Error: {e}")
+        print(f"Return code: {e.returncode}")  # The exit code
+        print(f"Command output: {e.output}")  # Any output (stdout/stderr)
+
 
 
 def process_packet(new_packet):
-- 
GitLab