Пример #1
0
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')
    parser.add_argument('remain', nargs=REMAINDER)

    args = parser.parse_args()

    # Display version and exit (if requested)
    if args.version:
        print("OpenShot version %s" % info.SETUP['version'])
        sys.exit()

    if args.list_languages:
        print("Supported Languages:")
        for lang in get_all_languages():
            print("  {:>12}  {}".format(lang[0], lang[1]))
        sys.exit()

    if args.lang:
        if args.lang in info.SUPPORTED_LANGUAGES:
            info.CMDLINE_LANGUAGE = args.lang
        else:
            print("Unsupported language '{}'! (See --list-languages)".format(
                args.lang))
            sys.exit(-1)

    reroute_output()

    log.info("------------------------------------------------")
    log.info("   OpenShot (version %s)" % info.SETUP['version'])
    log.info("------------------------------------------------")

    # Create Qt application, pass any unprocessed arguments
    argv = [sys.argv[0]]
    for arg in args.remain:
        argv.append(arg)
    app = OpenShotApp(argv)

    # Run and return result
    sys.exit(app.run())
Пример #2
0
def main():
    global app
    info.LOG_LEVEL_CONSOLE = "ERROR"
    try:
        app = OpenShotApp(sys.argv, mode="unittest")
    except Exception:
        import logging
        log = logging.getLogger(".")
        log.error("Failed to instantiate OpenShotApp", exc_info=1)
        sys.exit()
    unittest.main()
    app.exec_()
Пример #3
0
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')
    parser.add_argument('remain', nargs=REMAINDER)

    args = parser.parse_args()

    # Display version and exit (if requested)
    if args.version:
        print("OpenShot version %s" % info.SETUP['version'])
        sys.exit()

    if args.list_languages:
        print("Supported Languages:")
        for lang in get_all_languages():
            print("  {:>12}  {}".format(lang[0],lang[1]))
        sys.exit()

    if args.lang:
        if args.lang in info.SUPPORTED_LANGUAGES:
            info.CMDLINE_LANGUAGE = args.lang
        else:
            print("Unsupported language '{}'! (See --list-languages)".format(args.lang))
            sys.exit(-1)

    reroute_output()

    log.info("------------------------------------------------")
    log.info("   OpenShot (version %s)" % info.SETUP['version'])
    log.info("------------------------------------------------")

    # Create Qt application, pass any unprocessed arguments
    argv = [sys.argv[0]]
    for arg in args.remain:
        argv.append(arg)
    app = OpenShotApp(argv)

    # Run and return result
    sys.exit(app.run())
Пример #4
0
def main():
    """"Initialize settings (not implemented) and create main window/application."""

    # Display version and exit (if requested)
    if "--version" in sys.argv:
        print("OpenShot version %s" % info.SETUP['version'])
        exit()

    log.info("------------------------------------------------")
    log.info("   OpenShot (version %s)" % info.SETUP['version'])
    log.info("------------------------------------------------")

    # Create Qt application
    app = OpenShotApp(sys.argv)

    # Run and return result
    sys.exit(app.run())
Пример #5
0
def main():
    """"Initialize settings (not implemented) and create main window/application."""

    # Display version and exit (if requested)
    if "--version" in sys.argv:
        print("OpenShot version %s" % info.SETUP['version'])
        exit()

    log.info("------------------------------------------------")
    log.info("   OpenShot (version %s)" % info.SETUP['version'])
    log.info("------------------------------------------------")

    # Create Qt application
    app = OpenShotApp(sys.argv)

    # Run and return result
    sys.exit(app.run())
Пример #6
0
    def setUpClass(TestQueryClass):
        """ Init unit test data """
        # Create Qt application
        TestQueryClass.app = OpenShotApp(sys.argv, mode="unittest")
        TestQueryClass.clip_ids = []
        TestQueryClass.file_ids = []
        TestQueryClass.transition_ids = []

        # Import additional classes that need the app defined first
        from classes.query import Clip, File, Transition

        # Insert some clips into the project data
        for num in range(5):
            # Create clip
            c = openshot.Clip(os.path.join(info.IMAGES_PATH, "AboutLogo.png"))

            # Parse JSON
            clip_data = json.loads(c.Json())

            # Insert into project data
            query_clip = Clip()
            query_clip.data = clip_data
            query_clip.save()

            # Keep track of the ids
            TestQueryClass.clip_ids.append(query_clip.id)

        # Insert some files into the project data
        for num in range(5):
            # Create file
            r = openshot.DummyReader(openshot.Fraction(24, 1), 640, 480, 44100, 2, 30.0)

            # Parse JSON
            file_data = json.loads(r.Json())

            # Insert into project data
            query_file = File()
            query_file.data = file_data
            query_file.data["path"] = os.path.join(info.IMAGES_PATH, "AboutLogo.png")
            query_file.data["media_type"] = "image"
            query_file.save()

            # Keep track of the ids
            TestQueryClass.file_ids.append(query_file.id)

        # Insert some transitions into the project data
        for num in range(5):
            # Create mask object
            transition_object = openshot.Mask()
            transitions_data = json.loads(transition_object.Json())

            # Insert into project data
            query_transition = Transition()
            query_transition.data = transitions_data
            query_transition.save()

            # Keep track of the ids
            TestQueryClass.transition_ids.append(query_transition.id)
