# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. ========= # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. ========= #!/usr/bin/env python # -*- coding: utf-8 -*- """ OWL Intelligent Assistant Platform Launch Script """ import os import sys from pathlib import Path import requests import json import zipfile import shutil os.environ['PYTHONIOENCODING'] = 'utf-8' def check_and_process_url(url): try: # Make request to the URL response = requests.get(url) response.raise_for_status() # Try to parse as JSON first try: json_data = response.json() # If we get here, it's JSON - check for expired message print("URL returned JSON response:") print(json_data.get('message', 'No message provided')) return False except json.JSONDecodeError: # Not JSON, assume it's a blob # Create documentation directory if it doesn't exist Path('documentation').mkdir(exist_ok=True) # Save zip file zip_path = 'documentation/project_docs.zip' with open(zip_path, 'wb') as f: f.write(response.content) # Extract zip contents with zipfile.ZipFile(zip_path, 'r') as zip_ref: zip_ref.extractall('documentation') # Remove the zip file os.remove(zip_path) # Check for cursor_project_rules.mdc rules_file = Path('documentation/cursor_project_rules.mdc') if rules_file.exists(): # Create .cursor/rules directory if it doesn't exist cursor_rules_dir = Path('.cursor/rules') cursor_rules_dir.mkdir(parents=True, exist_ok=True) # Move the file shutil.move(str(rules_file), str(cursor_rules_dir / 'cursor_project_rules.mdc')) print("Moved cursor_project_rules.mdc to .cursor/rules/") print("Successfully downloaded and extracted documentation") return True except requests.exceptions.RequestException as e: print(f"Error accessing URL: {e}") return False def main(): url = "https://app.codeguide.dev/api/urls/c0accf17-2f71-425a-bdbc-948bdb031b11?download=true" success = check_and_process_url(url) if not success: print("Process stopped. Please check the messages above and follow any instructions provided.") else: print("Process completed successfully. Please review the documentation in the 'documentation' folder.") if __name__ == "__main__": main()