Skip to content

Commit

Permalink
Allow logfile parameter to be set to optional for Application object.
Browse files Browse the repository at this point in the history
Also fix a minor issue with traffic generator experiment imports
not consistently working by relocating to NLSR subdirectory.

Change-Id: Iad04ee0e3bb64a89133f45721c5d2c1e4c468dbf
  • Loading branch information
awlane committed Feb 3, 2025
1 parent 73add71 commit c02f5c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from minindn.apps.nfd import Nfd
from minindn.apps.nlsr import Nlsr
from minindn.util import copyExistentFile
from examples.nlsr.nlsr_common import getParser
from nlsr_common import getParser

def trafficServer(node, serverConfFile):
"""
Expand Down
8 changes: 6 additions & 2 deletions minindn/apps/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# If not, see <http://www.gnu.org/licenses/>.

from minindn.util import getPopen
from typing import Union, Optional

class Application(object):
def __init__(self, node):
Expand All @@ -34,11 +35,14 @@ def __init__(self, node):
self.logDir = '{}/log'.format(self.homeDir)
self.node.cmd('mkdir -p {}'.format(self.logDir))

def start(self, command, logfile, envDict=None):
def start(self, command: Union[str, list], logfile: Optional[str]=None, envDict: Optional[dict]=None) -> None:
if self.process is None:
self.logfile = open('{}/{}'.format(self.logDir, logfile), 'w')
if isinstance(command, str):
command = command.split()
if not logfile:
self.process = getPopen(self.node, command, envDict)
return
self.logfile = open('{}/{}'.format(self.logDir, logfile), 'w')
self.process = getPopen(self.node, command, envDict,
stdout=self.logfile, stderr=self.logfile)

Expand Down

0 comments on commit c02f5c3

Please sign in to comment.