Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add commandline processing to launch.py #1828

Merged
merged 8 commits into from
Jul 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/classes/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 7 additions & 6 deletions src/classes/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

28 changes: 26 additions & 2 deletions src/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"""

import sys
from argparse import ArgumentParser

try:
from classes import info
Expand All @@ -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("------------------------------------------------")
Expand Down