Wait for app to be ready with detailed status checking
(app, max_attempts=10, delay=2.5)
| 23 | |
| 24 | |
| 25 | async def wait_for_app_ready(app, max_attempts=10, delay=2.5) -> bool: |
| 26 | """Wait for app to be ready with detailed status checking""" |
| 27 | for i in range(max_attempts): |
| 28 | try: |
| 29 | if not app: |
| 30 | print(f'Attempt {i + 1}/{max_attempts}: App object is None') |
| 31 | await asyncio.sleep(delay) |
| 32 | continue |
| 33 | |
| 34 | if app: |
| 35 | app.activateWithOptions_(Cocoa.NSApplicationActivateIgnoringOtherApps) |
| 36 | await asyncio.sleep(1) |
| 37 | print(f'✅ App is running and ready') |
| 38 | return True |
| 39 | |
| 40 | await asyncio.sleep(delay) |
| 41 | |
| 42 | except Exception as e: |
| 43 | print(f'Error checking app status: {e}') |
| 44 | await asyncio.sleep(delay) |
| 45 | |
| 46 | return False |
| 47 | |
| 48 | |
| 49 | class FolderCreationState: |