def testMissingPath(self):
     try:
         e = ExecProc()
         e.setCommand(["-l"])
         output = e.execute()
     except ValueError as v:
         self.assertEqual(type(v),ValueError)
class MetricThread(Thread):
    
    def __init__(self,item,mutex):
        Thread.__init__(self,name=item.getName())
        self.setDaemon(True)
        self.mutex = mutex
        self.pollingInterval = item.getPollingInterval()
        self.name = item.getName()
        self.proc = ExecProc()
        self.proc.setCommand(item.getCommand())
        self.proc.setDebug(item.getDebug())
        
    def run(self): # run provides thread logic
        while True:
            output = self.proc.execute()
            with self.mutex:
                stdout.write(output.decode('utf-8'))
                stdout.flush()
            time.sleep(self.pollingInterval)
 def testExec(self):
     e = ExecProc()
     e.setCommand("ls -l src/test/resources/test-exec")
     output = e.execute()
     self.assertEquals(output,"total 0\n-rw-r--r--  1 davidg  staff  0 Aug 25 12:20 goodbye.txt\n-rw-r--r--  1 davidg  staff  0 Aug 25 12:20 hello.txt\n-rw-r--r--  1 davidg  staff  0 Aug 25 12:20 myDir\n")