Skip to content

Commit 83f4e6c

Browse files
patrickelectricjoaoantoniocardoso
authored andcommitted
generate: template: devices: Remove trailing spaces
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
1 parent 13338a0 commit 83f4e6c

File tree

5 files changed

+42
-42
lines changed

5 files changed

+42
-42
lines changed

generate/templates/omniscan450.py.in

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class Omniscan450(PingDevice):
141141
sync = file.read(2)
142142
if sync != b'BR':
143143
return None
144-
144+
145145
payload_len_bytes = file.read(2)
146146
if len(payload_len_bytes) < 2:
147147
return None
@@ -167,7 +167,7 @@ class Omniscan450(PingDevice):
167167
protocol = "tcp"
168168
elif self.iodev.type == socket.SOCK_DGRAM:
169169
protocol = "udp"
170-
170+
171171
if self.server_address:
172172
url = f"{protocol}://{self.server_address[0]}:{self.server_address[1]}"
173173
else:
@@ -220,12 +220,12 @@ class Omniscan450(PingDevice):
220220
checksum = sum(msg_data) & 0xFFFF
221221
msg_data += bytearray(struct.pack(pingmessage.PingMessage.endianess + pingmessage.PingMessage.checksum_format, checksum))
222222

223-
m.msg_data = msg_data
223+
m.msg_data = msg_data
224224
m.checksum = checksum
225225

226226
return m
227-
228-
# Enable logging
227+
228+
# Enable logging
229229
def start_logging(self, new_log = False, log_directory = None):
230230
if self.logging:
231231
return
@@ -243,7 +243,7 @@ class Omniscan450(PingDevice):
243243
def new_log(self, log_directory=None):
244244
dt = datetime.now()
245245
save_name = dt.strftime("%Y-%m-%d-%H-%M")
246-
246+
247247
if log_directory is None:
248248
project_root = Path.cwd().parent
249249
self.log_directory = project_root / "logs/omniscan"
@@ -270,7 +270,7 @@ class Omniscan450(PingDevice):
270270
def write_data(self, msg):
271271
if not self.logging or not self.current_log:
272272
return
273-
273+
274274
try:
275275
if self.bytes_written > MAX_LOG_SIZE_MB * 1000000:
276276
self.new_log(log_directory=self.log_directory)
@@ -314,18 +314,18 @@ class Omniscan450(PingDevice):
314314
def connect_tcp(self, host: str = None, port: int = 12345, timeout: float = 5.0):
315315
if host is None:
316316
host = '0.0.0.0'
317-
317+
318318
self.server_address = (host, port)
319319
try:
320320
print("Opening %s:%d" % self.server_address)
321321
self.iodev = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
322322
self.iodev.settimeout(timeout)
323323
self.iodev.connect(self.server_address)
324324
self.iodev.setblocking(0)
325-
325+
326326
except socket.timeout:
327327
print("Unable to connect to device")
328-
raise Exception("Connection timed out after {0} seconds".format(timeout))
328+
raise Exception("Connection timed out after {0} seconds".format(timeout))
329329
except Exception as exception:
330330
raise Exception("Failed to open the given TCP port: {0}".format(exception))
331331

@@ -355,7 +355,7 @@ class Omniscan450(PingDevice):
355355

356356
except BlockingIOError as exception:
357357
pass # Ignore exceptions related to read before connection, a result of UDP nature
358-
358+
359359
except ConnectionResetError as e:
360360
raise ConnectionError("Socket connection was reset: %s" % str(e))
361361

generate/templates/ping1d.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Ping1D(PingDevice):
1818
msg = pingmessage.PingMessage()
1919
# legacy hack logic is in PingMessage
2020
# TODO: remove that logic and construct/assemble an arbitrary PingMessage
21-
msg.request_id = m_id
21+
msg.request_id = m_id
2222
msg.pack_msg_data()
2323
self.write(msg.msg_data)
2424

generate/templates/ping360.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class Ping360(PingDevice):
125125
0
126126
)
127127
return self.wait_message([definitions.PING360_DEVICE_DATA, definitions.COMMON_NACK], 4.0)
128-
128+
129129
def transmit(self):
130130
return self.transmitAngle(self._angle)
131131

