You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is just a copy of connect_serial() method from brping/device.py (ver 0.1.5)
defconnect_serial(self, device_name: str, baudrate: int=115200):
ifdevice_nameisNone:
print("Device name is required")
returntry:
print("Opening %s at %d bps"% (device_name, baudrate))
## Serial object for device communication# write_timeout fixes it getting stuck forever atempting to write to# /dev/ttyAMA0 on Raspberry Pis, this raises an exception instead.self.iodev=serial.Serial(device_name, baudrate, write_timeout=1.0)
self.iodev.send_break()
time.sleep(0.001)
self.iodev.write("U".encode("ascii"))
exceptExceptionasexception:
raiseException("Failed to open the given serial port: {0}".format(exception))
The request here is:
Kindly avoid using the print function in a library like this. If the device name is required, it should be handled as an exception, not with a print and return:
raiseValueError("Device name is required")
And the next print is indeed a logging:
logger.info("Opening %s at %d bps", device_name, baudrate)
I've had to use workarounds to prevent these prints from being sent to my app's stdout:
defbrping_muted_print(*args, **kw):
iflen(args) ==1:
args=args[0]
log('brping: %s', args)
# brping module uses raw print statements for logging# with this trick, we turn them into proper logsbrping.device.print=brping_muted_print
Thanks
The text was updated successfully, but these errors were encountered:
The request here is:
Kindly avoid using the print function in a library like this.
This is definitely a reasonable request, and is one of many interface improvements that would be nice to provide.
I started #123 a couple of years ago but didn't end up completing it at the time, and am unfortunately not sure when I'll get back to it. The rest of our software team is also largely tied up with other projects, so it's unlikely this will get updated in the near future on our end.
You are of course welcome to submit a pull request if the change is important to you sooner than later - the relevant files to change would be brping/pingmessage.py, and those in generate/templates/ :-)
This is just a copy of connect_serial() method from brping/device.py (ver 0.1.5)
The request here is:
Kindly avoid using the
print
function in a library like this. If the device name is required, it should be handled as an exception, not with aprint
andreturn
:And the next
print
is indeed a logging:I've had to use workarounds to prevent these
print
s from being sent to my app's stdout:Thanks
The text was updated successfully, but these errors were encountered: