cps_loki/initialize.py

31 lines
1.1 KiB
Python
Raw Normal View History

import os
import subprocess
class GitCloner:
def __init__(self, directory):
self.directory = directory
2023-05-25 09:55:35 +00:00
def clone_repo(self, repo_url, branch='main'):
repo_name = repo_url.split('/')[-1].split('.')[0]
repo_path = os.path.join(self.directory, repo_name)
if os.path.exists(repo_path):
print(f"Repository '{repo_name}' already exists. Skipping cloning.")
return
command = ['git', 'clone', '--branch', branch, repo_url, repo_path]
try:
subprocess.check_output(command)
print(f"Successfully cloned repository '{repo_name}'.")
except subprocess.CalledProcessError as e:
print(f"Failed to clone repository '{repo_name}': {e}")
# Usage example
cloner = GitCloner('./src')
cloner.clone_repo('https://github.com/bjoernellens1/odrive_ros2_control', 'humble-fw-v0.5.1')
cloner.clone_repo('https://github.com/bjoernellens1/rmp220_teleop', 'bot_mini')
2023-05-25 09:54:47 +00:00
cloner.clone_repo('https://github.com/bjoernellens1/ros2_cam_openCV')
2023-05-26 08:39:42 +00:00
cloner.clone_repo('https://github.com/bjoernellens1/bot_mini_bringup.git')
2023-05-25 09:54:07 +00:00