generate/templates/s500.py.in

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class S500(PingDevice):
118118
def connect_tcp(self, host: str = None, port: int = 12345, timeout: float = 5.0):
119119
if host is None:
120120
host = '0.0.0.0'
121-
121+
122122
self.server_address = (host, port)
123123
try:
124124
print("Opening %s:%d" % self.server_address)
@@ -129,7 +129,7 @@ class S500(PingDevice):
129129

130130
except socket.timeout:
131131
print("Unable to connect to device")
132-
raise Exception("Connection timed out after {0} seconds".format(timeout))
132+
raise Exception("Connection timed out after {0} seconds".format(timeout))
133133
except Exception as exception:
134134
raise Exception("Failed to open the given TCP port: {0}".format(exception))
135135

@@ -158,9 +158,9 @@ class S500(PingDevice):
158158

159159
except BlockingIOError as exception:
160160
pass # Ignore exceptions related to read before connection, a result of UDP nature
161-
161+
162162
except ConnectionResetError as e:
163-
raise ConnectionError("Socket connection was reset: %s" % str(e))
163+
raise ConnectionError("Socket connection was reset: %s" % str(e))
164164

165165
# Converts power results to correct format
166166
@staticmethod
@@ -170,14 +170,14 @@ class S500(PingDevice):
170170
scaled_power_results.append(msg.min_pwr_db + (msg.pwr_results[i] / 65535.0) * (msg.max_pwr_db - msg.min_pwr_db))
171171
final_power_results = tuple(scaled_power_results)
172172
return final_power_results
173-
173+
174174
# Reads a single packet from a file
175175
@staticmethod
176176
def read_packet(file):
177177
sync = file.read(2)
178178
if sync != b'BR':
179179
return None
180-
180+
181181
payload_len_bytes = file.read(2)
182182
if len(payload_len_bytes) < 2:
183183
return None
@@ -203,7 +203,7 @@ class S500(PingDevice):
203203
protocol = "tcp"
204204
elif self.iodev.type == socket.SOCK_DGRAM:
205205
protocol = "udp"
206-
206+
207207
if self.server_address:
208208
url = f"{protocol}://{self.server_address[0]}:{self.server_address[1]}"
209209
else:
@@ -256,12 +256,12 @@ class S500(PingDevice):
256256
checksum = sum(msg_data) & 0xFFFF
257257
msg_data += bytearray(struct.pack(pingmessage.PingMessage.endianess + pingmessage.PingMessage.checksum_format, checksum))
258258

259-
m.msg_data = msg_data
259+
m.msg_data = msg_data
260260
m.checksum = checksum
261261

262262
return m
263263

264-
# Enable logging
264+
# Enable logging
265265
def start_logging(self, new_log = False, log_directory = None):
266266
if self.logging:
267267
return
@@ -270,15 +270,15 @@ class S500(PingDevice):
270270

271271
if self.current_log is None or new_log:
272272
self.new_log(log_directory)
273-
273+
274274
def stop_logging(self):
275275
self.logging = False
276276

277277
# Creates a new log file
278278
def new_log(self, log_directory=None):
279279
dt = datetime.now()
280280
save_name = dt.strftime("%Y-%m-%d-%H-%M")
281-
281+
282282
if log_directory is None:
283283
project_root = Path.cwd().parent
284284
self.log_directory = project_root / "logs/s500"
@@ -291,7 +291,7 @@ class S500(PingDevice):
291291

292292
if log_path.exists():
293293
log_path.unlink() # delete existing file (program was restarted quickly)
294-
294+
295295
self.current_log = log_path
296296
self.logging = True
297297
self.bytes_written = 0
@@ -304,7 +304,7 @@ class S500(PingDevice):
304304
def write_data(self, msg):
305305
if not self.logging or not self.current_log:
306306
return
307-
307+
308308
try:
309309
if self.bytes_written > MAX_LOG_SIZE_MB * 1000000:
310310
self.new_log(log_directory=self.log_directory)

generate/templates/surveyor240.py.in

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class Surveyor240(PingDevice):
135135
sync = file.read(2)
136136
if sync != b'BR':
137137
return None
138-
138+
139139
payload_len_bytes = file.read(2)
140140
if len(payload_len_bytes) < 2:
141141
return None
@@ -161,7 +161,7 @@ class Surveyor240(PingDevice):
161161
protocol = "tcp"
162162
elif self.iodev.type == socket.SOCK_DGRAM:
163163
protocol = "udp"
164-
164+
165165
if self.server_address:
166166
url = f"{protocol}://{self.server_address[0]}:{self.server_address[1]}"
167167
else:
@@ -214,12 +214,12 @@ class Surveyor240(PingDevice):
214214
checksum = sum(msg_data) & 0xFFFF
215215
msg_data += bytearray(struct.pack(pingmessage.PingMessage.endianess + pingmessage.PingMessage.checksum_format, checksum))
216216

