cura_app.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env python3
  2. # Copyright (c) 2015 Ultimaker B.V.
  3. # Cura is released under the terms of the AGPLv3 or higher.
  4. import os
  5. import sys
  6. # WORKAROUND: GITHUB-704 GITHUB-708
  7. # It looks like setuptools creates a .pth file in
  8. # the default /usr/lib which causes the default site-packages
  9. # to be inserted into sys.path before PYTHONPATH.
  10. # This can cause issues such as having libsip loaded from
  11. # the system instead of the one provided with Cura, which causes
  12. # incompatibility issues with libArcus
  13. if "PYTHONPATH" in os.environ.keys(): # If PYTHONPATH is used
  14. if sys.path[-1] == os.environ["PYTHONPATH"]: # .. check whether PYTHONPATH is placed incorrectly at the end of sys.path.
  15. sys.path.pop(-1) # If so remove that element..
  16. sys.path.insert(1, os.environ['PYTHONPATH']) # and add it at the correct place again.
  17. def exceptHook(hook_type, value, traceback):
  18. import cura.CrashHandler
  19. cura.CrashHandler.show(hook_type, value, traceback)
  20. sys.excepthook = exceptHook
  21. # Workaround for a race condition on certain systems where there
  22. # is a race condition between Arcus and PyQt. Importing Arcus
  23. # first seems to prevent Sip from going into a state where it
  24. # tries to create PyQt objects on a non-main thread.
  25. import Arcus #@UnusedImport
  26. import cura.CuraApplication
  27. if sys.platform == "win32" and hasattr(sys, "frozen"):
  28. import os
  29. dirpath = os.path.expanduser("~/AppData/Local/cura/")
  30. os.makedirs(dirpath, exist_ok = True)
  31. sys.stdout = open(os.path.join(dirpath, "stdout.log"), "w")
  32. sys.stderr = open(os.path.join(dirpath, "stderr.log"), "w")
  33. app = cura.CuraApplication.CuraApplication.getInstance()
  34. app.run()