Skip to content

Instantly share code, notes, and snippets.

@apzentral
Last active March 4, 2024 15:45
Show Gist options
  • Save apzentral/12bbf9e21c2a5afc7e2f7e4eca301620 to your computer and use it in GitHub Desktop.
Save apzentral/12bbf9e21c2a5afc7e2f7e4eca301620 to your computer and use it in GitHub Desktop.
Python: starting script
# -*- coding: utf-8 -*-
"""
Summary:
"""
import inspect
import logging
import os
import pathlib
import sys
import time
import traceback
logging.basicConfig(
format="[%(asctime)s.%(msecs)03d] [%(levelname)s] %(module)s:%(lineno)d - %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
CURRENT_FILE_NAME = inspect.getfile(inspect.currentframe())
CURRENT_DIR = os.path.dirname(os.path.abspath(CURRENT_FILE_NAME))
CURRENT_FILE_DIR = pathlib.Path(__file__).parent.resolve()
PARENTDIR = os.path.dirname(CURRENT_DIR)
sys.path.insert(0, PARENTDIR)
"""
Global
"""
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
"""
Function
"""
def run():
start_time = time.time()
logger.info("***** start *****")
logger.info(f"***** end ***** - total run time:{time.time() - start_time} second(s)")
"""
Run
"""
if __name__ == "__main__":
try:
run()
except Exception as e:
traceback.print_exc(file=sys.stdout)
raise e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment