def create(self): # make a fifo pipe if not os.path.exists(self.pipePath): os.mkfifo(self.pipePath) print """[%s] [Main Thread] Creating named pipe, to listen to incoming commands""" % time.time() self.fifo = open(self.pipePath, 'r') while True: line = self.fifo.readline()[:-1] if line: print '[%s] Command Recieved: %s' % (time.time(), line) # Spawn a new thread and process the argument # TODO: assumption no of IPs used will be less than 255 - 1 # come up with more scalable system here ip = self.baseIP + str(self.IPcount) self.IPcount += 1 commandproc(line, ip, self.domain) # Wait for 1 seconds now time.sleep(1)
def create(self): self.s.listen(5) # Now wait for client connection. while True: c, addr = self.s.accept() # Establish connection with client. print ("Got connection from %s ") % str(addr) commandproc(c, addr)