217-
m.msg_data = msg_data
217+
m.msg_data = msg_data
218218
m.checksum = checksum
219219

220220
return m
221221

222-
# Enable logging
222+
# Enable logging
223223
def start_logging(self, new_log = False, log_directory = None):
224224
if self.logging:
225225
return
@@ -228,15 +228,15 @@ class Surveyor240(PingDevice):
228228

229229
if self.current_log is None or new_log:
230230
self.new_log(log_directory)
231-
231+
232232
def stop_logging(self):
233233
self.logging = False
234234

235235
# Creates a new log file
236236
def new_log(self, log_directory=None):
237237
dt = datetime.now()
238238
save_name = dt.strftime("%Y-%m-%d-%H-%M")
239-
239+
240240
if log_directory is None:
241241
project_root = Path.cwd().parent
242242
self.log_directory = project_root / "logs/surveyor"
@@ -249,7 +249,7 @@ class Surveyor240(PingDevice):
249249

250250
if log_path.exists():
251251
log_path.unlink() # delete existing file (program was restarted quickly)
252-
252+
253253
self.current_log = log_path
254254
self.logging = True
255255
self.bytes_written = 0
@@ -262,7 +262,7 @@ class Surveyor240(PingDevice):
262262
def write_data(self, msg):
263263
if not self.logging or not self.current_log:
264264
return
265-
265+
266266
try:
267267
if self.bytes_written > MAX_LOG_SIZE_MB * 1000000:
268268
self.new_log(log_directory=self.log_directory)
@@ -291,9 +291,9 @@ class Surveyor240(PingDevice):
291291
self.write(response.msg_data)
292292

293293
return True
294-
294+
295295
return super().handle_message(msg)
296-
296+
297297
# Override wait_message to also handle UTC requests from Surveyor and for creating atof_t data
298298
def wait_message(self, message_ids, timeout=0.5):
299299
tstart = time.time()
@@ -302,7 +302,7 @@ class Surveyor240(PingDevice):
302302
if msg is not None:
303303
if msg.message_id == definitions.SURVEYOR240_UTC_REQUEST:
304304
continue
305-
305+
306306
if msg.message_id == definitions.SURVEYOR240_ATOF_POINT_DATA:
307307
atof_byte_array = bytearray(msg.atof_point_data)
308308
formatted_atof_array = struct.unpack('<' + 'I' * (4*int(msg.num_points)), atof_byte_array)
@@ -324,7 +324,7 @@ class Surveyor240(PingDevice):
324324
def connect_tcp(self, host: str = None, port: int = 12345, timeout: float = 5.0):
325325
if host is None:
326326
host = '0.0.0.0'
327-
327+
328328
self.server_address = (host, port)
329329
try:
330330
print("Opening %s:%d" % self.server_address)
@@ -335,7 +335,7 @@ class Surveyor240(PingDevice):
335335

336336
except socket.timeout:
337337
print("Unable to connect to device")
338-
raise Exception("Connection timed out after {0} seconds".format(timeout))
338+
raise Exception("Connection timed out after {0} seconds".format(timeout))
339339
except Exception as exception:
340340
raise Exception("Failed to open the given TCP port: {0}".format(exception))
341341

@@ -365,9 +365,9 @@ class Surveyor240(PingDevice):
365365

366366
except BlockingIOError as exception:
367367
pass # Ignore exceptions related to read before connection, a result of UDP nature
368-
368+
369369
except ConnectionResetError as e:
370-
raise ConnectionError("Socket connection was reset: %s" % str(e))
370+
raise ConnectionError("Socket connection was reset: %s" % str(e))
371371

372372
# Class to represent the atof_t struct
373373
class atof_t:
@@ -394,7 +394,7 @@ class Surveyor240(PingDevice):
394394

395395
atof = Surveyor240.atof_t(angle, tof, reserved)
396396
atof_list.append(atof)
397-
397+
398398
return tuple(atof_list)
399399

400400
# Creates yz_point_data and fills it with the correct data from the message

0 commit comments

Comments
 (0)