Main entry point for the application. Will handle log files and cleanup
(settings: Settings)
| 103 | |
| 104 | |
| 105 | def start(settings: Settings) -> int: |
| 106 | """Main entry point for the application. Will handle log files and cleanup""" |
| 107 | |
| 108 | # Delete: all old files |
| 109 | clean_tmp_files() |
| 110 | if settings.cleanup_files_on_start: |
| 111 | clean_files(settings) |
| 112 | |
| 113 | # And logs |
| 114 | observer.reset() |
| 115 | |
| 116 | # Set new keys |
| 117 | config.make_encryption_keys() |
| 118 | |
| 119 | # Prepare the project: copy all files to projects/<project_name>/ |
| 120 | prepare_project(settings.project_name) |
| 121 | |
| 122 | # Do the thing and catch the errors |
| 123 | ret = False |
| 124 | if config.catch_exception: |
| 125 | ret = start_real(settings) |
| 126 | else: |
| 127 | try: |
| 128 | ret = start_real(settings) |
| 129 | except Exception as e: |
| 130 | logger.error(f'Error compiling: {e}') |
| 131 | observer.write_logs(settings.project_path) |
| 132 | return 1 |
| 133 | |
| 134 | # Cleanup files |
| 135 | clean_tmp_files() |
| 136 | if settings.cleanup_files_on_exit: |
| 137 | clean_files(settings) |
| 138 | |
| 139 | # Write logs (on success) |
| 140 | observer.write_logs(settings.project_path) |
| 141 | return ret |
| 142 | |
| 143 | |
| 144 | def sanity_checks(settings): |