OpenShot Video Editor  2.0.0
launch.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 
3 ##
4 #
5 # @file
6 # @brief This file is used to launch OpenShot
7 # @author Jonathan Thomas <jonathan@openshot.org>
8 # @author Noah Figg <eggmunkee@hotmail.com>
9 #
10 # @mainpage OpenShot Video Editor 2.0
11 #
12 # Welcome to the OpenShot Video Editor 2.0 PyQt5 documentation. OpenShot was developed to
13 # make high-quality video editing and animation solutions freely available to the world. With a focus
14 # on stability, performance, and ease-of-use, we believe OpenShot is the best cross-platform,
15 # open-source video editing application in the world!
16 #
17 # This documentation is auto-generated by Doxygen, using the doxypy Python filter. If you are
18 # interested in how OpenShot Video Editor is designed, feel free to dive in, because this
19 # documentation was built just for you. If you are not a developer, please feel free to visit
20 # our main website (http://www.openshot.org/download/), and download a copy today for Linux, Mac, or Windows.
21 #
22 # @section LICENSE
23 #
24 # Copyright (c) 2008-2018 OpenShot Studios, LLC
25 # (http://www.openshotstudios.com). This file is part of
26 # OpenShot Video Editor (http://www.openshot.org), an open-source project
27 # dedicated to delivering high quality video editing and animation solutions
28 # to the world.
29 #
30 # OpenShot Video Editor is free software: you can redistribute it and/or modify
31 # it under the terms of the GNU General Public License as published by
32 # the Free Software Foundation, either version 3 of the License, or
33 # (at your option) any later version.
34 #
35 # OpenShot Video Editor is distributed in the hope that it will be useful,
36 # but WITHOUT ANY WARRANTY; without even the implied warranty of
37 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38 # GNU General Public License for more details.
39 #
40 # You should have received a copy of the GNU General Public License
41 # along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
42 #
43 
44 import sys
45 from argparse import ArgumentParser, REMAINDER
46 
47 try:
48  from classes import info
49  print("Loaded modules from current directory: %s" % info.PATH)
50 except ImportError:
51  import openshot_qt
52  sys.path.append(openshot_qt.OPENSHOT_PATH)
53  from classes import info
54  print("Loaded modules from installed directory: %s" % info.PATH)
55 
56 from classes.app import OpenShotApp
57 from classes.logger import log, reroute_output
58 from classes.language import get_all_languages
59 
60 
61 ##
62 # "Initialize settings (not implemented) and create main window/application.
63 def main():
64 
65  parser = ArgumentParser(description = 'OpenShot version ' + info.SETUP['version'])
66  parser.add_argument('-l', '--lang', action='store',
67  help='language code for interface (overrides '
68  'preferences and system environment)')
69  parser.add_argument('--list-languages', dest='list_languages',
70  action='store_true', help='List all language '
71  'codes supported by OpenShot')
72  parser.add_argument('-V', '--version', action='store_true')
73  parser.add_argument('remain', nargs=REMAINDER)
74 
75  args = parser.parse_args()
76 
77  # Display version and exit (if requested)
78  if args.version:
79  print("OpenShot version %s" % info.SETUP['version'])
80  sys.exit()
81 
82  if args.list_languages:
83  print("Supported Languages:")
84  for lang in get_all_languages():
85  print(" {:>12} {}".format(lang[0],lang[1]))
86  sys.exit()
87 
88  if args.lang:
89  if args.lang in info.SUPPORTED_LANGUAGES:
90  info.CMDLINE_LANGUAGE = args.lang
91  else:
92  print("Unsupported language '{}'! (See --list-languages)".format(args.lang))
93  sys.exit(-1)
94 
96 
97  log.info("------------------------------------------------")
98  log.info(" OpenShot (version %s)" % info.SETUP['version'])
99  log.info("------------------------------------------------")
100 
101  # Create Qt application, pass any unprocessed arguments
102  argv = [sys.argv[0]]
103  for arg in args.remain:
104  argv.append(arg)
105  app = OpenShotApp(argv)
106 
107  # Run and return result
108  sys.exit(app.run())
109 
110 
111 if __name__ == "__main__":
112  main()
def main
"Initialize settings (not implemented) and create main window/application.
Definition: launch.py:63
def get_all_languages
Get all language names and countries packaged with OpenShot.
Definition: language.py:142
def reroute_output
Route stdout and stderr to logger (custom handler)
Definition: logger.py:74