diff --git a/src/commandline.py b/src/commandline.py index d681c146..ebc2bc5b 100644 --- a/src/commandline.py +++ b/src/commandline.py @@ -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