mirror of
https://github.com/bjoernellens1/cps_loki.git
synced 2024-11-22 23:33:50 +00:00
include python script to initilaize the needed repos
This commit is contained in:
parent
5bba8a0085
commit
eb4c9c5d56
27
initialize.py
Normal file
27
initialize.py
Normal file
@ -0,0 +1,27 @@
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
class GitCloner:
|
||||
def __init__(self, directory):
|
||||
self.directory = directory
|
||||
|
||||
def clone_repo(self, repo_url, branch='master'):
|
||||
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')
|
Loading…
Reference in New Issue
Block a user