def startup(self): """ Start up wormgate """ if os.path.exists(TMP_FOLDER): deleteAllInFolder(TMP_FOLDER); os.makedirs(TMP_FOLDER) deamonize.daemonize('dev/null', TMP_FOLDER + 'output', TMP_FOLDER + 'error') thread.start_new_thread(self.die,()) thread.start_new_thread(self.showWormGateWindow, ()) self.fileserver = communication.FileServer(LISTEN_PORT, WORM_GATE_PORT) self.fileserver.main(self.setNumberOfStartedSegmets)
self.killMySelf() else: updates = json.loads(received, encoding='UTF-8') if not updates["ID"] in self.allWormSegments: self.allWormSegments.append(updates["ID"]) self.updateHeartBeatCount(float(updates["Heartbeat"])) def killMySelf(self): """ Simply stops all the python threads and quits """ quitPython() def updateHeartBeatCount(self, count): ''' Updates heartbeat count ''' self.heartbeatreciver += count if __name__ == "__main__": deamonize.daemonize('dev/null', 'output', 'error') os.putenv('DISPLAY', ':0') # Attach to local display worm = WormSegment() print "Startign the worm segment" worm.main() time.sleep(0.1); # Give display thread some time to terminate