def keepReadingJoystickFiles(thread_name, ipaddresses, lock): # reads the joystickfiles jsUpdate-<end_point>.txt that are output by Java # assumes these are in the directory below print("start keepReadingJoystickFiles thread_name=" + thread_name); path = os.path.realpath(__file__) path = path[0:path.rindex("/")] path = path[0:path.rindex("/")+1] # get parent directory prefix = "jsUpdate-" suffix = ".txt" print("keepReadingJoystickFiles path=" + path) while( True ): fileNames = os.listdir(path) for fileName in fileNames: if prefix in fileName: endpoint = fileName[len(prefix):len(fileName)-len(suffix)] print("keepReadingJoystickFiles fileName=" + fileName, "endpoint=" + endpoint) RequestUtils.enterOrLeaveVehicle(endpoint) # delete file os.remove(fileName) time.sleep(1)