diff --git a/src/classes/language.py b/src/classes/language.py index 38a4a8b372..7528422b14 100644 --- a/src/classes/language.py +++ b/src/classes/language.py @@ -171,9 +171,6 @@ def find_language_match(pattern, path, translator, locale_name): def get_all_languages(): """Get all language names and countries packaged with OpenShot""" - # Get app instance - app = QCoreApplication.instance() - # Loop through all supported language locale codes all_languages = [] for locale_name in info.SUPPORTED_LANGUAGES: diff --git a/src/classes/logger.py b/src/classes/logger.py index 5bf4de111d..5fcb7651af 100644 --- a/src/classes/logger.py +++ b/src/classes/logger.py @@ -67,11 +67,12 @@ def errors(self): fh.setFormatter(formatter) log.addHandler(fh) -# Route stdout and stderr to logger (custom handler) -if not getattr(sys, 'frozen', False): - so = StreamToLogger(log, logging.INFO) - sys.stdout = so +def reroute_output(): + """Route stdout and stderr to logger (custom handler)""" + if not getattr(sys, 'frozen', False): + so = StreamToLogger(log, logging.INFO) + sys.stdout = so - se = StreamToLogger(log, logging.ERROR) - sys.stderr = se + se = StreamToLogger(log, logging.ERROR) + sys.stderr = se diff --git a/src/launch.py b/src/launch.py index e2875b2e0c..d0945fd134 100755 --- a/src/launch.py +++ b/src/launch.py @@ -41,6 +41,7 @@ """ import sys +from argparse import ArgumentParser try: from classes import info @@ -51,17 +52,40 @@ print("Loaded modules from installed directory: %s" % info.PATH) from classes.app import OpenShotApp -from classes.logger import log +from classes.logger import log, reroute_output +from classes.language import get_all_languages def main(): """"Initialize settings (not implemented) and create main window/application.""" + parser = ArgumentParser(description = 'OpenShot version ' + info.SETUP['version']) + # parser.add_argument('-l', '--lang', action='store', + # help='language code for interface (overrides ' + # 'preferences and system environment)') + parser.add_argument('--list-languages', dest='list_languages', + action='store_true', help='List all language ' + 'codes supported by OpenShot') + parser.add_argument('-V', '--version', action='store_true') + + args = parser.parse_args() + # Display version and exit (if requested) - if "--version" in sys.argv: + if args.version: print("OpenShot version %s" % info.SETUP['version']) exit() + if args.list_languages: + print("Supported Languages:") + for lang in get_all_languages(): + print(" {:>12} {}".format(lang[0],lang[1])) + exit() + + # if args.lang: + # info.CMDLINE_LANG = args.lang + + reroute_output() + log.info("------------------------------------------------") log.info(" OpenShot (version %s)" % info.SETUP['version']) log.info("------------------------------------------------")