File size: 1,295 Bytes
e8d5a56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
import subprocess
import argparse
import sys

def clone_repository(repo_url, target_dir, branch="main"):
    """Clone a git repository to the specified directory with specific branch."""
    if os.path.exists(target_dir):
        print(f"Directory {target_dir} already exists. Skipping clone.")
        return
    
    os.makedirs(os.path.dirname(target_dir), exist_ok=True)
    
    try:
        subprocess.run(
            ["git", "clone", "-b", branch, repo_url, target_dir],
            check=True,
            capture_output=True,
            text=True
        )
        print(f"Successfully cloned {repo_url} (branch: {branch}) to {target_dir}")
    except subprocess.CalledProcessError as e:
        print(f"Failed to clone repository: {e.stderr}")
        sys.exit(1)

def main(motiondirector_url="https://github.com/danhtran2mind/MotionDirector", branch="main"):
    # Define target directory
    target_dir = os.path.join("src", "third_party", "MotionDirector")
    
    # Clone MotionDirector repository
    clone_repository(motiondirector_url, target_dir, branch)

if __name__ == "__main__":
    # Set arguments directly
    main(
        motiondirector_url="https://github.com/danhtran2mind/MotionDirector",
        branch="main"
    )