Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correction for following errors while running: #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Correction for following errors while running: #1

wants to merge 1 commit into from

Conversation

tomy983
Copy link

@tomy983 tomy983 commented May 22, 2022

[WARN] [1653246727.777205]: Zero length
Exception in thread Thread-5:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/home/pi/catkin_ws/src/ntrip_ros/scripts/ntripclient.py", line 72, in run
buf += data
TypeError: can only concatenate str (not "bytes") to str

+++++++++++++++++++++++++

Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/home/pi/catkin_ws/src/ntrip_ros/scripts/ntripclient.py", line 94, in run
rospy.logwarn("Zero length ", restart_count)
File "/opt/ros/noetic/lib/python3/dist-packages/rospy/core.py", line 193, in logwarn
_base_logger(msg, args, kwargs, level='warning')
File "/opt/ros/noetic/lib/python3/dist-packages/rospy/core.py", line 183, in _base_logger
logfunc(msg, *args, **kwargs)
File "/usr/lib/python3.8/logging/init.py", line 1458, in warning
self._log(WARNING, msg, args, **kwargs)
File "/usr/lib/python3.8/logging/init.py", line 1589, in _log
self.handle(record)
File "/usr/lib/python3.8/logging/init.py", line 1599, in handle
self.callHandlers(record)
File "/usr/lib/python3.8/logging/init.py", line 1661, in callHandlers
hdlr.handle(record)
File "/usr/lib/python3.8/logging/init.py", line 954, in handle
self.emit(record)
File "/opt/ros/noetic/lib/python3/dist-packages/rosgraph/roslogging.py", line 246, in emit
record_message = _defaultFormatter.format(record)
File "/usr/lib/python3.8/logging/init.py", line 668, in format
record.message = record.getMessage()
File "/usr/lib/python3.8/logging/init.py", line 373, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting

[WARN] [1653246727.777205]: Zero length 
Exception in thread Thread-5:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/home/pi/catkin_ws/src/ntrip_ros/scripts/ntripclient.py", line 72, in run
    buf += data
TypeError: can only concatenate str (not "bytes") to str

+++++++++++++++++++++++++

Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/home/pi/catkin_ws/src/ntrip_ros/scripts/ntripclient.py", line 94, in run
    rospy.logwarn("Zero length ", restart_count)
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/core.py", line 193, in logwarn
    _base_logger(msg, args, kwargs, level='warning')
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/core.py", line 183, in _base_logger
    logfunc(msg, *args, **kwargs)
  File "/usr/lib/python3.8/logging/__init__.py", line 1458, in warning
    self._log(WARNING, msg, args, **kwargs)
  File "/usr/lib/python3.8/logging/__init__.py", line 1589, in _log
    self.handle(record)
  File "/usr/lib/python3.8/logging/__init__.py", line 1599, in handle
    self.callHandlers(record)
  File "/usr/lib/python3.8/logging/__init__.py", line 1661, in callHandlers
    hdlr.handle(record)
  File "/usr/lib/python3.8/logging/__init__.py", line 954, in handle
    self.emit(record)
  File "/opt/ros/noetic/lib/python3/dist-packages/rosgraph/roslogging.py", line 246, in emit
    record_message = _defaultFormatter.format(record)
  File "/usr/lib/python3.8/logging/__init__.py", line 668, in format
    record.message = record.getMessage()
  File "/usr/lib/python3.8/logging/__init__.py", line 373, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
@joshmcculloch
Copy link

Hey, Not sure why this is closed. Maybe I just didn't see it in time.

@joshmcculloch joshmcculloch reopened this May 31, 2022
Copy link

@joshmcculloch joshmcculloch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the buf (line 100) is a bug and your fix should work. Any reason not to just use buf = bytes(). The logwarn line seems like it is making to functional change. Both original and submitted don't work as intended.

@@ -91,13 +91,13 @@ def run(self):
else:
''' If zero length data, close connection and reopen it '''
restart_count = restart_count + 1
rospy.logwarn("Zero length ", restart_count)
rospy.logwarn("Zero length ".format(restart_count))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rospy.logwarn("Zero length ".format(restart_count))
rospy.logwarn("Zero length - attempts {0}".format(restart_count))

connection.close()
connection = HTTPConnection(self.ntc.ntrip_server)
connection.request('GET', '/'+self.ntc.ntrip_stream, self.ntc.nmea_gga, headers)
response = connection.getresponse()
if response.status != 200: raise Exception("blah")
buf = ""
buf = bytes('', 'utf-8')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
buf = bytes('', 'utf-8')
buf = bytes()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants