示例#1
0
def server_stop_notif():  # just like a broadcast thread, to notify every connected clients to leave
    for user in Global.list_user:
        message = Global.message("System", user.name, "serverstop")
        Global.message_rep[user.name].append(message)
        Global.event[user.name].set()
    disp = "The server_stop notification has been sent to all the online clients, and they will automatically log out right now."
    print disp
    Global.log.write(disp + "\n")
    #------------ we should do the database backup task right here ------------
    Global.save_para(Global.MaxCon, Global.BLOCK_TIME, Global.LAST_HOUR, Global.TIME_OUT)
    disp = "[backup]MaxCon, BLOCK_TIME, LAST_HOUR, TIME_OUT all have been stored."
    print disp
    Global.log.write(disp + "\n")

    Global.save_u_p()
    disp = "[backup]user_password repository has been stored."
    print disp
    Global.log.write(disp + "\n")

    Global.save_message_rep()
    disp = "[backup]message_rep has been stored."
    print disp
    Global.log.write(disp + "\n")

    Global.save_file_rep()
    disp = "[backup]file_rep has been stored."
    print disp
    Global.log.write(disp + "\n")

    Global.save_block_rep()
    disp = "[backup]block_rep has been stored."
    print disp
    Global.log.write(disp + "\n")

    Global.save_list_block()
    disp = "[backup]list_block has been stored."
    print disp
    Global.log.write(disp + "\n")
    #---------------------------- backup done ---------------------------------
    return