Пример #7
0
def main():
    """"Initialize settings (not implemented) and create main window/application."""

    parser = argparse.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('--path',
                        dest='py_path',
                        action='append',
                        help='Additional locations to search for modules '
                        '(PYTHONPATH). Can be used multiple times.')
    parser.add_argument('-V', '--version', action='store_true')
    parser.add_argument('remain',
                        nargs=argparse.REMAINDER,
                        help=argparse.SUPPRESS)

    args = parser.parse_args()

    # Display version and exit (if requested)
    if args.version:
        print("OpenShot version %s" % info.SETUP['version'])
        sys.exit()

    if args.list_languages:
        from classes.language import get_all_languages
        print("Supported Languages:")
        for lang in get_all_languages():
            print("  {:>12}  {}".format(lang[0], lang[1]))
        sys.exit()

    if args.py_path:
        for p in args.py_path:
            try:
                if os.path.exists(os.path.realpath(p)):
                    sys.path.insert(0, os.path.realpath(p))
                    print("Added {} to PYTHONPATH".format(os.path.realpath(p)))
                else:
                    print("{} does not exist".format(os.path.realpath(p)))
            except TypeError as ex:
                print("Bad path {}: {}".format(p, ex))
                continue

    if args.lang:
        if args.lang in info.SUPPORTED_LANGUAGES:
            info.CMDLINE_LANGUAGE = args.lang
        else:
            print("Unsupported language '{}'! (See --list-languages)".format(
                args.lang))
            sys.exit(-1)

    # Create Qt application, pass any unprocessed arguments
    from classes.app import OpenShotApp

    argv = [sys.argv[0]]
    for arg in args.remain:
        argv.append(arg)
    app = OpenShotApp(argv)

    # Run and return result
    sys.exit(app.run())
Пример #8
0
def main():
    """"Initialize settings (not implemented) and create main window/application."""

    global app

    # Configure argument handling for commandline launches
    parser = argparse.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(
        '--path', dest='py_path', action='append',
        help='Additional locations to search for modules '
             '(PYTHONPATH). Can be used multiple times.')
    parser.add_argument(
        '--test-models', dest='modeltest',
        action='store_true',
        help="Load Qt's QAbstractItemModelTester into data models "
        '(requires Qt 5.11+)')
    parser.add_argument(
        '-b', '--web-backend', action='store',
        choices=['auto', 'webkit', 'webengine'], default='auto',
        help="Web backend to use for Timeline")
    parser.add_argument(
        '-d', '--debug', action='store_true',
        help='Enable debugging output')
    parser.add_argument(
        '--debug-file', action='store_true',
        help='Debugging output (logfile only)')
    parser.add_argument(
        '--debug-console', action='store_true',
        help='Debugging output (console only)')
    parser.add_argument('-V', '--version', action='store_true')
    parser.add_argument(
        'remain', nargs=argparse.REMAINDER, help=argparse.SUPPRESS)

    args, extra_args = parser.parse_known_args()

    # Display version and exit (if requested)
    if args.version:
        print(info.SETUP['version'])
        sys.exit()

    # Set up debugging log level to requested streams
    if args.debug or args.debug_file:
        info.LOG_LEVEL_FILE = 'DEBUG'
    if args.debug or args.debug_console:
        info.LOG_LEVEL_CONSOLE = 'DEBUG'

    if args.list_languages:
        from classes.language import get_all_languages
        print("Supported Languages:")
        for code, lang, country in get_all_languages():
            print("  {:>12}  {}".format(code, lang))
        sys.exit()

    if args.py_path:
        for p in args.py_path:
            try:
                if os.path.exists(os.path.realpath(p)):
                    sys.path.insert(0, os.path.realpath(p))
                    print("Added {} to PYTHONPATH".format(os.path.realpath(p)))
                else:
                    print("{} does not exist".format(os.path.realpath(p)))
            except TypeError as ex:
                print("Bad path {}: {}".format(p, ex))
                continue

    if args.modeltest:
        info.MODEL_TEST = True
        # Set default logging rules, if the user didn't
        if os.getenv('QT_LOGGING_RULES') is None:
            os.putenv('QT_LOGGING_RULES', 'qt.modeltest.debug=true')
    if args.web_backend:
        info.WEB_BACKEND = args.web_backend.lower()
    if args.lang:
        if args.lang in info.SUPPORTED_LANGUAGES:
            info.CMDLINE_LANGUAGE = args.lang
        else:
            print("Unsupported language '{}'! (See --list-languages)".format(args.lang))
            sys.exit(-1)

    # Normal startup, print module path and lauch application
    print("Loaded modules from: %s" % info.PATH)

    # Initialize sentry exception tracing
    from classes import sentry
    sentry.init_tracing()

    # Create Qt application, pass any unprocessed arguments
    from classes.app import OpenShotApp

    argv = [sys.argv[0]]
    argv.extend(extra_args)
    argv.extend(args.remain)
    app = OpenShotApp(argv)

    # Setup Qt application details
    app.setApplicationName('openshot')
    app.setApplicationVersion(info.SETUP['version'])
    try:
        # Qt 5.7+ only
        app.setDesktopFile("org.openshot.OpenShot")
    except AttributeError:
        pass

    # Launch GUI and start event loop
    app.gui()
    sys.exit(app.exec_())