How to use save_file method in localstack

Best Python code snippet using localstack_python

FileLogger.py

Source:FileLogger.py Github

copy

Full Screen

1import thread2from Motion.MovementSupervisor.Differential import DifferentialDriveMovementSupervisor3__author__ = 'Silvio'4class FileLoggerMovementSupervisor(DifferentialDriveMovementSupervisor):5 """6 Class to supervise a differential drive mobile robot in a movement using a .m file7 @param robot_parameters: Parameters of the robot8 @param file_name_provider: The name provider used to create the files9 @type robot_parameters: Motion.RobotParameters.DifferentialDriveRobotParameters10 @type file_name_provider: Motion.FileNameProvider.FileNameProvider11 """12 def __init__(self, robot_parameters, file_name_provider):13 super(FileLoggerMovementSupervisor, self).__init__()14 self.robot_parameters = robot_parameters15 self.file_name_provider = file_name_provider16 self.time_vector = list()17 self.sample_time_vector = list()18 self.x_position_vector = list()19 self.x_speed_vector = list()20 self.y_position_vector = list()21 self.y_speed_vector = list()22 self.z_position_vector = list()23 self.z_speed_vector = list()24 self.x_ref_vector = list()25 self.x_ref_speed_vector = list()26 self.y_ref_vector = list()27 self.y_ref_speed_vector = list()28 self.z_ref_vector = list()29 self.z_ref_speed_vector = list()30 self.speed_x_ref_vector = list()31 self.speed_y_ref_vector = list()32 self.angular_speed_1_vector = list()33 self.current_1_vector = list()34 self.angular_1_ref_vector = list()35 self.angular_speed_2_vector = list()36 self.current_2_vector = list()37 self.angular_2_ref_vector = list()38 self.updates_done = 039 def movement_begin(self, expected_updates):40 """41 Method to be called when the movement begins42 @param expected_updates: Number of times movement_updates wil be called43 @type expected_updates: int44 """45 self.updates_done = 046 self.time_vector = range(expected_updates)47 self.sample_time_vector = range(expected_updates)48 self.x_position_vector = range(expected_updates)49 self.x_speed_vector = range(expected_updates)50 self.y_position_vector = range(expected_updates)51 self.y_speed_vector = range(expected_updates)52 self.z_position_vector = range(expected_updates)53 self.z_speed_vector = range(expected_updates)54 self.x_ref_vector = range(expected_updates)55 self.x_ref_speed_vector = range(expected_updates)56 self.y_ref_vector = range(expected_updates)57 self.y_ref_speed_vector = range(expected_updates)58 self.z_ref_vector = range(expected_updates)59 self.z_ref_speed_vector = range(expected_updates)60 self.speed_x_ref_vector = range(expected_updates)61 self.speed_y_ref_vector = range(expected_updates)62 self.angular_speed_1_vector = range(expected_updates)63 self.current_1_vector = range(expected_updates)64 self.angular_1_ref_vector = range(expected_updates)65 self.angular_speed_2_vector = range(expected_updates)66 self.current_2_vector = range(expected_updates)67 self.angular_2_ref_vector = range(expected_updates)68 def movement_update(self, robot_state):69 """70 Method to be called when the state of the robot changes during the movement71 @type robot_state: Motion.RobotState.DifferentialDriveRobotState72 @param robot_state: the new state of the robot73 """74 if self.updates_done >= len(self.x_position_vector):75 return76 self.sample_time_vector[self.updates_done] = robot_state.elapsed_time77 self.x_position_vector[self.updates_done] = robot_state.location.x_position78 self.y_position_vector[self.updates_done] = robot_state.location.y_position79 self.z_position_vector[self.updates_done] = robot_state.location.z_position80 self.x_ref_vector[self.updates_done] = robot_state.reference_location.x_position81 self.y_ref_vector[self.updates_done] = robot_state.reference_location.y_position82 self.z_ref_vector[self.updates_done] = robot_state.reference_location.z_position83 self.x_ref_speed_vector[self.updates_done] = robot_state.reference_speed.x_speed84 self.y_ref_speed_vector[self.updates_done] = robot_state.reference_speed.y_speed85 self.z_ref_speed_vector[self.updates_done] = robot_state.reference_speed.z_speed86 self.speed_x_ref_vector[self.updates_done] = robot_state.x_speed_ref87 self.speed_y_ref_vector[self.updates_done] = robot_state.y_speed_ref88 self.angular_speed_1_vector[self.updates_done] = robot_state.angular_speed_189 self.angular_1_ref_vector[self.updates_done] = robot_state.set_point_190 self.current_1_vector[self.updates_done] = robot_state.current_191 self.angular_speed_2_vector[self.updates_done] = robot_state.angular_speed_292 self.angular_2_ref_vector[self.updates_done] = robot_state.set_point_293 self.current_2_vector[self.updates_done] = robot_state.current_294 self.updates_done += 195 def movement_end(self):96 """97 Method to be called when the movement ends98 """99 file_name = self.file_name_provider.get_file_name() + ".m"100 thread.start_new_thread(FileLoggerMovementSupervisor.file_writer_thread,101 (file_name, self.updates_done, self.x_position_vector, self.y_position_vector,102 self.z_position_vector, self.x_speed_vector, self.y_speed_vector, self.z_speed_vector,103 self.x_ref_vector, self.y_ref_vector, self.z_ref_vector, self.x_ref_speed_vector,104 self.y_ref_speed_vector, self.z_ref_speed_vector, self.angular_speed_1_vector,105 self.angular_speed_2_vector, self.current_1_vector, self.current_2_vector,106 self.angular_1_ref_vector, self.angular_2_ref_vector, self.speed_x_ref_vector,107 self.speed_y_ref_vector, self.sample_time_vector, self.time_vector,108 self.robot_parameters.wheel_radius, self.robot_parameters.wheel_distance,109 self.robot_parameters.constant_b, self.robot_parameters.constant_k1,110 self.robot_parameters.constant_k2, self.robot_parameters.constant_kc,111 self.robot_parameters.constant_ki, self.robot_parameters.constant_kd))112 @staticmethod113 def file_writer_thread(file_name, updates_done, x_position_vector, y_position_vector, z_position_vector,114 x_speed_vector,115 y_speed_vector, z_speed_vector, x_ref_vector, y_ref_vector, z_ref_vector,116 x_ref_speed_vector,117 y_ref_speed_vector, z_ref_speed_vector, angular_speed_1_vector, angular_speed_2_vector,118 current_1_vector, current_2_vector, angular_1_ref_vector, angular_2_ref_vector,119 speed_x_ref_vector, speed_y_ref_vector, sample_time_vector, time_vector, wheel_radius,120 wheel_distance, constant_b, constant_k1, constant_k2, constant_kc, constant_ki,121 constant_kd):122 time_vector[0] = 0.123 for i in range(updates_done - 1):124 time_vector[i + 1] = time_vector[i] + sample_time_vector[i]125 x_speed_vector[i] = (x_position_vector[i + 1] - x_position_vector[i]) / \126 (sample_time_vector[i])127 y_speed_vector[i] = (y_position_vector[i + 1] - y_position_vector[i]) / \128 (sample_time_vector[i])129 z_speed_vector[i] = (z_position_vector[i + 1] - z_position_vector[i]) / \130 (sample_time_vector[i])131 x_speed_vector[updates_done - 1] = x_speed_vector[updates_done - 2]132 y_speed_vector[updates_done - 1] = y_speed_vector[updates_done - 2]133 z_speed_vector[updates_done - 1] = z_speed_vector[updates_done - 2]134 save_file = open(file_name, 'w')135 save_file.write("close all;\r\n")136 save_file.write("clear all;\r\n")137 save_file.write("clc;\r\n\r\n")138 save_file.write("count=%f;\r\n" % updates_done)139 save_file.write("radius=%f;\r\n" % wheel_radius)140 save_file.write("distance=%f;\r\n" % wheel_distance)141 save_file.write("constant_b=%f;\r\n" % constant_b)142 save_file.write("constant_k1=%f;\r\n" % constant_k1)143 save_file.write("constant_k2=%f;\r\n" % constant_k2)144 save_file.write("constant_ki=%f;\r\n" % constant_ki)145 save_file.write("constant_kd=%f;\r\n" % constant_kd)146 save_file.write("constant_kc=%f;\r\n" % constant_kc)147 for i in range(updates_done):148 save_file.write("speed1(%d) = %f ;\r\n" % (i + 1, angular_speed_1_vector[i]))149 save_file.write("speed2(%d) = %f ;\r\n" % (i + 1, angular_speed_2_vector[i]))150 save_file.write("current1(%d) = %f ;\r\n" % (i + 1, current_1_vector[i]))151 save_file.write("current2(%d) = %f ;\r\n" % (i + 1, current_2_vector[i]))152 save_file.write("time(%d) = %f ;\r\n" % (i + 1, time_vector[i]))153 save_file.write("sample_time(%d) = %f ;\r\n" % (i + 1, sample_time_vector[i]))154 save_file.write("ref1(%d) = %f ;\r\n" % (i + 1, angular_1_ref_vector[i]))155 save_file.write("ref2(%d) = %f ;\r\n" % (i + 1, angular_2_ref_vector[i]))156 save_file.write("x(%d) = %f ;\r\n" % (i + 1, x_position_vector[i]))157 save_file.write("y(%d) = %f ;\r\n" % (i + 1, y_position_vector[i]))158 save_file.write("z(%d) = %f ;\r\n" % (i + 1, z_position_vector[i]))159 save_file.write("xd(%d) = %f ;\r\n" % (i + 1, x_ref_vector[i]))160 save_file.write("yd(%d) = %f ;\r\n" % (i + 1, y_ref_vector[i]))161 save_file.write("zd(%d) = %f ;\r\n" % (i + 1, z_ref_vector[i]))162 save_file.write("dx(%d) = %f ;\r\n" % (i + 1, x_speed_vector[i]))163 save_file.write("dy(%d) = %f ;\r\n" % (i + 1, y_speed_vector[i]))164 save_file.write("dz(%d) = %f ;\r\n" % (i + 1, z_speed_vector[i]))165 save_file.write("dxd(%d) = %f ;\r\n" % (i + 1, x_ref_speed_vector[i]))166 save_file.write("dyd(%d) = %f ;\r\n" % (i + 1, y_ref_speed_vector[i]))167 save_file.write("dzd(%d) = %f ;\r\n" % (i + 1, z_ref_speed_vector[i]))168 save_file.write("dxr(%d) = %f ;\r\n" % (i + 1, speed_x_ref_vector[i]))169 save_file.write("dyr(%d) = %f ;\r\n" % (i + 1, speed_y_ref_vector[i]))170 save_file.write("\r\nfigure;\r\n")171 save_file.write("plot(time,x,time,xd) ;\r\n")172 save_file.write("title(\'X Position vs Time.\') ;\r\n")173 save_file.write("legend(\'X\',\'X - Reference\') ;\r\n")174 save_file.write("xlabel(\'Time (s)') ;\r\n")175 save_file.write("ylabel(\'X Position (m)') ;\r\n")176 save_file.write("grid on\r\n")177 save_file.write("\r\nfigure;\r\n")178 save_file.write("plot(time,y,time,yd) ;\r\n")179 save_file.write("title(\'Y Position vs Time.\') ;\r\n")180 save_file.write("legend(\'Y\',\'Y - Reference\') ;\r\n")181 save_file.write("xlabel(\'Time (s)') ;\r\n")182 save_file.write("ylabel(\'Y Position (m)') ;\r\n")183 save_file.write("grid on\r\n")184 save_file.write("\r\nfigure;\r\n")185 save_file.write("plot(time,z,time,zd) ;\r\n")186 save_file.write("title(\'Orientation vs Time.\') ;\r\n")187 save_file.write("legend(\'Z\',\'Z - Reference\') ;\r\n")188 save_file.write("xlabel(\'Time (s)') ;\r\n")189 save_file.write("ylabel(\'Z Position (rad)') ;\r\n")190 save_file.write("grid on\r\n")191 save_file.write("\r\nfigure;\r\n")192 save_file.write("plot(x,y,xd,yd) ;\r\n")193 save_file.write("title(\'Y Position vs X Position (Path).\') ;\r\n")194 save_file.write("legend(\'Path\',\'Path - Reference\') ;\r\n")195 save_file.write("xlabel(\'X Position (m)') ;\r\n")196 save_file.write("ylabel(\'Y Position (m)') ;\r\n")197 save_file.write("grid on\r\n")198 save_file.write("\r\nfigure;\r\n")199 save_file.write("plot(time,speed1,time,ref1) ;\r\n")200 save_file.write("title(\'WL vs Time.\') ;\r\n")201 save_file.write("legend(\'WL\',\'WL - Reference\') ;\r\n")202 save_file.write("xlabel(\'Time (s)') ;\r\n")203 save_file.write("ylabel(\'Angular Speed (rad/s)') ;\r\n")204 save_file.write("grid on\r\n")205 save_file.write("\r\nfigure;\r\n")206 save_file.write("plot(time,speed2,time,ref2) ;\r\n")207 save_file.write("title(\'WR vs Time.\') ;\r\n")208 save_file.write("legend(\'WR\',\'WR - Reference\') ;\r\n")209 save_file.write("xlabel(\'Time (s)') ;\r\n")210 save_file.write("ylabel(\'Angular Speed (rad/s)') ;\r\n")211 save_file.write("grid on\r\n")212 save_file.write("\r\nfigure;\r\n")213 save_file.write("plot(time,current1,time,current2) ;\r\n")214 save_file.write("title(\'Currents vs Time.\') ;\r\n")215 save_file.write("legend(\'Left Motor\',\'Right Motor\') ;\r\n")216 save_file.write("xlabel(\'Time (s)') ;\r\n")217 save_file.write("ylabel(\'Current (A)') ;\r\n")218 save_file.write("grid on\r\n")219 save_file.write("\r\nfigure;\r\n")220 save_file.write("plot(time,dx,time,dxr,time,dxd) ;\r\n")221 save_file.write("title(\'X Speed vs Time.\') ;\r\n")222 save_file.write("legend(\'DX\',\'DXR - Reference\',\'DXD - Planning\') ;\r\n")223 save_file.write("xlabel(\'Time (s)') ;\r\n")224 save_file.write("ylabel(\'X Speed (m/s)') ;\r\n")225 save_file.write("grid on\r\n")226 save_file.write("\r\nfigure;\r\n")227 save_file.write("plot(time,dy,time,dyr,time,dyd) ;\r\n")228 save_file.write("title(\'Y Speed vs Time.\') ;\r\n")229 save_file.write("legend(\'DY\',\'DYR - Reference\',\'DYD - Planning\') ;\r\n")230 save_file.write("xlabel(\'Time (s)') ;\r\n")231 save_file.write("ylabel(\'Y Speed (m/s)') ;\r\n")232 save_file.write("grid on\r\n")233 save_file.write("\r\nfigure;\r\n")234 save_file.write("plot(time,dz,time,dzd) ;\r\n")235 save_file.write("title(\'Z Speed vs Time.\') ;\r\n")236 save_file.write("legend(\'DZ\',\'DZD - Planning\') ;\r\n")237 save_file.write("xlabel(\'Time (s)') ;\r\n")238 save_file.write("ylabel(\'Z Speed (rad/s)') ;\r\n")239 save_file.write("grid on\r\n")240 save_file.write("\r\nfigure;\r\n")241 save_file.write("plot(sample_time*1000);\r\n")242 save_file.write("title('Sample Time.');\r\n")243 save_file.write("ylabel ( 'Sample Time (ms)' ) ;\r\n")244 save_file.write("xlabel ( 'Sample (k)' ) ;\r\n")245 save_file.write("grid on\r\n")246 save_file.flush()...

