import os

def create_project_apps_py(path, app, name):
    with open(path, "w") as f:
        f.write("from django.apps import AppConfig\n")
        f.write("\n")
        f.write(f"class {name.capitalize()}Config(AppConfig):\n")
        f.write(f"    name = '{app}.{name}'\n")
        f.write(f"\n")
        f.write(f"    def ready(self):\n")
        f.write(f"        from bomiot.server.core.signal import bomiot_job_signals\n")
        f.write(f"        # # models is JobList will run one schedule job\n")
        f.write("        # bomiot_job_signals.send(sender=example_schedule_job, msg={\n")
        f.write(f'        #     "models": "JobList",\n')
        f.write('        #     "data": {\n')
        f.write(f'        #         "trigger": "interval",\n')
        f.write(f'        #         "seconds": 10\n')
        f.write("        #     }\n")
        f.write("        # })\n")
        f.write(f"# \n")
        f.write(f"        # # models is Function will run job once\n")
        f.write("        # bomiot_job_signals.send(sender=example_job, msg={\n")
        f.write(f'        #     "models": "Function",\n')
        f.write("        # })\n")
        f.write("\n")
        f.write(f"# # Schedule Job\n")
        f.write("ARGS_MAP = {\n")
        f.write(f"    'cron': ['year', 'month', 'day', 'week', 'day_of_week', 'hour', 'minute', 'second', 'start_date', 'end_date','timezone'],\n")
        f.write(f"    'interval': ['weeks', 'days', 'hours', 'minutes', 'seconds', 'start_date', 'end_date', 'timezone'],\n")
        f.write(f"    'date': ['run_date', 'timezone']\n")
        f.write("}\n")
        f.write("def example_job():\n")
        f.write(f'    print("This is an example job.")\n')
        f.write("\n")
        f.write(f"def example_schedule_job():\n")
        f.write(f'    print("This is an example schedule job.")\n')
        f.write("\n")
    f.close()


def create_plugins_apps_py(path, name):
    with open(path, "w") as f:
        f.write("from django.apps import AppConfig\n")
        f.write("\n")
        f.write(f"class {name.capitalize()}Config(AppConfig):\n")
        f.write(f"    name = '{name}'\n")
        f.write(f"\n")
        f.write(f"    def ready(self):\n")
        f.write(f"        from bomiot.server.core.signal import bomiot_job_signals\n")
        f.write(f"        # # models is JobList will run one schedule job\n")
        f.write("        # bomiot_job_signals.send(sender=example_schedule_job, msg={\n")
        f.write(f'        #     "models": "JobList",\n')
        f.write('        #     "data": {\n')
        f.write(f'        #         "trigger": "interval",\n')
        f.write(f'        #         "seconds": 10\n')
        f.write("        #     }\n")
        f.write("        # })\n")
        f.write(f"# \n")
        f.write(f"        # # models is Function will run job once\n")
        f.write("        # bomiot_job_signals.send(sender=example_job, msg={\n")
        f.write(f'        #     "models": "Function",\n')
        f.write("        # })\n")
        f.write("\n")
        f.write(f"# # Schedule Job\n")
        f.write("ARGS_MAP = {\n")
        f.write(f"    'cron': ['year', 'month', 'day', 'week', 'day_of_week', 'hour', 'minute', 'second', 'start_date', 'end_date','timezone'],\n")
        f.write(f"    'interval': ['weeks', 'days', 'hours', 'minutes', 'seconds', 'start_date', 'end_date', 'timezone'],\n")
        f.write(f"    'date': ['run_date', 'timezone']\n")
        f.write("}\n")
        f.write("def example_job():\n")
        f.write(f'    print("This is an example job.")\n')
        f.write("\n")
        f.write(f"def example_schedule_job():\n")
        f.write(f'    print("This is an example schedule job.")\n')
        f.write("\n")
    f.close()