Ns-3/linux tunnel experiments
[nepi.git] / src / nepi / resources / linux / application.py
index 23108e5..89a9cfb 100644 (file)
@@ -720,40 +720,49 @@ class LinuxApplication(ResourceManager):
         return self._state
 
     def execute_command(self, command, 
-            env = None,
-            sudo = False,
-            tty = False,
-            forward_x11 = False,
-            blocking = False):
+            env=None,
+            sudo=False,
+            tty=False,
+            forward_x11=False,
+            blocking=False):
 
         environ = ""
         if env:
-            environ = self.node.format_environment(env, inline = True)
+            environ = self.node.format_environment(env, inline=True)
         command = environ + command
         command = self.replace_paths(command)
 
         return self.node.execute(command,
-                sudo = sudo,
-                tty = tty,
-                forward_x11 = forward_x11,
-                blocking = blocking)
+                sudo=sudo,
+                tty=tty,
+                forward_x11=forward_x11,
+                blocking=blocking)
 
-    def replace_paths(self, command):
+    def replace_paths(self, command, node=None, app_home=None, run_home=None):
         """
         Replace all special path tags with shell-escaped actual paths.
         """
+        if not node:
+            node=self.node
+
+        if not app_home:
+            app_home=self.app_home
+
+        if not run_home:
+            run_home = self.run_home
+
         return ( command
-            .replace("${USR}", self.node.usr_dir)
-            .replace("${LIB}", self.node.lib_dir)
-            .replace("${BIN}", self.node.bin_dir)
-            .replace("${SRC}", self.node.src_dir)
-            .replace("${SHARE}", self.node.share_dir)
-            .replace("${EXP}", self.node.exp_dir)
-            .replace("${EXP_HOME}", self.node.exp_home)
-            .replace("${APP_HOME}", self.app_home)
-            .replace("${RUN_HOME}", self.run_home)
-            .replace("${NODE_HOME}", self.node.node_home)
-            .replace("${HOME}", self.node.home_dir)
+            .replace("${USR}", node.usr_dir)
+            .replace("${LIB}", node.lib_dir)
+            .replace("${BIN}", node.bin_dir)
+            .replace("${SRC}", node.src_dir)
+            .replace("${SHARE}", node.share_dir)
+            .replace("${EXP}", node.exp_dir)
+            .replace("${EXP_HOME}", node.exp_home)
+            .replace("${APP_HOME}", app_home)
+            .replace("${RUN_HOME}", run_home)
+            .replace("${NODE_HOME}", node.node_home)
+            .replace("${HOME}", node.home_dir)
             )
 
     def valid_connection(self, guid):