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