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

TypeError Exception in saving dot file #90

Open
keivanzavari opened this issue Nov 10, 2023 · 0 comments
Open

TypeError Exception in saving dot file #90

keivanzavari opened this issue Nov 10, 2023 · 0 comments

Comments

@keivanzavari
Copy link

I am running rqt_graph on Noetic and noticed that storing the graph as a dot file throws an exception:

Traceback (most recent call last):
  File "/opt/ros/noetic/lib/python3/dist-packages/rqt_graph/ros_graph.py", line 414, in _save_dot
    handle.write(self._current_dotcode)
TypeError: write(self, Union[QByteArray, bytes, bytearray]): argument 1 has unexpected type 'str'

After searching around and finding these

It seems that on line 414 it seems binary should be passed to the write function

404     def _save_dot(self):
405         file_name, _ = QFileDialog.getSaveFileName(
406             self._widget, self.tr('Save as DOT'), 'rosgraph.dot', self.tr('DOT graph (*.dot)'))
407         if file_name is None or file_name == '':
408             return
409 
410         handle = QFile(file_name)
411         if not handle.open(QIODevice.WriteOnly | QIODevice.Text):
412             return
413 
414         handle.write(self._current_dotcode)
415         handle.close()

This is despite the fact that handle has an if statement before it. Do I understand this correctly?
After adjusting the line to:

414         handle.write(f"{self._current_dotcode}".encode())

the problem goes away and I can successfully store the dot file.

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

No branches or pull requests

1 participant