Skip to content

Instantly share code, notes, and snippets.

View roodee's full-sized avatar

roodee roodee

  • Berlin, Germany
View GitHub Profile
@roodee
roodee / run_main.py
Last active September 12, 2023 11:56
Run procedure with appropriate logging and exception handling
from datetime import datetime
from os.path import abspath, dirname, join
from pathlib import Path
import logging
import logging.config
import some_module
if __name__ == '__main__':
@roodee
roodee / shell_script_runner.py
Created February 14, 2023 09:13
Use subprocess to run a shell script and log its console output
"""
Module providing one function, which calls a shell script and fetches it output for logging.
"""
from os.path import abspath, dirname, join
from os import listdir
import subprocess
import logging
@roodee
roodee / parse_configuration_file.py
Last active September 12, 2023 11:58
Parse configuration file
# Given is a configuration file in ini-format
# It contains sections, parameter names and values like this
#
# [section]
# param1 = value1
# param2 = value2
#
# Use configparser to parse the file
# Pass the names for section and parameter to retrieve the configured value
@roodee
roodee / add_dir_2_sys_path.py
Last active February 14, 2023 09:16
Add directory to system path
import sys
sys.path.insert(0,'/path/to/mod_directory')
# Reference: https://stackoverflow.com/questions/16114391/adding-directory-to-sys-path-pythonpath