Skip to content

Commit

Permalink
remove line
Browse files Browse the repository at this point in the history
  • Loading branch information
QuanyiLi committed Oct 20, 2023
1 parent e447a6d commit e10213e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,14 @@ jobs:
cd bridges/ros_bridge
ls -al
python _delete_rviz_line.py
sudo rosdep install --from-paths src --ignore-src -y --rosdistro humble
pwd
colcon build
source install/setup.bash
nohup ros2 launch metadrive_example_bridge metadrive_example_bridge.launch.py > ros.txt 2>&1 &
ros2 launch metadrive_example_bridge metadrive_example_bridge.launch.py
python ros_socket_server.py --test
# python ros_socket_server.py --test

# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v1
Expand Down
28 changes: 28 additions & 0 deletions bridges/ros_bridge/_delete_rviz_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
Only for github CI using!
"""
import os


def delete_line_from_file(file_name, line_number):
# Check if the line number is valid
if line_number < 1:
return

lines = []
with open(file_name, 'r') as f:
lines = f.readlines()

# Check if the line number is beyond the file's length
if line_number > len(lines):
return

with open(file_name, 'w') as f:
for idx, line in enumerate(lines):
if idx + 1 != line_number:
f.write(line)


# Usage
if __name__ == '__main__':
delete_line_from_file(os.path.join(os.path.dirname(__file__), 'src', "metadrive_example_bridge", 'package.xml'), 10)

0 comments on commit e10213e

Please sign in to comment.