From 153d4b1eca595064e819a4c307969dac56fca2ce Mon Sep 17 00:00:00 2001 From: jeboog Date: Mon, 22 Feb 2021 22:11:05 -0500 Subject: [PATCH] PEP8 reformatting --- pserver.py | 73 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/pserver.py b/pserver.py index 52b4bc6..8814124 100644 --- a/pserver.py +++ b/pserver.py @@ -7,66 +7,77 @@ app = Flask(__name__) + @app.route('/runSimulation/') # This is the endpoint that the javascript code will call to run simulation on server def runSimulation(input1): start_time = time.time() # Parse simulation parameters. - Param=input1.split("&") # Parameters are separated by '&' delimiter. + Param = input1.split("&") # Parameters are separated by '&' delimiter. print(Param) - ddd_state=(Param[0]=="true") + ddd_state = (Param[0] == "true") skip_sim = (Param[1] == "true") sumOut = (Param[2] == "true") logOut = (Param[3] == "true") - - packet_size=int(Param[4]) - rtsa=int(Param[5]) - max_queue_size=int(Param[6]) - ddd_mapping_delay=int(Param[7]) - propagation_delay=int(Param[8]) - number_of_ddd_ports=int(Param[9]) - time_to_next_ddd_port=int(Param[10]) - overlap_time_old_ddd=int(Param[11]) + packet_size = int(Param[4]) + rtsa = int(Param[5]) + max_queue_size = int(Param[6]) + ddd_mapping_delay = int(Param[7]) + propagation_delay = int(Param[8]) + number_of_ddd_ports = int(Param[9]) + time_to_next_ddd_port = int(Param[10]) + overlap_time_old_ddd = int(Param[11]) durationSim = float(Param[12]) numbSynAckResends = int(Param[13]) - clienttoRouter=int(Param[14]); - routertoClient=int(Param[15]); - routertoReflector=int(Param[16]); - routertoNormal=int(Param[17]); - normaltoRouter=int(Param[18]); - reflectortoRouter=int(Param[19]); - attackertoReflector=int(Param[20]); - queueLimit=int(Param[21]); - attackerType = float(Param[22]); - amplification = float(Param[23]); - + clienttoRouter = int(Param[14]) + routertoClient = int(Param[15]) + routertoReflector = int(Param[16]) + routertoNormal = int(Param[17]) + normaltoRouter = int(Param[18]) + reflectortoRouter = int(Param[19]) + attackertoReflector = int(Param[20]) + queueLimit = int(Param[21]) + attackerType = float(Param[22]) + amplification = float(Param[23]) - response = main.runSimulation(ddd_state, skip_sim, sumOut, logOut, packet_size,rtsa,max_queue_size,ddd_mapping_delay,propagation_delay,number_of_ddd_ports, time_to_next_ddd_port,overlap_time_old_ddd, durationSim, numbSynAckResends, clienttoRouter, routertoClient,routertoReflector,routertoNormal,normaltoRouter,reflectortoRouter,attackertoReflector, queueLimit, attackerType, amplification) + response = main.runSimulation(ddd_state, skip_sim, sumOut, + logOut, packet_size, rtsa, + max_queue_size, ddd_mapping_delay, + propagation_delay, number_of_ddd_ports, + time_to_next_ddd_port, overlap_time_old_ddd, + durationSim, numbSynAckResends, clienttoRouter, + routertoClient, routertoReflector, routertoNormal, + normaltoRouter, reflectortoRouter, + attackertoReflector, queueLimit, attackerType, + amplification) print('Backend Simulation Total Elapsed Time:', time.time() - start_time, 'seconds') # Converting response data structure into json string return jsonify(response) + @app.route('/download/') # This is the endpoint that the javascript code will call to run simulation on server def download(fileName): return send_file(fileName, as_attachment=True) + @app.route('/download2/') def download2(statement): - filename="" - newname="" - for i in range(0,len(statement)): + filename = "" + newname = "" + for i in range(0, len(statement)): # Search for delimiter. - if statement[i]=='&': + if(statement[i] == '&'): # Construct file names... - filename=statement[:i] - newname=statement[i+1:] + filename = statement[:i] + newname = statement[i+1:] break # Things are over. - return send_file(filename,as_attachment=True,attachment_filename=newname) + return send_file(filename, as_attachment=True, attachment_filename=newname) + @app.route('/') def index(): - return render_template('temp_index.html') # This renders index.html as the starting screen + return render_template('temp_index.html') # This renders index.html as the starting screen