Ashlesh Gawande | 792c6aa | 2015-07-10 12:18:36 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | import os |
| 3 | |
| 4 | class NdnApplication: |
| 5 | def __init__(self, node): |
| 6 | self.node = node |
| 7 | self.isRunning = False |
| 8 | |
| 9 | def start(self, command): |
| 10 | if self.isRunning is True: |
| 11 | try: |
| 12 | os.kill(int(self.processId), 0) |
| 13 | except OSError: |
| 14 | self.isRunning = False |
| 15 | |
| 16 | if self.isRunning is False: |
| 17 | self.node.cmd(command) |
| 18 | self.processId = self.node.cmd("echo $!")[:-1] |
| 19 | |
| 20 | self.isRunning = True |
| 21 | |
| 22 | def stop(self): |
| 23 | if self.isRunning: |
| 24 | self.node.cmd("sudo kill %s" % self.processId) |
| 25 | |
| 26 | self.isRunning = False |