Adjust string formatter to support python2.7
mxterry opened this issue · 6 comments
In many of my workstation with ROS, there only ros-lib of python2.7 is pre-installed, and it's hard to install ros for py3 without internet connection.
In fact, to support python2.7, it needs simply back to using format() instead of f-string here:
see my pull request later.
Are you able to download bagpy manually (https://pypi.org/project/bagpy/#files), copy it to those machines with a USB thumb drive, and then use the ros_readbagfile.py program as-is?
I really don't want to cater to Python2 considering Python3 has been out since 2008 and Python2 was deprecated completely in 2020.
You don't need all of ROS for python 3, just the rosbag module I think. I think sudo pip3 install bagpy
is how I got that for myself.
A few notes to summarize what I'm saying clearly:
- I do not want to make the code Python 2 compatible. That's going backwards.
- I do want to help you get it to meet your needs, however. Ideally I'd like to help you get whatever Python 3 files you need to make that happen. I want you to be able to run the code. I don't think you're missing much to make that happen, but I don't have a solution right now. I think if you are able to get my script to your computers which don't have internet, however, then certainly you can get a few more files there too to make my script run in Python 3 for you.
- I'm not a python nor ROS packaging expert and I don't know the solution, but I think with working together and figuring things out we can find a better solution than making code Python 2 compatible.
If anyone is curious, here is the last Python2 version of ros_readbagfile.py
(from commit 3a2275430f3d7c002dbfc608a3d091b2beffcf63
) just before I upgraded it from Python 2 to Python 3: https://github.com/ElectricRCAircraftGuy/eRCaGuy_dotfiles/blob/3a2275430f3d7c002dbfc608a3d091b2beffcf63/useful_scripts/ros_readbagfile.py
So, that version above runs in Python2.
Ok, I undersand your opinion on Python2. And in fact, I am personnally agree with it.
I'll try your solution of making the script run with python3.
@mxterry , thanks. If/when you get it working, please do return here and post a comment explaining how you solved the problem and got things installed to get it running. That will help you in the future, next time you have to do it again, as well as other people with the same problem.