#!/usr/bin/python

import os
import sys

# NOTE: this is a file related to the #SEF-9491
#   * it will automatically deletes .py files that are safe because the objects are not used in pickle
#   * it will be called by both the linux AND windows builds

# NOTE: relative to THIS file directory
ok_to_delete_files = ['daemons/arbiterdaemon.py',
                      'daemons/brokerdaemon.py',
                      'daemons/pollerdaemon.py',
                      'daemons/reactionnerdaemon.py',
                      'daemons/receiverdaemon.py',
                      'daemons/schedulerdaemon.py',
                      'executor.py',
                      'scheduler.py',
                      'satellite.py',
                      'log.py',
                      'dispatcher.py',
                      'daemon.py',
                      'executor_stats.py',
                      'runtime_stats/memory_stats.py',
                      'worker.py',
                      'worker_stats.py',
                      'checks_container.py',
                      'modulesmanager.py']

my_dir = os.path.dirname(__file__)
for pth in ok_to_delete_files:
    full_pth = os.path.join(my_dir, pth)
    if not os.path.exists(full_pth):
        print('AUTO REMOVE -- the path %s is already delete' % full_pth)
        continue
    print("AUTO REMOVE .py FILES: - %s " % full_pth)
    os.unlink(full_pth)

print('AUTO REMOVE -- deleting myself (%s)' % __file__)
os.unlink(__file__)

print('Done')
sys.exit(0)