Restore unnecessarily changed indentation

CURA-7435
This commit is contained in:
Erwan MATHIEU 2025-02-21 08:05:27 +01:00
parent 7a5657ca98
commit fedf5a4794
8 changed files with 52 additions and 70 deletions

View File

@ -120,7 +120,7 @@ jobs:
create-installers: create-installers:
name: Create installers name: Create installers
uses: ultimaker/cura-workflows/.github/workflows/cura-installers.yml@main uses: ultimaker/cura-workflows/.github/workflows/cura-installers.yml@main
needs: [ parse-version, create-packages ] needs: [parse-version, create-packages]
with: with:
cura_conan_version: cura/${{ inputs.cura_version }}@ultimaker/stable cura_conan_version: cura/${{ inputs.cura_version }}@ultimaker/stable
conan_args: "-c user.sentry:environment=production" conan_args: "-c user.sentry:environment=production"

View File

@ -36,15 +36,15 @@ pyinstaller:
src: "plugins" src: "plugins"
dst: "share/cura/plugins" dst: "share/cura/plugins"
native_cad_plugin: native_cad_plugin:
package: "native_cad_plugin" package: "native_cad_plugin"
src: "res/plugins/NativeCADplugin" src: "res/plugins/NativeCADplugin"
dst: "share/cura/plugins/NativeCADplugin" dst: "share/cura/plugins/NativeCADplugin"
enterprise_only: true enterprise_only: true
native_cad_plugin_bundled: native_cad_plugin_bundled:
package: "native_cad_plugin" package: "native_cad_plugin"
src: "res/bundled_packages" src: "res/bundled_packages"
dst: "share/cura/resources/bundled_packages" dst: "share/cura/resources/bundled_packages"
enterprise_only: true enterprise_only: true
cura_resources: cura_resources:
package: "cura" package: "cura"
src: "resources" src: "resources"
@ -111,8 +111,8 @@ pyinstaller:
- "win32timezone" - "win32timezone"
- "pkgutil" - "pkgutil"
hiddenimports_WINDOWS_ONLY: hiddenimports_WINDOWS_ONLY:
- "PyQt6.Qt" - "PyQt6.Qt"
- "PyQt6.Qt6" - "PyQt6.Qt6"
collect_all: collect_all:
- "cura" - "cura"
- "UM" - "UM"
@ -127,8 +127,8 @@ pyinstaller:
- "keyrings.alt" - "keyrings.alt"
- "pynavlib" - "pynavlib"
collect_all_WINDOWS_ONLY: collect_all_WINDOWS_ONLY:
- "PyQt6.Qt" - "PyQt6.Qt"
- "PyQt6.Qt6" - "PyQt6.Qt6"
icon: icon:
Windows: "./icons/Cura.ico" Windows: "./icons/Cura.ico"
Macos: "./icons/cura.icns" Macos: "./icons/cura.icns"
@ -609,15 +609,15 @@ pip_requirements_core:
pip_requirements_dev: pip_requirements_dev:
any_os: any_os:
pytest: { } pytest: {}
pyyaml: { } pyyaml: {}
sip: { version: "6.5.1" } sip: { version: "6.5.1" }
jinja2: { } jinja2: {}
pip_requirements_installer: pip_requirements_installer:
any_os: any_os:
pyinstaller: { version: "6.11.1" } pyinstaller: { version: "6.11.1" }
pyinstaller-hooks-contrib: { } pyinstaller-hooks-contrib: {}
python_translation_source_folders: python_translation_source_folders:
- cura - cura

View File

