mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-10 00:07:51 -06:00
Username & cura version are now sent in the auth request
CURA-49
This commit is contained in:
parent
4b6993bf7b
commit
dd92ac7c5f
1 changed files with 9 additions and 1 deletions
|
@ -12,6 +12,7 @@ from PyQt5.QtCore import QUrl, QTimer, pyqtSignal, pyqtProperty, pyqtSlot
|
||||||
from PyQt5.QtGui import QImage
|
from PyQt5.QtGui import QImage
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
i18n_catalog = i18nCatalog("cura")
|
i18n_catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
|
@ -228,6 +229,13 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
|
||||||
data = "{\"target\": \"%s\"}" % job_state
|
data = "{\"target\": \"%s\"}" % job_state
|
||||||
self._manager.put(put_request, data.encode())
|
self._manager.put(put_request, data.encode())
|
||||||
|
|
||||||
|
def _getUserName(self):
|
||||||
|
for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'):
|
||||||
|
user = os.environ.get(name)
|
||||||
|
if user:
|
||||||
|
return user
|
||||||
|
return "Unknown User" # Couldn't find out username.
|
||||||
|
|
||||||
def startPrint(self):
|
def startPrint(self):
|
||||||
if self._progress != 0:
|
if self._progress != 0:
|
||||||
self._error_message = Message(i18n_catalog.i18nc("@info:status", "Printer is still printing. Unable to start a new job."))
|
self._error_message = Message(i18n_catalog.i18nc("@info:status", "Printer is still printing. Unable to start a new job."))
|
||||||
|
@ -292,7 +300,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
|
||||||
request = QNetworkRequest(url)
|
request = QNetworkRequest(url)
|
||||||
request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json")
|
request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json")
|
||||||
self.setAuthenticationState(AuthState.AuthenticationRequested)
|
self.setAuthenticationState(AuthState.AuthenticationRequested)
|
||||||
self._manager.post(request, json.dumps({"application": "Cura", "user":"test"}).encode())
|
self._manager.post(request, json.dumps({"application": "Cura-" + Application.getInstance().getVersion(), "user": self._getUserName()}).encode())
|
||||||
|
|
||||||
## Handler for all requests that have finished.
|
## Handler for all requests that have finished.
|
||||||
def _onFinished(self, reply):
|
def _onFinished(self, reply):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue