Running python scripts from cron (e.g. gitinspector)

You may encounter several errors while running python scripts that work with terminal and translations:

  1. Error getting LANG from environ:
      File "/usr/lib/python2.7/dist-packages/gitinspector/localization.py", line 48, in init
        os.environ['LANG'] = lang[0]
      File "/usr/lib/python2.7/os.py", line 471, in __setitem__
        putenv(key, item)
    TypeError: must be string, not None
    
  2. Error getting sys.stdin.encoding
    
        argv.append(arg.decode(sys.stdin.encoding, "replace"))
    TypeError: decode() argument 1 must be string, not None
    
To solve these problems you only need to specify several environ variables when running your python scripts:
export LOCALE="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
export LANG="en_US.UTF-8"
export PYTHONIOENCODING='utf-8'

/usr/bin/gitinspector -f py,js,sql,html,css,txt,sh --grading --format=html path_to_repo