@ -133,7 +133,7 @@ class CuraConan(ConanFile):
save(self, collect_python_installs, code) save(self, collect_python_installs, code)
buffer = StringIO() buffer = StringIO()
self.run(f"""python {collect_python_installs}""", env="virtual_python_env", stdout=buffer) self.run(f"""python {collect_python_installs}""", env = "virtual_python_env", stdout = buffer)
rm(self, collect_python_installs, ".") rm(self, collect_python_installs, ".")
packages = str(buffer.getvalue()).strip('\r\n').split(";") packages = str(buffer.getvalue()).strip('\r\n').split(";")
@ -336,8 +336,8 @@ class CuraConan(ConanFile):
cura_app_name = self.name, cura_app_name = self.name,
cura_app_display_name = self._app_name, cura_app_display_name = self._app_name,
cura_version = cura_version, cura_version = cura_version,
cura_version_full=self.version, cura_version_full = self.version,
cura_build_type="Enterprise" if self.options.enterprise else "", cura_build_type = "Enterprise" if self.options.enterprise else "",
cura_debug_mode = self.options.cura_debug_mode, cura_debug_mode = self.options.cura_debug_mode,
cura_cloud_api_root = self.conan_data["urls"][self._urls]["cloud_api_root"], cura_cloud_api_root = self.conan_data["urls"][self._urls]["cloud_api_root"],
cura_cloud_api_version = self.options.cloud_api_version, cura_cloud_api_version = self.options.cloud_api_version,
@ -428,15 +428,13 @@ class CuraConan(ConanFile):
package_folder = self.dependencies[data['package']].package_folder package_folder = self.dependencies[data['package']].package_folder
if package_folder is None: if package_folder is None:
raise ConanException( raise ConanException(f"Unable to find package_folder for {data['package']}, check that it has not been skipped")
f"Unable to find package_folder for {data['package']}, check that it has not been skipped")
src_path = os.path.join(self.dependencies[data["package"]].package_folder, data["src"]) src_path = os.path.join(self.dependencies[data["package"]].package_folder, data["src"])
elif "root" in data: # get the paths relative from the install folder elif "root" in data: # get the paths relative from the install folder
src_path = os.path.join(self.install_folder, data["root"], data["src"]) src_path = os.path.join(self.install_folder, data["root"], data["src"])
else: else:
raise ConanException( raise ConanException("Misformatted conan data for pyinstaller datas, expected either package or root option")
"Misformatted conan data for pyinstaller datas, expected either package or root option")
if not Path(src_path).exists(): if not Path(src_path).exists():
raise ConanException(f"Missing folder {src_path} for pyinstaller data {data}") raise ConanException(f"Missing folder {src_path} for pyinstaller data {data}")
@ -452,8 +450,7 @@ class CuraConan(ConanFile):
if self.settings.os == "Windows": if self.settings.os == "Windows":
src_path = src_path.replace("\\", "\\\\") src_path = src_path.replace("\\", "\\\\")
else: else:
raise ConanException( raise ConanException("Misformatted conan data for pyinstaller binaries, expected either package or root option")
"Misformatted conan data for pyinstaller binaries, expected either package or root option")
if not Path(src_path).exists(): if not Path(src_path).exists():
raise ConanException(f"Missing folder {src_path} for pyinstaller binary {binary}") raise ConanException(f"Missing folder {src_path} for pyinstaller binary {binary}")
@ -486,8 +483,7 @@ class CuraConan(ConanFile):
# filter all binary files in binaries on the blacklist # filter all binary files in binaries on the blacklist
blacklist = pyinstaller_metadata["blacklist"] blacklist = pyinstaller_metadata["blacklist"]
filtered_binaries = [b for b in binaries if filtered_binaries = [b for b in binaries if not any([all([(part in b[0].lower()) for part in parts]) for parts in blacklist])]
not any([all([(part in b[0].lower()) for part in parts]) for parts in blacklist])]
# In case the installer isn't actually pyinstaller (Windows at the moment), outright remove the offending files: # In case the installer isn't actually pyinstaller (Windows at the moment), outright remove the offending files:
specifically_delete = set(binaries) - set(filtered_binaries) specifically_delete = set(binaries) - set(filtered_binaries)
@ -511,10 +507,10 @@ class CuraConan(ConanFile):
display_name = self._app_name, display_name = self._app_name,
entrypoint = entrypoint_location, entrypoint = entrypoint_location,
datas = datas, datas = datas,
binaries=filtered_binaries, binaries = filtered_binaries,
venv_script_path = str(self._script_dir), venv_script_path = str(self._script_dir),
hiddenimports=hiddenimports, hiddenimports = hiddenimports,
collect_all=collect_all, collect_all = collect_all,
icon = icon_path, icon = icon_path,
entitlements_file = entitlements_file, entitlements_file = entitlements_file,
osx_bundle_identifier = "'nl.ultimaker.cura'" if self.settings.os == "Macos" else "None", osx_bundle_identifier = "'nl.ultimaker.cura'" if self.settings.os == "Macos" else "None",
@ -539,8 +535,7 @@ class CuraConan(ConanFile):
copy(self, "cura_app.py", self.recipe_folder, self.export_sources_folder) copy(self, "cura_app.py", self.recipe_folder, self.export_sources_folder)
def validate(self): def validate(self):
if self.options.i18n_extract and self.settings.os == "Windows" and not self.conf.get( if self.options.i18n_extract and self.settings.os == "Windows" and not self.conf.get("tools.microsoft.bash:path", check_type=str):
"tools.microsoft.bash:path", check_type=str):
raise ConanInvalidConfiguration("Unable to extract translations on Windows without Bash installed") raise ConanInvalidConfiguration("Unable to extract translations on Windows without Bash installed")
def requirements(self): def requirements(self):
@ -572,17 +567,17 @@ class CuraConan(ConanFile):
# Copy CuraEngine.exe to bindirs of Virtual Python Environment # Copy CuraEngine.exe to bindirs of Virtual Python Environment
curaengine = self.dependencies["curaengine"].cpp_info curaengine = self.dependencies["curaengine"].cpp_info
copy(self, "CuraEngine.exe", curaengine.bindirs[0], self.source_folder, keep_path=False) copy(self, "CuraEngine.exe", curaengine.bindirs[0], self.source_folder, keep_path = False)
copy(self, "CuraEngine", curaengine.bindirs[0], self.source_folder, keep_path=False) copy(self, "CuraEngine", curaengine.bindirs[0], self.source_folder, keep_path = False)
# Copy the external plugins that we want to bundle with Cura # Copy the external plugins that we want to bundle with Cura
if self.options.enterprise: if self.options.enterprise:
rmdir(self, str(Path(self.source_folder, "plugins", "NativeCADplugin"))) rmdir(self, str(Path(self.source_folder, "plugins", "NativeCADplugin")))
native_cad_plugin = self.dependencies["native_cad_plugin"].cpp_info native_cad_plugin = self.dependencies["native_cad_plugin"].cpp_info
copy(self, "*", native_cad_plugin.resdirs[0], str(Path(self.source_folder, "plugins", "NativeCADplugin")), copy(self, "*", native_cad_plugin.resdirs[0], str(Path(self.source_folder, "plugins", "NativeCADplugin")),
keep_path=True) keep_path = True)
copy(self, "bundled_*.json", native_cad_plugin.resdirs[1], copy(self, "bundled_*.json", native_cad_plugin.resdirs[1],
str(Path(self.source_folder, "resources", "bundled_packages")), keep_path=False) str(Path(self.source_folder, "resources", "bundled_packages")), keep_path = False)
# Copy resources of cura_binary_data # Copy resources of cura_binary_data
cura_binary_data = self.dependencies["cura_binary_data"].cpp_info cura_binary_data = self.dependencies["cura_binary_data"].cpp_info
@ -666,8 +661,8 @@ class CuraConan(ConanFile):
self._generate_pyinstaller_spec(location=self.deploy_folder, self._generate_pyinstaller_spec(location=self.deploy_folder,
entrypoint_location = "'{}'".format(os.path.join(self.package_folder, self.cpp_info.bindirs[0], self.conan_data["pyinstaller"]["runinfo"]["entrypoint"])).replace("\\", "\\\\"), entrypoint_location = "'{}'".format(os.path.join(self.package_folder, self.cpp_info.bindirs[0], self.conan_data["pyinstaller"]["runinfo"]["entrypoint"])).replace("\\", "\\\\"),
icon_path = "'{}'".format(os.path.join(self.package_folder, self.cpp_info.resdirs[2], self.conan_data["pyinstaller"]["icon"][str(self.settings.os)])).replace("\\", "\\\\"), icon_path = "'{}'".format(os.path.join(self.package_folder, self.cpp_info.resdirs[2], self.conan_data["pyinstaller"]["icon"][str(self.settings.os)])).replace("\\", "\\\\"),
entitlements_file=entitlements_file if self.settings.os == "Macos" else "None", entitlements_file = entitlements_file if self.settings.os == "Macos" else "None",
cura_source_folder=self.package_folder) cura_source_folder = self.package_folder)
def package(self): def package(self):
copy(self, "cura_app.py", src = self.source_folder, dst = os.path.join(self.package_folder, self.cpp.package.bindirs[0])) copy(self, "cura_app.py", src = self.source_folder, dst = os.path.join(self.package_folder, self.cpp.package.bindirs[0]))

