#!/usr/bin/env python2
# -*- mode: python; coding: utf-8; -*-
# (c) Con Radchenko mailto:lankier@gmail.com
# Modified by crowd https://github.com/matimatik/fbless/

import sys
import locale
from cStringIO import StringIO
import curses
from fbless_lib.options import parse_arguments
from fbless_lib.main import MainWindow

parse_arguments()

stdout = sys.stdout
sys.stdout = StringIO()

## stderr = sys.stderr
## sys.stderr = StringIO()
locale.setlocale(locale.LC_ALL, '')

try:
    MainWindow().main_loop()
finally:
    try:
        curses.endwin()
    except:
        pass

value = sys.stdout.getvalue()
if value:
    print >> stdout, value

## value = sys.stderr.getvalue()
## if value:
##     print >> stderr, value