Full Screen

Full Screen

export_takk.py

Source:export_takk.py Github

copy

Full Screen

...212#213# def handle(self, *args, **options):214#215# mod = ModifierCategory().export().xlsx216# self.save_file(mod, 'modifier category')217#218# mod_item = Modifier().export().xlsx219# self.save_file(mod_item, 'modifier')220#221# order_message = Message().export().xlsx222# self.save_file(order_message, 'order message')223#224# order_message_item = MessageItem().export().xlsx225# self.save_file(order_message_item, 'order message item')226#227# delivery = Delivery().export().xlsx228# self.save_file(delivery, 'delivery')229#230# order = Order().export().xlsx231# self.save_file(order, 'order')232#233# cart = Cart().export().xlsx234# self.save_file(cart, 'cart')235#236# cart_modifier = CartModifier().export().xlsx237# self.save_file(cart_modifier, 'cart modifier')238#239# favorite_cart_item = FavoriteCartItem().export().xlsx240# self.save_file(favorite_cart_item, 'favorite cart item')241#242# favorite_cart = FavoriteCart().export().xlsx243# self.save_file(favorite_cart, 'favorite cart')244#245# transaction = Transaction().export().xlsx246# self.save_file(transaction, 'transaction')247#248# stripe_transaction = StripeTransaction().export().xlsx249# self.save_file(stripe_transaction, 'stripe transaction')250#251# paypal_transaction = PaypalTransaction().export().xlsx252# self.save_file(paypal_transaction, 'paypal transaction')253#254# cafe_menu = CafeMenu().export().xlsx255# self.save_file(cafe_menu, 'cafe_menu')256#257# product_category = ProductCategory().export().xlsx258# self.save_file(product_category, 'product category')259#260# product_image = ProductImage().export().xlsx261# self.save_file(product_image, 'product image')262#263# product = Product().export().xlsx264# self.save_file(product, 'product')265#266# product_size = ProductSize().export().xlsx267# self.save_file(product_size, 'product_size')268#269# size = Size().export().xlsx270# self.save_file(size, 'size')271#272# cafe_meals = CafeMeals().export().xlsx273# self.save_file(cafe_meals, 'cafe meals')274#275# product_modifier = ProductModifier().export().xlsx276# self.save_file(product_modifier, 'product modifier')277#278# product_profile = ProductProfile().export().xlsx279# self.save_file(product_profile, 'product profile')280#281# album = Album().export().xlsx282# self.save_file(album, 'album')283#284# file = File().export().xlsx285# self.save_file(file, 'file')286#287# user = User().export().xlsx288# self.save_file(user, 'user')289#290# budget = Budget().export().xlsx291# self.save_file(budget, 'budget')292#293# category = Category().export().xlsx294# self.save_file(category, 'cafe category')295#296# week_time = WeekTime().export().xlsx297# self.save_file(week_time, 'week time')298#299# cafe = Cafe().export().xlsx300# self.save_file(cafe, 'cafe')301#302# company = Company().export().xlsx303# self.save_file(company, 'company')304#305# cafe_general_settings = CafeGeneralSettings().export().xlsx306# self.save_file(cafe_general_settings, 'cafe general settings')307#308# cashier = Cashier().export().xlsx309# self.save_file(cashier, 'cashier')310#311# employee = Employee().export().xlsx312# self.save_file(employee, 'employee')313#314# point = Point().export().xlsx315# self.save_file(point, 'point')316#317# free_item = FreeItem().export().xlsx318# self.save_file(free_item, 'free_item')319#320# additional_percent = AdditionalPercent().export().xlsx321# self.save_file(additional_percent, 'additional percent')322#323# cashback = Cashback().export().xlsx324# self.save_file(cashback, 'cashback')325#326# mod = ModifierCategory().export().xlsx327# self.save_file(mod, 'modifier category')328#329# mod = ModifierCategory().export().xlsx330# self.save_file(mod, 'modifier category')331#332# mod = ModifierCategory().export().xlsx333# self.save_file(mod, 'modifier category')334#335# mod = ModifierCategory().export().xlsx336# self.save_file(mod, 'modifier category')337#338# mod = ModifierCategory().export().xlsx339# self.save_file(mod, 'modifier category')340#341# mod = ModifierCategory().export().xlsx342# self.save_file(mod, 'modifier category')343#344# mod = ModifierCategory().export().xlsx345# self.save_file(mod, 'modifier category')346#347# mod = ModifierCategory().export().xlsx348# self.save_file(mod, 'modifier category')349#350# mod = ModifierCategory().export().xlsx351# self.save_file(mod, 'modifier category')352#353# mod = ModifierCategory().export().xlsx354# self.save_file(mod, 'modifier category')355#356# mod = ModifierCategory().export().xlsx357# self.save_file(mod, 'modifier category')358#359# mod = ModifierCategory().export().xlsx360# self.save_file(mod, 'modifier category')361#362# mod = ModifierCategory().export().xlsx363# self.save_file(mod, 'modifier category')364#365# mod = ModifierCategory().export().xlsx366# self.save_file(mod, 'modifier category')367#368# mod = ModifierCategory().export().xlsx369# self.save_file(mod, 'modifier category')370#371# @staticmethod372# def save_file(x, name):373# with open('{}.xlsx'.format(name), 'wb') as save_user:374# save_user.write(x)375#376#...

Full Screen

Full Screen

home.py

Source:home.py Github

copy

Full Screen

1# Oliver2import math3import pickle4import time5def game(save_file):6 print("Hero is level", Hero)7 print("Evil is level", Enemy)8ver = 19while ver != "X":10 print("Welcome to Herterra")11 ver = input("N for new game, L to load or X to exit: ")12 if ver == "N":13 saver = 114 while saver == 1:15 save_file = input("Enter name for save: ")16 if save_file == "X":17 saver == 018 break19 try:20 open((save_file + ".pkl"), "rb")21 print(save_file, "is already being used, try a diferent name: ")22 except:23 with open((save_file + ".pkl"), "wb") as f:24 import base25 pickle.dump([base.Hero, base.Enemy], f)26 with open((save_file + ".pkl"), "rb") as f:27 pickle.load(f)28 print("save created")29 saver == 030 game(save_file)31 elif ver == "L":32 loader = 133 while loader == 1:34 save_file = input("Enter save name or X to back: ")35 if save_file == "X":36 loader == 037 break38 try:39 with open((save_file + ".pkl"), "rb") as f:40 pickle.load(f)41 print("save loaded")42 loader = 043 game(save_file)44 except:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful