#NEWLINE# @ task ( ignore_result = True ) #NEWLINE# def set_server_map( server_id , map_id ) : #NEWLINE# #INDENT# logger = set_server_map . get_logger ( ) #NEWLINE# try : #NEWLINE# #INDENT# map_obj = Map . objects . get ( pk = map_id ) #NEWLINE# #UNINDENT# except Map . DoesNotExist : #NEWLINE# #INDENT# logger . error ( '[S-{0}/M- ] Map not found (pk={1}).' . format ( server_id , map_id ) ) #NEWLINE# return False #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# server = Server . objects . get ( pk = server_id ) #NEWLINE# #UNINDENT# except Server . DoesNotExist : #NEWLINE# #INDENT# logger . error ( '[S- /M-{1}] Server not found (pk={0}).' . format ( server_id , map_id ) ) #NEWLINE# return False #NEWLINE# #UNINDENT# if ( server . played_map == map_obj ) : #NEWLINE# #INDENT# logger . info ( '[S-{0}/M-{1}] Map already set as currently played.' . format ( server_id , map_id ) ) #NEWLINE# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# old_map_id = server . played_map_id #NEWLINE# #UNINDENT# server . played_map = map_obj #NEWLINE# server . save ( ) #NEWLINE# logger . info ( '[S-{0}/M-{1}] Map set as currently played (was: M-{2}).' . format ( server_id , map_obj , old_map_id ) )