U
    wh5                     @   s>   d Z ddlZddlZddlZddlZdd Zedkr:e  dS )zb
Fix for ActivityCategorizer cache issue
This script clears Python cache and restarts the backend
    Nc                  C   s  t d t d tjdddgdd td tjtjt	d	} tj
| rht d
|   t|  ddddg}|D ]>}tjtjt	|}tj
|rxt d|  t| qxt d tjdddgdd t d td tdddddg t d t d t d t d d S )Nu.   🔧 Fixing ActivityCategorizer cache issue...u"   📍 Stopping timesheet-backend...Zpm2stopztimesheet-backendT)Zcapture_output   __pycache__u$   🗑️  Removing Python cache from z$activity_categorizer.cpython-312.pycz#fixed_sync_endpoint.cpython-312.pycz+activity_categorization_api.cpython-312.pycz%enhanced_activity_api.cpython-312.pycu   🗑️  Removing u$   🚀 Restarting timesheet-backend...Zrestartu   
📋 Checking logs...   Zlogsz--linesZ10u\   
✅ Fix completed! The backend should now be running without the 'non_work_keywords' error.u!   
💡 If the error persists, try:z"   1. pm2 delete timesheet-backendzF   2. pm2 start main.py --name timesheet-backend --interpreter python3)print
subprocessruntimesleepospathjoindirname__file__existsshutilrmtreeremove)Zpycache_dirZ	pyc_filesZpyc_fileZpyc_path r   ./fix_categorizer_cache.pymain   s6    


r   __main__)__doc__r   r   r   r	   r   __name__r   r   r   r   <module>   s   *