7628 Commits

Author SHA1 Message Date
Ghostkeeper
5da63fda26
Also catch BlockingIOError when getting a keyring attribute
This occurs when there's a timeout, on some systems, when asking for the password to the keyring. We'll interpret a timeout as a refusal to enter a password.

Fixes Sentry issue CURA-332.
2021-11-30 13:27:32 +01:00
Jelle Spijker
8427555d6a
Merge pull request #10901 from Ultimaker/CURA-8539_oauth_via_httprequestmanager
OAuth via HttpRequestManager
2021-11-23 13:59:45 +01:00
Jelle Spijker
36e28a245c
Fixed typing issues
Contributes to: CURA-8539
2021-11-23 13:56:04 +01:00
Jelle Spijker
0a43366ffc
Fixed some styling and typing issues
Some boyscouting.
Contributes to: CURA-8539
2021-11-23 11:10:22 +01:00
Jelle Spijker
70504f1b04
Modernize typing usage
Some boyscouting.
2021-11-23 11:10:22 +01:00
Ghostkeeper
3f92b46ac8
Don't restart refresh token while it's already processing
If two requests to the API occur at the same time, they will both see at the same time that they need an access token, and if it is expired they will both see that it needs refreshing. The server then sees two refreshes, both with the same refresh token. This is not allowed. The second one then gets a failure to refresh the token, which causes the user to log out.
Instead, we'll stop one of the refresh requests. They were fire-and-forget anyway, so it's not needed to actually continue the request.

Contributes to issue CURA-8539.
2021-11-22 18:52:43 +01:00
Ghostkeeper
1cdeb7d56b
Typing: When the user profile changes, it may also become None
This happens when logging out.

Contributes to issue CURA-8539.
2021-11-22 16:30:03 +01:00
Ghostkeeper
0196fd54ea
Add a few missing types
The return type missing caused the type checker to think it returned Any, which is clearly not true. And the type missing from _user_profile caused it to think it always had to be None, which is nonsense in any application.

Contributes to issue CURA-8539.
2021-11-22 16:24:22 +01:00
Ghostkeeper
1ee9f73075
Only call success_callback if it's not None
It could also be called as a fire-and-forget update thing.

Contributes to issue CURA-8539.
2021-11-22 16:20:37 +01:00
Ghostkeeper
595a6580f5
Use error callback and with correct number of parameters
It gives two parameters, additionally an error code. However our callback wrapper gets the error code from the reply itself so it doesn't need it.

Contributes to issue CURA-8539.
2021-11-22 16:17:30 +01:00
Ghostkeeper
8ea8cc752f
Also call processing functions for error callbacks
Otherwise the appropriate callbacks might not get called.

Contributes to issue CURA-8539.
2021-11-22 14:44:52 +01:00
Ghostkeeper
937d48a4e8
Add missing failed_callback
If it fails to check the token, respond through the callback with None as well.

Contributes to issue CURA-8539.
2021-11-22 13:24:06 +01:00
Ghostkeeper
c36863da56
Only call failed_callback if provided
Otherwise we'd crash because NoneType can't be called.

Contributes to issue CURA-8539.
2021-11-22 11:59:23 +01:00
Ghostkeeper
30d19844f2
Always callback if there is a callback, even if no auth data
Because not having auth data is a reason to return no profile too. Otherwise the other side might wait for a response for a long time.

Contributes to issue CURA-8539.
2021-11-22 10:45:01 +01:00
Ghostkeeper
1636cca601
Add missing return
We're calling back that there is no auth data, so we should stop here and not try to obtain a user profile.

Contributes to issue CURA-8539.
2021-11-22 10:34:39 +01:00
Ghostkeeper
ffb891fb69
Fix call to failed_callback
It provides 2 arguments (reply and error) which we both ignore and proceed to call failed_callback. And failed_callback may also be None in which case we don't call anything.

