mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Move definition ID to cloud name map to json file
This commit is contained in:
parent
d3b1294e8b
commit
1bc8b90b56
2 changed files with 16 additions and 7 deletions
|
@ -5,6 +5,7 @@ import urllib.parse
|
||||||
from json import JSONDecodeError
|
from json import JSONDecodeError
|
||||||
from time import time
|
from time import time
|
||||||
from typing import Callable, List, Type, TypeVar, Union, Optional, Tuple, Dict, Any, cast
|
from typing import Callable, List, Type, TypeVar, Union, Optional, Tuple, Dict, Any, cast
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from PyQt6.QtCore import QUrl
|
from PyQt6.QtCore import QUrl
|
||||||
from PyQt6.QtNetwork import QNetworkRequest, QNetworkReply
|
from PyQt6.QtNetwork import QNetworkRequest, QNetworkReply
|
||||||
|
@ -30,6 +31,14 @@ CloudApiClientModel = TypeVar("CloudApiClientModel", bound=BaseModel)
|
||||||
"""The generic type variable used to document the methods below."""
|
"""The generic type variable used to document the methods below."""
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(Path(__file__).parent / "machine_id_to_name.json", "rt") as f:
|
||||||
|
MACHINE_ID_TO_NAME: Dict[str, str] = json.load(f)
|
||||||
|
except Exception as e:
|
||||||
|
Logger.logException("e", f"Could not load machine_id_to_name.json: '{e}'")
|
||||||
|
MACHINE_ID_TO_NAME = {}
|
||||||
|
|
||||||
|
|
||||||
class CloudApiClient:
|
class CloudApiClient:
|
||||||
"""The cloud API client is responsible for handling the requests and responses from the cloud.
|
"""The cloud API client is responsible for handling the requests and responses from the cloud.
|
||||||
|
|
||||||
|
@ -84,13 +93,8 @@ class CloudApiClient:
|
||||||
# conversion!
|
# conversion!
|
||||||
# API points to "MakerBot Method" for a makerbot printertypes which we already changed to allign with other printer_type
|
# API points to "MakerBot Method" for a makerbot printertypes which we already changed to allign with other printer_type
|
||||||
|
|
||||||
method_x = {
|
if machine_type in MACHINE_ID_TO_NAME:
|
||||||
"ultimaker_method":"MakerBot Method",
|
machine_type = MACHINE_ID_TO_NAME[machine_type]
|
||||||
"ultimaker_methodx":"MakerBot Method X",
|
|
||||||
"ultimaker_methodxl":"MakerBot Method XL"
|
|
||||||
}
|
|
||||||
if machine_type in method_x:
|
|
||||||
machine_type = method_x[machine_type]
|
|
||||||
else:
|
else:
|
||||||
machine_type = machine_type.replace("_plus", "+")
|
machine_type = machine_type.replace("_plus", "+")
|
||||||
machine_type = machine_type.replace("_", " ")
|
machine_type = machine_type.replace("_", " ")
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"ultimaker_method": "MakerBot Method",
|
||||||
|
"ultimaker_methodx": "MakerBot Method X",
|
||||||
|
"ultimaker_methodxl": "MakerBot Method XL"
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue