2 # -*- coding: utf-8 -*-
4 from constants import TESTBED_ID
9 from nepi.util.constants import STATUS_NOT_STARTED, STATUS_RUNNING, \
12 class Application(object):
13 def __init__(self, api=None):
25 # Those are filled when an actual node is connected
28 # Those are filled when the app is started
29 # Having both pid and ppid makes it harder
30 # for pid rollover to induce tracking mistakes
33 self._stdout_path = None
34 self._stderr_path = None
37 return "%s<command:%s%s>" % (
38 self.__class__.__name__,
39 "sudo " if self.sudo else "",
50 return STATUS_FINISHED
53 status = self.status()
54 if status == STATUS_RUNNING:
55 # TODO: kill by pid & ppid
58 def remote_trace_path(self, whichtrace):
59 if whichtrace == 'stdout':
60 tracefile = self._stdout_path
61 elif whichtrace == 'stderr':
62 tracefile = self._stderr_path
68 def sync_trace(self, local_dir, whichtrace):
69 tracefile = self.remote_trace_path(whichtrace)
73 local_path = os.join(local_dir, tracefile)
76 f = open(local_path, "w")