|
| 1 | +#!/usr/bin/env python |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | +# |
| 4 | +# ScratchToCatrobat: A tool for converting Scratch projects into Catrobat programs. |
| 5 | +# Copyright (C) 2013-2017 The Catrobat Team |
| 6 | +# (<http://developer.catrobat.org/credits>) |
| 7 | +# |
| 8 | +# This program is free software: you can redistribute it and/or modify |
| 9 | +# it under the terms of the GNU Affero General Public License as |
| 10 | +# published by the Free Software Foundation, either version 3 of the |
| 11 | +# License, or (at your option) any later version. |
| 12 | +# |
| 13 | +# An additional term exception under section 7 of the GNU Affero |
| 14 | +# General Public License, version 3, is available at |
| 15 | +# http://developer.catrobat.org/license_additional_term |
| 16 | +# |
| 17 | +# This program is distributed in the hope that it will be useful, |
| 18 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | +# GNU Affero General Public License for more details. |
| 21 | +# |
| 22 | +# You should have received a copy of the GNU Affero General Public License |
| 23 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 24 | + |
| 25 | +from __future__ import print_function |
| 26 | +import os |
| 27 | +import platform |
| 28 | +import subprocess |
| 29 | +import sys |
| 30 | +sys.path.append(os.path.join(os.path.realpath(os.path.dirname(__file__)), "src")) |
| 31 | +from scratchtocatrobat.tools import helpers |
| 32 | +from scratchtocatrobat.main import main |
| 33 | + |
| 34 | +helpers.make_dir_if_not_exists(helpers.config.get("PATHS", ["data", "logging", "output", "web_output", "tmp"])) |
| 35 | +[jython_home_dir, jython_exec_path, jython_path] = helpers.config.get("PATHS", ["jython_home", "jython_exec", "jython"]) |
| 36 | + |
| 37 | +if not os.path.isdir(jython_home_dir): |
| 38 | + helpers.error("Invalid jython home path given. No valid directory. Please update 'jython_home' in the config file.") |
| 39 | +if not os.path.isfile(jython_exec_path): |
| 40 | + helpers.error("Jython script path '%s' must exist." % jython_exec_path.replace(".bat", "[.bat]")) |
| 41 | + |
| 42 | +helpers.inject_git_commmit_hook() |
| 43 | + |
| 44 | +env = os.environ |
| 45 | +env['JYTHONPATH'] = jython_path if sys.platform != 'win32' else jython_path.replace(":", ";") |
| 46 | + |
| 47 | +exec_args = [jython_exec_path, "-m", "scratchtocatrobat.main"] + sys.argv[1:] |
| 48 | +sys.exit(main()) |
0 commit comments