Merge branch 'maintenance' into devel
This commit is contained in:
commit
d88ca50de0
12 files changed
+209
-136
No files matched your search
+1
-1
@@ -268,7 +268,7 @@ See [the corresponding chapter in the documentation](http://docs.octoprint.org/e
|
||||
**ideally of only one commit** (use git's rebase and squash functionality).
|
||||
5. Make sure you **follow the current coding style**. This means:
|
||||
* Tabs instead of spaces in the Python files[2]
|
||||
* Spaces instead of tabs in the Javascript sources
|
||||
* Spaces instead of tabs in the JavaScript sources
|
||||
* English language (code, variables, comments, ...)
|
||||
* Comments where necessary: Tell *why* the code does something like it does
|
||||
it, structure your code
|
||||
|
||||
@@ -33,7 +33,7 @@ If you think something is bad about OctoPrint or its documentation the way it is
|
||||
in any way to make it better instead of just complaining about it -- this is an Open Source Project
|
||||
after all :)
|
||||
|
||||
For information about how to go about contributions of any kind, please see the project's
|
||||
For information about how to go about making contributions of any kind, please see the project's
|
||||
[Contribution Guidelines](https://github.com/foosel/OctoPrint/blob/master/CONTRIBUTING.md).
|
||||
|
||||
## Installation
|
||||
@@ -41,7 +41,7 @@ For information about how to go about contributions of any kind, please see the
|
||||
Installation instructions for installing from source for different operating
|
||||
systems can be found [on the wiki](https://github.com/foosel/OctoPrint/wiki#assorted-guides).
|
||||
|
||||
If you want to run OctoPrint on a Raspberry Pi you might want to take a look at [OctoPi](https://github.com/guysoft/OctoPi)
|
||||
If you want to run OctoPrint on a Raspberry Pi, you might want to take a look at [OctoPi](https://github.com/guysoft/OctoPi)
|
||||
which is a custom SD card image that includes OctoPrint plus dependencies.
|
||||
|
||||
The generic steps that should basically be done regardless of operating system
|
||||
@@ -59,7 +59,7 @@ for details.
|
||||
|
||||
After installation, please make sure you follow the first-run wizard and set up
|
||||
access control as necessary. If you want to not only be notified about new
|
||||
releases but also be able to automatically upgrade to them from within
|
||||
releases, but also be able to automatically upgrade to them from within
|
||||
OctoPrint, take a look [at the documentation of the Software Update Plugin](https://github.com/foosel/OctoPrint/wiki/Plugin:-Software-Update#making-octoprint-updateable-on-existing-installations)
|
||||
and at its settings.
|
||||
|
||||
@@ -70,7 +70,7 @@ OctoPrint via `setup.py`:
|
||||
|
||||
python setup.py install
|
||||
|
||||
You should also do this every time after pulling from the repository, since the dependencies might have changed.
|
||||
You should do this every time after pulling from the repository, since the dependencies may have changed.
|
||||
|
||||
OctoPrint currently only supports Python 2.7.
|
||||
|
||||
@@ -81,8 +81,8 @@ Running the `setup.py` script via
|
||||
python setup.py install
|
||||
|
||||
installs the `octoprint` script in your Python installation's scripts folder
|
||||
(which depending on whether you installed OctoPrint globally or into a virtual env will be on your `PATH` or not). The
|
||||
following usage examples assume that said `octoprint` script is on your `PATH`.
|
||||
(which, depending on whether you installed OctoPrint globally or into a virtual env, will be in your `PATH` or not). The
|
||||
following usage examples assume that the `octoprint` script is on your `PATH`.
|
||||
|
||||
You can start the server via
|
||||
|
||||
@@ -95,7 +95,7 @@ to only listen on the local interface on port 8080, the command line would be
|
||||
|
||||
octoprint serve --host=127.0.0.1 --port=8080
|
||||
|
||||
Alternatively, the host and port on which to bind can be defined via the configuration.
|
||||
Alternatively, the host and port on which to bind can be defined via the config file.
|
||||
|
||||
If you want to run OctoPrint as a daemon (only supported on Linux), use
|
||||
|
||||
@@ -103,19 +103,19 @@ If you want to run OctoPrint as a daemon (only supported on Linux), use
|
||||
|
||||
If you do not supply a custom pidfile location via `--pid PIDFILE`, it will be created at `/tmp/octoprint.pid`.
|
||||
|
||||
You can also specify the configfile or the base directory (for basing off the `uploads`, `timelapse` and `logs` folders),
|
||||
You can also specify the config file or the base directory (for basing off the `uploads`, `timelapse` and `logs` folders),
|
||||
e.g.:
|
||||
|
||||
octoprint serve --config /path/to/another/config.yaml --basedir /path/to/my/basedir
|
||||
|
||||
See `octoprint --help` for further information.
|
||||
|
||||
OctoPrint also ships with a `run` script in its source directory. You can also invoke that to start up the server, it
|
||||
OctoPrint also ships with a `run` script in its source directory. You can invoke it to start the server. It
|
||||
takes the same command line arguments as the `octoprint` script.
|
||||
|
||||
## Configuration
|
||||
|
||||
If not specified via the commandline, the configfile `config.yaml` for OctoPrint is expected in the settings folder,
|
||||
If not specified via the command line, the config file `config.yaml` for OctoPrint is expected in the settings folder,
|
||||
which is located at `~/.octoprint` on Linux, at `%APPDATA%/OctoPrint` on Windows and
|
||||
at `~/Library/Application Support/OctoPrint` on MacOS.
|
||||
|
||||
|
||||
+113
-76
@@ -34,90 +34,92 @@ Retrieve all printer profiles
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
[
|
||||
{
|
||||
"id": "_default",
|
||||
"name": "Default",
|
||||
"color": "default",
|
||||
"model": "Generic RepRap Printer",
|
||||
"default": true,
|
||||
"current": true,
|
||||
"resource": "http://example.com/api/printerprofiles/_default",
|
||||
"volume": {
|
||||
"formFactor": "rectangular",
|
||||
"origin": "lowerleft",
|
||||
"width": 200,
|
||||
"depth": 200,
|
||||
"height": 200
|
||||
},
|
||||
"heatedBed": true,
|
||||
"axes": {
|
||||
"x": {
|
||||
"speed": 6000,
|
||||
"inverted": false
|
||||
{
|
||||
"profiles": [
|
||||
{
|
||||
"id": "_default",
|
||||
"name": "Default",
|
||||
"color": "default",
|
||||
"model": "Generic RepRap Printer",
|
||||
"default": true,
|
||||
"current": true,
|
||||
"resource": "http://example.com/api/printerprofiles/_default",
|
||||
"volume": {
|
||||
"formFactor": "rectangular",
|
||||
"origin": "lowerleft",
|
||||
"width": 200,
|
||||
"depth": 200,
|
||||
"height": 200
|
||||
},
|
||||
"y": {
|
||||
"speed": 6000,
|
||||
"inverted": false
|
||||
"heatedBed": true,
|
||||
"axes": {
|
||||
"x": {
|
||||
"speed": 6000,
|
||||
"inverted": false
|
||||
},
|
||||
"y": {
|
||||
"speed": 6000,
|
||||
"inverted": false
|
||||
},
|
||||
"z": {
|
||||
"speed": 200,
|
||||
"inverted": false
|
||||
},
|
||||
"e": {
|
||||
"speed": 300,
|
||||
"inverted": false
|
||||
}
|
||||
},
|
||||
"z": {
|
||||
"speed": 200,
|
||||
"inverted": false
|
||||
},
|
||||
"e": {
|
||||
"speed": 300,
|
||||
"inverted": false
|
||||
"extruder": {
|
||||
"count": 1,
|
||||
"offsets": [
|
||||
{"x": 0.0, "y": 0.0}
|
||||
]
|
||||
}
|
||||
},
|
||||
"extruder": {
|
||||
"count": 1,
|
||||
"offsets": [
|
||||
{"x": 0.0, "y": 0.0}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "my_profile",
|
||||
"name": "My Profile",
|
||||
"color": "default",
|
||||
"model": "My Custom Printer",
|
||||
"default": false,
|
||||
"current": false,
|
||||
"resource": "http://example.com/api/printerprofiles/my_profile",
|
||||
"volume": {
|
||||
"formFactor": "rectangular",
|
||||
"origin": "lowerleft",
|
||||
"width": 200,
|
||||
"depth": 200,
|
||||
"height": 200
|
||||
},
|
||||
"heatedBed": true,
|
||||
"axes": {
|
||||
"x": {
|
||||
"speed": 6000,
|
||||
"inverted": false
|
||||
{
|
||||
"id": "my_profile",
|
||||
"name": "My Profile",
|
||||
"color": "default",
|
||||
"model": "My Custom Printer",
|
||||
"default": false,
|
||||
"current": false,
|
||||
"resource": "http://example.com/api/printerprofiles/my_profile",
|
||||
"volume": {
|
||||
"formFactor": "rectangular",
|
||||
"origin": "lowerleft",
|
||||
"width": 200,
|
||||
"depth": 200,
|
||||
"height": 200
|
||||
},
|
||||
"y": {
|
||||
"speed": 6000,
|
||||
"inverted": false
|
||||
"heatedBed": true,
|
||||
"axes": {
|
||||
"x": {
|
||||
"speed": 6000,
|
||||
"inverted": false
|
||||
},
|
||||
"y": {
|
||||
"speed": 6000,
|
||||
"inverted": false
|
||||
},
|
||||
"z": {
|
||||
"speed": 200,
|
||||
"inverted": false
|
||||
},
|
||||
"e": {
|
||||
"speed": 300,
|
||||
"inverted": false
|
||||
}
|
||||
},
|
||||
"z": {
|
||||
"speed": 200,
|
||||
"inverted": false
|
||||
},
|
||||
"e": {
|
||||
"speed": 300,
|
||||
"inverted": false
|
||||
"extruder": {
|
||||
"count": 1,
|
||||
"offsets": [
|
||||
{"x": 0.0, "y": 0.0}
|
||||
]
|
||||
}
|
||||
},
|
||||
"extruder": {
|
||||
"count": 1,
|
||||
"offsets": [
|
||||
{"x": 0.0, "y": 0.0}
|
||||
]
|
||||
}
|
||||
},
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
.. _sec-api-printerprofiles-add:
|
||||
@@ -537,6 +539,41 @@ Profile
|
||||
- 0..1
|
||||
- ``float``
|
||||
- The height of the print volume
|
||||
* - ``volume.custom_box``
|
||||
- 0..1
|
||||
- ``boolean`` or ``object``
|
||||
- If the printer has a custom bounding box where the print head can be safely moved to, exceeding the defined print
|
||||
volume, that bounding box will be defined here. Otherwise (safe area == print volume) this value will be ``false``.
|
||||
* - ``volume.custom_box.min_x``
|
||||
- 0..1
|
||||
- ``float``
|
||||
- Minimum X coordinate defining the safe custom bounding box. Smaller value than the minimum X coordinate of the
|
||||
print volume.
|
||||
* - ``volume.custom_box.max_x``
|
||||
- 0..1
|
||||
- ``float``
|
||||
- Maximum X coordinate defining the safe custom bounding box. Larger value than the maximum X coordinate of the
|
||||
print volume.
|
||||
* - ``volume.custom_box.min_y``
|
||||
- 0..1
|
||||
- ``float``
|
||||
- Minimum Y coordinate defining the safe custom bounding box. Smaller value than the minimum Y coordinate of the
|
||||
print volume.
|
||||
* - ``volume.custom_box.max_y``
|
||||
- 0..1
|
||||
- ``float``
|
||||
- Maximum Y coordinate defining the safe custom bounding box. Larger value than the maximum Y coordinate of the
|
||||
print volume.
|
||||
* - ``volume.custom_box.min_z``
|
||||
- 0..1
|
||||
- ``float``
|
||||
- Minimum Z coordinate defining the safe custom bounding box. Smaller value than the minimum Z coordinate of the
|
||||
print volume.
|
||||
* - ``volume.custom_box.max_z``
|
||||
- 0..1
|
||||
- ``float``
|
||||
- Maximum Z coordinate defining the safe custom bounding box. Larger value than the maximum Z coordinate of the
|
||||
print volume.
|
||||
* - ``heatedBed``
|
||||
- 0..1
|
||||
- ``boolean``
|
||||
|
||||
@@ -982,7 +982,15 @@ class LocalFileStorage(StorageInterface):
|
||||
continue
|
||||
|
||||
printer_profile = history_entry["printerProfile"]
|
||||
if not printer_profile:
|
||||
continue
|
||||
|
||||
print_time = history_entry["printTime"]
|
||||
try:
|
||||
print_time = float(print_time)
|
||||
except:
|
||||
self._logger.warn("Invalid print time value found in print history for {} in {}/.metadata.yaml: {!r}".format(name, path, print_time))
|
||||
continue
|
||||
|
||||
if not printer_profile in former_print_times:
|
||||
former_print_times[printer_profile] = []
|
||||
|
||||
@@ -109,6 +109,8 @@ class VirtualPrinter(object):
|
||||
|
||||
self._firmwareName = settings().get(["devel", "virtualPrinter", "firmwareName"])
|
||||
|
||||
self._okFormatString = settings().get(["devel", "virtualPrinter", "okFormatString"])
|
||||
|
||||
self.currentLine = 0
|
||||
self.lastN = 0
|
||||
|
||||
@@ -1073,11 +1075,7 @@ class VirtualPrinter(object):
|
||||
def _sendOk(self):
|
||||
if self.outgoing is None:
|
||||
return
|
||||
|
||||
if settings().getBoolean(["devel", "virtualPrinter", "okWithLinenumber"]):
|
||||
self._send("{} {}".format(self._ok(), self.lastN))
|
||||
else:
|
||||
self._send(self._ok())
|
||||
self._send(self._ok())
|
||||
|
||||
def _sendWaitAfterTimeout(self, timeout=5):
|
||||
time.sleep(timeout)
|
||||
@@ -1089,10 +1087,11 @@ class VirtualPrinter(object):
|
||||
self.outgoing.put(line)
|
||||
|
||||
def _ok(self):
|
||||
ok = "ok"
|
||||
ok = self._okFormatString
|
||||
if self._prepared_oks:
|
||||
ok = self._prepared_oks.pop(0)
|
||||
return ok
|
||||
|
||||
return ok.format(ok, lastN=self.lastN, buffer=self.buffered.maxsize - self.buffered.qsize())
|
||||
|
||||
class CharCountingQueue(queue.Queue):
|
||||
|
||||
|
||||
@@ -301,7 +301,7 @@ def index():
|
||||
|
||||
decorated_view = view
|
||||
decorated_view = util.flask.lastmodified(lambda _: compute_lastmodified())(decorated_view)
|
||||
decorated_view = util.flask.etagged(lambda _: compute_etag(additional=cache_key()))(decorated_view)
|
||||
decorated_view = util.flask.etagged(lambda _: compute_etag(additional=[cache_key()] + additional_etag))(decorated_view)
|
||||
decorated_view = util.flask.cached(timeout=-1,
|
||||
refreshif=validate_cache,
|
||||
key=cache_key,
|
||||
|
||||
@@ -335,7 +335,6 @@ default_settings = {
|
||||
"enabled": False,
|
||||
"okAfterResend": False,
|
||||
"forceChecksum": False,
|
||||
"okWithLinenumber": False,
|
||||
"numExtruders": 1,
|
||||
"includeCurrentToolInTemps": True,
|
||||
"includeFilenameInOpened": True,
|
||||
@@ -360,7 +359,8 @@ default_settings = {
|
||||
"sharedNozzle": False,
|
||||
"sendBusy": False,
|
||||
"simulateReset": True,
|
||||
"preparedOks": []
|
||||
"preparedOks": [],
|
||||
"okFormatString": "ok"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ $(function() {
|
||||
size: ko.observable(undefined)
|
||||
};
|
||||
|
||||
self.needsLoad = false;
|
||||
|
||||
self.renderer_centerModel = ko.observable(false);
|
||||
self.renderer_centerViewport = ko.observable(false);
|
||||
self.renderer_zoomOnModel = ko.observable(false);
|
||||
@@ -300,6 +302,7 @@ $(function() {
|
||||
|
||||
self.loadFile = function(path, date){
|
||||
self.enableReload(false);
|
||||
self.needsLoad = false;
|
||||
if (self.status == "idle" && self.errorCount < 3) {
|
||||
self.status = "request";
|
||||
OctoPrint.files.download("local", path)
|
||||
@@ -401,7 +404,11 @@ $(function() {
|
||||
self.loadedFileDate = undefined;
|
||||
} else {
|
||||
self.waitForApproval(false);
|
||||
self.loadFile(data.job.file.path, data.job.file.date);
|
||||
if (self.tabActive) {
|
||||
self.loadFile(data.job.file.path, data.job.file.date);
|
||||
} else {
|
||||
self.needsLoad = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -573,6 +580,9 @@ $(function() {
|
||||
|
||||
self.onTabChange = function(current, previous) {
|
||||
self.tabActive = current == "#gcode";
|
||||
if (self.tabActive && self.needsLoad) {
|
||||
self.loadFile(self.selectedFile.path(), self.selectedFile.date());
|
||||
}
|
||||
};
|
||||
|
||||
self.shiftLayer = function(value){
|
||||
|
||||
@@ -41,7 +41,7 @@ $(function() {
|
||||
}
|
||||
|
||||
OctoPrint.users.get(self.currentUser().name)
|
||||
.done(self.fromResponse);
|
||||
.done(self.updateCurrentUserData);
|
||||
};
|
||||
|
||||
self.requestData = function() {
|
||||
@@ -52,25 +52,31 @@ $(function() {
|
||||
self.fromResponse = function(response) {
|
||||
if (response && response.name) {
|
||||
self.loggedIn(true);
|
||||
self.username(response.name);
|
||||
self.isUser(response.user);
|
||||
self.isAdmin(response.admin);
|
||||
|
||||
self.currentUser(response);
|
||||
|
||||
self.updateCurrentUserData(response);
|
||||
callViewModels(self.allViewModels, "onUserLoggedIn", [response]);
|
||||
} else {
|
||||
self.loggedIn(false);
|
||||
self.username(undefined);
|
||||
self.isUser(false);
|
||||
self.isAdmin(false);
|
||||
|
||||
self.currentUser(undefined);
|
||||
|
||||
self.resetCurrentUserData();
|
||||
callViewModels(self.allViewModels, "onUserLoggedOut");
|
||||
}
|
||||
};
|
||||
|
||||
self.updateCurrentUserData = function(data) {
|
||||
self.username(data.name);
|
||||
self.isUser(data.user);
|
||||
self.isAdmin(data.admin);
|
||||
|
||||
self.currentUser(data);
|
||||
};
|
||||
|
||||
self.resetCurrentUserData = function() {
|
||||
self.username(undefined);
|
||||
self.isUser(false);
|
||||
self.isAdmin(false);
|
||||
|
||||
self.currentUser(undefined);
|
||||
};
|
||||
|
||||
self.login = function(u, p, r) {
|
||||
var username = u || self.loginUser();
|
||||
var password = p || self.loginPass();
|
||||
@@ -136,13 +142,17 @@ $(function() {
|
||||
});
|
||||
|
||||
$("body").on("click", function(e) {
|
||||
if (!toggle.hasClass("open")) {
|
||||
return;
|
||||
}
|
||||
|
||||
var anyFormLinkOrButton = $("#login_dropdown_loggedout a, #login_dropdown_loggedin a, #login_dropdown_loggedout button, #login_dropdown_loggedin button");
|
||||
var dropdown = $("li.dropdown#navbar_login");
|
||||
var anyLastpassButton = $("#__lpform_login_user, #__lpform_login_pass");
|
||||
|
||||
var isLinkOrButton = anyFormLinkOrButton.is(e.target) || anyFormLinkOrButton.has(e.target).length !== 0;
|
||||
var isDropdown = dropdown.is(e.target) || dropdown.has(e.target).length === 0;
|
||||
var isLastpass = anyLastpassButton.is(e.target) || anyLastpassButton.has(e.target).length === 0;
|
||||
var isDropdown = dropdown.is(e.target) || dropdown.has(e.target).length !== 0;
|
||||
var isLastpass = anyLastpassButton.is(e.target) || anyLastpassButton.has(e.target).length !== 0;
|
||||
|
||||
if (isLinkOrButton || !(isDropdown || isLastpass)) {
|
||||
toggle.removeClass("open");
|
||||
|
||||
@@ -8,10 +8,6 @@
|
||||
<link rel="apple-touch-icon" sizes="114x114" href="{{ url_for('static', filename='img/apple-touch-icon-114x114.png') }}">
|
||||
<link rel="apple-touch-icon" sizes="144x144" href="{{ url_for('static', filename='img/apple-touch-icon-144x144.png') }}">
|
||||
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
|
||||
{% include 'stylesheets.jinja2' %}
|
||||
{% include 'initscript.jinja2' %}
|
||||
</head>
|
||||
|
||||
+25
-19
@@ -26,7 +26,7 @@ class UserManager(object):
|
||||
def __init__(self):
|
||||
self._logger = logging.getLogger(__name__)
|
||||
self._session_users_by_session = dict()
|
||||
self._session_users_by_userid = dict()
|
||||
self._sessionids_by_userid = dict()
|
||||
self._enabled = True
|
||||
|
||||
@property
|
||||
@@ -61,9 +61,10 @@ class UserManager(object):
|
||||
self._session_users_by_session[user.get_session()] = user
|
||||
|
||||
userid = user.get_id()
|
||||
if not userid in self._session_users_by_userid:
|
||||
self._session_users_by_userid[userid] = []
|
||||
self._session_users_by_userid[userid].append(user)
|
||||
if not userid in self._sessionids_by_userid:
|
||||
self._sessionids_by_userid[userid] = set()
|
||||
|
||||
self._sessionids_by_userid[userid].add(user.get_session())
|
||||
|
||||
self._logger.debug("Logged in user: %r" % user)
|
||||
|
||||
@@ -80,15 +81,16 @@ class UserManager(object):
|
||||
return
|
||||
|
||||
userid = user.get_id()
|
||||
if userid in self._session_users_by_userid:
|
||||
users_by_userid = self._session_users_by_userid[userid]
|
||||
for u in users_by_userid:
|
||||
if u.get_session() == user.get_session():
|
||||
users_by_userid.remove(u)
|
||||
break
|
||||
sessionid = user.get_session()
|
||||
|
||||
if user.get_session() in self._session_users_by_session:
|
||||
del self._session_users_by_session[user.get_session()]
|
||||
if userid in self._sessionids_by_userid:
|
||||
try:
|
||||
self._sessionids_by_userid[userid].remove(sessionid)
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
if sessionid in self._session_users_by_session:
|
||||
del self._session_users_by_session[sessionid]
|
||||
|
||||
self._logger.debug("Logged out user: %r" % user)
|
||||
|
||||
@@ -165,13 +167,12 @@ class UserManager(object):
|
||||
pass
|
||||
|
||||
def removeUser(self, username):
|
||||
if username in self._session_users_by_userid:
|
||||
users = self._session_users_by_userid[username]
|
||||
sessions = [user.get_session() for user in users if isinstance(user, SessionUser)]
|
||||
if username in self._sessionids_by_userid:
|
||||
sessions = self._sessionids_by_userid[username]
|
||||
for session in sessions:
|
||||
if session in self._session_users_by_session:
|
||||
del self._session_users_by_session[session]
|
||||
del self._session_users_by_userid[username]
|
||||
del self._sessionids_by_userid[username]
|
||||
|
||||
def findUser(self, userid=None, session=None):
|
||||
if session is not None and session in self._session_users_by_session:
|
||||
@@ -217,6 +218,9 @@ class FilebasedUserManager(UserManager):
|
||||
if "settings" in attributes:
|
||||
settings = attributes["settings"]
|
||||
self._users[name] = User(name, attributes["password"], attributes["active"], attributes["roles"], apikey=apikey, settings=settings)
|
||||
for sessionid in self._sessionids_by_userid.get(name, set()):
|
||||
if sessionid in self._session_users_by_session:
|
||||
self._session_users_by_session[sessionid].update_user(self._users[name])
|
||||
else:
|
||||
self._customized = False
|
||||
|
||||
@@ -479,7 +483,7 @@ class User(UserMixin):
|
||||
self._roles = roles
|
||||
self._apikey = apikey
|
||||
|
||||
if not settings:
|
||||
if settings is None:
|
||||
settings = dict()
|
||||
self._settings = settings
|
||||
|
||||
@@ -590,7 +594,6 @@ class AnonymousUser(AnonymousUserMixin):
|
||||
class SessionUser(User):
|
||||
def __init__(self, user):
|
||||
self._user = user
|
||||
User.__init__(self, user._username, user._passwordHash, user._active, user._roles, user._apikey, user._settings)
|
||||
|
||||
import string
|
||||
import random
|
||||
@@ -600,7 +603,7 @@ class SessionUser(User):
|
||||
self._created = time.time()
|
||||
|
||||
def __getattribute__(self, item):
|
||||
if item in ("get_session", "_user", "_session", "_created"):
|
||||
if item in ("get_session", "update_user", "_user", "_session", "_created"):
|
||||
return object.__getattribute__(self, item)
|
||||
else:
|
||||
return getattr(object.__getattribute__(self, "_user"), item)
|
||||
@@ -614,6 +617,9 @@ class SessionUser(User):
|
||||
def get_session(self):
|
||||
return self._session
|
||||
|
||||
def update_user(self, user):
|
||||
self._user = user
|
||||
|
||||
def __repr__(self):
|
||||
return "SessionUser(id=%s,name=%s,active=%r,user=%r,admin=%r,session=%s,created=%s)" % (self.get_id(), self.get_name(), bool(self.is_active), bool(self.is_user), bool(self.is_admin), self._session, self._created)
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import tempfile
|
||||
import yaml
|
||||
import hashlib
|
||||
import ddt
|
||||
import time
|
||||
|
||||
import octoprint.settings
|
||||
|
||||
@@ -527,6 +528,9 @@ class TestSettings(unittest.TestCase):
|
||||
# current modification date of config.yaml
|
||||
current_modified = os.stat(config_path).st_mtime
|
||||
|
||||
# sleep a bit to make sure we do have a change in the timestamp
|
||||
time.sleep(1.0)
|
||||
|
||||
# set a new value
|
||||
settings.set(["api", "key"], "newkey")
|
||||
|
||||
@@ -542,6 +546,9 @@ class TestSettings(unittest.TestCase):
|
||||
settings = octoprint.settings.Settings()
|
||||
last_modified = settings.last_modified
|
||||
|
||||
# sleep a bit to make sure we do have a change in the timestamp
|
||||
time.sleep(1.0)
|
||||
|
||||
settings.save()
|
||||
self.assertEqual(settings.last_modified, last_modified)
|
||||
|
||||
|
||||
Reference in new issue
Block a user