Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cura_app.py - github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6c20910907d17b791f179c916386eddd2f4f6312 (plain)
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
47
48
49
50
#!/usr/bin/env python3

# Copyright (c) 2015 Ultimaker B.V.
# Cura is released under the terms of the AGPLv3 or higher.

import os
import sys

#WORKAROUND: GITHUB-704 GITHUB-708
# It looks like setuptools creates a .pth file in
# the default /usr/lib which causes the default site-packages
# to be inserted into sys.path before PYTHONPATH.
# This can cause issues such as having libsip loaded from
# the system instead of the one provided with Cura, which causes
# incompatibility issues with libArcus
if "PYTHONPATH" in os.environ.keys():                # If PYTHONPATH is used
    PYTHONPATH = os.environ["PYTHONPATH"]
    PYTHONPATH = PYTHONPATH.split(os.pathsep)
    PYTHONPATH_real = os.path.realpath(PYTHONPATH[0])
    PYTHONPATH = PYTHONPATH[1:]
    while PYTHONPATH:
        PYTHONPATH_real += ":%s" %(os.path.realpath(PYTHONPATH[0]))
        PYTHONPATH = PYTHONPATH[1:]
    if sys.path[1] != PYTHONPATH_real:      # .. check whether PYTHONPATH is placed incorrectly.
        sys.path.remove(PYTHONPATH_real)    # If so, remove that element..
        sys.path.insert(1, PYTHONPATH_real) # and add it at the correct place again.


def exceptHook(hook_type, value, traceback):
    import cura.CrashHandler
    cura.CrashHandler.show(hook_type, value, traceback)

sys.excepthook = exceptHook

# Workaround for a race condition on certain systems where there
# is a race condition between Arcus and PyQt. Importing Arcus
# first seems to prevent Sip from going into a state where it
# tries to create PyQt objects on a non-main thread.
import Arcus #@UnusedImport
import cura.CuraApplication

if sys.platform == "win32" and hasattr(sys, "frozen"):
    import os
    dirpath = os.path.expanduser("~/AppData/Local/cura/")
    os.makedirs(dirpath, exist_ok = True)
    sys.stdout = open(os.path.join(dirpath, "stdout.log"), "w")
    sys.stderr = open(os.path.join(dirpath, "stderr.log"), "w")

app = cura.CuraApplication.CuraApplication.getInstance()
app.run()