This tries to fix the bug related to stdout and stderr for TWBlue installed

This commit is contained in:
Manuel Cortez 2014-12-10 12:44:11 -06:00
parent b232a0b0ad
commit ef2ff9dbfc

View File

@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
import argparse
import sys
import paths
from StringIO import StringIO
parser = argparse.ArgumentParser(description="TW Blue command line launcher")
group = parser.add_mutually_exclusive_group()
@ -8,7 +10,13 @@ group.add_argument("-p", "--portable", help="Use TW Blue as a portable aplicatio
group.add_argument("-i", "--installed", help="Use TW Blue as an installed application. Config files will be saved on the user data directory", action="store_true")
parser.add_argument("-d", "--data-directory", action="store", dest="directory", help="Specifies the directory where TW Blue saves the data files")
args = parser.parse_args()
if args.installed == True: paths.mode = "installed"
if args.installed == True:
# Set a StringIO object as stdout and stderr to avoid problems using the installer.
sys.stdout = StringIO()
sys.stderr = StringIO()
paths.mode = "installed"
sys.stderr = open(paths.logs_path("stderr.log"), 'w')
sys.stdout = open(paths.logs_path("stdout.log"), 'w')
elif args.portable == True:
paths.mode = "portable"
if args.directory != None: paths.directory = args.directory