Contributes to issue CURA-8539.
2021-11-19 17:09:33 +01:00
Ghostkeeper
9895015235
Call getAccessTokenUsingRefreshToken asynchronously
Getting into nested inline functions into inline functions here. Let's see what the reviewer thinks of all this!

Contributes to issue CURA-8539.
2021-11-19 17:04:37 +01:00
Ghostkeeper
7091c5f3aa
Make getAuthenticationTokenUsingXYZ asynchronous
As a result, the local webserver now needs to synchronise that with a lock. Otherwise the do_GET function would no longer block, and wouldn't properly be able to return the correct redirect URL.

Contributes to issue CURA-8539.
2021-11-19 16:55:45 +01:00
Ghostkeeper
9b55ae6dda
Remove unused imports of requests
This was the objective, really.

Contributes to issue CURA-8539.
2021-11-19 16:25:50 +01:00
Ghostkeeper
acbbf83510
Deal with absence of callback function
It may be None, so then we don't need to call back. The consumer may just take it from self._user_profile.

Contributes to issue CURA-8539.
2021-11-19 16:23:48 +01:00
Ghostkeeper
a5202b61d2
Don't emit with new profile
The signal can't accept it because it's not a QObject.

Contributes to issue CURA-8539.
2021-11-19 16:22:41 +01:00
Ghostkeeper
bfb8440a04
Get user profile asynchronously when restoring from preferences
Do not stop the start-up process for it. Let the callback handle the updating if necessary.

Contributes to issue CURA-8539.
2021-11-19 16:20:00 +01:00
Ghostkeeper
92437a920d
Store account information asynchronously when completing request
And make the PyQt properties listen to the signal of completion.

Contributes to issue CURA-8539.
2021-11-19 16:02:25 +01:00
Ghostkeeper
591a2f89b8
Make getUserProfile return profile asynchronously
All via callbacks. Quite a mess.

Contributes to issue CURA-8539.
2021-11-19 15:29:29 +01:00
Ghostkeeper
6601728741
Merge branch 'feature_extruder_warning_icon' of https://github.com/fieldOfView/Cura into fieldOfView-feature_extruder_warning_icon 2021-11-19 13:48:45 +01:00
Ghostkeeper
920d9b9d44
Make _parseJWT asynchronous as well
Now it calls checkToken correctly. However now this _parseJWT is not called correctly since there are things calling this one in an attempt to be synchronous again.
There is the additional issue that we can't call getAccessTokenUsingRefreshToken synchronously now, because this runs on the main thread and it will then block the main thread until the request is made, which is never because the request is also done on the main thread via Qt's event loop.

Contributes to issue CURA-8539.
2021-11-18 17:33:39 +01:00
Ghostkeeper
aff0764c1d
Add failed callback for when the request fails
Maybe we should add a parameter to this to respond with an error message. But maybe later.

Contributes to issue CURA-8539.
2021-11-18 17:19:05 +01:00
Ghostkeeper
a9990eaa75
Make parseJWT asynchronous
This involves returning the user profile via a callback.
No longer use the Requests library, which doesn't properly use the SSL certificates locally on the computer like the QNetworkManager does.

Contributes to issue CURA-8539.
2021-11-18 17:11:27 +01:00
Ghostkeeper
d6f8984cf0
Use integer positions for fixed items too
Pynest2d requires it. It seems the SIP version we're using is lenient for this, but newer SIP versions are not.

Fixes #10801.
2021-11-18 11:44:09 +01:00
Karl Nilsson
e0e227404f
Fix picking pixel on integer indices
The QImage.pixel() function should only get integers.
In theory an input position of -2,-2 would get rounded to 0 now. However that shouldn't occur because the user can't click outside of the window. And if it does occur, it's not really a problem either that it's theoretically picking a position inside of the window when you click slightly next to it.

