def stop_test(request, running_test_id): running_test = TestRunning.objects.get(id=running_test_id) workspace = running_test.workspace jris = json.loads( json.dumps( running_test.jmeter_remote_instances, indent=4, sort_keys=True)) if jris is not None: for jri in jris: hostname = jri.get('hostname') pid = int(jri.get('pid')) ssh_key_id = int(LoadGeneratorServer.objects.get(address=hostname).ssh_key_id) ssh_key = SSHKey.objects.get(id=ssh_key_id).path ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(hostname, key_filename=ssh_key) cmds = ['kill -9 {0}'.format(str(pid))] stdin, stdout, stderr = ssh.exec_command(' ; '.join(cmds)) response = [] generate_data(running_test.id) try: proxy_process = psutil.Process(running_test.pid) proxy_process.terminate() response = [{ "message": "test was stopped", "test_id": running_test_id, "pid": running_test.pid }] running_test.delete() except psutil.NoSuchProcess: response = [{ "message": "test does not exist", "test_id": running_test_id }] running_test.delete() #post-test script execution: project_id = running_test.project_id header = script_header(project_id) project = Project.objects.get(id=project_id) body = project.script_post script = header + body with open(workspace + '/logs/' + "script_pre.log", 'w') as f: rc = call(script, shell=True, stdout=f) return JsonResponse(response, safe=False)
def main(): print("----------------------") print("| codedrome.com |") print("| Logarithmic Plots |") print("----------------------\n") data = datagenerator.generate_data() print_data(data) logarithmicplot.draw_logarithmic_plot(720, 540, "Logarithmic Plot", data, 6, "logarithmicplot1.svg")
import datagenerator import matrix as m matplotlib.rcParams.update({'font.size': 16}) # data_groundtruth() has the following inputs: # Generates Data # Input variables are: # initial position meters # initial velocity km/h # final velocity (should be a negative number) km/h # acceleration (should be a negative number) m/s^2 # how long the vehicle should idle # how long the vehicle should drive in reverse at constant velocity # time between lidar measurements in milliseconds time_groundtruth, distance_groundtruth, velocity_groundtruth, acceleration_groundtruth = datagenerator.generate_data( 5, 100, -10, -10, 5000, 5000, 50) data_groundtruth = pd.DataFrame({ 'time': time_groundtruth, 'distance': distance_groundtruth, 'velocity': velocity_groundtruth, 'acceleration': acceleration_groundtruth }) # ### Visualizing the Tracked Object Distance # # The next cell visualizes the simulating data. The first visualization shows # the object distance over time. You can see that the car is moving forward # although decelerating. Then the car stops for 5 seconds and then drives # backwards for 5 seconds. # In[2]:
def fetch_new_values(socketio, data): while True: generate_data(data) socketio.emit("car_data", data) sleep(0.5)