#!/usr/bin/python3
"""Live consumer class backend for the managed dispatcher alias."""
from pathlib import Path
import os
import sys
sys.path.insert(0, '/usr/share/sophomorix-nextgen')

sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
for stream in (sys.stdout, sys.stderr):
    stream.reconfigure(encoding='utf8', errors='surrogateescape')

from sophomorix_py.class_cli import main
from sophomorix_py.runtime import R

R.argv0 = os.environ.get('SOPHOMORIX_ARGV0', '/usr/sbin/sophomorix-class')
try:
    raise SystemExit(main(sys.argv[1:]))
except (OSError, RuntimeError, ValueError) as error:
    R.err('sophomorix-class: ' + str(error) + '\n')
    raise SystemExit(1)
finally:
    R.flush()