Fixes #10785.
2021-11-18 11:36:20 +01:00
Ghostkeeper
f1c763ad9f
Use HttpRequestManager to acquire new tokens
This is a re-write from a previous attempt. Instead of requests, which doesn't properly use SSL certificates installed on the computer among other things, we'll now use the HttpRequestManager which uses QNetworkManager under the hood and properly uses system settings.
The QNetworkManager is asynchronous which would normally be very nice, but due to the nature of this call we want to make it synchronous so we'll use a lock here.

Contributes to issue CURA-8539.
2021-11-17 14:32:53 +01:00
fieldOfView
19dbd1f168 Merge branch 'master' into feature_extruder_warning_icon 2021-11-16 14:56:43 +01:00
Jelle Spijker
cc92a9dc1c
Merge pull request #10841 from Ultimaker/master
Merge master into libArachne
2021-11-16 08:04:41 +01:00
Ghostkeeper
5e60cc6208
Merge branch 'bremco-graphics_buffer_update' 2021-11-15 15:20:10 +01:00
Ghostkeeper
b8ccb32836
Merge branch 'master' into libArachne_rebased
Conflicts:
	resources/definitions/ultimaker2.def.json -> Additions in Arachne around a place where we fixed an enum setting.
	resources/definitions/ultimaker3.def.json
	resources/definitions/ultimaker_s3.def.json
	resources/definitions/ultimaker_s5.def.json
2021-11-12 15:08:29 +01:00
Jaime van Kessel
b1f797f6cb Merge branch 'master' of github.com:Ultimaker/Cura 2021-11-09 15:10:39 +01:00
Jaime van Kessel
c1a839ccaa Also ensure that extruder settings are correct when discarding unsaved changes
CURA-8584
2021-11-09 15:10:09 +01:00
Ghostkeeper
ca942a15e8
Don't use infinite lifetimes lightly
This is very annoying if switching profiles. This is not a critical message. The message should disappear after the default amount of time.

Discovered while working on CURA-8584.
2021-11-09 14:45:40 +01:00
Jaime van Kessel
73ca50d958 Handle exception when adhesion extruder could not be found
This should be pretty rare; the crash would only happen due to a race condition

cura-8584
2021-11-09 10:17:32 +01:00
Remco Burema
4f20dc4c5d
Add documentation. 2021-11-07 22:26:34 +01:00
Remco Burema
6dff2bebb5
Merge branch 'master' into bremco-graphics_buffer_update 2021-11-07 22:12:17 +01:00
Jaime van Kessel
a613a70758 Don't disable group nodes if it's extruder is disabled
Group nodes don't really have an extruder, so exclude them from that check

CURA-7710
Fixes #8336
2021-11-05 16:31:35 +01:00
Jaime van Kessel
c7c052e51c Fix crash when profile referenced unavailable extruder
CURA-8584
2021-11-05 15:50:24 +01:00
Jaime van Kessel
ccfdfe5539 Merge branch 'CURA-8647_fix_beta_urls' of github.com:Ultimaker/Cura 2021-11-03 11:18:47 +01:00
Ghostkeeper
e929decce5
Merge branch 'speedup_inherit_button' 2021-11-02 17:59:28 +01:00
Remco Burema
112f61e32f
Fix URL's for the update checker for Beta's.
part of CURA-CURA-8647
2021-11-02 16:54:07 +01:00
Ghostkeeper
67cae04a24
Remove message explaining what caused the error
It doesn't matter to the user. Only the error message matters.

Contributes to issue CURA-8609.
2021-11-01 18:29:36 +01:00
Remco Burema
acde6ae489
Apply suggestions from code review
Co-authored-by: Ghostkeeper <Ghostkeeper@users.noreply.github.com>
2021-10-31 21:21:24 +01:00
Ghostkeeper
ce4117a3ee
Reset export USB button when re-opening window
To do that, I moved the property to track that state to the root of the window.

Contributes to issue CURA-8609.
2021-10-29 15:12:16 +02:00
Jaime van Kessel
42e066a5a8 Merge branch '4.12' of github.com:Ultimaker/Cura 2021-10-28 13:54:58 +02:00