Merge branch 'maintenance' of github.com:foosel/OctoPrint into dev/permission

This commit is contained in:
Marc Hannappel committed 2017-10-27 09:11:26 +02:00
commit 08c90e0909
38 files changed
+867 -218

No files matched your search

+3 -3
View File
@@ -206,10 +206,10 @@ def login():
user = octoprint.server.userManager.findUser(username)
if user is not None:
if not user.is_active():
return make_response(("Your account is deactivated", 403, []))
if octoprint.server.userManager.checkPassword(username, password):
if not user.is_active():
return make_response(("Your account is deactivated", 403, []))
if octoprint.server.userManager.enabled:
user = octoprint.server.userManager.login_user(user)
session["usersession.id"] = user.session
+14
View File
@@ -209,6 +209,11 @@ def getSettings():
"interval": int(s.getInt(["server", "onlineCheck", "interval"]) / 60),
"host": s.get(["server", "onlineCheck", "host"]),
"port": s.getInt(["server", "onlineCheck", "port"])
},
"pluginBlacklist": {
"enabled": s.getBoolean(["server", "pluginBlacklist", "enabled"]),
"url": s.get(["server", "pluginBlacklist", "url"]),
"ttl": int(s.getInt(["server", "pluginBlacklist", "ttl"]) / 60)
}
}
}
@@ -439,6 +444,15 @@ def _saveSettings(data):
pass
if "host" in data["server"]["onlineCheck"]: s.set(["server", "onlineCheck", "host"], data["server"]["onlineCheck"]["host"])
if "port" in data["server"]["onlineCheck"]: s.setInt(["server", "onlineCheck", "port"], data["server"]["onlineCheck"]["port"])
if "pluginBlacklist" in data["server"]:
if "enabled" in data["server"]["pluginBlacklist"]: s.setBoolean(["server", "pluginBlacklist", "enabled"], data["server"]["pluginBlacklist"]["enabled"])
if "url" in data["server"]["pluginBlacklist"]: s.set(["server", "pluginBlacklist", "url"], data["server"]["pluginBlacklist"]["url"])
if "ttl" in data["server"]["pluginBlacklist"]:
try:
ttl = int(data["server"]["pluginBlacklist"]["ttl"])
s.setInt(["server", "pluginBlacklist", "ttl"], ttl * 60)
except ValueError:
pass
if "plugins" in data:
for plugin in octoprint.plugin.plugin_manager().get_implementations(octoprint.plugin.SettingsPlugin):
+16 -6
View File
@@ -22,6 +22,7 @@ from octoprint.server.api import api
from octoprint.server import NO_CONTENT
from octoprint.access.permissions import Permissions
_DATA_FORMAT_VERSION = "v2"
#~~ timelapse handling
@@ -36,7 +37,8 @@ def _config_for_timelapse(timelapse):
return dict(type="zchange",
postRoll=timelapse.post_roll,
fps=timelapse.fps,
retractionZHop=timelapse.retraction_zhop)
retractionZHop=timelapse.retraction_zhop,
minDelay=timelapse.min_delay)
elif timelapse is not None and isinstance(timelapse, octoprint.timelapse.TimedTimelapse):
return dict(type="timed",
postRoll=timelapse.post_roll,
@@ -67,6 +69,7 @@ def _etag(unrendered, lm=None):
hash = hashlib.sha1()
hash.update(str(lm))
hash.update(repr(config))
hash.update(repr(_DATA_FORMAT_VERSION))
return hash.hexdigest()
@@ -225,10 +228,7 @@ def setTimelapseConfig():
except ValueError:
return make_response("Invalid value for capturePostRoll: %r" % data["capturePostRoll"], 400)
else:
if capturePostRoll >= 0:
config["options"]["capturePostRoll"] = capturePostRoll
else:
return make_response("Invalid value for capturePostRoll: %d" % capturePostRoll, 400)
config["options"]["capturePostRoll"] = capturePostRoll
if "retractionZHop" in data:
try:
@@ -239,8 +239,18 @@ def setTimelapseConfig():
if retractionZHop >= 0:
config["options"]["retractionZHop"] = retractionZHop
else:
return make_response("Invalid value for retraction Z-Hop: %d" % retractionZHop, 400)
return make_response("Invalid value for retraction Z-Hop: %f" % retractionZHop, 400)
if "minDelay" in data:
try:
minDelay = float(data["minDelay"])
except ValueError:
return make_response("Invalid value for minimum delay: %r" % data["minDelay"], 400)
else:
if minDelay > 0:
config["options"]["minDelay"] = minDelay
else:
return make_response("Invalid value for minimum delay: %f" % minDelay, 400)
if admin_permission.can() and "save" in data and data["save"] in valid_boolean_trues:
octoprint.timelapse.configure_timelapse(config, True)