Exemplo n.º 1
0
 def __init__(self, app: CuraApplication,
              on_error: Callable[[List[CloudError]], None]) -> None:
     super().__init__()
     self._app = app
     self._account = app.getCuraAPI().account
     self._scope = JsonDecoratorScope(UltimakerCloudScope(app))
     self._http = HttpRequestManager.getInstance()
     self._on_error = on_error
     self._upload = None  # type: Optional[ToolPathUploader]
Exemplo n.º 2
0
    def __init__(self, app: CuraApplication) -> None:
        if self.__instance is not None:
            raise RuntimeError("This is a Singleton. use getInstance()")

        self._scope = JsonDecoratorScope(
            UltimakerCloudScope(app))  # type: JsonDecoratorScope

        app.getPackageManager().packageInstalled.connect(
            self._onPackageInstalled)
Exemplo n.º 3
0
 def __init__(self, material_sync: "CloudMaterialSync"):
     super().__init__()
     self._material_sync = material_sync
     self._scope = JsonDecoratorScope(
         UltimakerCloudScope(cura.CuraApplication.CuraApplication.
                             getInstance()))  # type: JsonDecoratorScope
     self._archive_filename = None  # type: Optional[str]
     self._archive_remote_id = None  # type: Optional[str]  # ID that the server gives to this archive. Used to communicate about the archive to the server.
     self._printer_sync_status = {}  # type: Dict[str, str]
     self._printer_metadata = []  # type: List[Dict[str, Any]]
     self.processProgressChanged.connect(self._onProcessProgressChanged)
Exemplo n.º 4
0
    def __init__(self, application: CuraApplication) -> None:
        super().__init__()

        self.discrepancies = Signal()  # Emits SubscribedPackagesModel
        self._application = application  # type: CuraApplication
        self._scope = JsonDecoratorScope(UltimakerCloudScope(application))
        self._model = SubscribedPackagesModel()
        self._message = None  # type: Optional[Message]

        self._application.initializationFinished.connect(self._onAppInitialized)
        self._i18n_catalog = i18nCatalog("cura")
        self._sdk_version = ApplicationMetadata.CuraSDKVersion
Exemplo n.º 5
0
    def __init__(self, application: CuraApplication) -> None:
        super().__init__()

        self.discrepancies = Signal()  # Emits SubscribedPackagesModel
        self._application = application  # type: CuraApplication
        self._scope = JsonDecoratorScope(UltimakerCloudScope(application))
        self._model = SubscribedPackagesModel()
        self._message = None  # type: Optional[Message]

        self._application.initializationFinished.connect(self._onAppInitialized)
        self._i18n_catalog = i18nCatalog("cura")
        self._sdk_version = ApplicationMetadata.CuraSDKVersion
        self._last_notified_packages = set()  # type: Set[str]
        """Packages for which a notification has been shown. No need to bother the user twice fo equal content"""
Exemplo n.º 6
0
    def __init__(self, app: CuraApplication,
                 on_error: Callable[[List[CloudError]], None]) -> None:
        """Initializes a new cloud API client.

        :param app:
        :param account: The user's account object
        :param on_error: The callback to be called whenever we receive errors from the server.
        """
        super().__init__()
        self._app = app
        self._account = app.getCuraAPI().account
        self._scope = JsonDecoratorScope(UltimakerCloudScope(app))
        self._http = HttpRequestManager.getInstance()
        self._on_error = on_error
        self._upload = None  # type: Optional[ToolPathUploader]
Exemplo n.º 7
0
    def __init__(self, api_backup_url: str) -> None:
        """ Create a new backup Job. start the job by calling start()

        :param api_backup_url: The url of the 'backups' endpoint of the Cura Drive Api
        """

        super().__init__()

        self._api_backup_url = api_backup_url
        self._json_cloud_scope = JsonDecoratorScope(UltimakerCloudScope(CuraApplication.getInstance()))

        self._backup_zip = None  # type: Optional[bytes]
        self._job_done = threading.Event()
        """Set when the job completes. Does not indicate success."""
        self.backup_upload_error_message = ""
        """After the job completes, an empty string indicates success. Othrerwise, the value is a translated message."""
Exemplo n.º 8
0
    def __init__(self,
                 application: CuraApplication,
                 on_error: Callable[[List[CloudError]], None],
                 projects_limit_per_page: Optional[int] = None) -> None:
        """Initializes a new digital factory API client.

        :param application:
        :param on_error: The callback to be called whenever we receive errors from the server.
        """
        super().__init__()
        self._application = application
        self._account = application.getCuraAPI().account
        self._scope = JsonDecoratorScope(UltimakerCloudScope(application))
        self._http = HttpRequestManager.getInstance()
        self._on_error = on_error
        self._file_uploader = None  # type: Optional[DFFileUploader]

        self._projects_pagination_mgr = PaginationManager(
            limit=projects_limit_per_page
        ) if projects_limit_per_page else None  # type: Optional[PaginationManager]
