cura_app.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 sys
  5. # It looks like setuptools creates a .pth file in
  6. # the default /usr/lib which causes the default site-packages
  7. # to be inserted into sys.path before PYTHONPATH.
  8. # This can cause issues such as having libsip loaded from
  9. # the system instead of the one provided with Cura, which causes
  10. # incompatibility issues with libArcus
  11. sys.path.insert(1, os.environ.get('PYTHONPATH', ''))
  12. def exceptHook(hook_type, value, traceback):
  13. import cura.CrashHandler
  14. cura.CrashHandler.show(hook_type, value, traceback)
  15. sys.excepthook = exceptHook
  16. # Workaround for a race condition on certain systems where there
  17. # is a race condition between Arcus and PyQt. Importing Arcus
  18. # first seems to prevent Sip from going into a state where it
  19. # tries to create PyQt objects on a non-main thread.
  20. import Arcus #@UnusedImport
  21. import cura.CuraApplication
  22. if sys.platform == "win32" and hasattr(sys, "frozen"):
  23. import os
  24. dirpath = os.path.expanduser("~/AppData/Local/cura/")
  25. os.makedirs(dirpath, exist_ok = True)
  26. sys.stdout = open(os.path.join(dirpath, "stdout.log"), "w")
  27. sys.stderr = open(os.path.join(dirpath, "stderr.log"), "w")
  28. app = cura.CuraApplication.CuraApplication.getInstance()
  29. app.run()