| |
| """ |
| Phase 1: Ecosystem Cloning |
| Clones the main ASI ecosystem repository and all component repositories |
| """ |
|
|
| import os |
| import subprocess |
| from pathlib import Path |
|
|
| def run_phase1(): |
| print("Setting up ASI Ecosystem Integration...") |
| |
| |
| os.chdir('/app/asi-ecosystem') |
| print(f"Current working directory: {os.getcwd()}") |
| |
| try: |
| |
| print("Step 1: Cloning the main asi-ecosystem repository...") |
| |
| |
| if os.path.exists('asi-ecosystem'): |
| print("Removing existing asi-ecosystem directory...") |
| subprocess.run(['rm', '-rf', 'asi-ecosystem'], check=True) |
| |
| |
| result = subprocess.run([ |
| 'git', 'clone', |
| 'https://github.com/ronniross/asi-ecosystem.git' |
| ], capture_output=True, text=True) |
| |
| if result.returncode == 0: |
| print("Successfully cloned asi-ecosystem repository") |
| else: |
| print("Error cloning repository:") |
| print(result.stderr) |
| return False |
| |
| |
| print("Step 2: Navigating into the directory...") |
| os.chdir('/app/asi-ecosystem') |
| print(f"Current working directory: {os.getcwd()}") |
| |
| print("Repository contents:") |
| for item in os.listdir('.'): |
| print(f" {item}" if os.path.isdir(item) else f" {item}") |
| |
| |
| script_path = './scripts/clone_ecosystem.sh' |
| print(f"Checking for script at: {script_path}") |
| |
| if os.path.exists(script_path): |
| print("Script found!") |
| |
| subprocess.run(['chmod', '+x', script_path], check=True) |
| print("Made script executable") |
| else: |
| print("Script not found. Listing scripts directory:") |
| if os.path.exists('scripts'): |
| for item in os.listdir('scripts'): |
| print(f" scripts/{item}") |
| else: |
| print(" scripts directory does not exist") |
| return False |
| |
| |
| print("Step 3: Running the ecosystem integration script...") |
| |
| if os.path.exists(script_path): |
| try: |
| |
| result = subprocess.run([script_path], |
| capture_output=True, |
| text=True, |
| cwd='/app/asi-ecosystem') |
| |
| print("Script output:") |
| print(result.stdout) |
| |
| if result.stderr: |
| print("Script errors/warnings:") |
| print(result.stderr) |
| |
| if result.returncode == 0: |
| print("Script executed successfully!") |
| else: |
| print(f"Script failed with return code: {result.returncode}") |
| return False |
| |
| except Exception as e: |
| print(f"Error executing script: {e}") |
| return False |
| else: |
| print("Cannot execute script - file not found") |
| return False |
| |
| |
| print("Step 4: Verifying the final result...") |
| |
| print(f"Contents of {os.getcwd()}:") |
| for item in sorted(os.listdir('.')): |
| if os.path.isdir(item): |
| print(f"{item}/") |
| |
| if item == 'repositories': |
| repo_path = os.path.join('.', item) |
| if os.path.exists(repo_path): |
| print(f" Contents of {item}:") |
| for repo in sorted(os.listdir(repo_path)): |
| print(f" {repo}/") |
| else: |
| print(f" {item}") |
| |
| |
| print("Summary of cloned repositories:") |
| repositories_path = './repositories' |
| |
| if os.path.exists(repositories_path): |
| repos = [d for d in os.listdir(repositories_path) |
| if os.path.isdir(os.path.join(repositories_path, d))] |
| |
| print(f"Total repositories cloned: {len(repos)}") |
| for i, repo in enumerate(sorted(repos), 1): |
| repo_path = os.path.join(repositories_path, repo) |
| |
| git_path = os.path.join(repo_path, '.git') |
| status = "Git repo" if os.path.exists(git_path) else "Not a git repo" |
| print(f"{i:2d}. {repo:<30} {status}") |
| else: |
| print("No repositories folder found") |
| return False |
| |
| print("Phase 1 completed successfully!") |
| return True |
| |
| except Exception as e: |
| print(f"Phase 1 failed with error: {e}") |
| return False |
|
|