|
27 | 27 | from fastcrud.exceptions.http_exceptions import DuplicateValueException |
28 | 28 |
|
29 | 29 | from . import CREATE_DEFAULT_SUPERUSER_CHECKSUM as EXPECTED_CHECKSUM |
30 | | -from .utils import ScriptIntegrityError, verify_script_integrity |
| 30 | +from .utils import ScriptIntegrityError, get_audit_info, verify_script_integrity |
31 | 31 |
|
32 | | -logger = logging.getLogger(os.path.basename(__file__)) |
| 32 | +SCRIPT_PATH = os.path.abspath(__file__) |
| 33 | +SCRIPT_NAME = os.path.basename(__file__) |
| 34 | +logger = logging.getLogger(SCRIPT_NAME) |
| 35 | +audit_info = get_audit_info(SCRIPT_PATH) |
| 36 | +logger.warning(f"Script being run by: {json.dumps(audit_info, default=str, indent=2)}") |
33 | 37 |
|
34 | 38 | # Do not change these default values, read the file docstrings for context |
35 | 39 | DEFAULT_NAME = "Default Superuser" |
|
38 | 42 |
|
39 | 43 |
|
40 | 44 | async def async_main(password: str): |
41 | | - logger.info(f"Running script {os.path.basename(__file__)}") |
| 45 | + logger.info(f"Running script {SCRIPT_NAME}") |
42 | 46 | logger.debug("Creating hashed password") |
43 | 47 | hashed_password = get_password_hash(password) |
44 | 48 | logger.debug("Preparing superuser data") |
@@ -99,7 +103,7 @@ def main(password: str): |
99 | 103 |
|
100 | 104 | if __name__ == "__main__": |
101 | 105 | try: |
102 | | - verify_script_integrity(os.path.abspath(__file__), EXPECTED_CHECKSUM) |
| 106 | + verify_script_integrity(SCRIPT_PATH, EXPECTED_CHECKSUM) |
103 | 107 | except ScriptIntegrityError as e: |
104 | 108 | logger.error(e) |
105 | 109 | sys.exit(1) # Exit with failure code |
|
0 commit comments