I would like to see this functionally in a separate file. For example utils/utils.py. It could be a function 'get_version()'  that returns the hole version string with the git_commit_id, if present. So other functions (for example openslides --version) can also use this code.