killing the source engine lock files more agressivey
This commit is contained in:
		
							parent
							
								
									f43e56e5ec
								
							
						
					
					
						commit
						ba06b94845
					
				@ -28,10 +28,11 @@ def writeCfgInput(Input_user):
 | 
				
			|||||||
    with open(looptestPath, 'w') as f:
 | 
					    with open(looptestPath, 'w') as f:
 | 
				
			||||||
        f.write(Input_user)
 | 
					        f.write(Input_user)
 | 
				
			||||||
    #print("wrote to file: ", Input_user)
 | 
					    #print("wrote to file: ", Input_user)
 | 
				
			||||||
    if "connect to" in Input_user:
 | 
					    if "connect " in Input_user:
 | 
				
			||||||
        time.sleep(1.0)
 | 
					        time.sleep(1.0)
 | 
				
			||||||
 | 
					        open(looptestPath, 'w').close() #clearing file.
 | 
				
			||||||
    elif "wait" in Input_user:
 | 
					    elif "wait" in Input_user:
 | 
				
			||||||
        time.sleep(0.1)
 | 
					        time.sleep(0.35)
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        time.sleep(0.5)
 | 
					        time.sleep(0.5)
 | 
				
			||||||
        open(looptestPath, 'w').close() #clearing file.
 | 
					        open(looptestPath, 'w').close() #clearing file.
 | 
				
			||||||
@ -148,15 +149,7 @@ def bot_connect(data):
 | 
				
			|||||||
    writeCfgInput(str1)
 | 
					    writeCfgInput(str1)
 | 
				
			||||||
    time.sleep(1)
 | 
					    time.sleep(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while True:
 | 
					    handle_bz2_map_files()
 | 
				
			||||||
        still_downloading_map = False
 | 
					 | 
				
			||||||
        for f in glob.glob(f"/home/{whoami}/.steam/debian-installation/steamapps/common/Counter-Strike Source/cstrike/download/maps/*.bz2"):
 | 
					 | 
				
			||||||
            print('found f in bot_connect, so downloadig map?: ', f)
 | 
					 | 
				
			||||||
            still_downloading_map = True
 | 
					 | 
				
			||||||
            break
 | 
					 | 
				
			||||||
        if not still_downloading_map:
 | 
					 | 
				
			||||||
            break
 | 
					 | 
				
			||||||
        time.sleep(10)
 | 
					 | 
				
			||||||
    t = Timer(30, attempt_bot_connect)
 | 
					    t = Timer(30, attempt_bot_connect)
 | 
				
			||||||
    t.start()
 | 
					    t.start()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -177,14 +170,7 @@ def attempt_bot_connect():
 | 
				
			|||||||
    call_bot_connect = True
 | 
					    call_bot_connect = True
 | 
				
			||||||
    print('finished timer callback')
 | 
					    print('finished timer callback')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == '__main__':
 | 
					def handle_bz2_map_files():
 | 
				
			||||||
    atexit.register(exit_handler)
 | 
					 | 
				
			||||||
    local_port = data_ports['udp_port']
 | 
					 | 
				
			||||||
    external_port_messages = data_ports['chat_external_port']
 | 
					 | 
				
			||||||
    buffer_size = 4096 #potentially not large enough?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    clean_up_files()
 | 
					 | 
				
			||||||
    delete_lock_file()
 | 
					 | 
				
			||||||
    #if downloading maps we give it 10 seconds delay to see if the size changed, if not its probably safe to delete the .bz2 file as no download in progress
 | 
					    #if downloading maps we give it 10 seconds delay to see if the size changed, if not its probably safe to delete the .bz2 file as no download in progress
 | 
				
			||||||
    bz2_maps = {}
 | 
					    bz2_maps = {}
 | 
				
			||||||
    while True:
 | 
					    while True:
 | 
				
			||||||
@ -203,6 +189,16 @@ if __name__ == '__main__':
 | 
				
			|||||||
            break
 | 
					            break
 | 
				
			||||||
        time.sleep(10)
 | 
					        time.sleep(10)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    atexit.register(exit_handler)
 | 
				
			||||||
 | 
					    local_port = data_ports['udp_port']
 | 
				
			||||||
 | 
					    external_port_messages = data_ports['chat_external_port']
 | 
				
			||||||
 | 
					    buffer_size = 4096 #potentially not large enough?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    clean_up_files()
 | 
				
			||||||
 | 
					    delete_lock_file()
 | 
				
			||||||
 | 
					    handle_bz2_map_files()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    maps_folder_size = subprocess.Popen(["du", "-sh", f"/home/{whoami}/.steam/debian-installation/steamapps/common/Counter-Strike Source/cstrike/download/maps"], stdout=subprocess.PIPE).communicate()[0].decode().split("\t")[0]
 | 
					    maps_folder_size = subprocess.Popen(["du", "-sh", f"/home/{whoami}/.steam/debian-installation/steamapps/common/Counter-Strike Source/cstrike/download/maps"], stdout=subprocess.PIPE).communicate()[0].decode().split("\t")[0]
 | 
				
			||||||
    #deleting when maps folder larger than 150GB
 | 
					    #deleting when maps folder larger than 150GB
 | 
				
			||||||
    if maps_folder_size.endswith("G"): 
 | 
					    if maps_folder_size.endswith("G"): 
 | 
				
			||||||
@ -221,12 +217,9 @@ if __name__ == '__main__':
 | 
				
			|||||||
    sock.settimeout(5.0)
 | 
					    sock.settimeout(5.0)
 | 
				
			||||||
    messager_name = ""
 | 
					    messager_name = ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    t = Timer(10, delete_lock_file)
 | 
					 | 
				
			||||||
    t.start()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    #limit the cpu allowed to be used by the game instance. 
 | 
					    #limit the cpu allowed to be used by the game instance. 
 | 
				
			||||||
    t = Timer(11, cpulimit_pid_of_game)
 | 
					    time.sleep(11)
 | 
				
			||||||
    t.start()
 | 
					    cpulimit_pid_of_game()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        while True:
 | 
					        while True:
 | 
				
			||||||
@ -242,6 +235,7 @@ if __name__ == '__main__':
 | 
				
			|||||||
            #print('data: ', data)
 | 
					            #print('data: ', data)
 | 
				
			||||||
            if not data:
 | 
					            if not data:
 | 
				
			||||||
                continue
 | 
					                continue
 | 
				
			||||||
 | 
					            delete_lock_file()
 | 
				
			||||||
            #print("ip: ", ip, " port: ", port)
 | 
					            #print("ip: ", ip, " port: ", port)
 | 
				
			||||||
            if ip == data_ports['discord_bot_ip'] and port == external_port_messages:
 | 
					            if ip == data_ports['discord_bot_ip'] and port == external_port_messages:
 | 
				
			||||||
                if messager_name in data:
 | 
					                if messager_name in data:
 | 
				
			||||||
@ -296,4 +290,4 @@ if __name__ == '__main__':
 | 
				
			|||||||
                    strInput += "+duck; wait 50; -duck; wait 5; "
 | 
					                    strInput += "+duck; wait 50; -duck; wait 5; "
 | 
				
			||||||
                writeCfgInput(strInput)
 | 
					                writeCfgInput(strInput)
 | 
				
			||||||
    finally:
 | 
					    finally:
 | 
				
			||||||
        sock.close(
 | 
					        sock.close()
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user