Merge branch 'maintenance' into devel

This commit is contained in:
Gina Häußge committed 2020-09-28 11:43:17 +02:00
commit a24dad6bdb
84 files changed
+878 -286

No files matched your search

+1
View File
@@ -1,6 +1,7 @@
name: Build
on:
push:
pull_request: [opened, sychronize, reopened]
release:
types: [published, prereleased]
workflow_dispatch:
+1
View File
@@ -35,6 +35,7 @@ pypy
.eggs
.mypy_cache
.pytest_cache
.python-version
.tox
venv*
+12 -86
View File
@@ -287,9 +287,10 @@ See [How to open the Javascript Console in different browsers](https://webmaster
## Setting up a development environment
See [the corresponding chapter in the documentation](http://docs.octoprint.org/en/master/development/index.html#setting-up-a-development-environment).
See [the corresponding chapter in the documentation](https://docs.octoprint.org/en/master/development/environment.html).
This also includes information on how to run the test suite and how to build
the documentation.
the documentation, the bundled virtual printer plugin and OctoPrint's versioning
and branching strategy.
## Pull requests
@@ -297,7 +298,8 @@ the documentation.
consider if it wouldn't be better suited for a plugin.** As a general rule
of thumb, any feature that is only of interest to a small sub group should
be moved into a plugin. If the current plugin system doesn't allow you to
implement your feature as a plugin, create a "Brainstorming" ticket to get
implement your feature as a plugin, please get in touch on the
[forums](https://community.octoprint.org/c/development) to get
the discussion going on how best to solve *this* in OctoPrint's plugin
system - maybe that's the actual PR you have been waiting for to contribute :)
2. If you plan to make **any large or otherwise disruptive changes to the
@@ -335,7 +337,7 @@ the documentation.
from experiments).
8. Ensure your changes **pass the existing unit tests**. PRs that break
those cannot be accepted. You can run the unit tests locally (after
[initial development environment setup with "develop" dependencies](http://docs.octoprint.org/en/master/development/index.html#setting-up-a-development-environment))
[initial development environment setup with "develop" dependencies](https://docs.octoprint.org/en/master/development/environment.html))
by running
```
@@ -376,86 +378,13 @@ Template to use for Pull Request descriptions:
#### Further notes
```
## How is OctoPrint versioned?
See [the corresponding chapter in the documentation](https://docs.octoprint.org/en/master/development/versioning.html).
## What do the branches mean?
There are three main branches in OctoPrint:
* `master`: The master branch always contains the current stable release plus any changes
since made to *documentation*, *CI related tests* or *Github meta files*. OctoPrint's actual
code will only be modified on new releases. Will have a version number following
the scheme `<x>.<y>.<z>` (e.g. `1.5.1`).
* `maintenance`: Improvements and fixes of the current release that make up
the next release go here. More or less continuously updated. You can consider
this a preview of the next release version. It should be very stable at all
times. Anything you spot in here helps tremendously with getting a rock solid
next stable release, so if you want to help out development, running the
`maintenance` branch and reporting back anything you find is a very good way
to do that. Will usually have a version number following the scheme
`<x>.<y+1>.<0>.dev<commits since increase of y>` for an OctoPrint version of `<x>.<y>.<z>`
(e.g. `1.5.0.dev114`).
* `devel`: Ongoing development of what will go into the next big
release (MAJOR version number increases) will happen on this branch. Usually
kept stable, sometimes stuff can break though. Backwards incompatible changes will
be encountered here. Can be considered the "bleeding edge". Will usually have a version
number following the scheme `<x+1>.<0>.0.dev<commits since increase of y>` for a current
OctoPrint version of `<x>.<y>.<z>` (e.g. `2.0.0.dev123`).
There are couple more RC and staging branches that see regular use:
* `staging/hotfix`: Any preparation for potential hotfix releases takes place here.
Version number follows the scheme `<x>.<y>.<z+1>` (e.g. `1.5.1`) for a current release
of `<x>.<y>.<z>`.
* `rc/maintenance`: This branch is reserved for future releases that have graduated from
the `maintenance` branch and are now being pushed on the "Maintenance"
pre release channel for further testing. Version number follows the scheme
`<x>.<y>.<z>rc<n>` (e.g. `1.5.0rc1`).
* `staging/maintenance`: Any preparation for potential follow-up RCs takes place here.
Version number follows the scheme `<x>.<y>.<z>rc<n+1>.dev<commits since increase of n>` (e.g.
`1.5.0rc2.dev3`) for a current Maintenance RC of `<x>.<y>.<z>`.
* `rc/devel`: This branch is reserved for future releases that have graduated from
the `devel` branch and are now being pushed on the "Devel" pre release channel
for further testing. Version number follows the scheme `<x+1>.0.0rc<n>` (e.g. `2.0.0rc1`)
for a current stable OctoPrint version of `<x>.<y>.<z>`.
* `staging/devel`: Any preparation for potential follow-up Devel RCs takes place
here. Version number follows the scheme `<x>.0.0rc<n+1>.dev<commits since increase of n>` (e.g.
`2.0.0rc2.dev12`) for a current Devel RC of `<x>.0.0rc<n>`.
Additionally, from time to time you might see other branches pop up in the repository.
Those usually have one of the following prefixes:
* `hotfix/...`: Hotfixes under development that are to be merged into the `staging/hotfix`
and later the `master` branch.
* `fix/...`: Fixes under development that are to be merged into the `maintenance`
and `devel` branches.
* `improve/...`: Improvements under development that are to be merged into the
`maintenance` and `devel` branches.
* `dev/...` or `feature/...`: New functionality under development that is to be merged
into the `devel` branch.
There is also the `gh-pages` branch, which holds OctoPrint's web page, and a few
older development branches that are slowly being migrated or deleted.
## How OctoPrint is versioned
OctoPrint follows the [semantic versioning scheme](http://semver.org/) of **MAJOR.MINOR.PATCH**.
The **PATCH** version number will increase in case of hotfix releases [3].
Releases that only change the patch number indicate that they only contain bug fixes, and usually
only hotfixes at that. Example: 1.5.0 to 1.5.1.
The **MINOR** version number increases with releases that add new functionality while maintaining
backwards compatibility. Example: 1.4.x to 1.5.0.
Finally, the **MAJOR** version number increases if there are breaking API changes that concern any of the
documented interfaces (REST API, plugin interfaces, ...). Example: 1.x.y to 2.0.0.
OctoPrint's version numbers are automatically generated using [versioneer](https://github.com/warner/python-versioneer)
and depend on the selected git branch, nearest git tag and commits. The generated version number
should always be [PEP440](https://www.python.org/dev/peps/pep-0440/) compatible. Unless a git tag
is used for version number determination, the version number will also contain the git hash within
the local version identifier to allow for an exact determination of the active code base
(e.g. `1.2.9.dev68+g46c7a9c`). Additionally, instances with active uncommitted changes will contain
`.dirty` in the local version identifier.
See [the corresponding chapter in the documentation](https://docs.octoprint.org/en/master/development/branches.html).
## History
@@ -485,6 +414,7 @@ the local version identifier to allow for an exact determination of the active c
* 2018-10-18: Allow PRs against `maintenance` branch for improvements and small
new features, suggest getting in touch on the forum for larger changes
* 2020-08-10: Update versioning scheme and PR instructions
* 2020-09-23: Move branch & versioning into development docs
## Footnotes
* [1] - If you are wondering why, the problem is that anything that you add
@@ -496,7 +426,3 @@ the local version identifier to allow for an exact determination of the active c
it now would make the history and especially `git blame` completely
unusable, so for now we'll have to deal with it (this decision might be
revisited in the future).
* [3] - Up until 1.4.2, the PATCH version segment was the one increasing most often
due to OctoPrint's maintenance releases but with 1.5.0 this will *fully* adhere
to the concepts in semantic versioning mandating only bug fixes in patch releases.
Maintenance releases will henceforth increase the MINOR segment.
@@ -3,7 +3,9 @@
Action Command Notification support
===================================
The OctoPrint Action Command Notification Support Plugin comes bundled with OctoPrint (starting with 1.4.1).
.. versionadded:: 1.4.1
The OctoPrint Action Command Notification Support Plugin comes bundled with OctoPrint.
It allows firmware to trigger notifications users with the ``PLUGIN_ACTION_COMMAND_NOTIFICATION_SHOW`` permission
using :ref:`action commands <sec-features-action_commands>` about relevant events. These notifications will be shown
@@ -3,7 +3,9 @@
Action Command Prompt support
=============================
The OctoPrint Action Command Prompt Support Plugin comes bundled with OctoPrint (starting with 1.3.9).
.. versionadded:: 1.3.9
The OctoPrint Action Command Prompt Support Plugin comes bundled with OctoPrint.
It allows firmware to trigger dialog prompts for logged in users using :ref:`action commands <sec-features-action_commands>`, e.g. to wait
for user acknowledgement or allow the user to choose between options, and also to close the dialog again
+3 -1
View File
@@ -3,7 +3,9 @@
Announcement Plugin
===================
The OctoPrint Announcement Plugin comes bundled with OctoPrint (starting with 1.2.11).
.. versionadded:: 1.2.11
The OctoPrint Announcement Plugin comes bundled with OctoPrint.
It displays announcements fetched from OctoPrint's websites, such as important updates, release announcements, new
plugins and similar. Through some manual configuration via ``config.yaml`` it also allows adding additional channels
+3 -1
View File
@@ -3,7 +3,9 @@
Application Keys Plugin
=======================
The OctoPrint Application Keys Plugin comes bundled with OctoPrint (starting with version 1.3.10).
.. versionadded:: 1.3.10
The OctoPrint Application Keys Plugin comes bundled with OctoPrint.
It implements a workflow for third party apps or clients to obtain an application specific API key from OctoPrint to interact with it
on a user's behalf, via confirmation of the user through OctoPrint's web interface. Existing keys can be managed
+6
View File
@@ -3,6 +3,8 @@
Backup Plugin
=============
.. versionadded:: 1.3.10
The OctoPrint Backup Plugin comes bundled with OctoPrint (starting with 1.3.10).
It allows the creation and restoration of backups of OctoPrint's settings, data and installed plugins [#]_.
@@ -74,6 +76,8 @@ plugin_backup_backup_created
* ``path``: the path to the backup
* ``excludes``: the list of parts excluded from the backup
.. versionadded:: 1.5.0
.. _sec-bundledplugins-backup-hooks:
Hooks
@@ -86,6 +90,8 @@ octoprint.plugin.backup.additional_excludes
.. py:function:: additional_excludes_hook(excludes, *args, **kwargs)
.. versionadded:: 1.5.0
Use this to provide additional paths on your plugin's data folder to exclude from the backup. Your handler also
get a list of currently excluded sub paths in the base folder, so you can react to them. E.g. exclude things
in your data folder that relate to uploaded GCODE files if `uploads` is excluded, or exclude things that relate
+3 -1
View File
@@ -3,7 +3,9 @@
Discovery Plugin
================
The OctoPrint Discovery Plugin comes bundled with OctoPrint (starting with 1.2.0).
.. versionadded:: 1.2.0
The OctoPrint Discovery Plugin comes bundled with OctoPrint.
It allows discovery of the OctoPrint instances via SSDP/UPNP. If
`pybonjour <https://pypi.python.org/pypi/pybonjour>`_ is installed OctoPrint
+2
View File
@@ -3,6 +3,8 @@
Error Tracking Plugin
=====================
.. versionadded:: 1.3.11
The Error Tracking plugin will cause any logged exceptions in the server and the browser interface to be sent to
OctoPrint's `Sentry instance <https://sentry.io/>`_.
+2
View File
@@ -3,5 +3,7 @@
File Check
==========
.. versionadded:: 1.4.1
The file check plugin - while considered bundled with OctoPrint - is a separate project on its own release
cycle and documented on `its Github repository <https://github.com/OctoPrint/OctoPrint-FileCheck>`_.
+4
View File
@@ -3,5 +3,9 @@
Firmware Check
==============
.. versionadded:: 1.3.7
The firmware check plugin - while considered bundled with OctoPrint - is a separate project on its own release
cycle and documented on `its Github repository <https://github.com/OctoPrint/OctoPrint-FirmwareCheck>`_.
It was formerly called "Printer Safety Check" and directly bundled with OctoPrint.
+2
View File
@@ -3,6 +3,8 @@
GCode Viewer Plugin
===================
.. versionchanged:: 1.4.1
The GCode Viewer plugin provides a GCode viewer based on `Alex Ustyantsev's work <https://github.com/hudbrog/gCodeViewer>`_.
.. _fig-bundledplugins-gcodeviewer-example:
+2 -2
View File
@@ -3,9 +3,9 @@
Logging
=======
The OctoPrint Logging plugin comes bundled with OctoPrint starting with version 1.3.7.
.. versionadded:: 1.3.7
It implements the log management functionality that was formerly part of the core application and adds features to
The OctoPrint Logging plugin implements the log management functionality that was formerly part of the core application and adds features to
configure logging levels for sub modules through the included settings dialog.
.. _fig-bundledplugins-logging-settings:
+3 -2
View File
@@ -3,8 +3,9 @@
Plugin Manager
==============
The OctoPrint Plugin Manager comes bundled with OctoPrint starting with
version 1.2.0.
.. versionadded:: 1.2.0
The OctoPrint Plugin Manager comes bundled with OctoPrint.
It allows management of installed plugins (listing, enabling, disabling
and uninstalling) and installing new plugins from the official
+21
View File
@@ -3,10 +3,14 @@
Software Update Plugin
======================
.. versionadded:: 1.2.0
The Software Update Plugin allows receiving notifications about new releases
of OctoPrint or installed plugins which registered with it and -- if properly
configured -- also applying the found updates.
It comes bundled with OctoPrint.
.. _sec-bundledplugins-softwareupdate-firststeps:
First Steps
@@ -163,6 +167,7 @@ types are currently recognized:
field in Github release data - release will only be included if the
values match. Defaults to being unset, in which case the ``branch``
will be matched.
.. versionadded:: 1.2.16
* ``stable_branch``: Stable channel definition, optional. Structure:
* ``branch``: Branch associated with the channel, acts as ID
* ``name``: Human readable name of the release channel
@@ -170,11 +175,13 @@ types are currently recognized:
field in Github release data - release will only be included if the
values match. Defaults to being unset, in which case the ``branch``
will be matched.
.. versionadded:: 1.2.16
* ``prerelease_channel``: Release channel to limit updates to. If set only
those releases will be included if their ``target_comittish`` matches
the ones associated with the release channel identified by this, either
included in ``prerelease_channels`` or the ``stable_channel``. Only
taken into account if ``prerelease`` is ``true``.
.. versionadded:: 1.2.16
* ``release_compare``: Method to use to compare between current version
information and release versions on Github. One of ``python`` (version
comparison using ``pkg_resources.parse_version``, newer version detected
@@ -208,6 +215,8 @@ types are currently recognized:
``api_user`` to be set. **Important**: Never use your actual Bitbucket login password. Generate
a new app password. App passwords are user specific on Bitbucket.
.. versionadded:: 1.3.5
* ``git_commit``: Checks a local git repository for new commits on its
configured remote. Additional config parameters:
@@ -219,6 +228,8 @@ types are currently recognized:
* ``package``: (mandatory) Name of the package which to check.
.. versionadded:: 1.4.0
* ``httpheader``: Checks an HTTP header on a defined URL for changes. This can be used for easy checks
against things like ``ETag`` or ``Last-Modified`` headers. Additional
config parameters:
@@ -230,12 +241,16 @@ types are currently recognized:
* ``header_prefix``: Prefix to use for the obtained value in the version display. If not provided ``header_name``
will be used. If set to an empty string, no prefix will be added.
.. versionadded:: 1.4.1
* ``jsondata``: Checks the provided JSON endpoint for changes. The JSON endpoint must return an object with the
property ``version``, which should contain the latest version, e.g. ``{"version":"1.2.3"}``. Additional
config parameters:
* ``jsondata``: (mandatory) URL from which to fetch the JSON data
.. versionadded:: 1.4.1
* ``command_line``: Uses a provided script to determine whether an update
is available. Additional config parameters:
@@ -258,12 +273,16 @@ types are currently recognized:
* ``current_version``: Version to report for both local and remote version.
.. versionadded:: 1.3.7
* ``never_current``: Always reports that an update is necessary. Useful for debugging
software update mechanisms during development. Additional config parameters:
* ``local_version``: Current local version. Defaults to ``1.0.0``.
* ``remote_version``: Remote version to offer update to. Defaults to ``1.0.1``.
.. versionadded:: 1.3.7
.. _sec-bundledplugins-softwareupdate-configuration-updatemethods:
Update methods
@@ -309,6 +328,8 @@ supported:
a countdown in the meantime. Useful for debugging software update mechanisms
during development.
.. versionadded:: 1.3.7
.. note::
To allow default configurations for multiple update methods, if more than one of
+2
View File
@@ -3,6 +3,8 @@
Anonymous Usage Tracking Plugin
===============================
.. versionadded:: 1.3.10
The Anonymous Usage Tracking plugin provides valuable insights into how many instances running what versions of
OctoPrint are out there, whether they are successfully completing print jobs and various other metrics.
+2
View File
@@ -3,6 +3,8 @@
Virtual Printer
===============
.. versionchanged:: 1.4.1
The Virtual Printer plugin provides a virtual printer to connect to during development. It is able to simulate various
firmware quirks, communication issues and can be heavily configured through ``config.yaml``. See
:ref:`the development documentation on details and usage <sec-development-virtual-printer>`.
+75
View File
@@ -0,0 +1,75 @@
.. _sec-development-branches:
OctoPrint's branching model
===========================
There are three main branches in OctoPrint:
``master``
The master branch always contains the current stable release plus any changes
since made to *documentation*, *CI related tests* or *Github meta files*. OctoPrint's actual
code will only be modified on new releases. Will have a version number following
the scheme ``<x>.<y>.<z>`` (e.g. ``1.5.1``).
``maintenance``
Improvements and fixes of the current release that make up
the next release go here. More or less continuously updated. You can consider
this a preview of the next release version. It should be very stable at all
times. Anything you spot in here helps tremendously with getting a rock solid
next stable release, so if you want to help out development, running the
``maintenance`` branch and reporting back anything you find is a very good way
to do that. Will usually have a version number following the scheme
``<x>.<y+1>.<0>.dev<commits since increase of y>`` for an OctoPrint version of ``<x>.<y>.<z>``
(e.g. ``1.5.0.dev114``).
``devel``
Ongoing development of what will go into the next big
release (MAJOR version number increases) will happen on this branch. Usually
kept stable, sometimes stuff can break though. Backwards incompatible changes will
be encountered here. Can be considered the "bleeding edge". Will usually have a version
number following the scheme ``<x+1>.<0>.0.dev<commits since increase of y>`` for a current
OctoPrint version of ``<x>.<y>.<z>`` (e.g. ``2.0.0.dev123``).
There are couple more RC and staging branches that see regular use:
``staging/hotfix``
Any preparation for potential hotfix releases takes place here.
Version number follows the scheme ``<x>.<y>.<z+1>`` (e.g. ``1.5.1``) for a current release
of ``<x>.<y>.<z>``.
``rc/maintenance``
This branch is reserved for future releases that have graduated from
the ``maintenance`` branch and are now being pushed on the "Maintenance"
pre release channel for further testing. Version number follows the scheme
``<x>.<y>.<z>rc<n>`` (e.g. ``1.5.0rc1``).
``staging/maintenance``
Any preparation for potential follow-up RCs takes place here.
Version number follows the scheme ``<x>.<y>.<z>rc<n+1>.dev<commits since increase of n>`` (e.g.
``1.5.0rc2.dev3``) for a current Maintenance RC of ``<x>.<y>.<z>``.
``rc/devel``
This branch is reserved for future releases that have graduated from
the ``devel`` branch and are now being pushed on the "Devel" pre release channel
for further testing. Version number follows the scheme ``<x+1>.0.0rc<n>`` (e.g. ``2.0.0rc1``)
for a current stable OctoPrint version of ``<x>.<y>.<z>``.
``staging/devel``
Any preparation for potential follow-up Devel RCs takes place
here. Version number follows the scheme ``<x>.0.0rc<n+1>.dev<commits since increase of n>`` (e.g.
``2.0.0rc2.dev12``) for a current Devel RC of ``<x>.0.0rc<n>``.
Additionally, from time to time you might see other branches pop up in the repository.
Those usually have one of the following prefixes:
``hotfix/...``
Hotfixes under development that are to be merged into the ``staging/hotfix``
and later the ``master`` branch.
``fix/...``
Fixes under development that are to be merged into the ``maintenance``
and ``devel`` branches.
``improve/...``
Improvements under development that are to be merged into the
``maintenance`` and ``devel`` branches.
``dev/...`` or ``feature/...``
New functionality under development that is to be merged
into the ``devel`` branch.
There are also a few older development branches that are slowly being migrated or deleted.
All these branches and branch patterns are set up to automatically get a correct :ref:`version number <sec-development-versions>`
generated through versioneer and thus should also be adhered to during development.
+6 -1
View File
@@ -7,6 +7,11 @@ Development
.. toctree::
:maxdepth: 3
versioning.rst
branches.rst
environment.rst
virtual_printer.rst
profiling.rst
request-profiling.rst
If you are interested in contributing code to OctoPrint, first of all: Thank you! Please make sure to read the
`Contribution Guidelines <https://github.com/OctoPrint/OctoPrint/blob/master/CONTRIBUTING.md>`_!
+31
View File
@@ -0,0 +1,31 @@
.. _sec-development-versions:
OctoPrint's versioning strategy
===============================
OctoPrint's version numbers follow `PEP440 <https://www.python.org/dev/peps/pep-0440/>`_, with a version format of
**MAJOR.MINOR.PATCH** following the contract of `semantic versioning <http://semver.org/>`_.
The **PATCH** version number will increase in case of hotfix releases [#f1]_.
Releases that only change the patch number indicate that they only contain bug fixes, and usually
only hotfixes at that. Example: ``1.5.0`` to ``1.5.1``.
The **MINOR** version number increases with releases that add new functionality while maintaining
backwards compatibility on the documented APIs (both internal and external). Example: ``1.4.x`` to ``1.5.0``.
Finally, the **MAJOR** version number increases if there are breaking API changes that concern any of the
documented interfaces (REST API, plugin interfaces, ...). Example: ``1.x.y`` to ``2.0.0``.
OctoPrint's version numbers are automatically generated using a customized version of
`versioneer <https://github.com/warner/python-versioneer>`_ and depend on the selected git branch, nearest
git tag and commits. Unless a git tag is used for version number determination, the version number will
also contain the git hash within the local version identifier to allow for an exact determination of the
active code base (e.g. ``1.2.9.dev68+g46c7a9c``). Additionally, instances with active uncommitted changes
will contain ``.dirty`` in the local version identifier.
.. rubric:: Footnotes
.. [#f1] Up until 1.4.2, the PATCH version segment was the one increasing most often
due to OctoPrint's maintenance releases but with 1.5.0 this will *fully* adhere
to the concepts in semantic versioning mandating only bug fixes in patch releases.
Maintenance releases will henceforth increase the MINOR segment.
+67
View File
@@ -109,6 +109,9 @@ ClientOpened
**Note:** Name changed in version 1.1.0
.. versionchanged:: 1.1.0
.. versionchanged:: 1.4.0
ClientAuthed
A client has authenticated a user session on the push socket.
@@ -118,6 +121,8 @@ ClientAuthed
valid login session.
* ``username``: the name of the user who authed. On the push socket only available with a valid login session.
.. versionadded:: 1.4.0
ClientClosed
A client has disconnected from the push socket.
@@ -133,12 +138,16 @@ UserLoggedIn
* ``username``: the name of the user who logged in
.. versionadded:: 1.4.0
UserLoggedOut
A user logged out. On the push socket only available with a valid login session with admin rights.
Payload:
* ``username``: the name of the user who logged out
.. versionadded:: 1.4.0
ConnectivityChanged
The server's internet connectivity changed
@@ -147,6 +156,8 @@ ConnectivityChanged
* ``old``: Old connectivity value (true for online, false for offline)
* ``new``: New connectivity value (true for online, false for offline)
.. versionadded:: 1.3.5
.. _sec-events-available_events-printer_commmunication:
Printer communication
@@ -155,6 +166,8 @@ Printer communication
Connecting
The server is attempting to connect to the printer.
.. versionadded:: 1.3.0
Connected
The server has connected to the printer.
@@ -168,6 +181,8 @@ Disconnecting
event might not always be sent when the server and printer get disconnected
from each other. Do not depend on this for critical life cycle management.
.. versionadded:: 1.3.0
Disconnected
The server has disconnected from the printer
@@ -191,6 +206,8 @@ PrinterStateChanged
:func:`~octoprint.printer.PrinterInterface.get_state_id` for possible values.
* ``state_string``: Text representation of the new state.
.. versionadded:: 1.3.0
.. _sec-events-available_events-file_handling:
File handling
@@ -211,6 +228,8 @@ Upload
* ``file``: the file's path within its storage location. To be removed in 1.4.0.
.. versionchanged:: 1.4.0
FileAdded
A file has been added to a storage.
@@ -226,6 +245,8 @@ FileAdded
A copied file triggers this for its new path. A moved file first triggers ``FileRemoved`` for its original
path and then ``FileAdded`` for the new one.
.. versionadded:: 1.3.3
FileRemoved
A file has been removed from a storage.
@@ -240,6 +261,8 @@ FileRemoved
A moved file first triggers ``FileRemoved`` for its original path and then ``FileAdded`` for the new one.
.. versionadded:: 1.3.3
FolderAdded
A folder has been added to a storage.
@@ -253,6 +276,8 @@ FolderAdded
A copied folder triggers this for its new path. A moved folder first triggers ``FolderRemoved`` for its original
path and then ``FolderAdded`` for the new one.
.. versionadded:: 1.3.3
FolderRemoved
A folder has been removed from a storage.
@@ -265,6 +290,8 @@ FolderRemoved
A moved folder first triggers ``FolderRemoved`` for its original path and then ``FolderAdded`` for the new one.
.. versionadded:: 1.3.3
UpdatedFiles
A file list was modified.
@@ -279,6 +306,7 @@ UpdatedFiles
reasons of backwards compatibility and will also be sent on modification of ``printables``. It will however
be removed with 1.4.0.
.. versionchanged:: 1.4.0
MetadataAnalysisStarted
The metadata analysis of a file has started.
@@ -293,6 +321,8 @@ MetadataAnalysisStarted
* ``file``: the file's path within its storage location. To be removed in 1.4.0.
.. versionchanged:: 1.4.0
MetadataAnalysisFinished
The metadata analysis of a file has finished.
@@ -307,6 +337,8 @@ MetadataAnalysisFinished
* ``file``: the file's path within its storage location. To be removed in 1.4.0.
.. versionchanged:: 1.4.0
FileSelected
A file has been selected for printing.
@@ -321,6 +353,8 @@ FileSelected
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``). To be removed in 1.4.0.
* ``filename``: the file's name. To be removed in 1.4.0.
.. versionchanged:: 1.4.0
FileDeselected
No file is selected any more for printing.
@@ -334,6 +368,8 @@ TransferStarted
**Note:** Name changed in version 1.1.0
.. versionchanged:: 1.1.0
TransferDone
A file transfer to the printer's SD has finished.
@@ -365,6 +401,8 @@ PrintStarted
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``). To be removed in 1.4.0.
* ``filename``: the file's name. To be removed in 1.4.0.
.. versionchanged:: 1.4.0
PrintFailed
A print failed.
@@ -383,6 +421,8 @@ PrintFailed
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``). To be removed in 1.4.0.
* ``filename``: the file's name. To be removed in 1.4.0.
.. versionchanged:: 1.4.0
PrintDone
A print completed successfully.
@@ -400,6 +440,8 @@ PrintDone
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``). To be removed in 1.4.0.
* ``filename``: the file's name. To be removed in 1.4.0.
.. versionchanged:: 1.4.0
PrintCancelling
The print is about to be cancelled.
@@ -413,6 +455,8 @@ PrintCancelling
* ``user``: the user who cancelled the print job (if available)
* ``firmwareError``: the firmware error that caused cancelling the print job, if any
.. versionadded:: 1.3.7
PrintCancelled
The print has been cancelled.
@@ -443,6 +487,8 @@ PrintCancelled
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``). To be removed in 1.4.0.
* ``filename``: the file's name. To be removed in 1.4.0.
.. versionchanged:: 1.4.0
PrintPaused
The print has been paused.
@@ -472,6 +518,8 @@ PrintPaused
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``). To be removed in 1.4.0.
* ``filename``: the file's name. To be removed in 1.4.0.
.. versionchanged:: 1.4.0
PrintResumed
The print has been resumed.
@@ -489,6 +537,8 @@ PrintResumed
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``). To be removed in 1.4.0.
* ``filename``: the file's name. To be removed in 1.4.0.
.. versionchanged:: 1.4.0
.. _sec-events-available_events-gcode_processing:
GCODE processing
@@ -543,6 +593,8 @@ PositionUpdate
* ``t``: last tool selected *through OctoPrint*
* ``f``: last feedrate for move commands ``G0``, ``G1`` or ``G28`` sent *through OctoPrint*
.. versionadded:: 1.3.0
ToolChange
A tool change command was sent to the printer. The payload contains the former current tool index and the
new current tool index.
@@ -552,6 +604,8 @@ ToolChange
* ``old``: old tool index
* ``new``: new tool index
.. versionadded:: 1.3.5
.. _sec-events-available_events-timelapses:
Timelapses
@@ -577,6 +631,8 @@ CaptureFailed
* ``file``: the name of the image file that should have been saved
* ``error``: the error that was caught
.. versionadded:: 1.3.0
MovieRendering
The timelapse movie has started rendering.
@@ -669,6 +725,8 @@ SlicingProfileAdded
* ``slicer``: the slicer for which the profile was added
* ``profile``: the profile that was added
.. versionadded:: 1.2.12
SlicingProfileModified
A slicing profile was modified.
@@ -677,6 +735,8 @@ SlicingProfileModified
* ``slicer``: the slicer for which the profile was modified
* ``profile``: the profile that was modified
.. versionadded:: 1.2.12
SlicingProfileDeleted
A slicing profile was deleted.
@@ -685,6 +745,8 @@ SlicingProfileDeleted
* ``slicer``: the slicer for which the profile was deleted
* ``profile``: the profile that was deleted
.. versionadded:: 1.2.12
.. _sec-events-available_events-settings:
Settings
@@ -696,6 +758,8 @@ SettingsUpdated
This event may also be triggered if calling code of :py:class:`octoprint.settings.Settings.save` or
:py:class:`octoprint.plugin.PluginSettings.save` sets the ``trigger_event`` parameter to ``True``.
.. versionadded:: 1.2.0
.. _sec-events-available_events-printer_profile:
Printer Profile
@@ -707,3 +771,6 @@ PrinterProfileModified
Payload:
* ``identifier``: the identifier of the modified printer profile
.. versionadded:: 1.3.12
+2
View File
@@ -3,6 +3,8 @@
Access Control
==============
.. versionchanged:: 1.4.0
OctoPrint's bundled access control feature allows granular permission control
over which users or user groups are allowed to access which parts of OctoPrint.
+2
View File
@@ -25,6 +25,8 @@ start
When this command is received from the printer, a job is currently selected and *not* active, OctoPrint
will start it just like if the "Start"/"Restart" button had been clicked.
.. versionadded:: 1.5.0
cancel
When this command is received from the printer, OctoPrint will cancel a current print job just like if the
"Cancel" button had been clicked.
+2
View File
@@ -3,6 +3,8 @@
@ Commands
==========
.. versionadded:: 1.3.7
@ commands (also known as host commands elsewhere) are special commands you may include in GCODE files streamed
through OctoPrint to your printer or send as part of GCODE scripts, through the Terminal Tab, the API or plugins.
Contrary to other commands they will never be sent to the printer but instead trigger functions inside OctoPrint.
+2
View File
@@ -4,6 +4,8 @@
Plugins
*******
.. versionadded:: 1.2.0
Starting with OctoPrint 1.2.0, there's now a plugin system in place which allows to individually
extend OctoPrint's functionality.
+3
View File
@@ -4,6 +4,9 @@
Safe mode
*********
.. versionadded:: 1.3.0
.. versionchanged:: 1.3.13
With the advent of support for plugins in OctoPrint, it quickly became apparent that some of the bugs
reported on OctoPrint's bug tracker were actually bugs with installed third party plugins or language
packs instead of OctoPrint itself.
+108
View File
@@ -207,6 +207,8 @@ octoprint.access.permissions
.. py:function:: additional_permissions_hook(*args, **kwargs)
.. versionadded:: 1.4.0
Return a list of additional permissions to register in the system on behalf of the plugin. Use this
to add granular permissions to your plugin which can be configured for users and user groups in the general
access control settings of OctoPrint.
@@ -261,6 +263,8 @@ octoprint.access.users.factory
.. py:function:: user_manager_factory_hook(components, settings, *args, **kwargs)
.. versionadded:: 1.4.0
Return a :class:`~octoprint.access.users.UserManager` instance to use as global user manager object. This will
be called only once during initial server startup.
@@ -295,6 +299,8 @@ octoprint.accesscontrol.keyvalidator
.. py:function:: acl_keyvalidator_hook(apikey, *args, **kwargs)
.. versionadded:: 1.3.6
Via this hook plugins may validate their own customized API keys to be used to access OctoPrint's API.
``apikey`` will be the API key as read from the request headers.
@@ -326,6 +332,8 @@ octoprint.cli.commands
.. py:function:: cli_commands_hook(cli_group, pass_octoprint_ctx, *args, **kwargs)
.. versionadded:: 1.3.0
By providing a handler for this hook plugins may register commands on OctoPrint's command line interface (CLI).
Handlers are expected to return a list of callables annotated as `Click commands <http://click.pocoo.org/5/>`_ to register with the
@@ -449,6 +457,8 @@ octoprint.comm.protocol.firmware.info
.. py:function:: firmware_info_hook(comm_instance, firmware_name, firmware_data, *args, **kwargs)
.. versionadded:: 1.3.9
Be notified of firmware information received from the printer following an ``M115``.
Hook handlers may use this to react/adjust behaviour based on reported firmware data. OctoPrint parses the received
@@ -482,6 +492,8 @@ octoprint.comm.protocol.firmware.capabilities
.. py:function:: firmware_capability_hook(comm_instance, capability, enabled, already_defined, *args, **kwargs)
.. versionadded:: 1.3.9
Be notified of capability report entries received from the printer.
Hook handlers may use this to react to custom firmware capabilities. OctoPrint parses the received capability
@@ -509,6 +521,8 @@ octoprint.comm.protocol.action
.. py:function:: protocol_action_hook(comm_instance, line, action, name='', params='', *args, **kwargs)
.. versionadded:: 1.2.0
React to a :ref:`action command <sec-features-action_commands>` received from the printer.
Hook handlers may use this to react to custom firmware messages. OctoPrint parses the received action
@@ -553,6 +567,8 @@ This describes actually two hooks:
.. py:function:: protocol_atcommandphase_hook(comm_instance, phase, command, parameters, tags=None, *args, **kwargs)
.. versionadded:: 1.3.7
Trigger on :ref:`@ commands <sec-features-atcommands>` as they progress through the ``queuing`` and ``sending``
phases of the comm layer. See :ref:`the gcode phase hook <sec-plugins-hook-comm-protocol-gcode-phase>` for a
detailed description of each of these phases.
@@ -601,6 +617,8 @@ This actually describes four hooks:
.. py:function:: protocol_gcodephase_hook(comm_instance, phase, cmd, cmd_type, gcode, subcode=None, tags=None, *args, **kwargs)
.. versionadded:: 1.2.0
Pre- and postprocess commands as they progress through the various phases of being sent to the printer. The phases
are the following:
@@ -754,6 +772,8 @@ octoprint.comm.protocol.gcode.received
.. py:function:: gcode_received_hook(comm_instance, line, *args, **kwargs)
.. versionadded:: 1.3.0
Get the returned lines sent by the printer. Handlers should return the received line or in any case, the modified
version of it. If the handler returns None, processing will be aborted and the communication layer will get an
empty string as the received line. Note that Python functions will also automatically return ``None`` if an empty
@@ -787,6 +807,8 @@ octoprint.comm.protocol.gcode.error
.. py:function:: gcode_error_hook(comm_instance, error_message, *args, **kwargs)
.. versionadded:: 1.3.7
Get the messages of any errors messages sent by the printer, with the leading ``Error:`` or ``!!`` already
stripped. Handlers should return True if they handled that error internally and it should not be processed by
the system further. Normal processing of these kinds of errors - depending on the configuration of error
@@ -824,6 +846,9 @@ octoprint.comm.protocol.scripts
.. py:function:: protocol_scripts_hook(comm_instance, script_type, script_name, *args, **kwargs)
.. versionadded:: 1.2.0
.. versionchanged:: 1.3.7
Return a prefix to prepend, postfix to append, and optionally a dictionary of variables to provide to the script ``script_name`` of type ``type``. Handlers should
make sure to only proceed with returning additional scripts if the ``script_type`` and ``script_name`` match
handled scripts. If not, None should be returned directly.
@@ -868,6 +893,8 @@ octoprint.comm.protocol.temperatures.received
.. py:function:: protocol_temperatures_received_hook(comm_instance, parsed_temperatures, *args, **kwargs)
.. versionadded:: 1.3.6
Get the parsed temperatures returned by the printer, allowing handlers to modify them prior to handing them off
to the system. Handlers are expected to either return ``parsed_temperatures`` as-is or a modified copy thereof.
@@ -901,6 +928,8 @@ octoprint.comm.transport.serial.additional_port_names
.. py:function:: additional_port_names_hook(candidates, *args, **kwargs)
.. versionadded:: 1.4.1
Return additional port names (not glob patterns!) to use as a serial connection to the printer. Expected to be
``list`` of ``string``s.
@@ -920,6 +949,8 @@ octoprint.comm.transport.serial.factory
.. py:function:: serial_factory_hook(comm_instance, port, baudrate, read_timeout, *args, **kwargs)
.. versionadded:: 1.2.0
Return a serial object to use as serial connection to the printer. If a handler cannot create a serial object
for the specified ``port`` (and ``baudrate``), it should just return ``None``.
@@ -996,6 +1027,8 @@ octoprint.events.register_custom_events
.. py:function:: register_custom_events_hook(*args, **kwargs)
.. versionadded:: 1.3.11
Return a list of custom :ref:`events <sec-events>` to register in the system for your plugin.
Should return a list of strings which represent the custom events. Their name on the `octoprint.events.Events` object
@@ -1024,6 +1057,8 @@ octoprint.filemanager.analysis.factory
.. py:function:: analysis_queue_factory_hook(*args, **kwargs)
.. versionadded:: 1.3.9
Return additional (or replacement) analysis queue factories used for analysing uploaded files.
Should return a dictionary to merge with the existing dictionary of factories, mapping from extension tree leaf
@@ -1062,6 +1097,8 @@ octoprint.filemanager.extension_tree
.. py:function:: file_extension_hook(*args, **kwargs)
.. versionadded:: 1.2.0
Return additional entries for the tree of accepted file extensions for uploading/handling by the file manager.
Should return a dictionary to merge with the existing extension tree, adding additional extension groups to
@@ -1098,6 +1135,8 @@ octoprint.filemanager.preprocessor
.. py:function:: file_preprocessor_hook(path, file_object, links=None, printer_profile=None, allow_overwrite=False, *args, **kwargs)
.. versionadded:: 1.2.0
Replace the ``file_object`` used for saving added files to storage by calling :func:`~octoprint.filemanager.util.AbstractFileWrapper.save`.
``path`` will be the future path of the file on the storage. The file's name is accessible via
@@ -1130,6 +1169,8 @@ octoprint.filemanager.preprocessor
octoprint.plugin.backup.additional_excludes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. versionadded:: 1.5.0
See :ref:`here <sec-bundledplugins-backup-hooks-excludes>`.
.. _sec-plugins-hook-plugin-loginui-theming:
@@ -1137,6 +1178,8 @@ See :ref:`here <sec-bundledplugins-backup-hooks-excludes>`.
octoprint.plugin.loginui.theming
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. versionadded:: 1.4.0
See :ref:`here <sec-bundledplugins-loginui-hooks-theming>`.
.. _sec-plugins-hook-plugin-pluginmanager-reconnect:
@@ -1144,6 +1187,8 @@ See :ref:`here <sec-bundledplugins-loginui-hooks-theming>`.
octoprint.plugin.pluginmanager.reconnect_hooks
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. versionadded:: 1.4.0
See :ref:`here <sec-bundledplugins-pluginmanager-hooks-reconnect_hooks>`.
.. _sec-plugins-hook-plugin-softwareupdate-check_config:
@@ -1151,8 +1196,39 @@ See :ref:`here <sec-bundledplugins-pluginmanager-hooks-reconnect_hooks>`.
octoprint.plugin.softwareupdate.check_config
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. versionadded:: 1.2.0
See :ref:`here <sec-bundledplugins-softwareupdate-hooks-check_config>`.
.. _sec-plugins-hooks-plugin-printer-additional_state_data
octoprint.printer.additional_state_data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. py:function:: additional_state_data_hook(initial=False, *args, **kwargs)
.. versionadded:: 1.5.0
Use this to inject additional data into the data structure returned from the printer backend to the frontend
on the push socket or other registered :ref:`~octoprint.printer.PrinterCallback`s. Anything you return here
will be located beneath ``plugins.<your plugin id>`` in the resulting initial and current data push structure.
The ``initial`` parameter will be ``True`` if this the additional update sent to the callback. Your handler should
return a ``dict``, or ``None`` if nothing should be included.
.. warning::
Make sure to not perform any computationally expensive or otherwise long running actions within these handlers as
you could stall the whole state monitor and thus updates being pushed to the frontend.
This includes I/O of any kind.
Cache your data!
:param boolean initial: True if this is the initial update, False otherwise
:return: Additional data to include
:rtype: dict
.. _sec-plugins-hook-printer-factory:
octoprint.printer.factory
@@ -1160,6 +1236,8 @@ octoprint.printer.factory
.. py:function:: printer_factory_hook(components, *args, **kwargs)
.. versionadded:: 1.3.0
Return a :class:`~octoprint.printer.PrinterInstance` instance to use as global printer object. This will
be called only once during initial server startup.
@@ -1191,6 +1269,8 @@ octoprint.printer.estimation.factory
.. py:function:: print_time_estimator_factory(*args, **kwargs)
.. versionadded:: 1.3.9
Return a :class:`~octoprint.printer.estimation.PrintTimeEstimator` subclass (or factory) to use for print time
estimation. This will be called on each start of a print or streaming job with a single parameter ``job_type``
denoting the type of job that was just started: ``local`` meaning a print of a local file through the serial connection,
@@ -1237,6 +1317,8 @@ octoprint.printer.sdcardupload
.. py:function:: sd_card_upload_hook(printer, filename, path, start_callback, success_callback, failure_callback, *args, **kwargs)
.. versionadded:: 1.3.11
Via this hook plugins can change the way files are being uploaded to the sd card of the printer.
Implementations **must** call the provided ``start_callback`` on start of the file transfer and either the ``success_callback``
@@ -1322,6 +1404,8 @@ octoprint.server.api.after_request
.. py:function:: after_request_handlers_hook(*args, **kwargs)
.. versionadded:: 1.3.10
Allows adding additional after-request-handlers to API endpoints defined by OctoPrint itself and installed plugins.
Your plugin might need this to further restrict access to API methods.
@@ -1337,6 +1421,8 @@ octoprint.server.api.before_request
.. py:function:: after_request_handlers_hook(*args, **kwargs)
.. versionadded:: 1.3.10
Allows adding additional before-request-handlers to API endpoints defined by OctoPrint itself and installed plugins.
Your plugin might need this to further restrict access to API methods.
@@ -1352,6 +1438,8 @@ octoprint.server.http.access_validator
.. py:function:: access_validator_hook(request, *args, **kwargs)
.. versionadded:: 1.3.10
Allows adding additional access validators to the default tornado routers.
Your plugin might need to this to restrict acccess to downloads and webcam snapshots further.
@@ -1367,6 +1455,8 @@ octoprint.server.http.bodysize
.. py:function:: server_bodysize_hook(current_max_body_sizes, *args, **kwargs)
.. versionadded:: 1.2.0
Allows extending the list of custom maximum body sizes on the web server per path and HTTP method with custom entries
from plugins.
@@ -1409,6 +1499,8 @@ octoprint.server.http.routes
.. py:function:: server_route_hook(server_routes, *args, **kwargs)
.. versionadded:: 1.2.0
Allows extending the list of routes registered on the web server.
This is interesting for plugins which want to provide their own download URLs which will then be delivered statically
@@ -1476,6 +1568,8 @@ octoprint.server.sockjs.authed
.. py:function:: socket_authed_hook(socket, user, *args, **kwargs):
.. versionadded:: 1.3.10
Allows plugins to be notified that a user got authenticated or deauthenticated on the socket (e.g. due to logout).
:param object socket: the socket object which is about to be registered
@@ -1488,6 +1582,8 @@ octoprint.server.sockjs.register
.. py:function:: socket_registration_hook(socket, user, *args, **kwargs):
.. versionadded:: 1.3.10
Allows plugins to prevent a new :ref:`push socket client <sec-api-push>` to be registered to the system.
Handlers should return either ``True`` or ``False``. ``True`` signals to proceed with normal registration. ``False``
@@ -1507,6 +1603,8 @@ octoprint.server.sockjs.emit
.. py:function:: socket_emit_hook(socket, user, message, payload, *args, **kwargs):
.. versionadded:: 1.3.10
Allows plugins to prevent any messages to be emitted on an existing :ref:`push connection <sec-api-push>`.
Handlers should return either ``True`` to allow the message to be emitted, or ``False`` to prevent it.
@@ -1527,6 +1625,8 @@ octoprint.timelapse.extensions
.. py:function:: timelapse_extension_hook(*args, **kwargs)
.. versionadded:: 1.3.10
Allows extending the set of supported file extensions for timelapse files. Handlers must return a list of
additional file extensions.
@@ -1553,6 +1653,8 @@ octoprint.ui.web.templatetypes
.. py:function:: templatetype_hook(template_sorting, template_rules, *args, **kwargs)
.. versionadded:: 1.2.0
Allows extending the set of supported template types in the web interface. This is interesting for plugins which want
to offer other plugins to hook into their own offered UIs. Handlers must return a list of additional template
specifications in form of 3-tuples.
@@ -1671,6 +1773,8 @@ This actually describes two hooks:
.. py:function:: ui_theming_hook(*args, **kwargs)
.. versionadded:: 1.5.0
Support theming of the login or recovery dialog, just in case the core UI is themed as well. Use to return a list of additional
CSS file URLs to inject into the dialog HTML.
@@ -1700,6 +1804,8 @@ octoprint.timelapse.capture.pre
.. py:function:: capture_pre_hook(filename)
.. versionadded:: 1.4.0
Perform specific actions prior to capturing a timelapse frame.
``filename`` will be the future path of the frame to be saved.
@@ -1715,6 +1821,8 @@ octoprint.timelapse.capture.post
.. py:function:: capture_post_hook(filename, success)
.. versionadded:: 1.4.0
Perform specific actions after capturing a timelapse frame.
``filename`` will be the path of the frame that should have been saved.
+9 -5
View File
@@ -216,28 +216,32 @@ def delete(ctx, path, timeout):
@click.pass_context
def listen(ctx):
def on_connect(ws):
click.echo(">>> Connected!")
click.echo("--- Connected!")
def on_close(ws):
click.echo(">>> Connection closed!")
click.echo("--- Connection closed!")
def on_error(ws, error):
click.echo("!!! Error: {}".format(error))
def on_sent(ws, data):
click.echo(">>> {}".format(json.dumps(data)))
def on_heartbeat(ws):
click.echo("<3")
def on_message(ws, message_type, message_payload):
click.echo("Message: {}, Payload: {}".format(message_type, json.dumps(message_payload)))
click.echo("<<< {}, Payload: {}".format(message_type, json.dumps(message_payload)))
socket = ctx.obj.client.create_socket(on_connect=on_connect,
on_close=on_close,
on_error=on_error,
on_sent=on_sent,
on_heartbeat=on_heartbeat,
on_message=on_message)
click.echo(">>> Waiting for client to exit")
click.echo("--- Waiting for client to exit")
try:
socket.wait()
finally:
click.echo(">>> Goodbye...")
click.echo("--- Goodbye...")
+39 -10
View File
@@ -318,6 +318,27 @@ class PluginSettings(object):
:type force: boolean
:param trigger_event: Trigger the ``SettingsUpdated`` :ref:`event <sec-events-available_events-settings>` on save.
:type trigger_event: boolean
.. method:: add_overlay(overlay, at_end=False, key=None)
Adds a new config overlay for the plugin's settings. Will return the overlay's key in the map.
:param overlay: Overlay dict to add
:type overlay: dict
:param at_end: Whether to add overlay at end or start (default) of config hierarchy
:type at_end: boolean
:param key: Key to use to identify overlay. If not set one will be built based on the overlay's hash
:type key: str
:rtype: str
.. method:: remove_overlay(key)
Removes an overlay from the settings based on its key. Return ``True`` if the overlay could be found and was
removed, ``False`` otherwise.
:param key: The key of the overlay to remove
:type key: str
:rtype: boolean
"""
def __init__(self, settings, plugin_key, defaults=None, get_preprocessors=None, set_preprocessors=None):
@@ -368,17 +389,25 @@ class PluginSettings(object):
kwargs.update(preprocessors=self.set_preprocessors)
return kwargs
def wrap_overlay(args):
result = list(args)
overlay = result[0]
result[0] = dict(plugins={plugin_key: overlay})
return result
self.access_methods = dict(
has =("has", prefix_path_in_args, add_getter_kwargs),
get =("get", prefix_path_in_args, add_getter_kwargs),
get_int =("getInt", prefix_path_in_args, add_getter_kwargs),
get_float =("getFloat", prefix_path_in_args, add_getter_kwargs),
get_boolean=("getBoolean", prefix_path_in_args, add_getter_kwargs),
set =("set", prefix_path_in_args, add_setter_kwargs),
set_int =("setInt", prefix_path_in_args, add_setter_kwargs),
set_float =("setFloat", prefix_path_in_args, add_setter_kwargs),
set_boolean=("setBoolean", prefix_path_in_args, add_setter_kwargs),
remove =("remove", prefix_path_in_args, lambda x: x)
has = ("has", prefix_path_in_args, add_getter_kwargs),
get = ("get", prefix_path_in_args, add_getter_kwargs),
get_int = ("getInt", prefix_path_in_args, add_getter_kwargs),
get_float = ("getFloat", prefix_path_in_args, add_getter_kwargs),
get_boolean = ("getBoolean", prefix_path_in_args, add_getter_kwargs),
set = ("set", prefix_path_in_args, add_setter_kwargs),
set_int = ("setInt", prefix_path_in_args, add_setter_kwargs),
set_float = ("setFloat", prefix_path_in_args, add_setter_kwargs),
set_boolean = ("setBoolean", prefix_path_in_args, add_setter_kwargs),
remove = ("remove", prefix_path_in_args, lambda x: x),
add_overlay = ("add_overlay", wrap_overlay, lambda x: x),
remove_overlay = ("remove_overlay", lambda x: x, lambda x: x)
)
self.deprecated_access_methods = dict(
getInt ="get_int",
+42
View File
@@ -130,6 +130,9 @@ class ReloadNeedingPlugin(Plugin):
class EnvironmentDetectionPlugin(OctoPrintPlugin, RestartNeedingPlugin):
"""
.. versionadded:: 1.3.6
"""
def get_additional_environment(self):
pass
@@ -342,6 +345,8 @@ class TemplatePlugin(OctoPrintPlugin, ReloadNeedingPlugin):
callback and returning ``false`` there if it is detected that the user hasn't yet filled in the
wizard step.
.. versionadded:: 1.3.0
About
Plugins may define additional panels into OctoPrint's "About" dialog. Note that with the current implementation
further about dialog panels will be sorted alphabetically by their name and sorted after the predefined ones.
@@ -353,6 +358,8 @@ class TemplatePlugin(OctoPrintPlugin, ReloadNeedingPlugin):
wrapped div and the link in the navigation will have the additional classes and styles applied as defined via
the configuration supplied through :func:`get_template_configs`.
.. versionadded:: 1.3.0
Generic
Plugins may also inject arbitrary templates into the page of the web interface itself, e.g. in order to
add overlays or dialogs to be called from within the plugin's JavaScript code.
@@ -638,6 +645,8 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
server startup (basically eager caching instead of lazily waiting for the first request).
See below for details on this.
.. versionadded:: 1.3.0
"""
# noinspection PyMethodMayBeStatic,PyUnusedLocal
@@ -761,6 +770,8 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
list, tuple: A list or tuple of strings to use in the cache key. Will be joined by OctoPrint
using ``:`` as separator and appended to the existing ``ui:<identifier>:<base url>:<locale>``
cache key. Ignored if ``None`` is returned.
.. versionadded:: 1.3.0
"""
return None
@@ -774,6 +785,8 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
Returns:
list: A list of paths to additional files whose modification to track for (in)validating
the cache. Ignored if ``None`` is returned.
..versionadded:: 1.3.0
"""
return None
@@ -787,6 +800,8 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
Returns:
list: A list of paths representing the only files whose modification to track for (in)validating
the cache. Ignored if ``None`` is returned.
..versionadded:: 1.3.0
"""
return None
@@ -798,6 +813,8 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
Returns:
str: An alternatively calculated ETag value. Ignored if ``None`` is returned (default).
..versionadded:: 1.3.0
"""
return None
@@ -814,6 +831,8 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
Returns:
(list): A list of additional fields for the ETag generation, or None
..versionadded:: 1.3.0
"""
return default_additional
@@ -825,6 +844,8 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
Returns:
int: An alternatively calculated LastModified value. Ignored if ``None`` is returned (default).
..versionadded:: 1.3.0
"""
return None
@@ -849,6 +870,8 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
Returns:
dict: Additional data to persist in the preemptive cache configuration.
..versionadded:: 1.3.0
"""
return None
@@ -865,6 +888,8 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
Returns:
dict: Additional request data to persist in the preemptive cache configuration and to
use for request environment construction.
..versionadded:: 1.3.0
"""
return None
@@ -879,6 +904,8 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
Returns:
bool: Whether to suppress a record (True) or not (False, default)
..versionadded:: 1.3.0
"""
return False
@@ -899,6 +926,8 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
(callable) A filter function accepting the ``template_type`` and ``template_key`` of a template
and returning ``True`` to keep it and ``False`` to filter it out. If ``None`` is returned, no
filtering will take place.
..versionadded:: 1.3.0
"""
return default_template_filter
@@ -1313,6 +1342,8 @@ class BlueprintPlugin(OctoPrintPlugin, RestartNeedingPlugin):
See `the documentation for flask.Blueprint.errorhandler <http://flask.pocoo.org/docs/0.10/api/#flask.Blueprint.errorhandler>`_
and `the documentation for flask.Flask.errorhandler <http://flask.pocoo.org/docs/0.10/api/#flask.Flask.errorhandler>`_ for more
information.
..versionadded:: 1.3.0
"""
from collections import defaultdict
def decorator(f):
@@ -1669,6 +1700,8 @@ class SettingsPlugin(OctoPrintPlugin):
# another=dict(admin_only=dict(path="path"),
# field="field"),
# path=dict(to=dict(never=dict(return=None))))
..versionadded:: 1.2.17
"""
return dict()
@@ -1756,6 +1789,8 @@ class SettingsPlugin(OctoPrintPlugin):
The default implementation just minimizes the data persisted on disk to only contain
the differences to the defaults (in case the current data was persisted with an older
version of OctoPrint that still duplicated default data).
..versionadded:: 1.3.0
"""
import octoprint.util
from octoprint.settings import NoSuchSettingsPath
@@ -1895,6 +1930,8 @@ class SlicerPlugin(OctoPrintPlugin):
For the extension tree format, take a look at the docs of the :ref:`octoprint.filemanager.extension_tree hook <sec-plugins-hook-filemanager-extensiontree>`.
Returns: (dict) a dictionary containing a valid extension subtree.
..versionadded:: 1.3.11
"""
from octoprint.filemanager import ContentTypeMapping
return dict(model=dict(stl=ContentTypeMapping(["stl"], "application/sla")))
@@ -1909,6 +1946,8 @@ class SlicerPlugin(OctoPrintPlugin):
Arguments:
profile_path (str): The base folder where OctoPrint stores this slicer plugin's profiles
..versionadded:: 1.3.7
"""
try:
@@ -1930,6 +1969,9 @@ class SlicerPlugin(OctoPrintPlugin):
# noinspection PyMethodMayBeStatic
def get_slicer_profiles_lastmodified(self, profile_path):
"""
..versionadded:: 1.3.0
"""
import os
try:
from os import scandir
@@ -1,6 +1,6 @@
<h3>{{ _('Action Command Notification Settings') }}</h3>
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<div class="controls">
<label class="checkbox">
@@ -1,6 +1,6 @@
<h3>{{ _('Action Command Prompt Settings') }}</h3>
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<label class="control-label">{{ _('Enable support')}}</label>
<div class="controls">
@@ -4,7 +4,7 @@
<h3 id="plugin_appkeys_keygenerated_title"></h3>
</div>
<div class="modal-body">
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<label class="control-label">{{ _('User') }}</label>
<div class="controls">
@@ -33,7 +33,7 @@
<legend>{{ _('Manually generate an application key') }}</legend>
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<label class="control-label">{{ _('Application identifier') }}</label>
<div class="controls">
@@ -67,7 +67,7 @@
<p>{{ _('Create a new backup of the current state.') }}</p>
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<div class="controls">
<label class="checkbox">
@@ -1,4 +1,4 @@
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<label class="control-label">{{ _('Backup file') }}</label>
<div class="controls">
@@ -22,7 +22,7 @@
initial administrator account who will have full access to both the printer and OctoPrint's settings, then click
on "Keep Access Control Enabled":
</p>{% endtrans %}
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group" data-bind="css: {success: validUsername()}">
<label class="control-label" for="first_run_username">{{ _('Username') }}</label>
<div class="controls">
@@ -11,7 +11,7 @@
OctoPrint comes preconfigured to perform the connectivity check every 15 minutes. You may change the value here.
{% endtrans %}</p>
<form class="form-horizontal" data-bind="with: settingsViewModel, enable: !setup(), css {disabled: setup()}">
<form class="form-horizontal" data-bind="with: settingsViewModel, enable: !setup(), css {disabled: setup()}" onsubmit="return false;">
{% include "snippets/settings/server/serverOnlineCheckInterval.jinja2" %}
</form>
@@ -21,7 +21,7 @@
trust and that has a high availability.
{% endtrans %}</p>
<form class="form-horizontal" data-bind="with: settingsViewModel, enable: !setup(), css {disabled: setup()}">
<form class="form-horizontal" data-bind="with: settingsViewModel, enable: !setup(), css {disabled: setup()}" onsubmit="return false;">
{% include "snippets/settings/server/serverOnlineCheckHost.jinja2" %}
{% include "snippets/settings/server/serverOnlineCheckPort.jinja2" %}
{% include "snippets/settings/server/serverOnlineCheckTestConnectivity.jinja2" %}
@@ -34,7 +34,7 @@
side with the general connectivity check, leave the field empty.
{% endtrans %}</p>
<form class="form-horizontal" data-bind="with: settingsViewModel, enable: !setup(), css {disabled: setup()}">
<form class="form-horizontal" data-bind="with: settingsViewModel, enable: !setup(), css {disabled: setup()}" onsubmit="return false;">
<div class="control-group">
{% include "snippets/settings/server/serverOnlineCheckName.jinja2" %}
{% include "snippets/settings/server/serverOnlineCheckTestResolution.jinja2" %}
@@ -7,13 +7,13 @@
<h4>{{ _('OctoPrint related commands') }}</h4>
<form class="form-horizontal" data-bind="with: settingsViewModel">
<form class="form-horizontal" data-bind="with: settingsViewModel" onsubmit="return false;">
{% include "snippets/settings/server/serverCommandServerRestart.jinja2" %}
</form>
<h4>{{ _('System related commands') }}</h4>
<form class="form-horizontal" data-bind="with: settingsViewModel">
<form class="form-horizontal" data-bind="with: settingsViewModel" onsubmit="return false;">
{% include "snippets/settings/server/serverCommandSystemRestart.jinja2" %}
{% include "snippets/settings/server/serverCommandSystemShutdown.jinja2" %}
</form>
@@ -25,7 +25,7 @@
a fully qualified URL reachable <strong>from the OctoPrint server</strong>.
</p>{% endtrans %}
<form class="form-horizontal" data-bind="with: settingsViewModel">
<form class="form-horizontal" data-bind="with: settingsViewModel" onsubmit="return false;">
{% include "snippets/settings/webcam/webcamStreamUrl.jinja2" %}
{% include "snippets/settings/webcam/webcamSnapshotUrl.jinja2" %}
</form>
@@ -37,6 +37,6 @@
know the correct <strong>path to FFMPEG</strong>.
</p>{% endtrans %}
<form class="form-horizontal" data-bind="with: settingsViewModel">
<form class="form-horizontal" data-bind="with: settingsViewModel" onsubmit="return false;">
{% include "snippets/settings/webcam/ffmpegPath.jinja2" %}
</form>
+11 -11
View File
@@ -138,12 +138,13 @@ class DiscoveryPlugin(octoprint.plugin.StartupPlugin,
self.port = port
# Zeroconf
self.zeroconf_register("_http._tcp", self.get_instance_name(), txt_record=self._create_http_txt_record_dict())
self.zeroconf_register("_octoprint._tcp", self.get_instance_name(), txt_record=self._create_octoprint_txt_record_dict())
instance_name = self.get_instance_name()
self.zeroconf_register("_http._tcp", instance_name, txt_record=self._create_http_txt_record_dict())
self.zeroconf_register("_octoprint._tcp", instance_name, txt_record=self._create_octoprint_txt_record_dict())
for zc in self._settings.get(["zeroConf"]):
if "service" in zc:
self.zeroconf_register(zc["service"],
zc.get("name", self.get_instance_name()),
zc.get("name", instance_name),
port=zc.get("port"),
txt_record=zc.get("txtRecord"))
@@ -177,7 +178,7 @@ class DiscoveryPlugin(octoprint.plugin.StartupPlugin,
return octoprint.util.to_native_str(name) + octoprint.util.to_native_str(".") + service_type
def _format_zeroconf_txt(self, record):
result = dict()
result = {}
if not record:
return result
@@ -489,23 +490,22 @@ class DiscoveryPlugin(octoprint.plugin.StartupPlugin,
:return: a dictionary containing the defined key-value-pairs, ready to be turned into a TXT record
"""
entries = self._create_http_txt_record_dict()
import octoprint.server
import octoprint.server.api
entries.update(dict(
entries = self._create_http_txt_record_dict()
entries.update(
version=octoprint.server.VERSION,
api=octoprint.server.api.VERSION,
))
uuid=self.get_uuid()
)
modelName = self._settings.get(["model", "name"])
if modelName:
entries.update(dict(model=modelName))
entries.update(model=modelName)
vendor = self._settings.get(["model", "vendor"])
if vendor:
entries.update(dict(vendor=vendor))
entries.update(vendor=vendor)
return entries
@@ -15,7 +15,7 @@
</p>
{% endtrans %}
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<div class="controls">
<label class="checkbox">
@@ -1,4 +1,4 @@
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group" title="{{ _('Maximum size for which the GCode Viewer autoloads the file for preview')|edq }}">
<label class="control-label" for="settings-featureSizeThreshold">{{ _('GCode Viewer file size threshold') }}</label>
<div class="controls">
@@ -63,7 +63,7 @@
</div>
<h3>{{ _('Logging Levels') }}</h3>
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="row-fluid">
<div class="span8"><h5>{{ _('Name') }}</h5></div>
@@ -2,7 +2,7 @@
<p>{{ _('Please restart OctoPrint after changing any of this plugin\'s settings.') }}</p>
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<div class="controls">
<label class="checkbox">
@@ -15,7 +15,7 @@
<div>
<div><small><a href="#" class="muted" onclick="$(this).children().toggleClass('fa-caret-right fa-caret-down').parent().parent().parent().next().slideToggle('fast')"><i class="fa fa-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
<div class="hide">
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<label class="control-label">{{ _('Command for under voltage/overheat detection') }}</label>
<div class="controls">
@@ -1049,6 +1049,11 @@ $(function() {
self.logNotification.update(options);
}
}
// make sure the notification is visible
if (self.logNotification.state !== 'open' && self.logNotification.state !== 'opening') {
self.logNotification.open();
}
};
self._markWorking = function(title, line) {
@@ -297,7 +297,7 @@
<h4>{{ _('... from URL') }}</h4>
<form class="form-inline">
<form class="form-inline" onsubmit="return false;">
<div class="control-group row-fluid" data-bind="css: {error: invalidUrl}">
<div class="span9">
<input type="text" class="input-block-level" data-bind="value: installUrl, valueUpdate: 'input'" placeholder="{{ _('Enter URL...')|edq }}" >
@@ -309,7 +309,7 @@
<h4>{{ _('... from an uploaded file') }}</h4>
<form class="form-inline">
<form class="form-inline" onsubmit="return false;">
<div class="control-group row-fluid" data-bind="css: {error: invalidFile}">
<div class="input-prepend span9">
<span class="btn fileinput-button">
@@ -326,7 +326,7 @@
<div>
<div><small><a href="#" class="muted" onclick="$(this).children().toggleClass('fa-caret-right fa-caret-down').parent().parent().parent().next().slideToggle('fast')"><i class="fa fa-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
<div class="hide">
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<div class="controls">
<label class="checkbox">
@@ -350,7 +350,7 @@
<h3>{{ _('Plugin Configuration') }}</h3>
</div>
<div class="modal-body">
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<fieldset>
<legend>{{ _('Confirmations') }}</legend>
+159 -61
View File
@@ -17,6 +17,7 @@ import time
import logging
import logging.handlers
import hashlib
import requests
# noinspection PyCompatibility
from concurrent import futures
@@ -58,6 +59,8 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
DATA_FORMAT_VERSION = "v4"
CHECK_OVERLAY_KEY = "softwareupdate_check_overlay"
# noinspection PyMissingConstructor
def __init__(self):
self._update_in_progress = False
@@ -75,6 +78,10 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
self._version_cache_dirty = False
self._version_cache_timestamp = None
self._overlay_cache = dict()
self._overlay_cache_ttl = 0
self._overlay_cache_timestamp = None
self._environment_supported = True
self._environment_versions = dict()
self._environment_ready = threading.Event()
@@ -93,6 +100,8 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
self._version_cache_path = os.path.join(self.get_plugin_data_folder(), "versioncache.yaml")
self._load_version_cache()
self._overlay_cache_ttl = self._settings.get_int(["check_overlay_ttl"]) * 60
def refresh_checks(name, plugin):
self._refresh_configured_checks = True
self._send_client_message("update_versions")
@@ -147,8 +156,13 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
def _get_configured_checks(self):
with self._configured_checks_mutex:
if self._refresh_configured_checks or self._configured_checks is None:
if self._refresh_configured_checks \
or self._configured_checks is None \
or self._check_overlays_stale:
self._refresh_configured_checks = False
overlays = self._get_check_overlays()
self._configured_checks = self._settings.get(["checks"], merged=True)
update_check_hooks = self._plugin_manager.get_hooks("octoprint.plugin.softwareupdate.check_config")
@@ -176,9 +190,13 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
yaml_config = dict()
effective_config = default_config
if key in overlays:
effective_config = dict_merge(default_config, overlays[key])
if key in self._configured_checks:
yaml_config = self._configured_checks[key]
effective_config = dict_merge(default_config, yaml_config)
effective_config = dict_merge(effective_config, yaml_config)
# Make sure there's nothing persisted in that check that shouldn't be persisted
#
@@ -269,6 +287,45 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
if self._storage_sufficient
else "insufficient"))
@property
def _check_overlays_stale(self):
return self._overlay_cache is None or self._overlay_cache_timestamp is None \
or self._overlay_cache_timestamp + self._overlay_cache_ttl < time.time()
def _get_check_overlays(self, force=False):
if self._check_overlays_stale or force:
if self._connectivity_checker.online:
# reload from URL
url = self._settings.get(["check_overlay_url"])
self._logger.info("Fetching check overlays from {}".format(url))
try:
r = requests.get(url, timeout=3.1)
r.raise_for_status()
data = r.json()
except Exception as exc:
self._logger.error("Could not fetch check overlay from {}: {}".format(url, exc))
self._overlay_cache = dict()
else:
self._overlay_cache = data
else:
self._logger.info("Not fetching check overlays, we are offline")
self._overlay_cache = dict()
self._overlay_cache_timestamp = time.time()
default_overlay = dict()
defaults = self.get_settings_defaults()
for key in defaults["checks"]:
if key in self._overlay_cache:
default_overlay[key] = self._overlay_cache[key]
self._settings.remove_overlay(self.CHECK_OVERLAY_KEY)
if default_overlay:
self._settings.add_overlay(dict(checks=default_overlay), key=self.CHECK_OVERLAY_KEY)
return self._overlay_cache
def _load_version_cache(self):
if not os.path.isfile(self._version_cache_path):
return
@@ -362,15 +419,23 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
"ignore_throttled": False,
"minimum_free_storage": 150
"minimum_free_storage": 150,
"check_overlay_url": "https://plugins.octoprint.org/update_check_overlay.json",
"check_overlay_ttl": 6 * 60,
}
def on_settings_load(self):
# ensure we don't persist check configs we receive on the API
data = dict(octoprint.plugin.SettingsPlugin.on_settings_load(self))
if "checks" in data:
del data["checks"]
checks = self._get_configured_checks()
#~~ octoprint check settings
if "octoprint" in checks:
data["octoprint_checkout_folder"] = self._get_octoprint_checkout_folder(checks=checks)
data["octoprint_tracked_branch"] = self._get_octoprint_tracked_branch(checks=checks)
@@ -403,15 +468,18 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
else:
data["octoprint_checkout_folder"] = None
data["octoprint_type"] = None
data["octoprint_branch_mappings"] = []
#~~ pip check settings
data["pip_enable_check"] = "pip" in checks
return data
def on_settings_save(self, data):
#~~ plugin settings
for key in self.get_settings_defaults():
if key in ("checks", "cache_ttl", "notify_user", "minimum_free_storage",
if key in ("checks", "cache_ttl", "check_overlay_ttl", "notify_user", "minimum_free_storage",
"octoprint_checkout_folder", "octoprint_type", "octoprint_release_channel"):
continue
if key in data:
@@ -421,6 +489,10 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
self._settings.set_int(["cache_ttl"], data["cache_ttl"])
self._version_cache_ttl = self._settings.get_int(["cache_ttl"]) * 60
if "check_overlay_ttl" in data:
self._settings.set_int(["check_overlay_ttl"], data["check_overlay_ttl"])
self._overlay_cache_ttl = self._settings.get_int(["check_overlay_ttl"]) * 60
if "notify_users" in data:
self._settings.set_boolean(["notify_users"], data["notify_users"])
@@ -428,80 +500,89 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
self._settings.set_int(["minimum_free_storage"], data["minimum_free_storage"])
self._check_storage()
defaults = dict(
plugins=dict(softwareupdate=dict(
checks=dict(
octoprint=self.get_settings_defaults()["checks"]["octoprint"]
)
))
)
#~~ octoprint check settings
updated_octoprint_check_config = False
update_pip_check_config = False
if "octoprint_checkout_folder" in data:
self._settings.set(["checks", "octoprint", "checkout_folder"], data["octoprint_checkout_folder"], defaults=defaults, force=True)
if self._settings.get(["checks", "octoprint", "update_folder"]) and data["octoprint_checkout_folder"]:
self._settings.set(["checks", "octoprint", "update_folder"], None, defaults=defaults, force=True)
if data["octoprint_checkout_folder"]:
# force=True as that path is not part of the default config
self._settings.set(["checks", "octoprint", "checkout_folder"], data["octoprint_checkout_folder"], force=True)
if self._settings.get(["checks", "octoprint", "update_folder"]):
self._settings.remove(["checks", "octoprint", "update_folder"])
else:
self._settings.remove(["checks", "octoprint", "checkout_folder"])
updated_octoprint_check_config = True
if "octoprint_type" in data:
octoprint_type = data["octoprint_type"]
if octoprint_type == "github_release":
self._settings.set(["checks", "octoprint", "type"], octoprint_type, defaults=defaults)
self._settings.set(["checks", "octoprint", "method"], "pip", defaults=defaults)
self._settings.set(["checks", "octoprint", "type"], octoprint_type)
self._settings.set(["checks", "octoprint", "method"], "pip")
updated_octoprint_check_config = True
elif octoprint_type == "github_commit":
self._settings.set(["checks", "octoprint", "type"], octoprint_type, defaults=defaults)
self._settings.set(["checks", "octoprint", "method"], "pip", defaults=defaults)
self._settings.set(["checks", "octoprint", "type"], octoprint_type)
self._settings.set(["checks", "octoprint", "method"], "pip")
updated_octoprint_check_config = True
elif octoprint_type == "git_commit":
self._settings.set(["checks", "octoprint", "type"], octoprint_type, defaults=defaults)
self._settings.set(["checks", "octoprint", "method"], "update_script", defaults=defaults)
self._settings.set(["checks", "octoprint", "type"], octoprint_type)
self._settings.set(["checks", "octoprint", "method"], "update_script")
updated_octoprint_check_config = True
if "octoprint_tracked_branch" in data:
self._settings.set(["checks", "octoprint", "branch"], data["octoprint_tracked_branch"], defaults=defaults, force=True)
if data["octoprint_tracked_branch"]:
# force=True as that path is not part of the default config
self._settings.set(["checks", "octoprint", "branch"], data["octoprint_tracked_branch"], force=True)
else:
self._settings.remove(["checks", "octoprint", "branch"])
updated_octoprint_check_config = True
if "octoprint_pip_target" in data:
self._settings.set(["checks", "octoprint", "pip"], data["octoprint_pip_target"], defaults=defaults)
self._settings.set(["checks", "octoprint", "pip"], data["octoprint_pip_target"])
updated_octoprint_check_config = True
if "octoprint_release_channel" in data:
prerelease_branches = self._settings.get(["checks", "octoprint", "prerelease_branches"])
if prerelease_branches and data["octoprint_release_channel"] in [x["branch"] for x in prerelease_branches]:
self._settings.set(["checks", "octoprint", "prerelease"], True, defaults=defaults, force=True)
self._settings.set(["checks", "octoprint", "prerelease_channel"], data["octoprint_release_channel"],
defaults=defaults, force=True)
# force=True as those paths are not part of the default config
self._settings.set(["checks", "octoprint", "prerelease"], True, force=True)
self._settings.set(["checks", "octoprint", "prerelease_channel"], data["octoprint_release_channel"], force=True)
else:
self._settings.set(["checks", "octoprint", "prerelease"], False, defaults=defaults, force=True)
self._settings.set(["checks", "octoprint", "prerelease_channel"], None, defaults=defaults, force=True)
self._settings.remove(["checks", "octoprint", "prerelease"])
self._settings.remove(["checks", "octoprint", "prerelease_channel"])
updated_octoprint_check_config = True
if "pip_enable_check" in data:
checks = self._settings.get(["checks"], merged=True)
if data["pip_enable_check"] in octoprint.settings.valid_boolean_trues:
checks["pip"] = dict(type="pypi_release",
package="pip",
pip="pip=={target_version}")
elif "pip" in checks:
del checks["pip"]
self._settings.set(["checks"], checks, force=True)
self._settings.save()
update_pip_check_config = True
if updated_octoprint_check_config:
self._invalidate_version_cache("octoprint")
#~~ pip check settings
update_pip_check_config = False
if "pip_enable_check" in data:
pip_enable_check = data["pip_enable_check"] in octoprint.settings.valid_boolean_trues
pip_check_currently_enabled = "pip" in self._settings.get(["checks"], merged=True)
if pip_enable_check != pip_check_currently_enabled:
if pip_enable_check:
# force=True as that path is not part of the default config
self._settings.set(["checks", "pip"],
dict(type="pypi_release",
package="pip",
pip="pip=={target_version}"),
force=True)
else:
self._settings.remove(["checks", "pip"])
update_pip_check_config = True
if update_pip_check_config:
self._invalidate_version_cache("pip")
def get_settings_version(self):
return 8
return 9
def on_settings_migrate(self, target, current=None):
@@ -546,8 +627,8 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
self._settings.set(["environment_restart_command"], None)
self._settings.set(["octoprint_restart_command"], None)
if current is None or current == 2:
# No config version and config version 2 need the same fix, stripping
if current is None or current == 2 or current == 8:
# No config version and config version 2 and 8 need the same fix, stripping
# accidentally persisted data off the checks.
#
# We used to do the same processing for the plugin entries too here, but that interfered
@@ -568,7 +649,11 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
deletables=["current", "displayName", "displayVersion"]
else:
deletables=[]
self._clean_settings_check("octoprint", octoprint_check, self.get_settings_defaults()["checks"]["octoprint"], delete=deletables, save=False)
self._clean_settings_check("octoprint",
octoprint_check,
self.get_settings_defaults()["checks"]["octoprint"],
delete=deletables,
save=False)
elif current == 1:
# config version 1 had the error that the octoprint check got accidentally
@@ -612,7 +697,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
if len(data):
self._settings.set(["checks", key], data, defaults=dummy_defaults)
else:
self._settings.set(["checks", key], None, defaults=dummy_defaults)
self._settings.remove(["checks", key], defaults=dummy_defaults)
if save:
self._settings.save()
@@ -625,12 +710,15 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
@no_firstrun_access
@Permissions.PLUGIN_SOFTWAREUPDATE_CHECK.require(403)
def check_for_update(self):
if "check" in flask.request.values:
check_targets = list(map(lambda x: x.strip(), flask.request.values["check"].split(",")))
request_data = flask.request.values
if "targets" in request_data or "check" in request_data:
check_targets = list(map(lambda x: x.strip(),
request_data.get("targets", request_data.get("check", "")).split(",")))
else:
check_targets = None
force = flask.request.values.get("force", "false") in octoprint.settings.valid_boolean_trues
force = request_data.get("force", "false") in octoprint.settings.valid_boolean_trues
def view():
self._environment_ready.wait(timeout=30.0)
@@ -674,7 +762,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
storage=dict(sufficient=self._storage_sufficient,
free=storage)))
except exceptions.ConfigurationInvalid as e:
return flask.make_response("Update not properly configured, can't proceed: %s" % e.message, 500)
return flask.make_response("Update not properly configured, can't proceed: {}".format(e), 500)
def etag():
checks = self._get_configured_checks()
@@ -704,6 +792,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
hash_update(str(self._environment_supported))
hash_update(str(self._version_cache_timestamp))
hash_update(str(self._overlay_cache_timestamp))
hash_update(str(self._connectivity_checker.online))
hash_update(str(self._update_in_progress))
hash_update(self.DATA_FORMAT_VERSION)
@@ -714,7 +803,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
return with_revalidation_checking(etag_factory=lambda *args, **kwargs: etag(),
condition=lambda *args, **kwargs: condition(),
unless=lambda: force)(view)()
unless=lambda: force or self._check_overlays_stale)(view)()
@octoprint.plugin.BlueprintPlugin.route("/update", methods=["POST"])
@@ -744,15 +833,12 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
if json_data is None:
return flask.make_response("Invalid JSON", 400)
if "targets" in json_data:
targets = list(map(lambda x: x.strip(), json_data["targets"]))
if "targets" in json_data or "checks" in json_data:
targets = list(map(lambda x: x.strip(), json_data.get("targets", json_data.get("check", []))))
else:
targets = None
if "force" in json_data and json_data["force"] in octoprint.settings.valid_boolean_trues:
force = True
else:
force = False
force = json_data.get("force", "false") in octoprint.settings.valid_boolean_trues
to_be_checked, checks = self.perform_updates(targets=targets, force=force)
return flask.jsonify(dict(order=to_be_checked, checks=checks))
@@ -794,11 +880,15 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
patch["prerelease"] = prerelease
patch["prerelease_channel"] = data["channel"]
# disable/enable check
if "disabled" in data:
patch["disabled"] = data["disabled"] in octoprint.settings.valid_boolean_trues
# do we have changes to apply?
if patch:
current = self._settings.get(["checks", target], incl_defaults=False)
updated = dict_merge(current, patch)
self._settings.set(["checks", target], updated)
self._settings.set(["checks", target], updated, defaults=dict(plugins=dict(softwareupdate=dict(checks={target: dict()}))))
settings_dirty = True
self._invalidate_version_cache(target)
@@ -858,6 +948,9 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
:param check_targets: an iterable defining the targets to check, if not supplied defaults to all targets
"""
if force:
self._get_check_overlays(force=True)
checks = self._get_configured_checks()
if check_targets is None:
check_targets = list(checks.keys())
@@ -911,8 +1004,9 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
release_notes=None),
needs_online=True), target_information)
update_available = update_available or target_update_available
update_possible = update_possible or (target_update_possible and target_update_available)
target_disabled = populated_check.get("disabled", False)
update_available = update_available or (target_update_available and not target_disabled)
update_possible = update_possible or (target_update_possible and target_update_available and not target_disabled)
local_name = target_information["local"]["name"]
local_value = target_information["local"]["value"]
@@ -940,6 +1034,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
releaseNotes=release_notes,
online=target_online,
error=target_error,
disabled=target_disabled,
releaseChannels=dict())
if populated_check["type"] == "github_release" and "stable_branch" in populated_check and "prerelease_branches" in populated_check:
@@ -1046,13 +1141,16 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
self._logger.exception("Error while checking if {} can be updated".format(target))
update_possible = False
disabled = check.get("disabled", False)
self._version_cache[target] = dict(timestamp=time.time(),
hash=current_hash,
information=information,
available=update_available,
possible=update_possible,
online=online,
error=error)
error=error,
disabled=disabled)
self._version_cache_dirty = True
return information, update_available, update_possible, online, error
+9 -3
View File
@@ -35,10 +35,13 @@ def commands(cli_group, pass_octoprint_ctx, *args, **kwargs):
- octoprint plugins softwareupdate:check octoprint
This will only check OctoPrint itself for available
updates.
Note that the OctoPrint server needs to be running for this
command to work as it utilizes the server API.
"""
params = dict(force=force)
if targets:
params["check"] = ",".join(targets)
params["targets"] = ",".join(targets)
client = create_client(settings=cli_group.settings,
apikey=apikey,
@@ -119,11 +122,14 @@ def commands(cli_group, pass_octoprint_ctx, *args, **kwargs):
- octoprint plugins softwareupdate:update octoprint
This will only update OctoPrint and leave any further
components with pending updates at their current versions.
Note that the OctoPrint server needs to be running for this
command to work as it utilizes the server API.
"""
data = dict(force=force)
if targets:
data["check"] = targets
data["targets"] = targets
client = create_client(settings=cli_group.settings,
apikey=apikey,
@@ -176,7 +182,7 @@ def commands(cli_group, pass_octoprint_ctx, *args, **kwargs):
flags["waiting_for_restart"] = True
click.echo("Restarting to apply changes...")
elif plugin_message_type == "failure":
elif plugin_message_type == "error":
click.echo("Error")
ws.close()
@@ -32,7 +32,7 @@
data.force = true;
}
if (entries && entries.length) {
data.check = entries.join(",");
data.targets = entries.join(",");
}
return this.base.getWithQuery(this.checkUrl, data, opts);
};
@@ -1 +1 @@
#settings_plugin_softwareupdate_updatelist{display:block;width:auto;max-height:500px;overflow-x:hidden;overflow-y:scroll;padding-right:2px;margin-bottom:1em}td.settings_plugin_softwareupdate_column_update{width:16px}td.settings_plugin_softwareupdate_column_information .line{display:block}td.settings_plugin_softwareupdate_column_information .settings_plugin_softwareupdate_release_channel{line-height:20px;height:20px;font-size:9px;margin-bottom:0;vertical-align:baseline}#settings_plugin_softwareupdate_workingdialog_output{font-size:.8em}#settings_plugin_softwareupdate_workingdialog_output .message{font-weight:700}#settings_plugin_softwareupdate_workingdialog_output .separator{font-weight:700;color:#666}#settings_plugin_softwareupdate_workingdialog_output .stdout{color:#333}#settings_plugin_softwareupdate_workingdialog_output .stderr{color:#900}#settings_plugin_softwareupdate_workingdialog_output .call{color:#009}#settings_plugin_softwareupdate_workingdialog_output .message_error{font-weight:700;color:#900}.softwareupdate_notification ul{margin:10px 0 10px 25px}.softwareupdate_notification ul .name{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;display:block}
#settings_plugin_softwareupdate_updatelist{display:block;width:auto;max-height:500px;overflow-x:hidden;overflow-y:scroll;padding-right:2px;margin-bottom:1em}td.settings_plugin_softwareupdate_column_update{width:16px}td.settings_plugin_softwareupdate_column_update a{text-decoration:none;color:#000}td.settings_plugin_softwareupdate_column_information .line{display:block}td.settings_plugin_softwareupdate_column_information .settings_plugin_softwareupdate_release_channel{line-height:20px;height:20px;font-size:9px;margin-bottom:0;vertical-align:baseline}#settings_plugin_softwareupdate_workingdialog_output{font-size:.8em}#settings_plugin_softwareupdate_workingdialog_output .message{font-weight:700}#settings_plugin_softwareupdate_workingdialog_output .separator{font-weight:700;color:#666}#settings_plugin_softwareupdate_workingdialog_output .stdout{color:#333}#settings_plugin_softwareupdate_workingdialog_output .stderr{color:#900}#settings_plugin_softwareupdate_workingdialog_output .call{color:#009}#settings_plugin_softwareupdate_workingdialog_output .message_error{font-weight:700;color:#900}.softwareupdate_notification ul{margin:10px 0 10px 25px}.softwareupdate_notification ul .name{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;display:block}
@@ -106,6 +106,10 @@ $(function() {
return _.filter(self.versions.items(), function(info) { return info.updateAvailable && info.updatePossible; });
});
self.availableAndPossibleAndEnabled = ko.pureComputed(function() {
return _.filter(self.versions.items(), function(info) { return info.updateAvailable && info.updatePossible && !info.disabled });
})
self.throttled = ko.pureComputed(function() {
return self.piSupport && self.piSupport.currentIssue() && !self.settings.settings.plugins.pluginmanager.ignore_throttled();
});
@@ -257,6 +261,15 @@ $(function() {
})
}
value.toggleDisabled = function() {
var patch = {};
patch[key] = {disabled: !value.disabled};
OctoPrint.plugins.softwareupdate.configure(patch)
.done(function() {
self.performCheck(false, false, false, [key]);
});
}
versions.push(value);
});
self.versions.updateItems(versions);
@@ -282,7 +295,7 @@ $(function() {
text += "<ul class='fa-ul'>";
_.each(self.versions.items(), function(update_info) {
if (update_info.updateAvailable) {
if (update_info.updateAvailable && !update_info.disabled) {
text += "<li>"
+ "<i class='fa fa-li " + (update_info.updatePossible && self.environmentSupported() && self.storageSufficient() ? "fa-check" : "fa-remove")+ "'></i>"
+ "<span class='name' title='" + update_info.fullNameRemote + "'>" + update_info.fullNameRemote + "</span>"
@@ -332,7 +345,7 @@ $(function() {
click: function() {
if (self._updateClicked) return;
self._updateClicked = true;
self.update();
self.updateEnabled();
}
}]
};
@@ -505,6 +518,14 @@ $(function() {
});
};
self.updateAll = function(force) {
return self.update(force, self.availableAndPossible());
}
self.updateEnabled = function(force) {
return self.update(force, self.availableAndPossibleAndEnabled());
}
self.update = function(force, items) {
if (self.updateInProgress || !self.loginState.hasPermission(self.access.permissions.PLUGIN_SOFTWAREUPDATE_UPDATE)) {
self._updateClicked = false;
@@ -512,7 +533,7 @@ $(function() {
}
if (items === undefined) {
items = self.availableAndPossible();
items = self.availableAndPossibleAndEnabled();
}
if (self.printerState.isPrinting()) {
@@ -556,7 +577,8 @@ $(function() {
proceed: gettext("Proceed"),
onproceed: function() {
self.performUpdate((force === true),
_.map(items, function(info) { return info.key }));
_.map(items,
function(info) { return info.key }));
},
onclose: function() {
self._updateClicked = false;
@@ -10,6 +10,11 @@
td.settings_plugin_softwareupdate_column_update {
width: 16px;
a {
text-decoration: none;
color: #000;
}
}
td.settings_plugin_softwareupdate_column_information {
@@ -81,7 +81,7 @@
<tbody data-bind="foreach: versions.paginatedItems">
<tr data-bind="attr: {title: displayName}">
<td class="settings_plugin_softwareupdate_column_update">
<span data-bind="invisible: !updateAvailable"><i class="fa fa-bell-o" title="{{ _('Update available')|edq }}"></i></span>
<a href="javascript:void(0)" data-bind="click: toggleDisabled"><i class="fa" data-bind="css: { muted: !updateAvailable, 'fa-bell-o': !disabled, 'fa-bell-slash-o': disabled }" title="{{ _('Update available')|edq }}"></i></a><br />
</td>
<td class="settings_plugin_softwareupdate_column_information">
<a href="javascript:void(0)" data-bind="click: function() { $root.update(false, [$data]) }, visible: $root.enableUpdate() && updateAvailable && updatePossible" class="btn btn-primary pull-right">{{ _('Update') }}</a>
@@ -99,7 +99,7 @@
</table>
</div>
<button class="btn btn-primary btn-block" data-bind="click: function() { $root.update(); }, enable: enableUpdate, css: {disabled: !enableUpdate}"><i class="fa fa-spinner fa-spin" data-bind="visible: updateInProgress"></i> {{ _('Update all') }}</button>
<button class="btn btn-primary btn-block" data-bind="click: function() { $root.updateAll(); }, enable: enableUpdate, css: {disabled: !enableUpdate}"><i class="fa fa-spinner fa-spin" data-bind="visible: updateInProgress"></i> {{ _('Update all') }}</button>
<button class="btn btn-block" data-bind="click: function() { $root.performCheck(true, false, true); }, enable: !checking(), css: {disabled: checking()}"><i class="fa fa-spinner fa-spin" data-bind="visible: checking"></i> {{ _('Check for update now') }}</button>
<div>
@@ -107,7 +107,7 @@
<div class="hide">
<small class="muted" style="display: block">{{ _('Last cache refresh:') }} <span data-bind="text: cacheTimestampText"></span></small>
<button class="btn btn-block" data-bind="click: function() { $root.performCheck(true, true, true); }, enable: !checking(), css: {disabled: checking()}"><i class="fa fa-spinner fa-spin" data-bind="visible: checking"></i> {{ _('Force check for update (overrides cache used for update checks)') }}</button>
<button class="btn btn-block btn-danger" data-bind="visible: CONFIG_DEBUG, click: function() { $root.update(true); }, enable: enableUpdate() && !checking(), css: {disabled: !enableUpdate() || checking()}"><i class="fa fa-spinner fa-spin" data-bind="visible: checking"></i> {{ _('Force update now (even if no new versions are available)') }}</button>
<button class="btn btn-block btn-danger" data-bind="visible: CONFIG_DEBUG, click: function() { $root.updateAll(true); }, enable: enableUpdate() && !checking(), css: {disabled: !enableUpdate() || checking()}"><i class="fa fa-spinner fa-spin" data-bind="visible: checking"></i> {{ _('Force update all (even if no new versions are available)') }}</button>
</div>
</div>
@@ -117,7 +117,7 @@
<h3>{{ _('Plugin Configuration') }}</h3>
</div>
<div class="modal-body">
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
{% include "snippets/plugins/softwareupdate/versionTracking.jinja2" %}
{% include "snippets/plugins/softwareupdate/trackedBranch.jinja2" %}
{% include "snippets/plugins/softwareupdate/checkoutFolder.jinja2" %}
@@ -6,7 +6,7 @@
If you want to do that though it needs to know its checkout folder. You can configure that here.
</p>{% endtrans %}
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
{% include "snippets/plugins/softwareupdate/versionTracking.jinja2" %}
{% include "snippets/plugins/softwareupdate/checkoutFolder.jinja2" %}
{% include "snippets/plugins/softwareupdate/trackedBranch.jinja2" %}
@@ -2,7 +2,7 @@
{% include "snippets/plugins/tracking/trackingDescription.jinja2" %}
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<div class="controls">
<label class="checkbox">
@@ -1,6 +1,6 @@
<h3>Virtual Printer</h3>
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<div class="controls">
<label class="checkbox">
+33 -6
View File
@@ -112,6 +112,9 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
self._lastProgressReport = None
self._progressPlugins = plugin_manager().get_implementations(ProgressPlugin)
self._additional_data_hooks = plugin_manager().get_hooks("octoprint.printer.additional_state_data")
self._blacklisted_data_hooks = []
self._stateMonitor = StateMonitor(
interval=0.5,
on_update=self._sendCurrentDataCallbacks,
@@ -200,13 +203,34 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
extra=dict(callback=fqcn(callback)))
def _sendCurrentDataCallbacks(self, data):
plugin_data = self._get_additional_plugin_data(initial=False)
for callback in self._callbacks:
try:
callback.on_printer_send_current_data(copy.deepcopy(data))
data_copy = copy.deepcopy(data)
if plugin_data:
data_copy.update(plugins=copy.deepcopy(plugin_data))
callback.on_printer_send_current_data(data_copy)
except Exception:
self._logger.exception("Exception while pushing current data to callback {}".format(callback),
extra=dict(callback=fqcn(callback)))
def _get_additional_plugin_data(self, initial=False):
plugin_data = {}
for name, hook in self._additional_data_hooks.items():
if name in self._blacklisted_data_hooks:
continue
try:
additional = hook(initial=initial)
if additional and isinstance(additional, dict):
plugin_data[name] = additional
except Exception:
self._logger.exception("Error while retrieving additional data from plugin {}, blacklisting it for further loops".format(name),
extra={"plugin": name})
self._blacklisted_data_hooks.append(name)
return plugin_data
#~~ callback from metadata analysis event
def _on_event_MetadataAnalysisFinished(self, event, data):
@@ -1040,11 +1064,14 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
def _sendInitialStateUpdate(self, callback):
try:
data = self._stateMonitor.get_current_data()
data.update({
"temps": list(self._temps),
"logs": list(self._log),
"messages": list(self._messages)
})
data.update(temps=list(self._temps),
logs=list(self._log),
messages=list(self._messages))
plugin_data = self._get_additional_plugin_data(initial=False)
if plugin_data:
data.update(plugins=copy.deepcopy(plugin_data))
callback.on_printer_send_initial_data(data)
except Exception:
self._logger.exception(u"Error while pushing initial state update to callback {}".format(callback),
+39 -7
View File
@@ -475,7 +475,7 @@ class HierarchicalChainMap(ChainMap):
except KeyError:
return False
def get_by_path(self, path, only_local=False, only_defaults=False):
def get_by_path(self, path, only_local=False, only_defaults=False, merged=False):
if only_defaults:
current = self.parents
elif only_local:
@@ -490,6 +490,8 @@ class HierarchicalChainMap(ChainMap):
else:
raise KeyError(key)
if merged:
current = current.deep_dict()
return current[path[-1]]
def set_by_path(self, path, value):
@@ -590,6 +592,8 @@ class Settings(object):
However, these would be invalid paths: ``["key"]``, ``["serial", "port", "value"]``, ``["server", "host", 3]``.
"""
OVERLAY_KEY = "__overlay__"
def __init__(self, configfile=None, basedir=None):
self._logger = logging.getLogger(__name__)
@@ -937,13 +941,36 @@ class Settings(object):
self._migrate_config(config)
return config
def add_overlay(self, overlay, at_end=False):
def add_overlay(self, overlay, at_end=False, key=None):
assert isinstance(overlay, dict)
if key is None:
overlay_yaml = yaml.safe_dump(overlay)
import hashlib
hash = hashlib.md5()
hash.update(overlay_yaml.encode('utf-8'))
key = hash.hexdigest()
overlay[self.OVERLAY_KEY] = key
if at_end:
pos = len(self._map.maps) - 1
self._map.maps.insert(pos, overlay)
else:
self._map.maps.insert(1, overlay)
return key
def remove_overlay(self, key):
index = -1
for i, overlay in enumerate(self._overlay_maps):
if key == overlay.get(self.OVERLAY_KEY):
index = i
if index > -1:
del self._map.maps[index + 1]
return True
return False
def _migrate_config(self, config=None, persist=False):
if config is None:
config = self._config
@@ -1448,7 +1475,7 @@ class Settings(object):
if isinstance(value, dict) and merged:
try:
default_value = chain.get_by_path(parent_path + [key], only_defaults=True)
default_value = chain.get_by_path(parent_path + [key], only_defaults=True, merged=True)
if default_value is not None:
value = dict_merge(default_value, value)
except KeyError:
@@ -1627,15 +1654,20 @@ class Settings(object):
#~~ remove
def remove(self, path, config=None, error_on_path=False):
def remove(self, path, config=None, error_on_path=False, defaults=None):
if not path:
if error_on_path:
raise NoSuchSettingsPath()
return
if config is not None:
mappings = [config] + self._overlay_maps + [self._default_map]
chain = HierarchicalChainMap(*mappings)
if config is not None or defaults is not None:
if config is None:
config = self._config
if defaults is None:
defaults = dict(self._map.parents)
chain = HierarchicalChainMap(config, defaults)
else:
chain = self._map
+15 -6
View File
@@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================= */
(function( $ ) {
var pauseEvent = function(e) {
@@ -201,7 +201,7 @@
}
}
this.enabled = options.enabled &&
this.enabled = options.enabled &&
(this.element.data('slider-enabled') === undefined || this.element.data('slider-enabled') === true);
if(!this.enabled)
{
@@ -214,12 +214,13 @@
over: false,
inDrag: false,
showTooltip: function(){
this.recalculate();
this.tooltip.addClass('in');
this.over = true;
},
hideTooltip: function(){
if (this.inDrag === false && this.alwaysShowTooltip !== true) {
this.tooltip.removeClass('in');
@@ -476,12 +477,14 @@
disable: function() {
this.enabled = false;
this.tooltip.addClass('hide');
this.picker.addClass('slider-disabled');
this.element.trigger('slideDisabled');
},
enable: function() {
this.enabled = true;
this.tooltip.removeClass('hide');
this.picker.removeClass('slider-disabled');
this.element.trigger('slideEnabled');
},
@@ -496,7 +499,13 @@
isEnabled: function() {
return this.enabled;
}
},
recalculate: function() {
if (this.picker === undefined) return;
this.offset = this.picker.offset();
this.size = this.picker[0][this.sizePos];
},
};
var publicMethods = {
@@ -566,4 +575,4 @@
$.fn.slider.Constructor = Slider;
})( window.jQuery );
})( window.jQuery );
@@ -1,4 +1,4 @@
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group" title="{{ _('Name of this OctoPrint instance, will be shown in the navigation bar and broadcast on the network')|edq }}">
<label class="control-label" for="settings-appearanceName">{{ _('Title') }}</label>
<div class="controls">
@@ -76,7 +76,7 @@
<strong>{{ _('There is currently no central repository for language packs like there is for plugins - any help to change that is appreciated!') }}</strong>
</p>
<p>
{{ _('Until a repository is available, please see <a href="%(url)s" target="_blank" >the wiki</a> for language packs provided by the community.', url = "https://github.com/OctoPrint/OctoPrint/wiki#language-packs") }}
{{ _('Until a repository is available, please see <a href="%(url)s" target="_blank" >the wiki</a> for language packs provided by the community.', url = "https://community.octoprint.org/t/translating-octoprint/21144") }}
</p>
<h4>{{ _('Available Language Packs') }}</h4>
@@ -111,7 +111,7 @@
<h4>{{ _('Upload additional Language Packs') }}</h4>
<form class="form-inline">
<form class="form-inline" onsubmit="return false;">
<div class="control-group row-fluid" data-bind="css: {error: invalidTranslationArchive}">
<div class="input-prepend span9">
<span class="btn fileinput-button">
@@ -1,4 +1,4 @@
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<div class="controls">
<label class="checkbox">
@@ -1,4 +1,4 @@
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<h3>{{ _('Folders') }}</h3>
<div class="control-group" data-bind="css: {error: testFolderConfigBroken.uploads, success: testFolderConfigOk.uploads}">
@@ -1,4 +1,4 @@
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<label class="control-label">{{ _('Before print job starts') }}</label>
<div class="controls">
@@ -2,7 +2,7 @@
<strong>{{ _('Note: ') }}</strong>{{ _('Changing most of these settings requires restarting the connection with your printer for your changes to become effective.') }}
</div>
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<ul class="nav nav-pills">
<li class="active"><a href="#settings_serial_general" data-toggle="tab">{{ _('General') }}</a></li>
<li><a href="#settings_serial_timeouts" data-toggle="tab">{{ _('Intervals &amp; timeouts') }}</a></li>
@@ -1,4 +1,4 @@
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
{% include "snippets/settings/server/serverAllowFraming.jinja2" %}
<h3>{{ _('Commands') }}</h3>
@@ -1,4 +1,4 @@
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<h3>{{ _('Graph') }}</h3>
<div class="control-group">
<label class="control-label" for="settings-temperatureCutoff">{{ _('Graph cutoff') }}</label>
@@ -1,4 +1,4 @@
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="row-fluid">
<div class="span4"><h4>{{ _('Name') }}</h4></div>
<div class="span6"><h4>{{ _('RegExp') }} <small><a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions">?</a></small></h4></div>
@@ -1,6 +1,6 @@
<h3>{{ _('Webcam') }}</h3>
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
{% include "snippets/settings/webcam/webcamEnabled.jinja2" %}
{% include "snippets/settings/webcam/webcamStreamUrl.jinja2" %}
{% include "snippets/settings/webcam/webcamStreamRatio.jinja2" %}
@@ -16,7 +16,7 @@
<h3>{{ _('Timelapse Recordings') }}</h3>
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
{% include "snippets/settings/webcam/timelapseEnabled.jinja2" %}
{% include "snippets/settings/webcam/webcamSnapshotUrl.jinja2" %}
{% include "snippets/settings/webcam/ffmpegPath.jinja2" %}
@@ -9,7 +9,7 @@
</div>
<div data-bind="visible: enableSlicingDialog()">
<p>{{ _('Please configure which slicer and which slicing profile to use and name the GCode file to slice to below, or click "Cancel" if you do not wish to slice the file now.') }}</p>
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<label class="control-label">{{ _('Slicer') }}</label>
<div class="controls">
@@ -1,4 +1,4 @@
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<fieldset>
<legend>{{ _('Password') }}</legend>
<p>
@@ -1,4 +1,4 @@
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<fieldset>
<legend>{{ _('Language') }}</legend>
<div class="control-group">
+1 -1
View File
@@ -86,7 +86,7 @@
<small data-bind="visible: !restoreSupported()">{{ _('Online restore is not supported on your system.') }}</small>
<h2>{{ _('Create backup') }}</h2>
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<div class="controls">
<label class="checkbox">
@@ -68,7 +68,7 @@
</ul>
<div class="tab-content">
<div id="settings_accesscontrol_groups_add_general" class="tab-pane active">
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<label class="control-label" for="settings-groupsDialogAddGroupName">{{ _('Name') }}</label>
<div class="controls">
@@ -78,7 +78,7 @@
</ul>
<div class="tab-content">
<div id="settings_accesscontrol_users_add_general" class="tab-pane active">
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<label class="control-label" for="settings-usersDialogAddUserName">{{ _('Username') }}</label>
<div class="controls">
@@ -136,7 +136,7 @@
<h3>{{ _('Change password for user "%(user)s"', user='<span data-bind="text: $root.access.users.editor.name"></span>') }}</h3>
</div>
<div class="modal-body">
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<label class="control-label" for="settings-usersDialogChangePasswordPassword1">{{ _('New Password') }}</label>
<div class="controls">
@@ -1,4 +1,4 @@
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<div class="controls">
{{ _('Please define the maximum speed/feedrate of the individual axes and whether their control should be inverted or not.') }}
@@ -1,4 +1,4 @@
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<label class="control-label">{{ _('Form Factor') }}</label>
<div class="controls">
@@ -1,4 +1,4 @@
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<label class="control-label">{{ _('Nozzle Diameter') }}</label>
@@ -1,4 +1,4 @@
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group" data-bind="css: {error: nameInvalid()}">
<label class="control-label">{{ _('Name') }}</label>
<div class="controls">
+14 -11
View File
@@ -95,24 +95,27 @@
<div id="control-jog-extrusion" class="jog-panel" style="display: none;" data-bind="visible: loginState.hasPermissionKo(access.permissions.CONTROL)() && tools().length > 0">
<h1>Tool (E)</h1>
<div>
<div class="btn-group control-box">
<button class="btn dropdown-toggle" data-toggle="dropdown" data-bind="enable: isOperational() && !isPrinting() && !isPaused()">
{{ _('Select Tool...') }}
<span class="caret"></span>
</button>
<ul class="dropdown-menu" data-bind="foreach: tools">
<li><a href="#" data-bind="click: $root.sendSelectToolCommand, text: name(), enable: $root.isOperational() && !$root.isPrinting() && !$root.isPaused()"></a></li>
</ul>
</div>
<div class="input-append control-box">
<input type="number" class="input-mini text-right" data-bind="value: extrusionAmount, enable: isOperational() && !isPrinting()">
<span class="add-on">mm</span>
</div>
<button class="btn btn-block control-box" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendExtrudeCommand() }">{{ _('Extrude') }}</button>
<button class="btn btn-block control-box" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendRetractCommand() }">{{ _('Retract') }}</button>
<div data-bind="style: { visibility: tools().length > 1 ? 'visible' : 'hidden' }">
<div class="btn-group control-box" style="display: inline-block">
<button class="btn dropdown-toggle" data-toggle="dropdown" data-bind="enable: isOperational() && !isPrinting() && !isPaused()">
{{ _('Switch Tool...') }}
<span class="caret"></span>
</button>
<ul class="dropdown-menu" data-bind="foreach: tools">
<li><a href="#" data-bind="click: $root.sendSelectToolCommand, text: name(), enable: $root.isOperational() && !$root.isPrinting() && !$root.isPaused()"></a></li>
</ul>
</div>
<a class="text-info" style="display: inline-block; height: 30px; vertical-align: middle" href="javascript:void(0)" data-bind="popover: {placement: 'top', trigger: 'hover', title: '{{ _('Please note!') }}', content: '{{ _('The selected tool can only be set, it cannot be read back from the firmware due to a limitation of the communication protocol. There is no way to show the current setting.') }}'}"><i class="fa fa-info-circle"></i></a>
</div>
<!-- Flow rate -->
<div id="control-jog-flowrate" class="jog-panel">
<div id="control-jog-flowrate">
<label>{{ _('Flow rate modifier:') }} <a class="text-info" href="javascript:void(0)" data-bind="popover: {placement: 'top', trigger: 'hover', title: '{{ _('Please note!') }}', content: '{{ _('The flow rate can only be set, it cannot be read back from the firmware due to a limitation of the communication protocol. There is no way to show the current setting.') }}'}"><i class="fa fa-info-circle"></i></a></label>
<div class="input-append control-box">
<input type="number" class="input-mini" min="1" step="1" data-bind="textInput: flowRate, event: { blur: resetFlowRateDisplay, focus: cancelFlowRateDisplayReset }, css: { pulsate_text_opacity: flowRateResetter() !== undefined }">
@@ -165,7 +168,7 @@
<!-- /ko -->
</script>
<script type="text/html" id="customControls_controlTemplate">
<form class="form-inline custom_control">
<form class="form-inline custom_control" onsubmit="return false;">
<!-- ko template: { name: 'customControls_controlTemplate_input', data: $data, if: $data.hasOwnProperty('input') } --><!-- /ko -->
<!-- ko template: { name: 'customControls_controlTemplate_command', data: $data, if: $data.hasOwnProperty('command') || $data.hasOwnProperty('commands') || $data.hasOwnProperty('script') || $data.hasOwnProperty('javascript') } --><!-- /ko -->
<!-- ko template: { name: 'customControls_controlTemplate_output', data: $data, if: $data.hasOwnProperty('output') } --><!-- /ko -->
@@ -66,7 +66,7 @@
</form>
</td>
<td class="temperature_offset">
<form class="form-inline" style="margin:0">
<form class="form-inline" style="margin:0" onsubmit="return false;">
<div class="input-append">
<span class="input-mini uneditable-input text-right" style="width: 30px" data-bind="text: offset"></span>
<span class="add-on">&deg;C</span>
@@ -6,7 +6,7 @@
<h1>{{ _('Timelapse Configuration') }}</h1>
<form class="form-horizontal">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<label class="control-label" for="webcam_timelapse_mode">{{ _('Timelapse Mode') }}</label>
<div class="controls">
+42 -9
View File
@@ -7,6 +7,9 @@ __copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms
import io
import requests
import time
import json
import websocket
def build_base_url(https=False, httpuser=None, httppass=None, host=None, port=None, prefix=None):
@@ -63,7 +66,6 @@ class SocketClient(object):
callbacks[callback] = factory(callback)
# initialize socket instance with url and callbacks
import websocket
kwargs = dict(self._ws_kwargs)
kwargs.update(callbacks)
self._ws = websocket.WebSocketApp(self._url, **kwargs)
@@ -283,7 +285,6 @@ class Client(object):
def create_socket(self, **kwargs):
import uuid
import random
import json
# creates websocket URL for SockJS according to
# - http://sockjs.github.io/sockjs-protocol/sockjs-protocol-0.3.3.html#section-37
@@ -300,8 +301,27 @@ class Client(object):
on_message_cb = kwargs.get("on_message", None)
on_close_cb = kwargs.get("on_close", None)
on_error_cb = kwargs.get("on_error", None)
on_sent_cb = kwargs.get("on_sent", None)
daemon = kwargs.get("daemon", True)
def send(ws, data):
payload = '["' + json.dumps(data).replace('"', '\\"') + '"]'
ws.send(payload)
if callable(on_sent_cb):
on_sent_cb(ws, data)
def authenticate(ws):
# perform passive login to retrieve username and session key for API key
response = self.post("/api/login", {"passive": True})
response.raise_for_status()
data = response.json()
# prepare auth payload
auth_message = {"auth": "{name}:{session}".format(**data)}
# send it
send(ws, auth_message)
def on_message(ws, message):
message_type = message[0]
@@ -332,6 +352,9 @@ class Client(object):
for d in data:
for internal_type, internal_message in d.items():
on_message_cb(ws, internal_type, internal_message)
if internal_type == "connected":
# we just got connected to the server, authenticate
authenticate(ws)
def on_open(ws):
if callable(on_open_cb):
@@ -345,13 +368,23 @@ class Client(object):
if callable(on_error_cb):
on_error_cb(ws, error)
socket = SocketClient(url,
use_ssl=use_ssl,
daemon=daemon,
on_open=on_open,
on_message=on_message,
on_close=on_close,
on_error=on_error)
class CustomSocketClient(SocketClient):
def auth(self, username, key):
self.send({"auth": "{}:{}".format(username, key)})
def throttle(self, factor):
self.send({"throttle": factor})
def send(self, data):
send(self._ws, data)
socket = CustomSocketClient(url,
use_ssl=use_ssl,
daemon=daemon,
on_open=on_open,
on_message=on_message,
on_close=on_close,
on_error=on_error)
socket.connect()
return socket