Merge branch 'maintenance' of github.com:foosel/OctoPrint into dev/permission
This commit is contained in:
commit
08c90e0909
38 files changed
+867
-218
No files matched your search
@@ -6,7 +6,7 @@
|
||||
* [Babel JavaScript Support](https://github.com/mitsuhiko/babel/blob/master/contrib/babel.js): BSD
|
||||
* [Bootstrap](http://getbootstrap.com/): Apache License 2.0
|
||||
* [Bootstrap Modal](http://jschr.github.io/bootstrap-modal/): Apache License 2.0
|
||||
* [Bootstrap Slider Knockout Bindings](https://github.com/cosminstefanxp/bootstrap-slider-knockout-binding): MIT
|
||||
* [Bootstrap Slider Knockout Binding](https://github.com/cosminstefanxp/bootstrap-slider-knockout-binding): MIT
|
||||
* [Bootstrap Slider](http://seiyria.com/bootstrap-slider/): Apache License 2.0
|
||||
* [Bootstrap Tabdrop](http://www.eyecon.ro/bootstrap-tabdrop): Apache License 2.0
|
||||
* [Detect Mobile Browser](http://detectmobilebrowsers.com/): Public Domain
|
||||
@@ -36,6 +36,8 @@
|
||||
* [Awesome-Slugify](https://pypi.python.org/pypi/awesome-slugify): GPLv3
|
||||
* [chainmap](https://bitbucket.org/jeunice/chainmap): Python
|
||||
* [Click](http://click.pocoo.org/): BSD
|
||||
* [dateutil](https://dateutil.readthedocs.io/): BSD
|
||||
* [emoji](https://github.com/carpedm20/emoji/): BSD
|
||||
* [feedparser](https://github.com/kurtmckee/feedparser): BSD
|
||||
* [Flask](http://flask.pocoo.org/): BSD
|
||||
* [Flask-Assets](http://github.com/miracle2k/flask-assets): BSD
|
||||
@@ -44,6 +46,8 @@
|
||||
* [Flask-Markdown](http://github.com/dcolish/flask-markdown): BSD
|
||||
* [Flask-Principal](http://packages.python.org/Flask-Principal/): MIT
|
||||
* [future](https://python-future.org/): MIT
|
||||
* [futures](https://github.com/agronholm/pythonfutures): Python
|
||||
* [monotonic](https://github.com/atdt/monotonic): Apache License 2.0
|
||||
* [netaddr](https://github.com/drkjam/netaddr/): BSD
|
||||
* [netifaces](https://bitbucket.org/al45tair/netifaces): MIT
|
||||
* [pkginfo](http://pypi.python.org/pypi/pkginfo/): Python
|
||||
@@ -60,6 +64,7 @@
|
||||
* [Tornado](http://www.tornadoweb.org/): Apache License 2.0
|
||||
* [watchdog](http://github.com/gorakhargosh/watchdog): Apache License 2.0
|
||||
* [websocket-client](https://github.com/liris/websocket-client): LGPLv3
|
||||
* [wrapt](http://wrapt.readthedocs.org/): BSD
|
||||
|
||||
## Development (testing, documentation generation, etc)
|
||||
|
||||
@@ -69,4 +74,5 @@
|
||||
* [pypandoc](https://github.com/bebraw/pypandoc): MIT
|
||||
* [Sphinx](http://sphinx-doc.org/): BSD
|
||||
* [sphinxcontrib-httpdomain](https://bitbucket.org/birkenfeld/sphinx-contrib/src/default/httpdomain/): BSD
|
||||
* [sphinxcontrib-mermad](https://github.com/mgaitan/sphinxcontrib-mermaid): BSD
|
||||
* [sphinx_rtd_theme](https://github.com/snide/sphinx_rtd_theme/): BSD
|
||||
@@ -285,9 +285,13 @@ The following settings are only relevant to you if you want to do OctoPrint deve
|
||||
# to false.
|
||||
okWithLinenumber: false
|
||||
|
||||
# Number of extruders to simulate on the virtual printer.
|
||||
# Number of extruders to simulate on the virtual printer. Map from tool id (0, 1, ...) to temperature
|
||||
# in °C
|
||||
numExtruders: 1
|
||||
|
||||
# Allows pinning certain hotends to a fixed temperature
|
||||
pinnedExtruders: null
|
||||
|
||||
# Whether to include the current tool temperature in the M105 output as separate T segment or not.
|
||||
#
|
||||
# True: > M105
|
||||
@@ -304,13 +308,6 @@ The following settings are only relevant to you if you want to do OctoPrint deve
|
||||
# > File opened
|
||||
includeFilenameInOpened: true
|
||||
|
||||
# The maximum movement speeds of the simulated printer's axes, in mm/s
|
||||
movementSpeed:
|
||||
x: 6000
|
||||
y: 6000
|
||||
z: 200
|
||||
e: 300
|
||||
|
||||
# Whether the simulated printer should also simulate a heated bed or not
|
||||
hasBed: true
|
||||
|
||||
@@ -331,6 +328,18 @@ The following settings are only relevant to you if you want to do OctoPrint deve
|
||||
# to make sure nothing gets lost on the line
|
||||
repetierStyleResends: false
|
||||
|
||||
# If enabled, ok will be sent before a commands output, otherwise after or inline (M105)
|
||||
#
|
||||
# True: > M20
|
||||
# < ok
|
||||
# < Begin file list
|
||||
# < End file list
|
||||
# False: > M20
|
||||
# < Begin file list
|
||||
# < End file list
|
||||
# < ok
|
||||
okBeforeCommandOutput: false
|
||||
|
||||
# If enabled, reports the first extruder in M105 responses as T instead of T0
|
||||
#
|
||||
# True: > M105
|
||||
@@ -358,7 +367,8 @@ The following settings are only relevant to you if you want to do OctoPrint deve
|
||||
# side will block
|
||||
rxBuffer: 64
|
||||
|
||||
# Size of simulated command buffer
|
||||
# Size of simulated command buffer, number of commands. If full, buffered commands will block
|
||||
# until a slot frees up
|
||||
commandBuffer: 4
|
||||
|
||||
# Whether to support the M112 command with simulated kill
|
||||
@@ -370,6 +380,58 @@ The following settings are only relevant to you if you want to do OctoPrint deve
|
||||
# Whether to simulate broken M29 behaviour (missing ok after response)
|
||||
brokenM29: true
|
||||
|
||||
# Whether F is supported as individual command
|
||||
supportF: false
|
||||
|
||||
# Firmware name to report (useful for testing firmware detection)
|
||||
firmwareName: Virtual Marlin 1.0
|
||||
|
||||
# Simulate a shared nozzle
|
||||
sharedNozzle: false
|
||||
|
||||
# Send "busy" messages if busy processing something
|
||||
sendBusy: false
|
||||
|
||||
# Simulate a reset on connect
|
||||
simulateReset: true
|
||||
|
||||
# Lines to send on simulated reset
|
||||
resetLines:
|
||||
- start
|
||||
- Marlin: Virtual Marlin!
|
||||
- "\x80"
|
||||
- "SD card ok"
|
||||
|
||||
# Initial set of prepared oks to use instead of regular ok (e.g. to simulate
|
||||
# mis-sent oks). Can also be filled at runtime via the debug command prepare_ok
|
||||
preparedOks: []
|
||||
|
||||
# Format string for ok response.
|
||||
#
|
||||
# Placeholders:
|
||||
# - lastN: last acknowledged line number
|
||||
# - buffer: empty slots in internal command buffer
|
||||
#
|
||||
# Example format string for "extended" ok format:
|
||||
# ok N{lastN} P{buffer}
|
||||
okFormatString: ok
|
||||
|
||||
# Format string for M115 output.
|
||||
#
|
||||
# Placeholders:
|
||||
# - firmare_name: The firmware name as defined in firmwareName
|
||||
m115FormatString: "FIRMWARE_NAME: {firmware_name} PROTOCOL_VERSION:1.0"
|
||||
|
||||
# Whether to include capability report in M115 output
|
||||
m115ReportCapabilites: false
|
||||
|
||||
# Capabilities to report if capability report is enabled
|
||||
capabilities:
|
||||
AUTOREPORT_TEMP: true
|
||||
|
||||
# Simulated ambient temperature in °C
|
||||
ambientTemperature: 21.3
|
||||
|
||||
.. _sec-configuration-config_yaml-estimation:
|
||||
|
||||
Estimation
|
||||
|
||||
@@ -48,7 +48,8 @@ INSTALL_REQUIRES = [
|
||||
"python-dateutil>=2.6,<2.7",
|
||||
"wrapt>=1.10.10,<1.11",
|
||||
"futures>=3.1.1,<3.2",
|
||||
"emoji>=0.4.5,<0.5"
|
||||
"emoji>=0.4.5,<0.5",
|
||||
"monotonic>=1.3,<1.4"
|
||||
]
|
||||
|
||||
if sys.platform == "darwin":
|
||||
|
||||
+160
-8
@@ -57,8 +57,9 @@ class FatalStartupError(BaseException):
|
||||
|
||||
def init_platform(basedir, configfile, use_logging_file=True, logging_file=None,
|
||||
logging_config=None, debug=False, verbosity=0, uncaught_logger=None,
|
||||
uncaught_handler=None, safe_mode=False, after_preinit_logging=None,
|
||||
uncaught_handler=None, safe_mode=False, ignore_blacklist=False, after_preinit_logging=None,
|
||||
after_settings=None, after_logging=None, after_safe_mode=None,
|
||||
after_event_manager=None, after_connectivity_checker=None,
|
||||
after_plugin_manager=None):
|
||||
kwargs = dict()
|
||||
|
||||
@@ -94,13 +95,28 @@ def init_platform(basedir, configfile, use_logging_file=True, logging_file=None,
|
||||
if callable(after_safe_mode):
|
||||
after_safe_mode(**kwargs)
|
||||
|
||||
plugin_manager = init_pluginsystem(settings, safe_mode=safe_mode)
|
||||
event_manager = init_event_manager(settings)
|
||||
|
||||
kwargs["event_manager"] = event_manager
|
||||
if callable(after_event_manager):
|
||||
after_event_manager(**kwargs)
|
||||
|
||||
connectivity_checker = init_connectivity_checker(settings, event_manager)
|
||||
|
||||
kwargs["connectivity_checker"] = connectivity_checker
|
||||
if callable(after_connectivity_checker):
|
||||
after_connectivity_checker(**kwargs)
|
||||
|
||||
plugin_manager = init_pluginsystem(settings,
|
||||
safe_mode=safe_mode,
|
||||
ignore_blacklist=ignore_blacklist,
|
||||
connectivity_checker=connectivity_checker)
|
||||
kwargs["plugin_manager"] = plugin_manager
|
||||
|
||||
if callable(after_plugin_manager):
|
||||
after_plugin_manager(**kwargs)
|
||||
|
||||
return settings, logger, safe_mode, plugin_manager
|
||||
return settings, logger, safe_mode, event_manager, connectivity_checker, plugin_manager
|
||||
|
||||
|
||||
def init_settings(basedir, configfile):
|
||||
@@ -200,7 +216,7 @@ def init_logging(settings, use_logging_file=True, logging_file=None, default_con
|
||||
},
|
||||
"loggers": {
|
||||
"SERIAL": {
|
||||
"level": "CRITICAL",
|
||||
"level": "INFO",
|
||||
"handlers": ["serialFile"],
|
||||
"propagate": False
|
||||
},
|
||||
@@ -281,17 +297,21 @@ def set_logging_config(config, debug, verbosity, uncaught_logger, uncaught_handl
|
||||
return logger
|
||||
|
||||
|
||||
def init_pluginsystem(settings, safe_mode=False):
|
||||
def init_pluginsystem(settings, safe_mode=False, ignore_blacklist=True, connectivity_checker=None):
|
||||
"""Initializes the plugin manager based on the settings."""
|
||||
|
||||
import os
|
||||
|
||||
logger = log.getLogger(__name__)
|
||||
logger = log.getLogger(__name__ + ".startup")
|
||||
|
||||
plugin_folders = [(os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "plugins")), True),
|
||||
settings.getBaseFolder("plugins")]
|
||||
plugin_entry_points = ["octoprint.plugin"]
|
||||
plugin_disabled_list = settings.get(["plugins", "_disabled"])
|
||||
|
||||
plugin_blacklist = []
|
||||
if not ignore_blacklist and settings.getBoolean(["server", "pluginBlacklist", "enabled"]):
|
||||
plugin_blacklist = get_plugin_blacklist(settings, connectivity_checker=connectivity_checker)
|
||||
|
||||
plugin_validators = []
|
||||
if safe_mode:
|
||||
@@ -311,13 +331,14 @@ def init_pluginsystem(settings, safe_mode=False):
|
||||
plugin_folders=plugin_folders,
|
||||
plugin_entry_points=plugin_entry_points,
|
||||
plugin_disabled_list=plugin_disabled_list,
|
||||
plugin_blacklist=plugin_blacklist,
|
||||
plugin_validators=plugin_validators)
|
||||
|
||||
settings_overlays = dict()
|
||||
disabled_from_overlays = dict()
|
||||
|
||||
def handle_plugin_loaded(name, plugin):
|
||||
if hasattr(plugin.instance, "__plugin_settings_overlay__"):
|
||||
if plugin.instance and hasattr(plugin.instance, "__plugin_settings_overlay__"):
|
||||
plugin.needs_restart = True
|
||||
|
||||
# plugin has a settings overlay, inject it
|
||||
@@ -356,7 +377,7 @@ def init_pluginsystem(settings, safe_mode=False):
|
||||
|
||||
if not addon in already_processed and not addon in disabled_list:
|
||||
disabled_list.append(addon)
|
||||
logger.info("Disabling plugin {} as defined by plugin {} through settings overlay".format(addon, name))
|
||||
logger.info("Disabling plugin {} as defined by plugin {}".format(addon, name))
|
||||
already_processed.append(name)
|
||||
|
||||
def handle_plugin_enabled(name, plugin):
|
||||
@@ -370,6 +391,137 @@ def init_pluginsystem(settings, safe_mode=False):
|
||||
pm.reload_plugins(startup=True, initialize_implementations=False)
|
||||
return pm
|
||||
|
||||
|
||||
def get_plugin_blacklist(settings, connectivity_checker=None):
|
||||
import requests
|
||||
import os
|
||||
import time
|
||||
import yaml
|
||||
|
||||
from octoprint.util import bom_aware_open
|
||||
from octoprint.util.version import is_octoprint_compatible
|
||||
|
||||
logger = log.getLogger(__name__ + ".startup")
|
||||
|
||||
if connectivity_checker is not None and not connectivity_checker.online:
|
||||
logger.info("We don't appear to be online, not fetching plugin blacklist")
|
||||
return []
|
||||
|
||||
def format_blacklist(entries):
|
||||
format_entry = lambda x: "{} ({})".format(x[0], x[1]) if isinstance(x, (list, tuple)) and len(x) == 2 \
|
||||
else "{} (any)".format(x)
|
||||
return ", ".join(map(format_entry, entries))
|
||||
|
||||
def process_blacklist(entries):
|
||||
result = []
|
||||
|
||||
if not isinstance(entries, list):
|
||||
return result
|
||||
|
||||
for entry in entries:
|
||||
if not "plugin" in entry:
|
||||
continue
|
||||
|
||||
if "octoversions" in entry and not is_octoprint_compatible(*entry["octoversions"]):
|
||||
continue
|
||||
|
||||
if "version" in entry:
|
||||
logger.debug("Blacklisted plugin: {}, version: {}".format(entry["plugin"], entry["version"]))
|
||||
result.append((entry["plugin"], entry["version"]))
|
||||
elif "versions" in entry:
|
||||
logger.debug("Blacklisted plugin: {}, versions: {}".format(entry["plugin"], ", ".join(entry["versions"])))
|
||||
for version in entry["versions"]:
|
||||
result.append((entry["plugin"], version))
|
||||
else:
|
||||
logger.debug("Blacklisted plugin: {}".format(entry["plugin"]))
|
||||
result.append(entry["key"])
|
||||
|
||||
return result
|
||||
|
||||
def fetch_blacklist_from_cache(path, ttl):
|
||||
if not os.path.isfile(path):
|
||||
return None
|
||||
|
||||
if os.stat(path).st_mtime + ttl < time.time():
|
||||
return None
|
||||
|
||||
with bom_aware_open(path, encoding="utf-8", mode="r") as f:
|
||||
result = yaml.safe_load(f)
|
||||
|
||||
if isinstance(result, list):
|
||||
return result
|
||||
|
||||
def fetch_blacklist_from_url(url, timeout=3, cache=None):
|
||||
result = []
|
||||
try:
|
||||
r = requests.get(url, timeout=timeout)
|
||||
result = process_blacklist(r.json())
|
||||
|
||||
if cache is not None:
|
||||
try:
|
||||
with bom_aware_open(cache, encoding="utf-8", mode="w") as f:
|
||||
yaml.safe_dump(result, f)
|
||||
except:
|
||||
logger.info("Fetched plugin blacklist but couldn't write it to its cache file.")
|
||||
except:
|
||||
logger.info("Unable to fetch plugin blacklist from {}, proceeding without it.".format(url))
|
||||
return result
|
||||
|
||||
try:
|
||||
# first attempt to fetch from cache
|
||||
cache_path = os.path.join(settings.getBaseFolder("data"), "plugin_blacklist.yaml")
|
||||
ttl = settings.getInt(["server", "pluginBlacklist", "ttl"])
|
||||
blacklist = fetch_blacklist_from_cache(cache_path, ttl)
|
||||
|
||||
if blacklist is None:
|
||||
# no result from the cache, let's fetch it fresh
|
||||
url = settings.get(["server", "pluginBlacklist", "url"])
|
||||
timeout = settings.getFloat(["server", "pluginBlacklist", "timeout"])
|
||||
blacklist = fetch_blacklist_from_url(url, timeout=timeout, cache=cache_path)
|
||||
|
||||
if blacklist is None:
|
||||
# still now result, so no blacklist
|
||||
blacklist = []
|
||||
|
||||
if blacklist:
|
||||
logger.info("Blacklist processing done, "
|
||||
"adding {} blacklisted plugin versions: {}".format(len(blacklist),
|
||||
format_blacklist(blacklist)))
|
||||
else:
|
||||
logger.info("Blacklist processing done")
|
||||
|
||||
return blacklist
|
||||
except:
|
||||
logger.exception("Something went wrong while processing the plugin blacklist. Proceeding without it.")
|
||||
|
||||
|
||||
def init_event_manager(settings):
|
||||
from octoprint.events import eventManager
|
||||
return eventManager()
|
||||
|
||||
|
||||
def init_connectivity_checker(settings, event_manager):
|
||||
from octoprint.events import Events
|
||||
from octoprint.util import ConnectivityChecker
|
||||
|
||||
# start regular check if we are connected to the internet
|
||||
connectivityEnabled = settings.getBoolean(["server", "onlineCheck", "enabled"])
|
||||
connectivityInterval = settings.getInt(["server", "onlineCheck", "interval"])
|
||||
connectivityHost = settings.get(["server", "onlineCheck", "host"])
|
||||
connectivityPort = settings.getInt(["server", "onlineCheck", "port"])
|
||||
|
||||
def on_connectivity_change(old_value, new_value):
|
||||
event_manager.fire(Events.CONNECTIVITY_CHANGED, payload=dict(old=old_value, new=new_value))
|
||||
|
||||
connectivityChecker = ConnectivityChecker(connectivityInterval,
|
||||
connectivityHost,
|
||||
port=connectivityPort,
|
||||
enabled=connectivityEnabled,
|
||||
on_change=on_connectivity_change)
|
||||
|
||||
return connectivityChecker
|
||||
|
||||
|
||||
#~~ server main method
|
||||
|
||||
def main():
|
||||
|
||||
@@ -106,9 +106,9 @@ def standard_options(hidden=False):
|
||||
factory("--config", "-c", "configfile", type=click.Path(), callback=set_ctx_obj_option, is_eager=True, expose_value=False,
|
||||
help="Specify the config file to use."),
|
||||
factory("--verbose", "-v", "verbosity", count=True, callback=set_ctx_obj_option, is_eager=True, expose_value=False,
|
||||
help="Increase logging verbosity"),
|
||||
help="Increase logging verbosity."),
|
||||
factory("--safe", "safe_mode", is_flag=True, callback=set_ctx_obj_option, is_eager=True, expose_value=False,
|
||||
help="Enable safe mode; disables all third party plugins")
|
||||
help="Enable safe mode; disables all third party plugins.")
|
||||
]
|
||||
|
||||
return bulk_options(options)
|
||||
@@ -123,6 +123,7 @@ legacy_options = bulk_options([
|
||||
hidden_option("--daemon", type=click.Choice(["start", "stop", "restart"]), callback=set_ctx_obj_option),
|
||||
hidden_option("--pid", type=click.Path(), default="/tmp/octoprint.pid", callback=set_ctx_obj_option),
|
||||
hidden_option("--iknowwhatimdoing", "allow_root", is_flag=True, callback=set_ctx_obj_option),
|
||||
hidden_option("--ignore-blacklist", "ignore_blacklist", is_flag=True, callback=set_ctx_obj_option)
|
||||
])
|
||||
"""Legacy options available directly on the "octoprint" command in earlier versions.
|
||||
Kept available for reasons of backwards compatibility, but hidden from the
|
||||
|
||||
@@ -43,6 +43,7 @@ class OctoPrintPluginCommands(click.MultiCommand):
|
||||
if self._initialized:
|
||||
return
|
||||
|
||||
click.echo("Initializing settings & plugin subsystem...")
|
||||
if ctx.obj is None:
|
||||
ctx.obj = OctoPrintContext()
|
||||
|
||||
@@ -51,7 +52,8 @@ class OctoPrintPluginCommands(click.MultiCommand):
|
||||
from octoprint import init_settings, init_pluginsystem, FatalStartupError
|
||||
try:
|
||||
self.settings = init_settings(get_ctx_obj_option(ctx, "basedir", None), get_ctx_obj_option(ctx, "configfile", None))
|
||||
self.plugin_manager = init_pluginsystem(self.settings, safe_mode=get_ctx_obj_option(ctx, "safe_mode", False))
|
||||
self.plugin_manager = init_pluginsystem(self.settings,
|
||||
safe_mode=get_ctx_obj_option(ctx, "safe_mode", False))
|
||||
except FatalStartupError as e:
|
||||
click.echo(e.message, err=True)
|
||||
click.echo("There was a fatal error initializing the settings or the plugin system.", err=True)
|
||||
|
||||
+32
-20
@@ -11,7 +11,8 @@ import sys
|
||||
|
||||
from octoprint.cli import bulk_options, standard_options, set_ctx_obj_option, get_ctx_obj_option
|
||||
|
||||
def run_server(basedir, configfile, host, port, debug, allow_root, logging_config, verbosity, safe_mode, octoprint_daemon=None):
|
||||
def run_server(basedir, configfile, host, port, debug, allow_root, logging_config, verbosity, safe_mode,
|
||||
ignore_blacklist, octoprint_daemon=None):
|
||||
"""Initializes the environment and starts up the server."""
|
||||
|
||||
from octoprint import init_platform, __display_version__, FatalStartupError
|
||||
@@ -19,7 +20,7 @@ def run_server(basedir, configfile, host, port, debug, allow_root, logging_confi
|
||||
def log_startup(recorder=None, safe_mode=None, **kwargs):
|
||||
from octoprint.logging import get_divider_line
|
||||
|
||||
logger = logging.getLogger("octoprint.server")
|
||||
logger = logging.getLogger("octoprint.startup")
|
||||
|
||||
logger.info(get_divider_line("*"))
|
||||
logger.info("Starting OctoPrint {}".format(__display_version__))
|
||||
@@ -71,15 +72,17 @@ def run_server(basedir, configfile, host, port, debug, allow_root, logging_confi
|
||||
OctoPrintLogHandler.registerRolloverCallback(rollover_callback)
|
||||
|
||||
try:
|
||||
settings, _, safe_mode, plugin_manager = init_platform(basedir,
|
||||
configfile,
|
||||
logging_file=logging_config,
|
||||
debug=debug,
|
||||
verbosity=verbosity,
|
||||
uncaught_logger=__name__,
|
||||
safe_mode=safe_mode,
|
||||
after_safe_mode=log_startup,
|
||||
after_plugin_manager=log_register_rollover)
|
||||
settings, _, safe_mode, event_manager, \
|
||||
connectivity_checker, plugin_manager = init_platform(basedir,
|
||||
configfile,
|
||||
logging_file=logging_config,
|
||||
debug=debug,
|
||||
verbosity=verbosity,
|
||||
uncaught_logger=__name__,
|
||||
safe_mode=safe_mode,
|
||||
ignore_blacklist=ignore_blacklist,
|
||||
after_safe_mode=log_startup,
|
||||
after_plugin_manager=log_register_rollover)
|
||||
except FatalStartupError as e:
|
||||
click.echo(e.message, err=True)
|
||||
click.echo("There was a fatal error starting up OctoPrint.", err=True)
|
||||
@@ -87,6 +90,8 @@ def run_server(basedir, configfile, host, port, debug, allow_root, logging_confi
|
||||
from octoprint.server import Server
|
||||
octoprint_server = Server(settings=settings,
|
||||
plugin_manager=plugin_manager,
|
||||
event_manager=event_manager,
|
||||
connectivity_checker=connectivity_checker,
|
||||
host=host,
|
||||
port=port,
|
||||
debug=debug,
|
||||
@@ -107,7 +112,9 @@ server_options = bulk_options([
|
||||
click.option("--iknowwhatimdoing", "allow_root", is_flag=True, callback=set_ctx_obj_option,
|
||||
help="Allow OctoPrint to run as user root."),
|
||||
click.option("--debug", is_flag=True, callback=set_ctx_obj_option,
|
||||
help="Enable debug mode.")
|
||||
help="Enable debug mode."),
|
||||
click.option("--ignore-blacklist", "ignore_blacklist", is_flag=True, callback=set_ctx_obj_option,
|
||||
help="Disable processing of the plugin blacklist.")
|
||||
])
|
||||
"""Decorator to add the options shared among the server commands: ``--host``, ``--port``,
|
||||
``--logging``, ``--iknowwhatimdoing`` and ``--debug``."""
|
||||
@@ -126,7 +133,7 @@ def server_commands():
|
||||
|
||||
|
||||
@server_commands.command(name="safemode")
|
||||
@standard_options(hidden=True)
|
||||
@standard_options()
|
||||
@click.pass_context
|
||||
def enable_safemode(ctx, **kwargs):
|
||||
"""Sets the safe mode flag for the next start."""
|
||||
@@ -147,8 +154,8 @@ def enable_safemode(ctx, **kwargs):
|
||||
|
||||
|
||||
@server_commands.command(name="serve")
|
||||
@standard_options()
|
||||
@server_options
|
||||
@standard_options(hidden=True)
|
||||
@click.pass_context
|
||||
def serve_command(ctx, **kwargs):
|
||||
"""Starts the OctoPrint server."""
|
||||
@@ -166,18 +173,20 @@ def serve_command(ctx, **kwargs):
|
||||
configfile = get_value("configfile")
|
||||
verbosity = get_value("verbosity")
|
||||
safe_mode = get_value("safe_mode")
|
||||
ignore_blacklist = get_value("ignore_blacklist")
|
||||
|
||||
run_server(basedir, configfile, host, port, debug,
|
||||
allow_root, logging, verbosity, safe_mode)
|
||||
allow_root, logging, verbosity, safe_mode,
|
||||
ignore_blacklist)
|
||||
|
||||
|
||||
if sys.platform != "win32" and sys.platform != "darwin":
|
||||
# we do not support daemon mode under windows or macosx
|
||||
|
||||
@server_commands.command(name="daemon")
|
||||
@standard_options()
|
||||
@server_options
|
||||
@daemon_options
|
||||
@standard_options(hidden=True)
|
||||
@click.argument("command", type=click.Choice(["start", "stop", "restart", "status"]),
|
||||
metavar="start|stop|restart|status")
|
||||
@click.pass_context
|
||||
@@ -185,7 +194,7 @@ if sys.platform != "win32" and sys.platform != "darwin":
|
||||
"""
|
||||
Starts, stops or restarts in daemon mode.
|
||||
|
||||
Please note that daemon mode is only supported under Linux right now.
|
||||
Please note that daemon mode is not supported under Windows and MacOSX right now.
|
||||
"""
|
||||
|
||||
def get_value(key):
|
||||
@@ -202,6 +211,7 @@ if sys.platform != "win32" and sys.platform != "darwin":
|
||||
configfile = get_value("configfile")
|
||||
verbosity = get_value("verbosity")
|
||||
safe_mode = get_value("safe_mode")
|
||||
ignore_blacklist = get_value("ignore_blacklist")
|
||||
|
||||
if pid is None:
|
||||
click.echo("No path to a pidfile set",
|
||||
@@ -210,7 +220,8 @@ if sys.platform != "win32" and sys.platform != "darwin":
|
||||
|
||||
from octoprint.daemon import Daemon
|
||||
class OctoPrintDaemon(Daemon):
|
||||
def __init__(self, pidfile, basedir, configfile, host, port, debug, allow_root, logging_config, verbosity, safe_mode):
|
||||
def __init__(self, pidfile, basedir, configfile, host, port, debug, allow_root, logging_config, verbosity,
|
||||
safe_mode, ignore_blacklist):
|
||||
Daemon.__init__(self, pidfile)
|
||||
|
||||
self._basedir = basedir
|
||||
@@ -222,14 +233,15 @@ if sys.platform != "win32" and sys.platform != "darwin":
|
||||
self._logging_config = logging_config
|
||||
self._verbosity = verbosity
|
||||
self._safe_mode = safe_mode
|
||||
self._ignore_blacklist = ignore_blacklist
|
||||
|
||||
def run(self):
|
||||
run_server(self._basedir, self._configfile, self._host, self._port, self._debug,
|
||||
self._allow_root, self._logging_config, self._verbosity, self._safe_mode,
|
||||
octoprint_daemon=self)
|
||||
self._ignore_blacklist, octoprint_daemon=self)
|
||||
|
||||
octoprint_daemon = OctoPrintDaemon(pid, basedir, configfile, host, port, debug, allow_root, logging, verbosity,
|
||||
safe_mode)
|
||||
safe_mode, ignore_blacklist)
|
||||
|
||||
if command == "start":
|
||||
octoprint_daemon.start()
|
||||
|
||||
@@ -45,7 +45,8 @@ def _validate_plugin(phase, plugin_info):
|
||||
return True
|
||||
|
||||
def plugin_manager(init=False, plugin_folders=None, plugin_types=None, plugin_entry_points=None, plugin_disabled_list=None,
|
||||
plugin_restart_needing_hooks=None, plugin_obsolete_hooks=None, plugin_validators=None):
|
||||
plugin_blacklist=None, plugin_restart_needing_hooks=None, plugin_obsolete_hooks=None,
|
||||
plugin_validators=None):
|
||||
"""
|
||||
Factory method for initially constructing and consecutively retrieving the :class:`~octoprint.plugin.core.PluginManager`
|
||||
singleton.
|
||||
@@ -65,6 +66,7 @@ def plugin_manager(init=False, plugin_folders=None, plugin_types=None, plugin_en
|
||||
this defaults to the entry point ``octoprint.plugin``.
|
||||
plugin_disabled_list (list): A list of plugin identifiers that are currently disabled. If not provided this
|
||||
defaults to all plugins for which ``enabled`` is set to ``False`` in the settings.
|
||||
plugin_blacklist (list): A list of plugin identifiers/identifier-version tuples that are currently blacklisted.
|
||||
plugin_restart_needing_hooks (list): A list of hook namespaces which cause a plugin to need a restart in order
|
||||
be enabled/disabled. Does not have to contain full hook identifiers, will be matched with startswith similar
|
||||
to logging handlers
|
||||
@@ -120,6 +122,7 @@ def plugin_manager(init=False, plugin_folders=None, plugin_types=None, plugin_en
|
||||
plugin_entry_points,
|
||||
logging_prefix="octoprint.plugins.",
|
||||
plugin_disabled_list=plugin_disabled_list,
|
||||
plugin_blacklist=plugin_blacklist,
|
||||
plugin_restart_needing_hooks=plugin_restart_needing_hooks,
|
||||
plugin_obsolete_hooks=plugin_obsolete_hooks,
|
||||
plugin_validators=plugin_validators)
|
||||
|
||||
@@ -36,6 +36,8 @@ import fnmatch
|
||||
import pkg_resources
|
||||
import pkginfo
|
||||
|
||||
from past.builtins import basestring
|
||||
|
||||
try:
|
||||
from os import scandir
|
||||
except ImportError:
|
||||
@@ -57,7 +59,7 @@ class PluginInfo(object):
|
||||
Arguments:
|
||||
key (str): Identifier of the plugin
|
||||
location (str): Installation folder of the plugin
|
||||
instance (module): Plugin module instance
|
||||
instance (module): Plugin module instance - this may be ``None`` if the plugin has been blacklisted!
|
||||
name (str): Human readable name of the plugin
|
||||
version (str): Version of the plugin
|
||||
description (str): Description of the plugin
|
||||
@@ -140,6 +142,7 @@ class PluginInfo(object):
|
||||
self.instance = instance
|
||||
self.origin = None
|
||||
self.enabled = True
|
||||
self.blacklisted = False
|
||||
self.bundled = False
|
||||
self.loaded = False
|
||||
self.managable = True
|
||||
@@ -201,7 +204,7 @@ class PluginInfo(object):
|
||||
|
||||
def long_str(self, show_bundled=False, bundled_strs=(" [B]", ""),
|
||||
show_location=False, location_str=" - {location}",
|
||||
show_enabled=False, enabled_strs=("* ", " ")):
|
||||
show_enabled=False, enabled_strs=("* ", " ", "X ")):
|
||||
"""
|
||||
Long string representation of the plugin's information. Will return a string of the format ``<enabled><str(self)><bundled><location>``.
|
||||
|
||||
@@ -209,8 +212,8 @@ class PluginInfo(object):
|
||||
The will be filled from ``enabled_str``, ``bundled_str`` and ``location_str`` as follows:
|
||||
|
||||
``enabled_str``
|
||||
a 2-tuple, the first entry being the string to insert when the plugin is enabled, the second
|
||||
entry the string to insert when it is not.
|
||||
a 3-tuple, the first entry being the string to insert when the plugin is enabled, the second
|
||||
entry the string to insert when it is not, the third entry the string when it is blacklisted.
|
||||
``bundled_str``
|
||||
a 2-tuple, the first entry being the string to insert when the plugin is bundled, the second
|
||||
entry the string to insert when it is not.
|
||||
@@ -230,7 +233,7 @@ class PluginInfo(object):
|
||||
str: The long string representation of the plugin as described above
|
||||
"""
|
||||
if show_enabled:
|
||||
ret = enabled_strs[0] if self.enabled else enabled_strs[1]
|
||||
ret = enabled_strs[2] if self.blacklisted else (enabled_strs[0] if self.enabled else enabled_strs[1])
|
||||
else:
|
||||
ret = ""
|
||||
|
||||
@@ -445,7 +448,7 @@ class PluginInfo(object):
|
||||
return self._get_instance_attribute(self.__class__.attr_disable, default=lambda: True)
|
||||
|
||||
def _get_instance_attribute(self, attr, default=None, defaults=None):
|
||||
if not hasattr(self.instance, attr):
|
||||
if self.instance is None or not hasattr(self.instance, attr):
|
||||
if defaults is not None:
|
||||
for value in defaults:
|
||||
if value is not None:
|
||||
@@ -463,8 +466,8 @@ class PluginManager(object):
|
||||
"""
|
||||
|
||||
def __init__(self, plugin_folders, plugin_types, plugin_entry_points, logging_prefix=None,
|
||||
plugin_disabled_list=None, plugin_restart_needing_hooks=None, plugin_obsolete_hooks=None,
|
||||
plugin_validators=None):
|
||||
plugin_disabled_list=None, plugin_blacklist=None, plugin_restart_needing_hooks=None,
|
||||
plugin_obsolete_hooks=None, plugin_validators=None):
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
if logging_prefix is None:
|
||||
@@ -477,11 +480,14 @@ class PluginManager(object):
|
||||
plugin_entry_points = []
|
||||
if plugin_disabled_list is None:
|
||||
plugin_disabled_list = []
|
||||
if plugin_blacklist is None:
|
||||
plugin_blacklist = []
|
||||
|
||||
self.plugin_folders = plugin_folders
|
||||
self.plugin_types = plugin_types
|
||||
self.plugin_entry_points = plugin_entry_points
|
||||
self.plugin_disabled_list = plugin_disabled_list
|
||||
self.plugin_blacklist = plugin_blacklist
|
||||
self.plugin_restart_needing_hooks = plugin_restart_needing_hooks
|
||||
self.plugin_obsolete_hooks = plugin_obsolete_hooks
|
||||
self.plugin_validators = plugin_validators
|
||||
@@ -543,7 +549,7 @@ class PluginManager(object):
|
||||
if existing is None:
|
||||
existing = dict(self.plugins)
|
||||
|
||||
result = dict()
|
||||
result = OrderedDict()
|
||||
if self.plugin_folders:
|
||||
result.update(self._find_plugins_from_folders(self.plugin_folders, existing, ignored_uninstalled=ignore_uninstalled))
|
||||
if self.plugin_entry_points:
|
||||
@@ -552,7 +558,7 @@ class PluginManager(object):
|
||||
return result
|
||||
|
||||
def _find_plugins_from_folders(self, folders, existing, ignored_uninstalled=True):
|
||||
result = dict()
|
||||
result = OrderedDict()
|
||||
|
||||
for folder in folders:
|
||||
flagged_readonly = False
|
||||
@@ -596,7 +602,7 @@ class PluginManager(object):
|
||||
return result
|
||||
|
||||
def _find_plugins_from_entry_points(self, groups, existing, ignore_uninstalled=True):
|
||||
result = dict()
|
||||
result = OrderedDict()
|
||||
|
||||
# let's make sure we have a current working set ...
|
||||
working_set = pkg_resources.WorkingSet()
|
||||
@@ -674,6 +680,12 @@ class PluginManager(object):
|
||||
self.logger.warn("Could not locate plugin {key}".format(key=key))
|
||||
return None
|
||||
|
||||
if self._is_plugin_blacklisted(key) or (version is not None and self._is_plugin_version_blacklisted(key, version)):
|
||||
plugin = PluginInfo(key, module[1], None, name=name, version=version, description=summary, author=author, url=url, license=license)
|
||||
plugin.blacklisted = True
|
||||
self.logger.warn("Plugin {} is blacklisted. Not importing it, only registering a dummy entry.".format(plugin))
|
||||
return plugin
|
||||
|
||||
plugin = self._import_plugin(key, *module, name=name, version=version, summary=summary, author=author, url=url, license=license)
|
||||
if plugin is None:
|
||||
return None
|
||||
@@ -696,6 +708,19 @@ class PluginManager(object):
|
||||
def _is_plugin_disabled(self, key):
|
||||
return key in self.plugin_disabled_list or key.endswith('disabled')
|
||||
|
||||
def _is_plugin_blacklisted(self, key):
|
||||
return key in self.plugin_blacklist
|
||||
|
||||
def _is_plugin_version_blacklisted(self, key, version):
|
||||
def matches_plugin(entry):
|
||||
if isinstance(entry, (tuple, list)) and len(entry) == 2:
|
||||
entry_key, entry_version = entry
|
||||
return entry_key == key and entry_version == version
|
||||
return False
|
||||
|
||||
return any(map(lambda entry: matches_plugin(entry),
|
||||
self.plugin_blacklist))
|
||||
|
||||
def reload_plugins(self, startup=False, initialize_implementations=True, force_reload=None):
|
||||
self.logger.info("Loading plugins from {folders} and installed plugin packages...".format(
|
||||
folders=", ".join(map(lambda x: x[0] if isinstance(x, tuple) else str(x), self.plugin_folders))
|
||||
@@ -710,7 +735,8 @@ class PluginManager(object):
|
||||
# 1st pass: loading the plugins
|
||||
for name, plugin in plugins.items():
|
||||
try:
|
||||
self.load_plugin(name, plugin, startup=startup, initialize_implementation=initialize_implementations)
|
||||
if not plugin.blacklisted:
|
||||
self.load_plugin(name, plugin, startup=startup, initialize_implementation=initialize_implementations)
|
||||
except PluginNeedsRestart:
|
||||
pass
|
||||
except PluginLifecycleException as e:
|
||||
@@ -724,6 +750,9 @@ class PluginManager(object):
|
||||
for name, plugin in plugins.items():
|
||||
try:
|
||||
if plugin.loaded and not self._is_plugin_disabled(name):
|
||||
if plugin.blacklisted:
|
||||
self.logger.warn("Plugin {} is blacklisted. Not enabling it.".format(plugin))
|
||||
continue
|
||||
self.enable_plugin(name, plugin=plugin, initialize_implementation=initialize_implementations, startup=startup)
|
||||
except PluginNeedsRestart:
|
||||
pass
|
||||
@@ -780,6 +809,11 @@ class PluginManager(object):
|
||||
|
||||
plugin.loaded = True
|
||||
|
||||
# we might only now have a version, so check again if we are blacklisted
|
||||
if not plugin.blacklisted and plugin.version and self._is_plugin_version_blacklisted(plugin.key,
|
||||
plugin.version):
|
||||
plugin.blacklisted = True
|
||||
|
||||
self.logger.debug("Loaded plugin {name}: {plugin}".format(**locals()))
|
||||
except PluginLifecycleException as e:
|
||||
raise e
|
||||
@@ -1146,7 +1180,7 @@ class PluginManager(object):
|
||||
|
||||
|
||||
def log_all_plugins(self, show_bundled=True, bundled_str=(" (bundled)", ""), show_location=True,
|
||||
location_str=" = {location}", show_enabled=True, enabled_str=(" ", "!"),
|
||||
location_str=" = {location}", show_enabled=True, enabled_str=(" ", "!", "#"),
|
||||
only_to_handler=None):
|
||||
all_plugins = self.enabled_plugins.values() + self.disabled_plugins.values()
|
||||
|
||||
|
||||
@@ -62,7 +62,8 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin,
|
||||
def get_assets(self):
|
||||
if self.is_wizard_required():
|
||||
return dict(
|
||||
js=["js/corewizard.js"]
|
||||
js=["js/corewizard.js"],
|
||||
css=["css/corewizard.css"]
|
||||
)
|
||||
else:
|
||||
return dict()
|
||||
@@ -91,7 +92,7 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin,
|
||||
return result
|
||||
|
||||
def get_wizard_version(self):
|
||||
return 1
|
||||
return 2
|
||||
|
||||
#~~ ACL subwizard
|
||||
|
||||
@@ -190,6 +191,23 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin,
|
||||
def _get_onlinecheck_additional_wizard_template_data(self):
|
||||
return dict(mandatory=self._is_onlinecheck_wizard_required())
|
||||
|
||||
#~~ Plugin blacklist subwizard
|
||||
|
||||
def _is_pluginblacklist_wizard_firstrunonly(self):
|
||||
return False
|
||||
|
||||
def _is_pluginblacklist_wizard_required(self):
|
||||
return self._settings.global_get(["server", "pluginBlacklist", "enabled"]) is None
|
||||
|
||||
def _get_pluginblacklist_wizard_details(self):
|
||||
return dict(required=self._is_pluginblacklist_wizard_required())
|
||||
|
||||
def _get_pluginblacklist_wizard_name(self):
|
||||
return gettext("Plugin blacklist")
|
||||
|
||||
def _get_pluginblacklist_additional_wizard_template_data(self):
|
||||
return dict(mandatory=self._is_pluginblacklist_wizard_required())
|
||||
|
||||
#~~ Printer profile subwizard
|
||||
|
||||
def _is_printerprofile_wizard_firstrunonly(self):
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
#wizard_plugin_corewizard_pluginblacklist p {
|
||||
line-height: 1.5;
|
||||
margin-bottom: 1.5em;
|
||||
}
|
||||
@@ -207,6 +207,85 @@ $(function() {
|
||||
|
||||
}
|
||||
|
||||
function CoreWizardPluginBlacklistViewModel(parameters) {
|
||||
var self = this;
|
||||
|
||||
self.settingsViewModel = parameters[0];
|
||||
|
||||
self.setup = ko.observable(false);
|
||||
|
||||
self.decision = ko.observable();
|
||||
self.required = false;
|
||||
self.active = false;
|
||||
|
||||
self.enablePluginBlacklist = function() {
|
||||
self.settingsViewModel.server_pluginBlacklist_enabled(true);
|
||||
self.decision(true);
|
||||
self._sendData();
|
||||
};
|
||||
|
||||
self.disablePluginBlacklist = function() {
|
||||
self.settingsViewModel.server_pluginBlacklist_enabled(false);
|
||||
self.decision(false);
|
||||
self._sendData();
|
||||
};
|
||||
|
||||
self.onBeforeWizardTabChange = function(next, current) {
|
||||
if (!self.required) return true;
|
||||
|
||||
if (!current || !_.startsWith(current, "wizard_plugin_corewizard_pluginblacklist_") || self.setup()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
self._showDecisionNeededDialog();
|
||||
return false;
|
||||
};
|
||||
|
||||
self.onBeforeWizardFinish = function() {
|
||||
if (!self.required) return true;
|
||||
|
||||
if (self.setup()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
self._showDecisionNeededDialog();
|
||||
return false;
|
||||
};
|
||||
|
||||
self.onWizardPreventSettingsRefreshDialog = function() {
|
||||
return self.active;
|
||||
};
|
||||
|
||||
self.onWizardDetails = function(response) {
|
||||
self.required = response && response.corewizard && response.corewizard.details && response.corewizard.details.pluginblacklist && response.corewizard.details.pluginblacklist.required;
|
||||
};
|
||||
|
||||
self._showDecisionNeededDialog = function() {
|
||||
showMessageDialog({
|
||||
title: gettext("Please set up the plugin blacklist processing"),
|
||||
message: gettext("You haven't yet decided on whether to enable or disable the plugin blacklist processing. You need to either enable or disable it before continuing.")
|
||||
});
|
||||
};
|
||||
|
||||
self._sendData = function() {
|
||||
var data = {
|
||||
server: {
|
||||
pluginBlacklist: {
|
||||
enabled: self.settingsViewModel.server_pluginBlacklist_enabled()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
self.active = true;
|
||||
self.settingsViewModel.saveData(data)
|
||||
.done(function() {
|
||||
self.setup(true);
|
||||
self.active = false;
|
||||
});
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
function CoreWizardPrinterProfileViewModel(parameters) {
|
||||
var self = this;
|
||||
|
||||
@@ -258,6 +337,10 @@ $(function() {
|
||||
CoreWizardOnlineCheckViewModel,
|
||||
["settingsViewModel"],
|
||||
"#wizard_plugin_corewizard_onlinecheck"
|
||||
], [
|
||||
CoreWizardPluginBlacklistViewModel,
|
||||
["settingsViewModel"],
|
||||
"#wizard_plugin_corewizard_pluginblacklist"
|
||||
], [
|
||||
CoreWizardPrinterProfileViewModel,
|
||||
["printerProfilesViewModel"],
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<h3>{{ _('Configure plugin blacklist processing') }}</h3>
|
||||
|
||||
<p>{% trans %}
|
||||
To protect against known severe issues with certain versions of third party plugins, OctoPrint supports the use
|
||||
of a centralized plugin version blacklist to automatically disable such plugin versions before they can interfere with
|
||||
normal operation, allowing you to uninstall or update them to a newer version.
|
||||
{% endtrans %}</p>
|
||||
|
||||
<p>{% trans %}
|
||||
Please decide whether to allow fetch and use of this centralized blacklist starting with the next server start.
|
||||
You may also change your decision at any time through Settings > Server right from within OctoPrint.
|
||||
{% endtrans %}</p>
|
||||
|
||||
<div class="row-fluid">
|
||||
<a href="#" class="btn btn-danger span6" data-bind="click: function() { if(!setup()){disablePluginBlacklist()}}, enable: !setup(), css: {disabled: setup()}">{{ _('Disable Plugin Blacklist Processing') }}</a>
|
||||
<a href="#" class="btn btn-primary span6" data-bind="click: function() { if(!setup()){enablePluginBlacklist()}}, enable: !setup(), css: {disabled: setup()}">{{ _('Enable Plugin Blacklist Processing') }}</a>
|
||||
</div>
|
||||
|
||||
<div class="pluginblacklist_decision" style="display: none" data-bind="visible: setup()">
|
||||
<div class="text-center" style="display: none" data-bind="visible: decision()">{% trans %}
|
||||
Plugin blacklist processing is <strong class="text-success">enabled</strong>.
|
||||
{% endtrans %}</div>
|
||||
<div class="text-center" style="display: none" data-bind="visible: !decision()">{% trans %}
|
||||
Plugin blacklist processing is <strong class="text-danger">disabled</strong>.
|
||||
{% endtrans %}</div>
|
||||
</div>
|
||||
@@ -14,7 +14,8 @@ from octoprint.settings import valid_boolean_trues
|
||||
from octoprint.server.util.flask import restricted_access, with_revalidation_checking, check_etag
|
||||
from octoprint.server import VERSION
|
||||
from octoprint.access.permissions import Permissions
|
||||
from octoprint.util.pip import LocalPipCaller
|
||||
from octoprint.util.pip import LocalPipCaller, UnknownPip
|
||||
from octoprint.util.version import get_octoprint_version_string, get_octoprint_version, is_octoprint_compatible
|
||||
|
||||
from flask import jsonify, make_response
|
||||
from flask_babel import gettext
|
||||
@@ -32,9 +33,9 @@ import dateutil.parser
|
||||
import time
|
||||
import threading
|
||||
|
||||
_DATA_FORMAT_VERSION = "v2"
|
||||
|
||||
# Access permissions hook
|
||||
|
||||
def additional_permissions(components):
|
||||
return [
|
||||
dict(name="Manage Plugins", description=gettext("Allows to use the plugin manager to manage plugins"),
|
||||
@@ -53,7 +54,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
octoprint.plugin.EventHandlerPlugin):
|
||||
|
||||
ARCHIVE_EXTENSIONS = (".zip", ".tar.gz", ".tgz", ".tar")
|
||||
|
||||
|
||||
# valid pip install URL schemes according to https://pip.pypa.io/en/stable/reference/pip_install/
|
||||
URL_SCHEMES = ("http", "https", "git",
|
||||
"git+http", "git+https", "git+ssh", "git+git",
|
||||
@@ -252,7 +253,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
plugins=self._repository_plugins
|
||||
),
|
||||
os=self._get_os(),
|
||||
octoprint=self._get_octoprint_version_string(),
|
||||
octoprint=get_octoprint_version_string(),
|
||||
pip=dict(
|
||||
available=self._pip_caller.available,
|
||||
version=self._pip_caller.version_string,
|
||||
@@ -275,6 +276,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
hash.update(repr(self._notices))
|
||||
hash.update(repr(safe_mode))
|
||||
hash.update(repr(self._connectivity_checker.online))
|
||||
hash.update(repr(_DATA_FORMAT_VERSION))
|
||||
return hash.hexdigest()
|
||||
|
||||
def condition():
|
||||
@@ -321,7 +323,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
if url is not None:
|
||||
if not any(map(lambda scheme: url.startswith(scheme + "://"), self.URL_SCHEMES)):
|
||||
raise ValueError("Invalid URL to pip install from")
|
||||
|
||||
|
||||
source = url
|
||||
source_type = "url"
|
||||
already_installed_check = lambda line: url in line
|
||||
@@ -539,7 +541,8 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
|
||||
if not needs_restart:
|
||||
try:
|
||||
self._plugin_manager.disable_plugin(plugin.key, plugin=plugin)
|
||||
if plugin.enabled:
|
||||
self._plugin_manager.disable_plugin(plugin.key, plugin=plugin)
|
||||
except octoprint.plugin.core.PluginLifecycleException as e:
|
||||
self._logger.exception(u"Problem disabling plugin {name}".format(name=plugin.key))
|
||||
result = dict(result=False, uninstalled=True, disabled=False, unloaded=False, reason=e.reason)
|
||||
@@ -547,7 +550,8 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
return jsonify(result)
|
||||
|
||||
try:
|
||||
self._plugin_manager.unload_plugin(plugin.key)
|
||||
if plugin.loaded:
|
||||
self._plugin_manager.unload_plugin(plugin.key)
|
||||
except octoprint.plugin.core.PluginLifecycleException as e:
|
||||
self._logger.exception(u"Problem unloading plugin {name}".format(name=plugin.key))
|
||||
result = dict(result=False, uninstalled=True, disabled=True, unloaded=False, reason=e.reason)
|
||||
@@ -767,7 +771,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
return False
|
||||
|
||||
current_os = self._get_os()
|
||||
octoprint_version = self._get_octoprint_version(base=True)
|
||||
octoprint_version = get_octoprint_version(base=True)
|
||||
|
||||
def map_repository_entry(entry):
|
||||
result = copy.deepcopy(entry)
|
||||
@@ -782,7 +786,8 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
|
||||
if "compatibility" in entry:
|
||||
if "octoprint" in entry["compatibility"] and entry["compatibility"]["octoprint"] is not None and isinstance(entry["compatibility"]["octoprint"], (list, tuple)) and len(entry["compatibility"]["octoprint"]):
|
||||
result["is_compatible"]["octoprint"] = self._is_octoprint_compatible(octoprint_version, entry["compatibility"]["octoprint"])
|
||||
result["is_compatible"]["octoprint"] = is_octoprint_compatible(*entry["compatibility"]["octoprint"],
|
||||
octoprint_version=octoprint_version)
|
||||
|
||||
if "os" in entry["compatibility"] and entry["compatibility"]["os"] is not None and isinstance(entry["compatibility"]["os"], (list, tuple)) and len(entry["compatibility"]["os"]):
|
||||
result["is_compatible"]["os"] = self._is_os_compatible(current_os, entry["compatibility"]["os"])
|
||||
@@ -860,26 +865,6 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
self._notices = notices
|
||||
return True
|
||||
|
||||
def _is_octoprint_compatible(self, octoprint_version, compatibility_entries):
|
||||
"""
|
||||
Tests if the current ``octoprint_version`` is compatible to any of the provided ``compatibility_entries``.
|
||||
"""
|
||||
|
||||
for octo_compat in compatibility_entries:
|
||||
try:
|
||||
if not any(octo_compat.startswith(c) for c in ("<", "<=", "!=", "==", ">=", ">", "~=", "===")):
|
||||
octo_compat = ">={}".format(octo_compat)
|
||||
|
||||
s = next(pkg_resources.parse_requirements("OctoPrint" + octo_compat))
|
||||
if octoprint_version in s:
|
||||
break
|
||||
except:
|
||||
self._logger.exception("Something is wrong with this compatibility string for OctoPrint: {}".format(octo_compat))
|
||||
else:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def _is_os_compatible(current_os, compatibility_entries):
|
||||
"""
|
||||
@@ -912,38 +897,6 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
else:
|
||||
return "unmapped"
|
||||
|
||||
def _get_octoprint_version_string(self):
|
||||
return VERSION
|
||||
|
||||
def _get_octoprint_version(self, base=False):
|
||||
octoprint_version_string = self._get_octoprint_version_string()
|
||||
|
||||
if "-" in octoprint_version_string:
|
||||
octoprint_version_string = octoprint_version_string[:octoprint_version_string.find("-")]
|
||||
|
||||
octoprint_version = pkg_resources.parse_version(octoprint_version_string)
|
||||
|
||||
# A leading v is common in github release tags and old setuptools doesn't remove it. While OctoPrint's
|
||||
# versions should never contains such a prefix, we'll make sure to have stuff behave the same
|
||||
# regardless of setuptools version anyhow.
|
||||
if octoprint_version and isinstance(octoprint_version, tuple) and octoprint_version[0].lower() == "*v":
|
||||
octoprint_version = octoprint_version[1:]
|
||||
|
||||
if base:
|
||||
if isinstance(octoprint_version, tuple):
|
||||
# old setuptools
|
||||
base_version = []
|
||||
for part in octoprint_version:
|
||||
if part.startswith("*"):
|
||||
break
|
||||
base_version.append(part)
|
||||
base_version.append("*final")
|
||||
octoprint_version = tuple(base_version)
|
||||
else:
|
||||
# new setuptools
|
||||
octoprint_version = pkg_resources.parse_version(octoprint_version.base_version)
|
||||
return octoprint_version
|
||||
|
||||
@property
|
||||
def _reconnect_hooks(self):
|
||||
reconnect_hooks = self.__class__.RECONNECT_HOOKS
|
||||
@@ -985,6 +938,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
bundled=plugin.bundled,
|
||||
managable=plugin.managable,
|
||||
enabled=plugin.enabled,
|
||||
blacklisted=plugin.blacklisted,
|
||||
safe_mode_victim=getattr(plugin, "safe_mode_victim", False),
|
||||
safe_mode_enabled=getattr(plugin, "safe_mode_enabled", False),
|
||||
pending_enable=(not plugin.enabled and not getattr(plugin, "safe_mode_enabled", False) and plugin.key in self._pending_enable),
|
||||
@@ -1003,13 +957,14 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
if key not in self._notices:
|
||||
return
|
||||
|
||||
octoprint_version = self._get_octoprint_version(base=True)
|
||||
octoprint_version = get_octoprint_version(base=True)
|
||||
plugin_notifications = self._notices.get(key, [])
|
||||
|
||||
def filter_relevant(notification):
|
||||
return "text" in notification and "date" in notification and \
|
||||
("versions" not in notification or plugin.version in notification["versions"]) and \
|
||||
("octoversions" not in notification or self._is_octoprint_compatible(octoprint_version, notification["octoversions"]))
|
||||
("octoversions" not in notification or is_octoprint_compatible(*notification["octoversions"],
|
||||
octoprint_version=octoprint_version))
|
||||
|
||||
def map_notification(notification):
|
||||
return self._to_external_notification(key, notification)
|
||||
|
||||
@@ -223,7 +223,9 @@ $(function() {
|
||||
|
||||
self.enableToggle = function(data) {
|
||||
var command = self._getToggleCommand(data);
|
||||
return self.enableManagement() && (command == "disable" || !data.safe_mode_victim || data.safe_mode_enabled) && data.key != 'pluginmanager';
|
||||
var not_safemode_victim = !data.safe_mode_victim || data.safe_mode_enabled;
|
||||
var not_blacklisted = !data.blacklisted;
|
||||
return self.enableManagement() && (command == "disable" || (not_safemode_victim && not_blacklisted)) && data.key != 'pluginmanager';
|
||||
};
|
||||
|
||||
self.enableUninstall = function(data) {
|
||||
@@ -700,7 +702,7 @@ $(function() {
|
||||
return self.isCompatible(data) ? (self.installed(data) ? gettext("Reinstall") : gettext("Install")) : (data.disabled ? gettext("Disabled") : gettext("Incompatible"));
|
||||
};
|
||||
|
||||
self._displayNotification = function(response, titleSuccess, textSuccess, textRestart, textReload, textReconnect, titleError, textError) {
|
||||
self._displayNotification = function(response, action, titleSuccess, textSuccess, textRestart, textReload, textReconnect, titleError, textError) {
|
||||
var notification;
|
||||
|
||||
var beforeClose = function(notification) {
|
||||
@@ -708,7 +710,17 @@ $(function() {
|
||||
};
|
||||
|
||||
if (response.result) {
|
||||
if (response.needs_restart) {
|
||||
if (action == "install" && response.plugin && response.plugin.blacklisted) {
|
||||
notification = new PNotify({
|
||||
title: titleSuccess,
|
||||
text: textSuccess,
|
||||
type: "warning",
|
||||
callbacks: {
|
||||
before_close: beforeClose
|
||||
},
|
||||
hide: false
|
||||
})
|
||||
} else if (response.needs_restart) {
|
||||
var options = {
|
||||
title: titleSuccess,
|
||||
text: textRestart,
|
||||
@@ -860,7 +872,9 @@ $(function() {
|
||||
self.toggleButtonTitle = function(data) {
|
||||
var command = self._getToggleCommand(data);
|
||||
if (command == "enable") {
|
||||
if (data.safe_mode_victim && !data.safe_mode_enabled) {
|
||||
if (data.blacklisted) {
|
||||
return gettext("Blacklisted");
|
||||
} else if (data.safe_mode_victim && !data.safe_mode_enabled) {
|
||||
return gettext("Disabled due to active safe mode");
|
||||
} else {
|
||||
return gettext("Enable Plugin");
|
||||
@@ -1122,6 +1136,17 @@ $(function() {
|
||||
textRestart = textSuccess;
|
||||
textReload = textSuccess;
|
||||
textReconnect = textSuccess;
|
||||
} else if (data.plugin && data.plugin.blacklisted) {
|
||||
if (data.was_reinstalled) {
|
||||
titleSuccess = _.sprintf(gettext("Plugin \"%(name)s\" reinstalled"), {name: name});
|
||||
textSuccess = gettext("The plugin was reinstalled successfully, however it is blacklisted and therefore won't be loaded.");
|
||||
} else {
|
||||
titleSuccess = _.sprintf(gettext("Plugin \"%(name)s\" installed"), {name: name});
|
||||
textSuccess = gettext("The plugin was installed successfully, however it is blacklisted and therefore won't be loaded.");
|
||||
}
|
||||
textRestart = textSuccess;
|
||||
textReload = textSuccess;
|
||||
textReconnect = textSuccess;
|
||||
} else if (data.was_reinstalled) {
|
||||
titleSuccess = _.sprintf(gettext("Plugin \"%(name)s\" reinstalled"), {name: name});
|
||||
textSuccess = gettext("The plugin was reinstalled successfully");
|
||||
@@ -1234,7 +1259,7 @@ $(function() {
|
||||
return;
|
||||
}
|
||||
|
||||
self._displayNotification(data, titleSuccess, textSuccess, textRestart, textReload, textReconnect, titleError, textError);
|
||||
self._displayNotification(data, action, titleSuccess, textSuccess, textRestart, textReload, textReconnect, titleError, textError);
|
||||
self.requestData();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<tbody data-bind="foreach: plugins.paginatedItems">
|
||||
<tr>
|
||||
<td class="settings_plugin_plugin_manager_plugins_name">
|
||||
<div data-bind="css: {muted: !enabled}"><span data-bind="text: name"></span> <span data-bind="visible: version">(<span data-bind="text: version"></span>)</span> <i title="{{ _('Bundled with OctoPrint') }}" class="fa fa-th-large" data-bind="visible: bundled"></i> <i class="fa fa-lock" title="{{ _('Cannot be uninstalled through OctoPrint') }}" data-bind="visible: !managable"></i> <i title="{{ _('Restart of OctoPrint needed for changes to take effect') }}" class="fa fa-refresh" data-bind="visible: pending_enable || pending_disable || pending_install || pending_uninstall"></i> <i title="{{ _('Pending install') }}" class="fa fa-plus" data-bind="visible: pending_install"></i> <i title="{{ _('Pending uninstall') }}" class="fa fa-minus" data-bind="visible: pending_uninstall"></i> <i title="{{ _('Disabled due to safe mode') }}" class="fa fa-medkit" data-bind="visible: safe_mode_victim"></i> <i class="fa fa-exclamation-triangle" title="{{ _('There are notices available regarding this plugin') }}" data-bind="visible: notifications && notifications.length"></i></div>
|
||||
<div data-bind="css: {muted: !enabled}"><span data-bind="text: name"></span> <span data-bind="visible: version">(<span data-bind="text: version"></span>)</span> <i title="{{ _('Bundled with OctoPrint') }}" class="fa fa-th-large" data-bind="visible: bundled"></i> <i class="fa fa-lock" title="{{ _('Cannot be uninstalled through OctoPrint') }}" data-bind="visible: !managable"></i> <i title="{{ _('Restart of OctoPrint needed for changes to take effect') }}" class="fa fa-refresh" data-bind="visible: pending_enable || pending_disable || pending_install || pending_uninstall"></i> <i title="{{ _('Pending install') }}" class="fa fa-plus" data-bind="visible: pending_install"></i> <i title="{{ _('Pending uninstall') }}" class="fa fa-minus" data-bind="visible: pending_uninstall"></i> <i title="{{ _('Disabled due to safe mode') }}" class="fa fa-medkit" data-bind="visible: safe_mode_victim"></i> <i class="fa fa-exclamation-triangle" title="{{ _('There are notices available regarding this plugin') }}" data-bind="visible: notifications && notifications.length"></i> <i class="fa fa-ban" title="{{ _('This plugin is blacklisted') }}" data-bind="visible: blacklisted"></i></div>
|
||||
<div data-bind="visible: notifications && notifications.length"><a href="javascript:void(0)" class="text-error" style="text-decoration: underline" data-bind="click: function() { $root.showPluginNotifications($data) }, text: $root.showPluginNotificationsLinkText($data)"></a></div>
|
||||
<div><small class="muted" data-bind="text: description"> </small></div>
|
||||
<div data-bind="css: {muted: !enabled}">
|
||||
|
||||
@@ -55,8 +55,8 @@ class VirtualPrinter(object):
|
||||
self.buffered = queue.Queue(maxsize=settings().getInt(["devel", "virtualPrinter", "commandBuffer"]))
|
||||
|
||||
if settings().getBoolean(["devel", "virtualPrinter", "simulateReset"]):
|
||||
for item in ['start\n', 'Marlin: Virtual Marlin!\n', '\x80\n', 'SD card ok\n']:
|
||||
self._send(item)
|
||||
for item in settings().get(["devel", "virtualPrinter", "resetLines"]):
|
||||
self._send(item + "\n")
|
||||
|
||||
self._prepared_oks = []
|
||||
prepared = settings().get(["devel", "virtualPrinter", "preparedOks"])
|
||||
|
||||
@@ -208,6 +208,9 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
|
||||
from octoprint.logging.handlers import SerialLogHandler
|
||||
SerialLogHandler.on_open_connection()
|
||||
if not logging.getLogger("SERIAL").isEnabledFor(logging.DEBUG):
|
||||
# if serial.log is not enabled, log a line to explain that to reduce "serial.log is empty" in tickets...
|
||||
logging.getLogger("SERIAL").info("serial.log is currently not enabled, you can enable it via Settings > Serial Connection > Log communication to serial.log")
|
||||
|
||||
self._comm = comm.MachineCom(port, baudrate, callbackObject=self, printerProfileManager=self._printerProfileManager)
|
||||
|
||||
|
||||
@@ -159,9 +159,12 @@ def load_user(id):
|
||||
|
||||
|
||||
class Server(object):
|
||||
def __init__(self, settings=None, plugin_manager=None, host="0.0.0.0", port=5000, debug=False, safe_mode=False, allow_root=False, octoprint_daemon=None):
|
||||
def __init__(self, settings=None, plugin_manager=None, connectivity_checker=None, event_manager=None,
|
||||
host="0.0.0.0", port=5000, debug=False, safe_mode=False, allow_root=False, octoprint_daemon=None):
|
||||
self._settings = settings
|
||||
self._plugin_manager = plugin_manager
|
||||
self._connectivity_checker = connectivity_checker
|
||||
self._event_manager = event_manager
|
||||
self._host = host
|
||||
self._port = port
|
||||
self._debug = debug
|
||||
@@ -249,7 +252,7 @@ class Server(object):
|
||||
pluginManager.reload_plugins(startup=True, initialize_implementations=False)
|
||||
|
||||
printerProfileManager = PrinterProfileManager()
|
||||
eventManager = events.eventManager()
|
||||
eventManager = self._event_manager
|
||||
analysisQueue = octoprint.filemanager.analysis.AnalysisQueue()
|
||||
slicingManager = octoprint.slicing.SlicingManager(self._settings.getBaseFolder("slicingProfiles"), printerProfileManager)
|
||||
|
||||
@@ -277,11 +280,7 @@ class Server(object):
|
||||
def on_connectivity_change(old_value, new_value):
|
||||
eventManager.fire(events.Events.CONNECTIVITY_CHANGED, payload=dict(old=old_value, new=new_value))
|
||||
|
||||
connectivityChecker = octoprint.util.ConnectivityChecker(connectivityInterval,
|
||||
connectivityHost,
|
||||
port=connectivityPort,
|
||||
enabled=connectivityEnabled,
|
||||
on_change=on_connectivity_change)
|
||||
connectivityChecker = self._connectivity_checker
|
||||
|
||||
def on_settings_update(*args, **kwargs):
|
||||
# make sure our connectivity checker runs with the latest settings
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -154,6 +154,11 @@ default_settings = {
|
||||
"host": "8.8.8.8",
|
||||
"port": 53
|
||||
},
|
||||
"pluginBlacklist": {
|
||||
"enabled": None,
|
||||
"url": "http://plugins.octoprint.org/blacklist.json",
|
||||
"ttl": 15 * 60 # 15 min
|
||||
},
|
||||
"diskspace": {
|
||||
"warning": 500 * 1024 * 1024, # 500 MB
|
||||
"critical": 200 * 1024 * 1024, # 200 MB
|
||||
@@ -363,12 +368,10 @@ default_settings = {
|
||||
"smoothieTemperatureReporting": False,
|
||||
"extendedSdFileList": False,
|
||||
"throttle": 0.01,
|
||||
"waitOnLongMoves": False,
|
||||
"rxBuffer": 64,
|
||||
"txBuffer": 40,
|
||||
"commandBuffer": 4,
|
||||
"sendWait": True,
|
||||
"waitInterval": 1.0,
|
||||
"rxBuffer": 64,
|
||||
"commandBuffer": 4,
|
||||
"supportM112": True,
|
||||
"echoOnM117": True,
|
||||
"brokenM29": True,
|
||||
@@ -377,6 +380,7 @@ default_settings = {
|
||||
"sharedNozzle": False,
|
||||
"sendBusy": False,
|
||||
"simulateReset": True,
|
||||
"resetLines": ['start', 'Marlin: Virtual Marlin!', '\x80', 'SD card ok'],
|
||||
"preparedOks": [],
|
||||
"okFormatString": "ok",
|
||||
"m115FormatString": "FIRMWARE_NAME: {firmware_name} PROTOCOL_VERSION:1.0",
|
||||
|
||||
@@ -1 +1 @@
|
||||
.btn{display:inline-block;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border:1px solid #ccc;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.btn[disabled]{color:#333;background-color:#e6e6e6}.btn.active,.btn:active{background-color:#ccc\9}.btn:focus,.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class*=" icon-"],.btn-large [class^=icon-]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class*=" icon-"],.btn-small [class^=icon-]{margin-top:0}.btn-mini [class*=" icon-"],.btn-mini [class^=icon-]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type=submit].btn-block,input[type=reset].btn-block,input[type=button].btn-block{width:100%}.btn-danger.active,.btn-info.active,.btn-inverse.active,.btn-primary.active,.btn-success.active,.btn-warning.active{color:rgba(255,255,255,.75)}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0044cc', GradientType=0);border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.btn-primary[disabled]{color:#fff;background-color:#04c}.btn-primary.active,.btn-primary:active{background-color:#039\9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0);border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406}.btn-warning.active,.btn-warning:active{background-color:#c67605\9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);backLine truncated
|
||||
.btn{display:inline-block;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border:1px solid #ccc;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.btn[disabled]{color:#333;background-color:#e6e6e6}.btn.active,.btn:active{background-color:#ccc\9}.btn:focus,.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class*=" icon-"],.btn-large [class^=icon-]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class*=" icon-"],.btn-small [class^=icon-]{margin-top:0}.btn-mini [class*=" icon-"],.btn-mini [class^=icon-]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type=submit].btn-block,input[type=reset].btn-block,input[type=button].btn-block{width:100%}.btn-danger.active,.btn-info.active,.btn-inverse.active,.btn-primary.active,.btn-success.active,.btn-warning.active{color:rgba(255,255,255,.75)}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0044cc', GradientType=0);border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.btn-primary[disabled]{color:#fff;background-color:#04c}.btn-primary.active,.btn-primary:active{background-color:#039\9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0);border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406}.btn-warning.active,.btn-warning:active{background-color:#c67605\9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);backLine truncated
|
||||
@@ -221,6 +221,10 @@ $(function() {
|
||||
self.server_onlineCheck_host = ko.observable();
|
||||
self.server_onlineCheck_port = ko.observable();
|
||||
|
||||
self.server_pluginBlacklist_enabled = ko.observable();
|
||||
self.server_pluginBlacklist_url = ko.observable();
|
||||
self.server_pluginBlacklist_ttl = ko.observable();
|
||||
|
||||
self.settings = undefined;
|
||||
self.lastReceivedSettings = undefined;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ $(function() {
|
||||
self.defaultPostRoll = 0;
|
||||
self.defaultInterval = 10;
|
||||
self.defaultRetractionZHop = 0;
|
||||
self.defaultMinDelay = 5.0;
|
||||
self.defaultCapturePostRoll = true;
|
||||
|
||||
self.timelapseType = ko.observable(undefined);
|
||||
@@ -18,8 +19,11 @@ $(function() {
|
||||
self.timelapsePostRoll = ko.observable(self.defaultPostRoll);
|
||||
self.timelapseFps = ko.observable(self.defaultFps);
|
||||
self.timelapseRetractionZHop = ko.observable(self.defaultRetractionZHop);
|
||||
self.timelapseMinDelay = ko.observable(self.defaultMinDelay);
|
||||
self.timelapseCapturePostRoll = ko.observable(self.defaultCapturePostRoll);
|
||||
|
||||
self.serverConfig = ko.observable();
|
||||
|
||||
self.persist = ko.observable(false);
|
||||
self.isDirty = ko.observable(false);
|
||||
|
||||
@@ -43,14 +47,17 @@ $(function() {
|
||||
});
|
||||
|
||||
self.timelapseTypeSelected = ko.pureComputed(function() {
|
||||
return ("off" != self.timelapseType());
|
||||
return ("off" !== self.timelapseType());
|
||||
});
|
||||
self.intervalInputEnabled = ko.pureComputed(function() {
|
||||
return ("timed" == self.timelapseType());
|
||||
return ("timed" === self.timelapseType());
|
||||
});
|
||||
self.saveButtonEnabled = ko.pureComputed(function() {
|
||||
return self.loginState.hasPermission(self.access.permissions.TIMELAPSE_ADMIN) && self.isDirty() && self.isOperational() && !self.isPrinting();
|
||||
});
|
||||
self.resetButtonEnabled = ko.pureComputed(function() {
|
||||
return self.saveButtonEnabled() && self.serverConfig() !== undefined;
|
||||
});
|
||||
|
||||
self.timelapseType.subscribe(function() {
|
||||
self.isDirty(true);
|
||||
@@ -67,6 +74,9 @@ $(function() {
|
||||
self.timelapseRetractionZHop.subscribe(function(newValue) {
|
||||
self.isDirty(true);
|
||||
});
|
||||
self.timelapseMinDelay.subscribe(function() {
|
||||
self.isDirty(true);
|
||||
});
|
||||
self.timelapseCapturePostRoll.subscribe(function() {
|
||||
self.isDirty(true);
|
||||
});
|
||||
@@ -157,33 +167,44 @@ $(function() {
|
||||
}
|
||||
|
||||
// timelapse config
|
||||
self.fromConfig(response.config);
|
||||
self.serverConfig(response.config);
|
||||
};
|
||||
|
||||
self.fromConfig = function(config) {
|
||||
self.timelapseType(config.type);
|
||||
|
||||
if (config.type == "timed" && config.interval != undefined && config.interval > 0) {
|
||||
if (config.type === "timed" && config.interval !== undefined && config.interval > 0) {
|
||||
self.timelapseTimedInterval(config.interval);
|
||||
} else {
|
||||
self.timelapseTimedInterval(self.defaultInterval);
|
||||
}
|
||||
|
||||
if (config.type == "timed" && config.capturePostRoll != undefined){
|
||||
if (config.type === "timed" && config.capturePostRoll !== undefined){
|
||||
self.timelapseCapturePostRoll(config.capturePostRoll);
|
||||
} else {
|
||||
self.timelapseCapturePostRoll(self.defaultCapturePostRoll);
|
||||
}
|
||||
|
||||
if (config.type == "zchange" && config.retractionZHop != undefined && config.retractionZHop > 0) {
|
||||
if (config.type === "zchange" && config.retractionZHop !== undefined && config.retractionZHop > 0) {
|
||||
self.timelapseRetractionZHop(config.retractionZHop);
|
||||
} else {
|
||||
self.timelapseRetractionZHop(self.defaultRetractionZHop);
|
||||
}
|
||||
|
||||
if (config.postRoll != undefined && config.postRoll >= 0) {
|
||||
if (config.type === "zchange" && config.minDelay !== undefined && config.minDelay >= 0) {
|
||||
self.timelapseMinDelay(config.minDelay);
|
||||
} else {
|
||||
self.timelapseMinDelay(self.defaultMinDelay);
|
||||
}
|
||||
|
||||
if (config.postRoll !== undefined && config.postRoll >= 0) {
|
||||
self.timelapsePostRoll(config.postRoll);
|
||||
} else {
|
||||
self.timelapsePostRoll(self.defaultPostRoll);
|
||||
}
|
||||
|
||||
if (config.fps != undefined && config.fps > 0) {
|
||||
if (config.fps !== undefined && config.fps > 0) {
|
||||
self.timelapseFps(config.fps);
|
||||
} else {
|
||||
self.timelapseFps(self.defaultFps);
|
||||
@@ -385,19 +406,25 @@ $(function() {
|
||||
"save": self.persist()
|
||||
};
|
||||
|
||||
if (self.timelapseType() == "timed") {
|
||||
if (self.timelapseType() === "timed") {
|
||||
payload["interval"] = self.timelapseTimedInterval();
|
||||
payload["capturePostRoll"] = self.timelapseCapturePostRoll();
|
||||
}
|
||||
|
||||
if (self.timelapseType() == "zchange") {
|
||||
if (self.timelapseType() === "zchange") {
|
||||
payload["retractionZHop"] = self.timelapseRetractionZHop();
|
||||
payload["minDelay"] = self.timelapseMinDelay();
|
||||
}
|
||||
|
||||
OctoPrint.timelapse.saveConfig(payload)
|
||||
.done(self.fromResponse);
|
||||
};
|
||||
|
||||
self.reset = function() {
|
||||
if (self.serverConfig() === undefined) return;
|
||||
self.fromConfig(self.serverConfig());
|
||||
};
|
||||
|
||||
self.displayTimelapsePopup = function(options) {
|
||||
if (self.timelapsePopup !== undefined) {
|
||||
self.timelapsePopup.remove();
|
||||
@@ -406,7 +433,7 @@ $(function() {
|
||||
_.extend(options, {
|
||||
callbacks: {
|
||||
before_close: function(notice) {
|
||||
if (self.timelapsePopup == notice) {
|
||||
if (self.timelapsePopup === notice) {
|
||||
self.timelapsePopup = undefined;
|
||||
}
|
||||
}
|
||||
@@ -487,7 +514,7 @@ $(function() {
|
||||
self.onEventMovieFailed = function(payload) {
|
||||
var title, html;
|
||||
|
||||
if (payload.reason == "no_frames") {
|
||||
if (payload.reason === "no_frames") {
|
||||
title = gettext("Cannot render timelapse");
|
||||
html = "<p>" + _.sprintf(gettext("Rendering of timelapse %(movie_prefix)s is not possible since no frames were captured. Is the snapshot URL configured correctly?"), payload) + "</p>";
|
||||
} else if (payload.reason = "returncode") {
|
||||
@@ -514,7 +541,7 @@ $(function() {
|
||||
type: "success",
|
||||
callbacks: {
|
||||
before_close: function(notice) {
|
||||
if (self.timelapsePopup == notice) {
|
||||
if (self.timelapsePopup === notice) {
|
||||
self.timelapsePopup = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -983,6 +983,10 @@ ul.dropdown-menu li a {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.text-block {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.overflow_visible {
|
||||
overflow: visible !important;
|
||||
}
|
||||
|
||||
@@ -10,4 +10,8 @@
|
||||
{% include "snippets/settings/server/serverOnlineCheckDescription.jinja2" %}
|
||||
{% include "snippets/settings/server/serverOnlineCheck.jinja2" %}
|
||||
|
||||
<h3>{{ _('Plugin blacklist processing') }}</h3>
|
||||
|
||||
{% include "snippets/settings/server/serverPluginBlacklistDescription.jinja2" %}
|
||||
{% include "snippets/settings/server/serverPluginBlacklist.jinja2" %}
|
||||
</form>
|
||||
@@ -0,0 +1,11 @@
|
||||
{% include "snippets/settings/server/serverPluginBlacklistEnabled.jinja2" %}
|
||||
|
||||
<div data-bind="visible: server_pluginBlacklist_enabled">
|
||||
<div class="advanced_options">
|
||||
<div><small><a href="#" class="muted" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', parent: '.advanced_options', container: '.hide' }"><i class="fa fa-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
|
||||
<div class="hide">
|
||||
{% include "snippets/settings/server/serverPluginBlacklistUrl.jinja2" %}
|
||||
{% include "snippets/settings/server/serverPluginBlacklistTtl.jinja2" %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<p>{% trans %}
|
||||
<strong>To protect against known severe issues with certain versions of third party plugins</strong>, OctoPrint supports
|
||||
the use of a centralized plugin version blacklist to automatically disable such plugins before they can interfere
|
||||
with normal operation.
|
||||
{% endtrans %}</p>
|
||||
@@ -0,0 +1,8 @@
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: server_pluginBlacklist_enabled" id="settings-serverPluginBlacklistEnabled"> {{ _('Enable plugin blacklist processing on startup') }}
|
||||
<span class="help-block">{{ _('Any changes take effect only on the next server start.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,9 @@
|
||||
<div class="control-group" title="{{ _('How long to cache the blacklist, in minutes. You should normally not have to change this.') }}">
|
||||
<label class="control-label">{{ _('Blacklist cache TTL') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" class="input-mini" data-bind="value: server_pluginBlacklist_ttl">
|
||||
<span class="add-on">min</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,6 @@
|
||||
<div class="control-group" title="{{ _('Plugin blacklist URL. You should normally not have to change this.') }}">
|
||||
<label class="control-label" for="settings-serverPluginBlacklistUrl">{{ _('Blacklist URL') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: server_pluginBlacklist_url" id="settings-serverPluginBlacklistUrl">
|
||||
</div>
|
||||
</div>
|
||||
@@ -2,63 +2,101 @@
|
||||
<div class="alert" data-bind="visible: isPrinting()">
|
||||
{{ _('Take note that timelapse configuration is disabled while your printer is printing.') }}
|
||||
</div>
|
||||
|
||||
<h1>{{ _('Timelapse Configuration') }}</h1>
|
||||
|
||||
<label for="webcam_timelapse_mode">{{ _('Timelapse Mode') }}</label>
|
||||
<select id="webcam_timelapse_mode" data-bind="value: timelapseType, enable: !isPrinting()">
|
||||
<option value="off">{{ _('Off') }}</option>
|
||||
<option value="timed">{{ _('Timed') }}</option>
|
||||
<option value="zchange">{{ _('On Z Change') }}</option>
|
||||
</select>
|
||||
<span class="help-block" data-bind="visible: timelapseType() == 'zchange'"><span class="label label-warning">{{ _('Warning') }}</span> {{ _('Do not use with spiralized ("Joris") vases or similar continuous Z models.') }}</span>
|
||||
<span class="help-block" data-bind="visible: timelapseType() == 'zchange'"><span class="label label-info">{{ _('Note') }}</span> {% trans %}Does not work when printing from the printer's SD Card (no way to detect the change in Z reliably). Use "Timed" mode for those prints instead.{% endtrans %}</span>
|
||||
|
||||
<div id="webcam_timelapse_timedsettings" data-bind="visible: intervalInputEnabled">
|
||||
<label for="webcam_timelapse_interval">{{ _('Interval between snapshots (in seconds)') }}</label>
|
||||
<div class="input-append">
|
||||
<input type="text" class="input-mini" id="webcam_timelapse_interval" data-bind="value: timelapseTimedInterval, valueUpdate: 'afterkeydown', enable: !isPrinting()">
|
||||
<span class="add-on">{{ _('sec') }}</span>
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="webcam_timelapse_mode">{{ _('Timelapse Mode') }}</label>
|
||||
<div class="controls">
|
||||
<select id="webcam_timelapse_mode" data-bind="value: timelapseType, enable: !isPrinting()">
|
||||
<option value="off">{{ _('Off') }}</option>
|
||||
<option value="timed">{{ _('Timed') }}</option>
|
||||
<option value="zchange">{{ _('On Z Change') }}</option>
|
||||
</select>
|
||||
<span class="help-block" data-bind="visible: timelapseType() == 'zchange'"><span class="label label-info">{{ _('Note') }}</span> {% trans %}Does not work when printing from the printer's SD Card (no way to detect the change in Z reliably). Use "Timed" mode for those prints instead.{% endtrans %}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label for="webcam_timelapse_fps">{{ _('Timelapse frame rate (in frames per second)') }}</label>
|
||||
<div class="input-append">
|
||||
<input type="text" class="input-mini" id="webcam_timelapse_fps" data-bind="value: timelapseFps, valueUpdate: 'afterkeydown', enable: !isPrinting() && timelapseTypeSelected()">
|
||||
<span class="add-on">{{ _('fps') }}</span>
|
||||
</div>
|
||||
|
||||
<label for="webcam_timelapse_postRoll">{{ _('Timelapse post roll (in rendered seconds)') }}</label>
|
||||
<div class="input-append">
|
||||
<input type="text" class="input-mini" id="webcam_timelapse_postRoll" data-bind="value: timelapsePostRoll, valueUpdate: 'afterkeydown', enable: !isPrinting() && timelapseTypeSelected()">
|
||||
<span class="add-on">{{ _('sec') }}</span>
|
||||
</div>
|
||||
<div id="webcam_timelapse_capturePostRoll" data-bind="visible: timelapseType() == 'timed'">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: timelapseCapturePostRoll, valueUpdate: 'afterkeydown', enable: !isPrinting()"> {{ _('Capture post roll images') }}
|
||||
<span class="help-block">{{ _('If this is unchecked, OctoPrint will simply repeat the last frame for the post roll instead of continuing to capture new frames.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div id="webcam_timelapse_retractionsettings" data-bind="visible: timelapseType() == 'zchange'">
|
||||
<label for="webcam_timelapse_retractionZHop">{{ _('Retraction Z-Hop (in mm)') }}</label>
|
||||
<div class="input-append">
|
||||
<input type="text" class="input-mini" id="webcam_timelapse_retractionZHop" data-bind="value: timelapseRetractionZHop, valueUpdate: 'afterkeydown', enable: !isPrinting()">
|
||||
<span class="add-on">{{ _('mm') }}</span>
|
||||
<div id="webcam_timelapse_mindelay" class="control-group" data-bind="visible: timelapseType() == 'zchange'">
|
||||
<label class="control-label" for="webcam_timelapse_minDelay">{{ _('Minimum interval') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" min="1" class="input-mini" id="webcam_timelapse_minDelay" data-bind="value: timelapseMinDelay, valueUpdate: 'afterkeydown', enable: !isPrinting()">
|
||||
<span class="add-on">{{ _('sec') }}</span>
|
||||
</div>
|
||||
<span class="help-block">{{ _('OctoPrint will rate limit snapshots to this minimum interval. This it to prevent against performance issues with vase mode/continous z prints.') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<span class="help-block">{{ _('Enter the retraction z-hop used in the firmware or the gcode file to trigger snapshots for the timelapse only if a real layer change happens. For this to work properly your retraction z-hop has to be different from your layerheight!') }}</span>
|
||||
</div>
|
||||
|
||||
<div data-bind="visible: loginState.hasPermissionKo(access.permissions.TIMELAPSE_ADMIN)()">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: persist, enable: isOperational() && !isPrinting()"> {{ _('Save as default') }}
|
||||
<span class="help-block">{{ _('Check this to make your selected timelapse mode and options persist across restarts.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
<div id="webcam_timelapse_timedsettings" class="control-group" data-bind="visible: intervalInputEnabled">
|
||||
<label class="control-label" for="webcam_timelapse_interval">{{ _('Snapshot interval') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" min="1" class="input-mini" id="webcam_timelapse_interval" data-bind="value: timelapseTimedInterval, valueUpdate: 'afterkeydown', enable: !isPrinting()">
|
||||
<span class="add-on">{{ _('sec') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button class="btn" data-bind="click: save, enable: saveButtonEnabled">{{ _('Save changes') }}</button>
|
||||
<span class="help-inline" data-bind="visible: saveButtonEnabled">{{ _('You have unsaved changes.') }}</span>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="webcam_timelapse_fps">{{ _('Timelapse frame rate') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" min="1" class="input-mini" id="webcam_timelapse_fps" data-bind="value: timelapseFps, valueUpdate: 'afterkeydown', enable: !isPrinting() && timelapseTypeSelected()">
|
||||
<span class="add-on">{{ _('fps') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="webcam_timelapse_postRoll">{{ _('Timelapse post roll') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" min="0" class="input-mini" id="webcam_timelapse_postRoll" data-bind="value: timelapsePostRoll, valueUpdate: 'afterkeydown', enable: !isPrinting() && timelapseTypeSelected()">
|
||||
<span class="add-on">{{ _('sec') }}</span>
|
||||
</div>
|
||||
<span class="help-block">{{ _('OctoPrint will take additional pictures to add this many seconds to the end of your rendered timelapse.') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group" data-bind="visible: timelapseType() == 'timed'">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: timelapseCapturePostRoll, valueUpdate: 'afterkeydown', enable: !isPrinting()"> {{ _('Capture post roll images') }}
|
||||
<span class="help-block">{{ _('If this is unchecked, OctoPrint will simply repeat the last frame for the post roll instead of continuing to capture new frames.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="webcam_timelapse_retractionsettings" class="control-group" data-bind="visible: timelapseType() == 'zchange'">
|
||||
<label class="control-label" for="webcam_timelapse_retractionZHop">{{ _('Retraction Z-Hop') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" min="0.0" class="input-mini" id="webcam_timelapse_retractionZHop" data-bind="value: timelapseRetractionZHop, valueUpdate: 'afterkeydown', enable: !isPrinting()">
|
||||
<span class="add-on">{{ _('mm') }}</span>
|
||||
</div>
|
||||
<span class="help-block">{{ _('Enter the retraction z-hop used in the firmware or the gcode file to trigger snapshots for the timelapse only if a real layer change happens. For this to work properly your retraction z-hop has to be different from your layerheight!') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: persist, enable: isOperational() && !isPrinting()"> {{ _('Save as default') }}
|
||||
<span class="help-block">{{ _('Check this to make your selected timelapse mode and options persist across restarts.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<strong class="text-center text-block" data-bind="visible: saveButtonEnabled">{{ _('You have unsaved changes. Don\'t forget to save them.') }}</strong>
|
||||
<button class="btn btn-primary btn-block" data-bind="click: save, enable: saveButtonEnabled">{{ _('Save changes') }}</button>
|
||||
<button class="btn btn-block" data-bind="click: reset, enable: resetButtonEnabled">{{ _('Reset to active configuration') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<h1>{{ _('Finished Timelapses') }}</h1>
|
||||
|
||||
@@ -22,6 +22,7 @@ import octoprint.util as util
|
||||
|
||||
from octoprint.settings import settings
|
||||
from octoprint.events import eventManager, Events
|
||||
from octoprint.util import monotonic_time
|
||||
|
||||
import sarge
|
||||
import collections
|
||||
@@ -301,10 +302,14 @@ def configure_timelapse(config=None, persist=False):
|
||||
|
||||
elif "zchange" == type:
|
||||
retractionZHop = 0
|
||||
if "options" in config and "retractionZHop" in config["options"] and config["options"]["retractionZHop"] > 0:
|
||||
if "options" in config and "retractionZHop" in config["options"] and config["options"]["retractionZHop"] >= 0:
|
||||
retractionZHop = config["options"]["retractionZHop"]
|
||||
|
||||
current = ZTimelapse(post_roll=postRoll, retraction_zhop=retractionZHop, fps=fps)
|
||||
minDelay = 5
|
||||
if "options" in config and "minDelay" in config["options"] and config["options"]["minDelay"] > 0:
|
||||
minDelay = config["options"]["minDelay"]
|
||||
|
||||
current = ZTimelapse(post_roll=postRoll, retraction_zhop=retractionZHop, min_delay=minDelay, fps=fps)
|
||||
|
||||
elif "timed" == type:
|
||||
interval = 10
|
||||
@@ -632,14 +637,24 @@ class Timelapse(object):
|
||||
|
||||
|
||||
class ZTimelapse(Timelapse):
|
||||
def __init__(self, post_roll=0, retraction_zhop=0, fps=25):
|
||||
def __init__(self, retraction_zhop=0, min_delay=5.0, post_roll=0, fps=25):
|
||||
Timelapse.__init__(self, post_roll=post_roll, fps=fps)
|
||||
|
||||
if min_delay < 0:
|
||||
min_delay = 0
|
||||
|
||||
self._retraction_zhop = retraction_zhop
|
||||
self._min_delay = min_delay
|
||||
self._last_snapshot = None
|
||||
self._logger.debug("ZTimelapse initialized")
|
||||
|
||||
@property
|
||||
def retraction_zhop(self):
|
||||
return self._retraction_zhop
|
||||
|
||||
@property
|
||||
def min_delay(self):
|
||||
return self._min_delay
|
||||
|
||||
def event_subscriptions(self):
|
||||
return [
|
||||
@@ -661,18 +676,25 @@ class ZTimelapse(Timelapse):
|
||||
Timelapse.process_post_roll(self)
|
||||
|
||||
def _on_z_change(self, event, payload):
|
||||
# check if height difference equals z-hop, if so don't take a picture
|
||||
if self._retraction_zhop != 0 and payload["old"] is not None and payload["new"] is not None:
|
||||
# check if height difference equals z-hop, if so don't take a picture
|
||||
diff = round(abs(payload["new"] - payload["old"]), 3)
|
||||
zhop = round(self._retraction_zhop, 3)
|
||||
if diff == zhop:
|
||||
return
|
||||
|
||||
# check if last picture has been less than min_delay ago, if so don't take a picture (anti vase mode...)
|
||||
now = monotonic_time()
|
||||
if self._min_delay and self._last_snapshot and self._last_snapshot + self._min_delay > now:
|
||||
self._logger.debug("Rate limited z-change, not taking a snapshot")
|
||||
return
|
||||
|
||||
self.capture_image()
|
||||
self._last_snapshot = now
|
||||
|
||||
|
||||
class TimedTimelapse(Timelapse):
|
||||
def __init__(self, post_roll=0, interval=1, fps=25, capture_post_roll=True):
|
||||
def __init__(self, interval=1, capture_post_roll=True, post_roll=0, fps=25):
|
||||
Timelapse.__init__(self, post_roll=post_roll, fps=fps)
|
||||
self._interval = interval
|
||||
if self._interval < 1:
|
||||
|
||||
@@ -956,6 +956,15 @@ except ImportError:
|
||||
return drive + pathname
|
||||
|
||||
|
||||
try:
|
||||
import monotonic
|
||||
monotonic_time = monotonic.monotonic
|
||||
except RuntimeError:
|
||||
# no source of monotonic time available, nothing left but using time.time *cringe*
|
||||
import time
|
||||
monotonic_time = time.time
|
||||
|
||||
|
||||
class RepeatedTimer(threading.Thread):
|
||||
"""
|
||||
This class represents an action that should be run repeatedly in an interval. It is similar to python's
|
||||
|
||||
@@ -1387,7 +1387,7 @@ class MachineCom(object):
|
||||
# reliable firmware name (NAME + VER) out of the Malyan M115 response.
|
||||
name = data.get("NAME")
|
||||
ver = data.get("VER")
|
||||
if "malyan" in name.lower() and ver:
|
||||
if name and "malyan" in name.lower() and ver:
|
||||
firmware_name = name.strip() + " " + ver.strip()
|
||||
|
||||
if not self._firmware_info_received and firmware_name:
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
# coding=utf-8
|
||||
"""
|
||||
This module provides a bunch of utility methods and helpers for version handling.
|
||||
"""
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
|
||||
import pkg_resources
|
||||
import logging
|
||||
|
||||
from octoprint._version import get_versions
|
||||
|
||||
|
||||
_VERSION = get_versions()["version"]
|
||||
|
||||
|
||||
def get_octoprint_version_string():
|
||||
return _VERSION
|
||||
|
||||
|
||||
def get_octoprint_version(base=False):
|
||||
octoprint_version_string = get_octoprint_version_string()
|
||||
|
||||
if "-" in octoprint_version_string:
|
||||
octoprint_version_string = octoprint_version_string[:octoprint_version_string.find("-")]
|
||||
|
||||
octoprint_version = pkg_resources.parse_version(octoprint_version_string)
|
||||
|
||||
# A leading v is common in github release tags and old setuptools doesn't remove it. While OctoPrint's
|
||||
# versions should never contain such a prefix, we'll make sure to have stuff behave the same
|
||||
# regardless of setuptools version anyhow.
|
||||
if octoprint_version and isinstance(octoprint_version, tuple) and octoprint_version[0].lower() == "*v":
|
||||
octoprint_version = octoprint_version[1:]
|
||||
|
||||
if base:
|
||||
if isinstance(octoprint_version, tuple):
|
||||
# old setuptools
|
||||
base_version = []
|
||||
for part in octoprint_version:
|
||||
if part.startswith("*"):
|
||||
break
|
||||
base_version.append(part)
|
||||
base_version.append("*final")
|
||||
octoprint_version = tuple(base_version)
|
||||
else:
|
||||
# new setuptools
|
||||
octoprint_version = pkg_resources.parse_version(octoprint_version.base_version)
|
||||
return octoprint_version
|
||||
|
||||
|
||||
def is_octoprint_compatible(*compatibility_entries, **kwargs):
|
||||
"""
|
||||
Tests if the current ``octoprint_version`` is compatible to any of the provided ``compatibility_entries``.
|
||||
|
||||
Arguments:
|
||||
compatibility_entries (str): compatibility string(s) to test against, result will be `True` if any match
|
||||
is found
|
||||
octoprint_version (tuple or SetuptoolsVersion): optional OctoPrint version to match against, if not current
|
||||
base version will be determined via :func:`get_octoprint_version`.
|
||||
|
||||
Returns:
|
||||
(bool) ``True`` if any of the provided compatibility entries matches or there are no entries, else ``False``
|
||||
"""
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if not compatibility_entries:
|
||||
return True
|
||||
|
||||
octoprint_version = kwargs.get("octoprint_version")
|
||||
if octoprint_version is None:
|
||||
octoprint_version = get_octoprint_version(base=True)
|
||||
|
||||
for octo_compat in compatibility_entries:
|
||||
try:
|
||||
if not any(octo_compat.startswith(c) for c in ("<", "<=", "!=", "==", ">=", ">", "~=", "===")):
|
||||
octo_compat = ">={}".format(octo_compat)
|
||||
|
||||
s = next(pkg_resources.parse_requirements("OctoPrint" + octo_compat))
|
||||
if octoprint_version in s:
|
||||
break
|
||||
except:
|
||||
logger.exception("Something is wrong with this compatibility string for OctoPrint: {}".format(octo_compat))
|
||||
else:
|
||||
return False
|
||||
|
||||
return True
|
||||
Reference in new issue
Block a user