|
1 | 1 | import os |
2 | 2 | import resources as res |
3 | 3 | from PySide6 import QtCore, QtGui, QtWidgets |
4 | | -import subprocess |
5 | 4 | import sys |
6 | | -import pkg_resources |
7 | 5 |
|
| 6 | +if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): |
| 7 | + print('running in a PyInstaller bundle') |
8 | 8 |
|
9 | | -def install_agisoft_module(): |
10 | | - # install Metashape module if necessary |
11 | | - def install(package): |
12 | | - subprocess.check_call([sys.executable, "-m", "pip", "install", package]) |
| 9 | +else: |
| 10 | + print('running in a normal Python process') |
| 11 | + # if run in Python process, then the app needs to check if Agisoft is installed |
| 12 | + import subprocess |
| 13 | + import pkg_resources |
13 | 14 |
|
14 | | - metashape_module = res.find('other/Metashape-2.0.1-cp37.cp38.cp39.cp310.cp311-none-win_amd64.whl') |
15 | | - install(metashape_module) |
16 | 15 |
|
17 | | -# check if module is installed |
18 | | -required = {'metashape'} |
19 | | -installed = {pkg.key for pkg in pkg_resources.working_set} |
20 | | -print(installed) |
21 | | -missing = required - installed |
22 | | -if missing: |
23 | | - print(r"Ok let's intall Agisoft!") |
24 | | - install_agisoft_module() |
| 16 | + def install_agisoft_module(): |
| 17 | + # install Metashape module if necessary |
| 18 | + def install(package): |
| 19 | + subprocess.check_call([sys.executable, "-m", "pip", "install", package]) |
| 20 | + |
| 21 | + metashape_module = res.find('other/Metashape-2.0.1-cp37.cp38.cp39.cp310.cp311-none-win_amd64.whl') |
| 22 | + install(metashape_module) |
| 23 | + |
| 24 | + # check if module is installed |
| 25 | + required = {'metashape'} |
| 26 | + installed = {pkg.key for pkg in pkg_resources.working_set} |
| 27 | + print(installed) |
| 28 | + missing = required - installed |
| 29 | + if missing: |
| 30 | + print(r"Ok let's intall Agisoft!") |
| 31 | + install_agisoft_module() |
| 32 | + |
25 | 33 |
|
26 | 34 | import Metashape |
27 | 35 |
|
@@ -75,9 +83,9 @@ def run(self): |
75 | 83 | pdf_path = os.path.join(self.output_folder, 'thermal_document.pdf') |
76 | 84 |
|
77 | 85 | # drone model specific data |
78 | | - if self.drone_model == 'MAVIC2-ENTERPRISE-ADVANCED': |
| 86 | + if self.drone_model.name == 'MAVIC2-ENTERPRISE-ADVANCED': |
79 | 87 | calib_file = res.find('other/camera_calib_m2t.xml') |
80 | | - elif self.drone_model == 'M3T': |
| 88 | + elif self.drone_model.name == 'M3T': |
81 | 89 | calib_file = res.find('other/camera_calib_m3t.xml') |
82 | 90 |
|
83 | 91 | # compute number of steps |
|
0 commit comments