Exemplo n.º 9
0
    def __init__(self, parent: Optional["QObject"] = None) -> None:
        super().__init__(parent)
        self._package_manager: CuraPackageManager = cast(
            CuraPackageManager,
            CuraApplication.getInstance().getPackageManager())
        self._plugin_registry: PluginRegistry = CuraApplication.getInstance(
        ).getPluginRegistry()
        self._account = CuraApplication.getInstance().getCuraAPI().account
        self._error_message = ""
        self.addRoleName(self.PackageRole, "package")
        self._is_loading = False
        self._has_more = False
        self._has_footer = True
        self._to_install: Dict[str, str] = {}

        self._ongoing_requests: Dict[str, Optional[HttpRequestData]] = {
            "download_package": None
        }
        self._scope = JsonDecoratorScope(
            UltimakerCloudScope(CuraApplication.getInstance()))
        self._license_dialogs: Dict[str, QObject] = {}
Exemplo n.º 10
0
    def __init__(self, application: CuraApplication) -> None:
        super().__init__()

        self._application = application  # type: CuraApplication

        # Network:
        self._download_request_data = None  # type: Optional[HttpRequestData]
        self._download_progress = 0  # type: float
        self._is_downloading = False  # type: bool
        self._cloud_scope = UltimakerCloudScope(
            application)  # type: UltimakerCloudScope
        self._json_scope = JsonDecoratorScope(
            self._cloud_scope)  # type: JsonDecoratorScope

        self._request_urls = {}  # type: Dict[str, str]
        self._to_update = [
        ]  # type: List[str] # Package_ids that are waiting to be updated
        self._old_plugin_ids = set()  # type: Set[str]
        self._old_plugin_metadata = dict()  # type: Dict[str, Dict[str, Any]]

        # The responses as given by the server parsed to a list.
        self._server_response_data = {
            "authors": [],
            "packages": [],
            "updates": []
        }  # type: Dict[str, List[Any]]

        # Models:
        self._models = {
            "authors": AuthorsModel(self),
            "packages": PackagesModel(self),
            "updates": PackagesModel(self)
        }  # type: Dict[str, Union[AuthorsModel, PackagesModel]]

        self._plugins_showcase_model = PackagesModel(self)
        self._plugins_available_model = PackagesModel(self)
        self._plugins_installed_model = PackagesModel(self)
        self._plugins_installed_model.setFilter({"is_bundled": "False"})
        self._plugins_bundled_model = PackagesModel(self)
        self._plugins_bundled_model.setFilter({"is_bundled": "True"})
        self._materials_showcase_model = AuthorsModel(self)
        self._materials_available_model = AuthorsModel(self)
        self._materials_installed_model = PackagesModel(self)
        self._materials_installed_model.setFilter({"is_bundled": "False"})
        self._materials_bundled_model = PackagesModel(self)
        self._materials_bundled_model.setFilter({"is_bundled": "True"})
        self._materials_generic_model = PackagesModel(self)

        self._license_model = LicenseModel()

        # These properties are for keeping track of the UI state:
        # ----------------------------------------------------------------------
        # View category defines which filter to use, and therefore effectively
        # which category is currently being displayed. For example, possible
        # values include "plugin" or "material", but also "installed".
        self._view_category = "plugin"  # type: str

        # View page defines which type of page layout to use. For example,
        # possible values include "overview", "detail" or "author".
        self._view_page = "welcome"  # type: str

        # Active package refers to which package is currently being downloaded,
        # installed, or otherwise modified.
        self._active_package = None  # type: Optional[Dict[str, Any]]

        self._dialog = None  # type: Optional[QObject]
        self._confirm_reset_dialog = None  # type: Optional[QObject]
        self._resetUninstallVariables()

        self._restart_required = False  # type: bool

        # variables for the license agreement dialog
        self._license_dialog_plugin_file_location = ""  # type: str

        self._application.initializationFinished.connect(
            self._onAppInitialized)
 def __init__(self) -> None:
     self._cura_api = CuraApplication.getInstance().getCuraAPI()
     self._json_cloud_scope = JsonDecoratorScope(
         UltimakerCloudScope(CuraApplication.getInstance()))