View File

@ -266,11 +266,9 @@ class BuildVolume(SceneNode):
renderer.queueNode(self, mode = RenderBatch.RenderMode.Lines) renderer.queueNode(self, mode = RenderBatch.RenderMode.Lines)
renderer.queueNode(self, mesh = self._origin_mesh, backface_cull = True) renderer.queueNode(self, mesh = self._origin_mesh, backface_cull = True)
renderer.queueNode(self, mesh=self._grid_mesh, shader=self._grid_shader, backface_cull=True, transparent=True, renderer.queueNode(self, mesh=self._grid_mesh, shader=self._grid_shader, backface_cull=True, transparent=True, sort=-10)
sort=-10)
if self._disallowed_area_mesh: if self._disallowed_area_mesh:
renderer.queueNode(self, mesh=self._disallowed_area_mesh, shader=self._shader, transparent=True, renderer.queueNode(self, mesh=self._disallowed_area_mesh, shader=self._shader, transparent=True, backface_cull=True, sort=-5)
backface_cull=True, sort=-5)
if self._error_mesh: if self._error_mesh:
renderer.queueNode(self, mesh=self._error_mesh, shader=self._shader, transparent=True, renderer.queueNode(self, mesh=self._error_mesh, shader=self._shader, transparent=True,

View File

@ -44,12 +44,12 @@ def generate_nsi(source_path: str, dist_path: str, filename: str, version: str):
nsis_content = template.render( nsis_content = template.render(
app_name=f"UltiMaker Cura {version}", app_name = f"UltiMaker Cura {version}",
main_app = "UltiMaker-Cura.exe", main_app = "UltiMaker-Cura.exe",
version=version, version = version,
version_major=str(parsed_version.major), version_major = str(parsed_version.major),
version_minor=str(parsed_version.minor), version_minor = str(parsed_version.minor),
version_patch=str(parsed_version.patch), version_patch = str(parsed_version.patch),
company = "UltiMaker", company = "UltiMaker",
web_site = "https://ultimaker.com", web_site = "https://ultimaker.com",
year = datetime.now().year, year = datetime.now().year,
@ -78,8 +78,7 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser(description = "Create Windows exe installer of Cura.") parser = argparse.ArgumentParser(description = "Create Windows exe installer of Cura.")
parser.add_argument("--source_path", type=str, help="Path to Conan install Cura folder.") parser.add_argument("--source_path", type=str, help="Path to Conan install Cura folder.")
parser.add_argument("--dist_path", type=str, help="Path to Pyinstaller dist folder") parser.add_argument("--dist_path", type=str, help="Path to Pyinstaller dist folder")
parser.add_argument("--filename", type=str, parser.add_argument("--filename", type=str, help="Filename of the exe (e.g. 'UltiMaker-Cura-5.1.0-beta-Windows-X64.exe')")
help="Filename of the exe (e.g. 'UltiMaker-Cura-5.1.0-beta-Windows-X64.exe')")
parser.add_argument("--version", type=str, help="The full cura version, e.g. 5.9.0-beta.1+24132") parser.add_argument("--version", type=str, help="The full cura version, e.g. 5.9.0-beta.1+24132")
args = parser.parse_args() args = parser.parse_args()
generate_nsi(args.source_path, args.dist_path, args.filename, args.version) generate_nsi(args.source_path, args.dist_path, args.filename, args.version)

View File

@ -196,8 +196,7 @@ class DigitalFactoryApiClient:
url = "{}/projects/{}/files".format(self.CURA_API_ROOT, library_project_id) url = "{}/projects/{}/files".format(self.CURA_API_ROOT, library_project_id)
self._http.get(url, self._http.get(url,
scope = self._scope, scope = self._scope,
callback=self._parseCallback(on_finished, DigitalFactoryFileResponse, failed, callback=self._parseCallback(on_finished, DigitalFactoryFileResponse, failed, default_values={'username': ''}),
default_values={'username': ''}),
error_callback = failed, error_callback = failed,
timeout = self.DEFAULT_REQUEST_TIMEOUT) timeout = self.DEFAULT_REQUEST_TIMEOUT)
@ -236,8 +235,7 @@ class DigitalFactoryApiClient:
if status_code >= 300 and on_error is not None: if status_code >= 300 and on_error is not None:
on_error() on_error()
else: else:
self._parseModels(response, on_finished, model, pagination_manager=pagination_manager, self._parseModels(response, on_finished, model, pagination_manager = pagination_manager, default_values = default_values)
default_values=default_values)
self._anti_gc_callbacks.append(parse) self._anti_gc_callbacks.append(parse)
return parse return parse

View File

@ -124,8 +124,7 @@ class SliceInfo(QObject, Extension):
return list(sorted(user_modified_setting_keys)) return list(sorted(user_modified_setting_keys))
def _flattenData(self, data: Any, result: dict, current_flat_key: Optional[str] = None, def _flattenData(self, data: Any, result: dict, current_flat_key: Optional[str] = None, lift_list: bool = False) -> None:
lift_list: bool = False) -> None:
if isinstance(data, dict): if isinstance(data, dict):
for key, value in data.items(): for key, value in data.items():
total_flat_key = key if current_flat_key is None else f"{current_flat_key}_{key}" total_flat_key = key if current_flat_key is None else f"{current_flat_key}_{key}"

View File

@ -84,7 +84,6 @@ def test_cleanAuthService() -> None:
assert authorization_service.getAccessToken() is None assert authorization_service.getAccessToken() is None
def test_refreshAccessTokenSuccess(http_request_manager): def test_refreshAccessTokenSuccess(http_request_manager):
authorization_service = AuthorizationService(OAUTH_SETTINGS, Preferences()) authorization_service = AuthorizationService(OAUTH_SETTINGS, Preferences())
authorization_service.initialize() authorization_service.initialize()
@ -92,14 +91,11 @@ def test_refreshAccessTokenSuccess(http_request_manager):
authorization_service._storeAuthData(SUCCESSFUL_AUTH_RESPONSE) authorization_service._storeAuthData(SUCCESSFUL_AUTH_RESPONSE)
authorization_service.onAuthStateChanged.emit = MagicMock() authorization_service.onAuthStateChanged.emit = MagicMock()
with patch("UM.TaskManagement.HttpRequestManager.HttpRequestManager.getInstance", with patch("UM.TaskManagement.HttpRequestManager.HttpRequestManager.getInstance", MagicMock(return_value=http_request_manager)):
MagicMock(return_value=http_request_manager)):
with patch.object(AuthorizationService, "getUserProfile", return_value=UserProfile()): with patch.object(AuthorizationService, "getUserProfile", return_value=UserProfile()):
with patch.object(AuthorizationHelpers, "getAccessTokenUsingRefreshToken", with patch.object(AuthorizationHelpers, "getAccessTokenUsingRefreshToken", side_effect=lambda refresh_token, callback: callback(SUCCESSFUL_AUTH_RESPONSE)):
side_effect=lambda refresh_token, callback: callback(SUCCESSFUL_AUTH_RESPONSE)):
authorization_service.refreshAccessToken() authorization_service.refreshAccessToken()
authorization_service.onAuthStateChanged.emit.assert_called_once_with(logged_in=True) authorization_service.onAuthStateChanged.emit.assert_called_once_with(logged_in = True)
def test__parseJWTNoRefreshToken(http_request_manager): def test__parseJWTNoRefreshToken(http_request_manager):
""" """
@ -113,8 +109,7 @@ def test__parseJWTNoRefreshToken(http_request_manager):
mock_callback = Mock() # To log the final profile response. mock_callback = Mock() # To log the final profile response.
with patch("UM.TaskManagement.HttpRequestManager.HttpRequestManager.getInstance", with patch("UM.TaskManagement.HttpRequestManager.HttpRequestManager.getInstance", MagicMock(return_value=http_request_manager)):
MagicMock(return_value=http_request_manager)):
authorization_service._parseJWT(mock_callback) authorization_service._parseJWT(mock_callback)
mock_callback.assert_called_once() mock_callback.assert_called_once()
profile_reply = mock_callback.call_args_list[0][0][0] profile_reply = mock_callback.call_args_list[0][0][0]
@ -200,12 +195,10 @@ def test_refreshAccessTokenFailed():
http_mock.post = lambda url, data, headers_dict, callback, error_callback, urgent, timeout: callback(mock_reply) http_mock.post = lambda url, data, headers_dict, callback, error_callback, urgent, timeout: callback(mock_reply)
with patch("UM.TaskManagement.HttpRequestManager.HttpRequestManager.readJSON", Mock(return_value = {"error_description": "Mock a failed request!"})): with patch("UM.TaskManagement.HttpRequestManager.HttpRequestManager.readJSON", Mock(return_value = {"error_description": "Mock a failed request!"})):
with patch("UM.TaskManagement.HttpRequestManager.HttpRequestManager.getInstance", MagicMock(return_value = http_mock)): with patch("UM.TaskManagement.HttpRequestManager.HttpRequestManager.getInstance", MagicMock(return_value = http_mock)): authorization_service._storeAuthData(SUCCESSFUL_AUTH_RESPONSE)
authorization_service._storeAuthData(SUCCESSFUL_AUTH_RESPONSE) with patch("cura.OAuth2.AuthorizationHelpers.AuthorizationHelpers.getAccessTokenUsingRefreshToken", side_effect=lambda refresh_token, callback: callback(FAILED_AUTH_RESPONSE)):
with patch("cura.OAuth2.AuthorizationHelpers.AuthorizationHelpers.getAccessTokenUsingRefreshToken",
side_effect=lambda refresh_token, callback: callback(FAILED_AUTH_RESPONSE)):
authorization_service.refreshAccessToken() authorization_service.refreshAccessToken()
authorization_service.onAuthStateChanged.emit.assert_called_with(logged_in=False) authorization_service.onAuthStateChanged.emit.assert_called_with(logged_in = False)
def test_refreshAccesTokenWithoutData(): def test_refreshAccesTokenWithoutData():
authorization_service = AuthorizationService(OAUTH_SETTINGS, Preferences()) authorization_service = AuthorizationService(OAUTH_SETTINGS, Preferences())