Merge branch 'maintenance' into devel
This commit is contained in:
commit
635156cf7a
64 files changed
+1185
-441
No files matched your search
@@ -176,3 +176,17 @@ jobs:
|
||||
uses: pypa/gh-action-pypi-publish@master
|
||||
with:
|
||||
password: ${{ secrets.pypi_password }}
|
||||
|
||||
notify-custopizer-build:
|
||||
name: 📧 Notify OctoPi-UpToDate
|
||||
if: github.event_name == 'release'
|
||||
needs: publish-on-pypi
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 🚀 Repository Dispatch
|
||||
uses: peter-evans/repository-dispatch@v1
|
||||
with:
|
||||
token: ${{ secrets.REPODISPATCH_TOKEN }}
|
||||
repository: OctoPrint/OctoPi-UpToDate
|
||||
event-type: octoprint_release
|
||||
client-payload: '{"version": "${{ github.ref }}"}'
|
||||
@@ -14,7 +14,7 @@ jobs:
|
||||
- name: 🚀 Repository Dispatch
|
||||
uses: peter-evans/repository-dispatch@v1
|
||||
with:
|
||||
token: ${{ secrets.DOCS_ACCESS_TOKEN }}
|
||||
token: ${{ secrets.REPODISPATCH_TOKEN }}
|
||||
repository: OctoPrint/docs.octoprint.org
|
||||
event-type: docs
|
||||
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
|
||||
@@ -145,6 +145,7 @@ date of first contribution):
|
||||
* [Elton Law](https://github.com/eltonlaw)
|
||||
* ["sparxooo"](https://github.com/sparxooo)
|
||||
* ["Stevil Knevil"](https://github.com/StevilKnevil)
|
||||
* [ldursw](https://github.com/ldursw)
|
||||
|
||||
OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by
|
||||
[Daid Braam](https://github.com/daid). Parts of its communication layer and
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
* [pusher.color.js](http://cache.preserve.io/5g18q0pw/index.html) (original link dead): MIT
|
||||
* [SockJS](https://github.com/sockjs/sockjs-client): MIT
|
||||
* [sprintf-js](http://alexei.ro/): BSD
|
||||
* [UAParser.js](https://faisalman.github.io/ua-parser-js/): MIT
|
||||
|
||||
## Server
|
||||
|
||||
|
||||
+2
-2
@@ -81,7 +81,7 @@ Retrieve a group
|
||||
|
||||
Retrieves an individual group record.
|
||||
|
||||
Will return a :http:statuscode:`200` with a :ref:`group record <sec-api-access-datamodel-groups-grouprecord>`
|
||||
Will return a :http:statuscode:`200` with a :ref:`group record <sec-api-access-datamodel-groups-list>`
|
||||
as body.
|
||||
|
||||
Requires the ``SETTINGS`` permission.
|
||||
@@ -156,7 +156,7 @@ Retrieve a user
|
||||
|
||||
Retrieves information about a user.
|
||||
|
||||
Will return a :http:statuscode:`200` with a :ref:`user record <sec-api-access-datamodel-users-userrecord>`
|
||||
Will return a :http:statuscode:`200` with a :ref:`user record <sec-api-datamodel-access>`
|
||||
as body.
|
||||
|
||||
Requires either the ``SETTINGS`` permission or to be logged in as the user.
|
||||
|
||||
@@ -596,7 +596,7 @@ Permission record
|
||||
- Human readable description of the permission
|
||||
* - ``needs``
|
||||
- 1
|
||||
- :ref:`Needs object <sec-api-access-datamodel-general-needs>`
|
||||
- :ref:`Needs object <sec-api-datamodel-access-needs>`
|
||||
- Needs assigned to the permission
|
||||
|
||||
.. _sec-api-datamodel-access-groups:
|
||||
|
||||
+18
-3
@@ -44,8 +44,7 @@ For testing purposes it is also possible to supply the API key via a query param
|
||||
Please be advised that clients should use the header field variant if at all possible.
|
||||
|
||||
If the key is missing or invalid, OctoPrint will treat the request as it would any unauthenticated anonymous request to the endpoint.
|
||||
Consequently, if the bundled :ref:`ForceLogin plugin <sec-bundledplugins-forcelogin>` is active (which is the default), that means
|
||||
that any requests without or with an invalid API key targeting other API endpoints than :ref:`Login <sec-api-general-login>`
|
||||
That means that any requests without or with an invalid API key targeting other API endpoints than :ref:`Login <sec-api-general-login>`
|
||||
will be denied with a :http:statuscode:`403`.
|
||||
|
||||
.. warning::
|
||||
@@ -119,7 +118,8 @@ check the corresponding checkbox in the API settings dialog.
|
||||
|
||||
Support for CORS can be enabled in the "API" settings
|
||||
|
||||
.. note::
|
||||
.. warning::
|
||||
|
||||
This means any browser page can send requests to the OctoPrint API. Authorization is still required however.
|
||||
|
||||
If CORS is not enabled you will get errors like the following::
|
||||
@@ -127,6 +127,15 @@ If CORS is not enabled you will get errors like the following::
|
||||
XMLHttpRequest cannot load http://localhost:8081/api/files. No 'Access-Control-Allow-Origin'
|
||||
header is present on the requested resource.
|
||||
|
||||
|
||||
.. note::
|
||||
|
||||
For security reasons, OctoPrint will not set the ``Access-Control-Allow-Credentials``
|
||||
header, even if CORS support is enabled. That means that cookies will not be sent by
|
||||
the browser to OctoPrint, effectively making it impossible to authenticate through
|
||||
the login mechanism (or reusing an existing login session). When accessing OctoPrint
|
||||
via CORS, you'll therefore always need to use an API key.
|
||||
|
||||
.. _sec-api-general-login:
|
||||
|
||||
Login
|
||||
@@ -150,6 +159,12 @@ Login
|
||||
mismatch or an unknown user. That was incompatible with basic authentication since it was a wrong use of
|
||||
the :http:statuscode:`401` code and got therefore changed as part of a bug fix.
|
||||
|
||||
.. note::
|
||||
|
||||
You cannot use this endpoint to login from a third party page via CORS, see above. You can however use it
|
||||
to retrieve user information via passive login with an API key (e.g. if you need the ``session`` to authenticate
|
||||
on the web socket.
|
||||
|
||||
:json passive: If present, performs a passive login only, returning information about the current user that's
|
||||
active either through an existing session or the used API key
|
||||
:json user: (active login only) Username
|
||||
|
||||
@@ -17,9 +17,9 @@ Retrieve all printer profiles
|
||||
|
||||
.. http:get:: /api/printerprofiles
|
||||
|
||||
Retrieves a list of all configured printer profiles.
|
||||
Retrieves an object representing all configured printer profiles.
|
||||
|
||||
Returns a :http:statuscode:`200` with a list of :ref:`profiles <sec-api-printerprofiles-datamodel-profile>`.
|
||||
Returns a :http:statuscode:`200` with a :ref:`profile list <sec-api-printerprofiles-datamodel-profilelist>`.
|
||||
|
||||
Requires the ``CONNECTION`` permission.
|
||||
|
||||
@@ -37,8 +37,8 @@ Retrieve all printer profiles
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"profiles": [
|
||||
{
|
||||
"profiles": {
|
||||
"_default": {
|
||||
"id": "_default",
|
||||
"name": "Default",
|
||||
"color": "default",
|
||||
@@ -80,7 +80,7 @@ Retrieve all printer profiles
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"my_profile": {
|
||||
"id": "my_profile",
|
||||
"name": "My Profile",
|
||||
"color": "default",
|
||||
@@ -122,7 +122,7 @@ Retrieve all printer profiles
|
||||
]
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -457,7 +457,7 @@ Profile list
|
||||
- Collection of all printer profiles available in the system
|
||||
* - ``profiles.<profile id>``
|
||||
- 0..1
|
||||
- :ref:`Profile <sec-api-slicing-datamodel-profile>`
|
||||
- :ref:`Profile <sec-api-printerprofiles-datamodel-profile>`
|
||||
- Information about a profile stored in the system.
|
||||
|
||||
.. _sec-api-printerprofiles-datamodel-update:
|
||||
@@ -475,7 +475,7 @@ Add or update request
|
||||
- Description
|
||||
* - ``profiles``
|
||||
- 1
|
||||
- :ref:`Profile <sec-api-slicing-datamodel-profile>`
|
||||
- :ref:`Profile <sec-api-printerprofiles-datamodel-profile>`
|
||||
- Information about the profile being added/updated. Only the values to be overwritten need to be supplied.
|
||||
Unset fields will be taken from the base profile, which for add requests will be the
|
||||
current default profile unless a different base is defined in the ``basedOn`` property
|
||||
|
||||
@@ -8,7 +8,7 @@ Version information
|
||||
|
||||
Retrieve information regarding server and API version. Returns a JSON object with three keys, ``api`` containing
|
||||
the API version, ``server`` containing the server version, ``text`` containing the server version including
|
||||
the prefix ``OctoPrint `` (to determine that this is indeed a genuine OctoPrint instance).
|
||||
the prefix ``OctoPrint`` (to determine that this is indeed a genuine OctoPrint instance).
|
||||
|
||||
**Example Request**
|
||||
|
||||
|
||||
@@ -39,13 +39,11 @@ Supported action commands
|
||||
notification <message>
|
||||
Displays the notification ``<message>``
|
||||
|
||||
.. _sec-bundledplugins-action_command_prompt-example:
|
||||
.. _sec-bundledplugins-action_command_notification-example:
|
||||
|
||||
Example communication with the firmware
|
||||
---------------------------------------
|
||||
|
||||
.. _sec-bundledplugins-action_command_prompt-sourcecode:
|
||||
|
||||
To display the :ref:`above notification <fig-bundledplugins-action_command_notification-example>` the firmware sent this action command:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
@@ -118,8 +118,7 @@ Announced Services
|
||||
ZeroConf Service ``_http._tcp``
|
||||
+++++++++++++++++++++++++++++++
|
||||
|
||||
If :ref:`pybonjour <sec-bundledplugins-discovery-firststeps-pybonjour>` is
|
||||
correctly installed, OctoPrint will announce itself on the network via ZeroConf
|
||||
OctoPrint will announce itself on the network via ZeroConf
|
||||
as service ``_http._tcp``, with the TXT record containing the standard fields.
|
||||
|
||||
See also `this documentation of _http._tcp TXT records <http://www.dns-sd.org/txtrecords.html>`_
|
||||
@@ -130,8 +129,7 @@ for more information.
|
||||
ZeroConf Service ``_octoprint._tcp``
|
||||
++++++++++++++++++++++++++++++++++++
|
||||
|
||||
If :ref:`pybonjour <sec-bundledplugins-discovery-firststeps-pybonjour>` is
|
||||
correctly installed, OctoPrint will announce itself on the network via ZeroConf
|
||||
OctoPrint will announce itself on the network via ZeroConf
|
||||
as service ``_octoprint._tcp``. The TXT record may contain the following fields:
|
||||
|
||||
* ``path``: path prefix to actual OctoPrint instance, inherited from ``_http._tcp``
|
||||
|
||||
@@ -20,6 +20,5 @@ Bundled Plugins
|
||||
gcodeviewer.rst
|
||||
logging.rst
|
||||
pluginmanager.rst
|
||||
printer_safety_check.rst
|
||||
softwareupdate.rst
|
||||
virtual_printer.rst
|
||||
@@ -197,20 +197,24 @@ types are currently recognized:
|
||||
* ``prerelease``: ``True`` or ``False``, default ``False``, set to
|
||||
``True`` to also include releases on Github marked as prerelease.
|
||||
* ``prerelease_branches``: Prerelease channel definitions, optional. List of:
|
||||
|
||||
* ``branch``: Branch associated with the channel, acts as ID
|
||||
* ``name``: Human readable name of the release channel
|
||||
* ``commitish``: List of values to check against ``target_commitish``
|
||||
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
|
||||
* ``commitish``: List of values to check against ``target_commitish``
|
||||
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_commitish`` matches
|
||||
@@ -218,6 +222,7 @@ types are currently recognized:
|
||||
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
|
||||
|
||||
@@ -35,7 +35,7 @@ The plugin supports the following configuration keys:
|
||||
* ``plugin``: Whether to track plugin related events (install, uninstall, ...)
|
||||
* ``update``: Whether to track update related events (update successful or not, ...)
|
||||
* ``printer``: Whether to track printer related events (connected, firmware, ...)
|
||||
* ``printer_safety_check``: Whether to track warnings of the :ref:`Printer Safety Check <sec-bundledplugins-printer_safety_check>`
|
||||
* ``printer_safety_check``: Whether to track warnings of the Printer Safety Check plugin
|
||||
* ``throttled``: Whether to track throttle events detected on the underlying system
|
||||
|
||||
.. _sec-bundledplugins-tracking-sourcecode:
|
||||
|
||||
@@ -89,10 +89,6 @@ connection options (``baseurl`` and ``apikey``) directly in the constructor or s
|
||||
:ref:`Application Key Plugin <sec-bundledplugins-appkeys>`
|
||||
A bundled plugin that implements an authorization workflow for third party clients. It adds various additional
|
||||
methods to the JS Client Library.
|
||||
:ref:`ForceLogin Plugin <sec-bundledplugins-forcelogin>`
|
||||
A bundled plugin that disables anonymous access to the regular OctoPrint UI by implementing a custom UI and
|
||||
various hooks. Utilizes the client library's :ref:`browser component <sec-jsclientlib-browser>` to login the
|
||||
user.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 3
|
||||
|
||||
@@ -4,7 +4,6 @@ octoprint.plugin
|
||||
----------------
|
||||
|
||||
.. automodule:: octoprint.plugin
|
||||
:members:
|
||||
|
||||
.. _sec-modules-plugin-core:
|
||||
|
||||
@@ -12,7 +11,6 @@ octoprint.plugin.core
|
||||
---------------------
|
||||
|
||||
.. automodule:: octoprint.plugin.core
|
||||
:members:
|
||||
|
||||
.. _sec-modules-plugin-types:
|
||||
|
||||
@@ -20,4 +18,3 @@ octoprint.plugin.types
|
||||
----------------------
|
||||
|
||||
.. automodule:: octoprint.plugin.types
|
||||
:members:
|
||||
@@ -4,7 +4,6 @@ octoprint.printer
|
||||
-----------------
|
||||
|
||||
.. automodule:: octoprint.printer
|
||||
:members:
|
||||
|
||||
.. _sec-modules-printer-profile:
|
||||
|
||||
@@ -12,4 +11,3 @@ octoprint.printer.profile
|
||||
-------------------------
|
||||
|
||||
.. automodule:: octoprint.printer.profile
|
||||
:members:
|
||||
@@ -4,4 +4,3 @@ octoprint.settings
|
||||
------------------
|
||||
|
||||
.. automodule:: octoprint.settings
|
||||
:members:
|
||||
@@ -4,7 +4,6 @@ octoprint.slicing
|
||||
-----------------
|
||||
|
||||
.. automodule:: octoprint.slicing
|
||||
:members:
|
||||
|
||||
.. _sec-modules-slicing-exceptions:
|
||||
|
||||
@@ -12,4 +11,3 @@ octoprint.slicing.exceptions
|
||||
----------------------------
|
||||
|
||||
.. automodule:: octoprint.slicing.exceptions
|
||||
:members:
|
||||
+76
-7
@@ -931,7 +931,7 @@ octoprint.comm.transport.serial.additional_port_names
|
||||
.. 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.
|
||||
``list`` of ``string``.
|
||||
|
||||
Useful in combination with :ref:`octoprint.comm.transport.serial.factory <sec-plugins-hook-comm-transport-serial-factory>`
|
||||
to implement custom serial-like ports through plugins.
|
||||
@@ -1191,7 +1191,7 @@ octoprint.plugin.softwareupdate.check_config
|
||||
|
||||
See :ref:`here <sec-bundledplugins-softwareupdate-hooks-check_config>`.
|
||||
|
||||
.. _sec-plugins-hooks-plugin-printer-additional_state_data
|
||||
.. _sec-plugins-hooks-plugin-printer-additional_state_data:
|
||||
|
||||
octoprint.printer.additional_state_data
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -1201,7 +1201,7 @@ octoprint.printer.additional_state_data
|
||||
.. 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
|
||||
on the push socket or other registered :class:`octoprint.printer.PrinterCallback`. 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
|
||||
@@ -1600,8 +1600,6 @@ octoprint.server.sockjs.register
|
||||
Handlers should return either ``True`` or ``False``. ``True`` signals to proceed with normal registration. ``False``
|
||||
signals to not register the client.
|
||||
|
||||
See the bundled :ref:`Forcelogin Plugin <sec-bundledplugins-forcelogin>` for an example on how to utilize this.
|
||||
|
||||
:param object socket: the socket object which is about to be registered
|
||||
:param object user: the user currently authenticated on the socket - might be None
|
||||
:return: whether to proceed with registration (``True``) or not (``False``)
|
||||
@@ -1620,8 +1618,6 @@ octoprint.server.sockjs.emit
|
||||
|
||||
Handlers should return either ``True`` to allow the message to be emitted, or ``False`` to prevent it.
|
||||
|
||||
See the bundled :ref:`Forcelogin Plugin <sec-bundledplugins-forcelogin>` for an example on how to utilize this.
|
||||
|
||||
:param object socket: the socket object on which a message is about to be emitted
|
||||
:param object user: the user currently authenticated on the socket - might be None
|
||||
:param string message: the message type about to be emitted
|
||||
@@ -1629,6 +1625,79 @@ octoprint.server.sockjs.emit
|
||||
:return: whether to proceed with sending the message (``True``) or not (``False``)
|
||||
:rtype: boolean
|
||||
|
||||
.. _sec-plugins-hook-system-additional_commands:
|
||||
|
||||
octoprint.system.additional_commands
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. py:function:: additional_commands_hook(*args, **kwargs)
|
||||
|
||||
.. versionadded:: 1.7.0
|
||||
|
||||
Allows adding additional system commands into the system menu. Handlers must return
|
||||
a list of system command definitions, each definition matching the following data
|
||||
structure:
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``name``
|
||||
- 1
|
||||
- String
|
||||
- The name to display in the menu.
|
||||
* - ``action``
|
||||
- 1
|
||||
- String
|
||||
- An identifier for the action, must only consist of lower case a-z, numbers, ``-`` and ``_`` (``[a-z0-9-_]``).
|
||||
* - ``command``
|
||||
- 1
|
||||
- String
|
||||
- The system command to execute.
|
||||
* - ``confirm``
|
||||
- 0..1
|
||||
- String
|
||||
- An optional message to show as a confirmation dialog before executing the command.
|
||||
* - ``async``
|
||||
- 0..1
|
||||
- bool
|
||||
- If ``True``, the command will be run asynchronously and the API call will return immediately after enqueuing it for execution.
|
||||
* - ``ignore``
|
||||
- 0..1
|
||||
- bool
|
||||
- If ``True``, OctoPrint will ignore the result of the command's (and ``before``'s, if set) execution and return a successful result regardless. Defaults to ``False``.
|
||||
* - ``debug``
|
||||
- 0..1
|
||||
- bool
|
||||
- If ``True``, the command will generate debug output in the log including the command line that's run. Use with care. Defaults to ``False``
|
||||
* - ``before``
|
||||
- 0..1
|
||||
- callable
|
||||
- Optional callable to execute before the actual ``command`` is run. If ``ignore`` is false and this fails in any way, the command will not run and an error returned.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def get_additional_commands(*args, **kwargs):
|
||||
return [
|
||||
{
|
||||
"name": "Just a test",
|
||||
"action": "test",
|
||||
"command": "logger This is just a test of an OctoPrint system command from a plugin",
|
||||
"before": lambda: print("Hello World!")
|
||||
}
|
||||
]
|
||||
|
||||
__plugin_hooks__ = {
|
||||
"octoprint.system.additional_commands": get_additional_commands
|
||||
}
|
||||
|
||||
:return: a list of command specifications
|
||||
:rtype: list
|
||||
|
||||
.. _sec-plugins-hook-timelapse-extensions:
|
||||
|
||||
octoprint.timelapse.extensions
|
||||
|
||||
@@ -225,6 +225,12 @@ onUserPermissionsChanged(user)
|
||||
will be provided as only parameter. Note that this may also be triggered for not logged in guests if the guest
|
||||
group is modified. In this case ``user`` will be undefined.
|
||||
|
||||
onBeforePrintStart(callback)
|
||||
Called before a print is started either by clicking the "Print" button in the state panel or the select & print icon
|
||||
in the file list. The callback to actually proceed with starting the print is provided as the only parameter. By returning
|
||||
``false`` from this, plugins may prevent a print from actually starting, optionally starting it at a later date by
|
||||
calling ``callback`` themselves. This can be used for example to implement an additional confirmation dialog.
|
||||
|
||||
onTabChange(next, current)
|
||||
Called before the main tab view switches to a new tab, so `before` the new tab becomes visible. Called with the
|
||||
next (changed to) and current (still visible) tab's hash (e.g. ``#control``). Note that ``current`` might be undefined
|
||||
|
||||
@@ -64,6 +64,7 @@ INSTALL_REQUIRES = [
|
||||
"zeroconf>=0.24,<0.25",
|
||||
"zipstream-new>=1.1.8,<1.2",
|
||||
"pathvalidate>=2.4.1,<3",
|
||||
"colorlog>=5.0.1,<6",
|
||||
# vendor bundled dependencies
|
||||
"unidecode>=0.04.14,<0.05", # dependency of awesome-slugify
|
||||
"blinker>=1.4,<2", # dependency of flask_principal
|
||||
|
||||
@@ -260,11 +260,22 @@ def init_logging(
|
||||
|
||||
# default logging configuration
|
||||
if default_config is None:
|
||||
simple_format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
||||
default_config = {
|
||||
"version": 1,
|
||||
"formatters": {
|
||||
"simple": {
|
||||
"format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
||||
"simple": {"format": simple_format},
|
||||
"colored": {
|
||||
"class": "colorlog.ColoredFormatter",
|
||||
"format": "%(log_color)s" + simple_format,
|
||||
"log_colors": {
|
||||
"DEBUG": "light_white",
|
||||
"INFO": "white",
|
||||
"WARNING": "yellow",
|
||||
"ERROR": "red",
|
||||
"CRITICAL": "bold_red",
|
||||
},
|
||||
"reset": True,
|
||||
},
|
||||
"serial": {"format": "%(asctime)s - %(message)s"},
|
||||
"timings": {"format": "%(asctime)s - %(message)s"},
|
||||
@@ -274,7 +285,7 @@ def init_logging(
|
||||
"console": {
|
||||
"class": "octoprint.logging.handlers.OctoPrintStreamHandler",
|
||||
"level": "DEBUG",
|
||||
"formatter": "simple",
|
||||
"formatter": "colored",
|
||||
"stream": "ext://sys.stdout",
|
||||
},
|
||||
"file": {
|
||||
|
||||
@@ -2,8 +2,8 @@ __author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
|
||||
import collections
|
||||
import copy
|
||||
import logging
|
||||
import os
|
||||
import queue
|
||||
@@ -16,6 +16,20 @@ from octoprint.util import dict_merge
|
||||
from octoprint.util import get_fully_qualified_classname as fqcn
|
||||
from octoprint.util.platform import CLOSE_FDS
|
||||
|
||||
EMPTY_RESULT = {
|
||||
"_empty": True,
|
||||
"printingArea": {
|
||||
"minX": 0,
|
||||
"maxX": 0,
|
||||
"minY": 0,
|
||||
"maxY": 0,
|
||||
"minZ": 0,
|
||||
"maxZ": 0,
|
||||
},
|
||||
"dimensions": {"width": 0, "height": 0, "depth": 0},
|
||||
"filament": {},
|
||||
}
|
||||
|
||||
|
||||
class QueueEntry(
|
||||
collections.namedtuple(
|
||||
@@ -476,6 +490,7 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue):
|
||||
raise RuntimeError(error.strip())
|
||||
elif "EMPTY:" in output:
|
||||
self._logger.info("Result is empty, no extrusions found")
|
||||
result = copy.deepcopy(EMPTY_RESULT)
|
||||
elif "RESULTS:" not in output:
|
||||
raise RuntimeError("No analysis result found")
|
||||
else:
|
||||
|
||||
@@ -1155,7 +1155,7 @@ class LocalFileStorage(StorageInterface):
|
||||
"""
|
||||
Raises a :class:`ValueError` for a ``name`` containing ``/`` or ``\\``. Otherwise
|
||||
sanitizes the given ``name`` using ``octoprint.files.sanitize_filename``. Also
|
||||
strips leading ``.``s.
|
||||
strips any leading ``.``.
|
||||
"""
|
||||
return sanitize_filename(name, really_universal=self._really_universal)
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class StreamWrapper(AbstractFileWrapper):
|
||||
A wrapper allowing processing of one or more consecutive streams.
|
||||
|
||||
Arguments:
|
||||
*streams: One or more :py:`io.IOBase` streams to process one after another to save to storage.
|
||||
*streams: One or more :py:class:`io.IOBase` streams to process one after another to save to storage.
|
||||
"""
|
||||
|
||||
def __init__(self, filename, *streams):
|
||||
@@ -121,7 +121,7 @@ class MultiStream(io.RawIOBase):
|
||||
their contents in the order they are provided to the constructor.
|
||||
|
||||
Arguments:
|
||||
*streams: One or more :py:`io.IOBase` streams to concatenate.
|
||||
*streams: One or more :py:class:`io.IOBase` streams to concatenate.
|
||||
"""
|
||||
|
||||
def __init__(self, *streams):
|
||||
|
||||
+202
-186
@@ -52,6 +52,182 @@ def _load_module(name, spec):
|
||||
return imp.load_module(name, f, filename, details)
|
||||
|
||||
|
||||
def parse_plugin_metadata(path):
|
||||
result = {}
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if not path:
|
||||
return result
|
||||
|
||||
if os.path.isdir(path):
|
||||
path = os.path.join(path, "__init__.py")
|
||||
|
||||
if not os.path.isfile(path):
|
||||
return result
|
||||
|
||||
if not path.endswith(".py"):
|
||||
# we only support parsing plain text source files
|
||||
return result
|
||||
|
||||
logger.debug(f"Parsing plugin metadata from AST of {path}".format(path))
|
||||
|
||||
try:
|
||||
import ast
|
||||
|
||||
with open(path, "rb") as f:
|
||||
root = ast.parse(f.read(), filename=path)
|
||||
|
||||
assignments = list(
|
||||
filter(lambda x: isinstance(x, ast.Assign) and x.targets, root.body)
|
||||
)
|
||||
function_defs = list(
|
||||
filter(lambda x: isinstance(x, ast.FunctionDef) and x.name, root.body)
|
||||
)
|
||||
all_relevant = assignments + function_defs
|
||||
|
||||
def extract_target_ids(node):
|
||||
return list(
|
||||
map(
|
||||
lambda x: x.id,
|
||||
filter(lambda x: isinstance(x, ast.Name), node.targets),
|
||||
)
|
||||
)
|
||||
|
||||
def extract_names(node):
|
||||
if isinstance(node, ast.Assign):
|
||||
return extract_target_ids(node)
|
||||
elif isinstance(node, ast.FunctionDef):
|
||||
return [
|
||||
node.name,
|
||||
]
|
||||
else:
|
||||
return []
|
||||
|
||||
for key in (
|
||||
ControlProperties.attr_name,
|
||||
ControlProperties.attr_version,
|
||||
ControlProperties.attr_author,
|
||||
ControlProperties.attr_description,
|
||||
ControlProperties.attr_url,
|
||||
ControlProperties.attr_license,
|
||||
ControlProperties.attr_pythoncompat,
|
||||
):
|
||||
for a in reversed(assignments):
|
||||
targets = extract_target_ids(a)
|
||||
if key in targets:
|
||||
if isinstance(a.value, ast.Str):
|
||||
result[key] = a.value.s
|
||||
|
||||
elif (
|
||||
isinstance(a.value, ast.Call)
|
||||
and hasattr(a.value, "func")
|
||||
and a.value.func.id == "gettext"
|
||||
and a.value.args
|
||||
and isinstance(a.value.args[0], ast.Str)
|
||||
):
|
||||
result[key] = a.value.args[0].s
|
||||
|
||||
break
|
||||
|
||||
for key in (ControlProperties.attr_hidden,):
|
||||
for a in reversed(assignments):
|
||||
targets = extract_target_ids(a)
|
||||
if key in targets:
|
||||
if isinstance(a.value, ast.Name) and a.value.id in (
|
||||
"True",
|
||||
"False",
|
||||
):
|
||||
result[key] = bool(a.value.id)
|
||||
|
||||
break
|
||||
|
||||
for a in reversed(all_relevant):
|
||||
targets = extract_names(a)
|
||||
if any(map(lambda x: x in targets, ControlProperties.all())):
|
||||
result["has_control_properties"] = True
|
||||
break
|
||||
|
||||
except SyntaxError:
|
||||
raise
|
||||
except Exception:
|
||||
logger.exception(f"Error while parsing AST from {path}")
|
||||
|
||||
return result
|
||||
|
||||
|
||||
class ControlProperties:
|
||||
attr_name = "__plugin_name__"
|
||||
""" Module attribute from which to retrieve the plugin's human readable name. """
|
||||
|
||||
attr_description = "__plugin_description__"
|
||||
""" Module attribute from which to retrieve the plugin's description. """
|
||||
|
||||
attr_disabling_DISCOURAGED = "__plugin_disabling_discouraged__"
|
||||
""" Module attribute from which to retrieve the reason why disabling the plugin is discouraged. Only effective if ``self.bundled`` is True. """
|
||||
|
||||
attr_version = "__plugin_version__"
|
||||
""" Module attribute from which to retrieve the plugin's version. """
|
||||
|
||||
attr_author = "__plugin_author__"
|
||||
""" Module attribute from which to retrieve the plugin's author. """
|
||||
|
||||
attr_url = "__plugin_url__"
|
||||
""" Module attribute from which to retrieve the plugin's website URL. """
|
||||
|
||||
attr_license = "__plugin_license__"
|
||||
""" Module attribute from which to retrieve the plugin's license. """
|
||||
|
||||
attr_pythoncompat = "__plugin_pythoncompat__"
|
||||
"""
|
||||
Module attribute from which to retrieve the plugin's python compatibility string.
|
||||
|
||||
If unset a default of ``>=2.7,<3`` will be assumed, meaning that the plugin will be considered compatible to
|
||||
Python 2 but not Python 3.
|
||||
|
||||
To mark a plugin as Python 3 compatible, a string of ``>=2.7,<4`` is recommended.
|
||||
|
||||
Bundled plugins will automatically be assumed to be compatible.
|
||||
"""
|
||||
|
||||
attr_hidden = "__plugin_hidden__"
|
||||
"""
|
||||
Module attribute from which to determine if the plugin's hidden or not.
|
||||
|
||||
Only evaluated for bundled plugins, in order to hide them from the Plugin Manager
|
||||
and similar places.
|
||||
"""
|
||||
|
||||
attr_hooks = "__plugin_hooks__"
|
||||
""" Module attribute from which to retrieve the plugin's provided hooks. """
|
||||
|
||||
attr_implementation = "__plugin_implementation__"
|
||||
""" Module attribute from which to retrieve the plugin's provided mixin implementation. """
|
||||
|
||||
attr_helpers = "__plugin_helpers__"
|
||||
""" Module attribute from which to retrieve the plugin's provided helpers. """
|
||||
|
||||
attr_check = "__plugin_check__"
|
||||
""" Module attribute which to call to determine if the plugin can be loaded. """
|
||||
|
||||
attr_load = "__plugin_load__"
|
||||
""" Module attribute which to call when loading the plugin. """
|
||||
|
||||
attr_unload = "__plugin_unload__"
|
||||
""" Module attribute which to call when unloading the plugin. """
|
||||
|
||||
attr_enable = "__plugin_enable__"
|
||||
""" Module attribute which to call when enabling the plugin. """
|
||||
|
||||
attr_disable = "__plugin_disable__"
|
||||
""" Module attribute which to call when disabling the plugin. """
|
||||
|
||||
default_pythoncompat = ">=2.7,<3"
|
||||
|
||||
@classmethod
|
||||
def all(cls):
|
||||
return [getattr(cls, key) for key in dir(cls) if key.startswith("attr_")]
|
||||
|
||||
|
||||
_EntryPointOrigin = namedtuple(
|
||||
"EntryPointOrigin", "type, entry_point, module_name, package_name, package_version"
|
||||
)
|
||||
@@ -143,71 +319,6 @@ class PluginInfo:
|
||||
license (str): License of the plugin
|
||||
"""
|
||||
|
||||
attr_name = "__plugin_name__"
|
||||
""" Module attribute from which to retrieve the plugin's human readable name. """
|
||||
|
||||
attr_description = "__plugin_description__"
|
||||
""" Module attribute from which to retrieve the plugin's description. """
|
||||
|
||||
attr_disabling_discouraged = "__plugin_disabling_discouraged__"
|
||||
""" Module attribute from which to retrieve the reason why disabling the plugin is discouraged. Only effective if ``self.bundled`` is True. """
|
||||
|
||||
attr_version = "__plugin_version__"
|
||||
""" Module attribute from which to retrieve the plugin's version. """
|
||||
|
||||
attr_author = "__plugin_author__"
|
||||
""" Module attribute from which to retrieve the plugin's author. """
|
||||
|
||||
attr_url = "__plugin_url__"
|
||||
""" Module attribute from which to retrieve the plugin's website URL. """
|
||||
|
||||
attr_license = "__plugin_license__"
|
||||
""" Module attribute from which to retrieve the plugin's license. """
|
||||
|
||||
attr_pythoncompat = "__plugin_pythoncompat__"
|
||||
"""
|
||||
Module attribute from which to retrieve the plugin's python compatibility string.
|
||||
|
||||
If unset a default of ``>=2.7,<3`` will be assumed, meaning that the plugin will be considered compatible to
|
||||
Python 2 but not Python 3.
|
||||
|
||||
To mark a plugin as Python 3 compatible, a string of ``>=2.7,<4`` is recommended.
|
||||
|
||||
Bundled plugins will automatically be assumed to be compatible.
|
||||
"""
|
||||
|
||||
attr_hidden = "__plugin_hidden__"
|
||||
"""
|
||||
Module attribute from which to determine if the plugin's hidden or not.
|
||||
|
||||
Only evaluated for bundled plugins, in order to hide them from the Plugin Manager
|
||||
and similar places.
|
||||
"""
|
||||
|
||||
attr_hooks = "__plugin_hooks__"
|
||||
""" Module attribute from which to retrieve the plugin's provided hooks. """
|
||||
|
||||
attr_implementation = "__plugin_implementation__"
|
||||
""" Module attribute from which to retrieve the plugin's provided mixin implementation. """
|
||||
|
||||
attr_helpers = "__plugin_helpers__"
|
||||
""" Module attribute from which to retrieve the plugin's provided helpers. """
|
||||
|
||||
attr_check = "__plugin_check__"
|
||||
""" Module attribute which to call to determine if the plugin can be loaded. """
|
||||
|
||||
attr_load = "__plugin_load__"
|
||||
""" Module attribute which to call when loading the plugin. """
|
||||
|
||||
attr_unload = "__plugin_unload__"
|
||||
""" Module attribute which to call when unloading the plugin. """
|
||||
|
||||
attr_enable = "__plugin_enable__"
|
||||
""" Module attribute which to call when enabling the plugin. """
|
||||
|
||||
attr_disable = "__plugin_disable__"
|
||||
""" Module attribute which to call when disabling the plugin. """
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
key,
|
||||
@@ -411,7 +522,9 @@ class PluginInfo:
|
||||
str: Name of the plugin, fallback is the plugin's identifier.
|
||||
"""
|
||||
return self._get_instance_attribute(
|
||||
self.__class__.attr_name, defaults=(self._name, self.key), incl_metadata=True
|
||||
ControlProperties.attr_name,
|
||||
defaults=(self._name, self.key),
|
||||
incl_metadata=True,
|
||||
)
|
||||
|
||||
@property
|
||||
@@ -425,7 +538,9 @@ class PluginInfo:
|
||||
str or None: Description of the plugin.
|
||||
"""
|
||||
return self._get_instance_attribute(
|
||||
self.__class__.attr_description, default=self._description, incl_metadata=True
|
||||
ControlProperties.attr_description,
|
||||
default=self._description,
|
||||
incl_metadata=True,
|
||||
)
|
||||
|
||||
@property
|
||||
@@ -440,7 +555,7 @@ class PluginInfo:
|
||||
"""
|
||||
return (
|
||||
self._get_instance_attribute(
|
||||
self.__class__.attr_disabling_discouraged, default=False
|
||||
ControlProperties.attr_disabling_DISCOURAGED, default=False
|
||||
)
|
||||
if self.bundled
|
||||
else False
|
||||
@@ -459,7 +574,7 @@ class PluginInfo:
|
||||
self._version
|
||||
if self._version is not None
|
||||
else self._get_instance_attribute(
|
||||
self.__class__.attr_version, default=self._version, incl_metadata=True
|
||||
ControlProperties.attr_version, default=self._version, incl_metadata=True
|
||||
)
|
||||
)
|
||||
|
||||
@@ -473,7 +588,7 @@ class PluginInfo:
|
||||
str or None: Author of the plugin.
|
||||
"""
|
||||
return self._get_instance_attribute(
|
||||
self.__class__.attr_author, default=self._author, incl_metadata=True
|
||||
ControlProperties.attr_author, default=self._author, incl_metadata=True
|
||||
)
|
||||
|
||||
@property
|
||||
@@ -486,7 +601,7 @@ class PluginInfo:
|
||||
str or None: Website URL for the plugin.
|
||||
"""
|
||||
return self._get_instance_attribute(
|
||||
self.__class__.attr_url, default=self._url, incl_metadata=True
|
||||
ControlProperties.attr_url, default=self._url, incl_metadata=True
|
||||
)
|
||||
|
||||
@property
|
||||
@@ -499,7 +614,7 @@ class PluginInfo:
|
||||
str or None: License of the plugin.
|
||||
"""
|
||||
return self._get_instance_attribute(
|
||||
self.__class__.attr_license, default=self._license, incl_metadata=True
|
||||
ControlProperties.attr_license, default=self._license, incl_metadata=True
|
||||
)
|
||||
|
||||
@property
|
||||
@@ -512,7 +627,7 @@ class PluginInfo:
|
||||
str: Python compatibility string of the plugin
|
||||
"""
|
||||
return self._get_instance_attribute(
|
||||
self.__class__.attr_pythoncompat, default=">=2.7,<3", incl_metadata=True
|
||||
ControlProperties.attr_pythoncompat, default=">=2.7,<3", incl_metadata=True
|
||||
)
|
||||
|
||||
@property
|
||||
@@ -524,7 +639,7 @@ class PluginInfo:
|
||||
bool: Whether the plugin should be flagged as hidden or not
|
||||
"""
|
||||
return self._get_instance_attribute(
|
||||
self.__class__.attr_hidden, default=False, incl_metadata=True
|
||||
ControlProperties.attr_hidden, default=False, incl_metadata=True
|
||||
)
|
||||
|
||||
@property
|
||||
@@ -536,7 +651,7 @@ class PluginInfo:
|
||||
Returns:
|
||||
dict: Hooks provided by the plugin.
|
||||
"""
|
||||
return self._get_instance_attribute(self.__class__.attr_hooks, default={})
|
||||
return self._get_instance_attribute(ControlProperties.attr_hooks, default={})
|
||||
|
||||
@property
|
||||
def implementation(self):
|
||||
@@ -548,7 +663,7 @@ class PluginInfo:
|
||||
object: Implementation provided by the plugin.
|
||||
"""
|
||||
return self._get_instance_attribute(
|
||||
self.__class__.attr_implementation, default=None
|
||||
ControlProperties.attr_implementation, default=None
|
||||
)
|
||||
|
||||
@property
|
||||
@@ -560,7 +675,7 @@ class PluginInfo:
|
||||
Returns:
|
||||
dict: Helpers provided by the plugin.
|
||||
"""
|
||||
return self._get_instance_attribute(self.__class__.attr_helpers, default={})
|
||||
return self._get_instance_attribute(ControlProperties.attr_helpers, default={})
|
||||
|
||||
@property
|
||||
def check(self):
|
||||
@@ -573,7 +688,7 @@ class PluginInfo:
|
||||
otherwise.
|
||||
"""
|
||||
return self._get_instance_attribute(
|
||||
self.__class__.attr_check, default=lambda: True
|
||||
ControlProperties.attr_check, default=lambda: True
|
||||
)
|
||||
|
||||
@property
|
||||
@@ -586,7 +701,7 @@ class PluginInfo:
|
||||
callable: Load method for the plugin module.
|
||||
"""
|
||||
return self._get_instance_attribute(
|
||||
self.__class__.attr_load, default=lambda: True
|
||||
ControlProperties.attr_load, default=lambda: True
|
||||
)
|
||||
|
||||
@property
|
||||
@@ -599,7 +714,7 @@ class PluginInfo:
|
||||
callable: Unload method for the plugin module.
|
||||
"""
|
||||
return self._get_instance_attribute(
|
||||
self.__class__.attr_unload, default=lambda: True
|
||||
ControlProperties.attr_unload, default=lambda: True
|
||||
)
|
||||
|
||||
@property
|
||||
@@ -612,7 +727,7 @@ class PluginInfo:
|
||||
callable: Enable method for the plugin module.
|
||||
"""
|
||||
return self._get_instance_attribute(
|
||||
self.__class__.attr_enable, default=lambda: True
|
||||
ControlProperties.attr_enable, default=lambda: True
|
||||
)
|
||||
|
||||
@property
|
||||
@@ -625,7 +740,7 @@ class PluginInfo:
|
||||
callable: Disable method for the plugin module.
|
||||
"""
|
||||
return self._get_instance_attribute(
|
||||
self.__class__.attr_disable, default=lambda: True
|
||||
ControlProperties.attr_disable, default=lambda: True
|
||||
)
|
||||
|
||||
def _get_instance_attribute(
|
||||
@@ -653,11 +768,7 @@ class PluginInfo:
|
||||
|
||||
@property
|
||||
def control_properties(self):
|
||||
return [
|
||||
getattr(self.__class__, key)
|
||||
for key in dir(self.__class__)
|
||||
if key.startswith("attr_")
|
||||
]
|
||||
return ControlProperties.all()
|
||||
|
||||
@property
|
||||
def looks_like_plugin(self):
|
||||
@@ -667,109 +778,14 @@ class PluginInfo:
|
||||
return self.parsed_metadata.get("has_control_properties", False)
|
||||
|
||||
def _parse_metadata(self):
|
||||
result = {}
|
||||
|
||||
path = self.location
|
||||
if not path:
|
||||
return result
|
||||
|
||||
if os.path.isdir(path):
|
||||
path = os.path.join(self.location, "__init__.py")
|
||||
|
||||
if not os.path.isfile(path):
|
||||
return result
|
||||
|
||||
if not path.endswith(".py"):
|
||||
# we only support parsing plain text source files
|
||||
return result
|
||||
|
||||
self._logger.debug(f"Parsing plugin metadata for {self.key} from AST of {path}")
|
||||
|
||||
try:
|
||||
import ast
|
||||
|
||||
with open(path, "rb") as f:
|
||||
root = ast.parse(f.read(), filename=path)
|
||||
|
||||
assignments = list(
|
||||
filter(lambda x: isinstance(x, ast.Assign) and x.targets, root.body)
|
||||
)
|
||||
function_defs = list(
|
||||
filter(lambda x: isinstance(x, ast.FunctionDef) and x.name, root.body)
|
||||
)
|
||||
all_relevant = assignments + function_defs
|
||||
|
||||
def extract_target_ids(node):
|
||||
return list(
|
||||
map(
|
||||
lambda x: x.id,
|
||||
filter(lambda x: isinstance(x, ast.Name), node.targets),
|
||||
)
|
||||
)
|
||||
|
||||
def extract_names(node):
|
||||
if isinstance(node, ast.Assign):
|
||||
return extract_target_ids(node)
|
||||
elif isinstance(node, ast.FunctionDef):
|
||||
return [
|
||||
node.name,
|
||||
]
|
||||
else:
|
||||
return []
|
||||
|
||||
for key in (
|
||||
self.__class__.attr_name,
|
||||
self.__class__.attr_version,
|
||||
self.__class__.attr_author,
|
||||
self.__class__.attr_description,
|
||||
self.__class__.attr_url,
|
||||
self.__class__.attr_license,
|
||||
self.__class__.attr_pythoncompat,
|
||||
):
|
||||
for a in reversed(assignments):
|
||||
targets = extract_target_ids(a)
|
||||
if key in targets:
|
||||
if isinstance(a.value, ast.Str):
|
||||
result[key] = a.value.s
|
||||
|
||||
elif (
|
||||
isinstance(a.value, ast.Call)
|
||||
and hasattr(a.value, "func")
|
||||
and a.value.func.id == "gettext"
|
||||
and a.value.args
|
||||
and isinstance(a.value.args[0], ast.Str)
|
||||
):
|
||||
result[key] = a.value.args[0].s
|
||||
|
||||
break
|
||||
|
||||
for key in (self.__class__.attr_hidden,):
|
||||
for a in reversed(assignments):
|
||||
targets = extract_target_ids(a)
|
||||
if key in targets:
|
||||
if isinstance(a.value, ast.Name) and a.value.id in (
|
||||
"True",
|
||||
"False",
|
||||
):
|
||||
result[key] = bool(a.value.id)
|
||||
|
||||
break
|
||||
|
||||
for a in reversed(all_relevant):
|
||||
targets = extract_names(a)
|
||||
if any(map(lambda x: x in targets, self.control_properties)):
|
||||
result["has_control_properties"] = True
|
||||
break
|
||||
|
||||
return parse_plugin_metadata(self.location)
|
||||
except SyntaxError:
|
||||
self._logger.exception(f"Invalid syntax in {path} for plugin {self.key}")
|
||||
self.invalid_syntax = True
|
||||
except Exception:
|
||||
self._logger.exception(
|
||||
f"Error while parsing AST from {path} for plugin {self.key}"
|
||||
f"Invalid syntax in plugin file of plugin {self.key}".format(self.key)
|
||||
)
|
||||
|
||||
return result
|
||||
self.invalid_syntax = True
|
||||
return {}
|
||||
|
||||
|
||||
class PluginManager:
|
||||
|
||||
@@ -79,10 +79,10 @@
|
||||
<p>{{ _('Create a new backup of the current state.') }}</p>
|
||||
|
||||
<form class="form-horizontal" onsubmit="return false;">
|
||||
<div class="control-group">
|
||||
<div class="control-group" title="{{ _('All files in the uploads folder and subfolders. These are the files in the Files List, plus any metadata that has been generated for those files.')|edq }}">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="value: 'uploads', checked: excludeFromBackup"> {{ _('Exclude uploaded files & metadata from backup') }}
|
||||
<input type="checkbox" data-bind="value: 'uploads', checked: excludeFromBackup"> {{ _('Exclude uploaded files (& associated metadata) from backup') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -100,6 +100,7 @@ def map_repository_entry(entry):
|
||||
already_installed_string = "Requirement already satisfied (use --upgrade to upgrade)"
|
||||
success_string = "Successfully installed"
|
||||
failure_string = "Could not install"
|
||||
python_mismatch_string = "requires a different Python:"
|
||||
|
||||
|
||||
class PluginManagerPlugin(
|
||||
@@ -940,6 +941,22 @@ class PluginManagerPlugin(
|
||||
self._send_result_notification("install", result)
|
||||
return result
|
||||
|
||||
if any(map(lambda x: python_mismatch_string in x, stderr)):
|
||||
self._logger.error(
|
||||
"Installing the plugin from {} failed, pip reported a Python version mismatch".format(
|
||||
source
|
||||
)
|
||||
)
|
||||
result = {
|
||||
"result": False,
|
||||
"source": source,
|
||||
"source_type": source_type,
|
||||
"reason": "Pip reported a Python version mismatch",
|
||||
"faq": "https://faq.octoprint.org/plugin-python-mismatch",
|
||||
}
|
||||
self._send_result_notification("install", result)
|
||||
return result
|
||||
|
||||
try:
|
||||
result_line = list(
|
||||
filter(
|
||||
@@ -1094,6 +1111,42 @@ class PluginManagerPlugin(
|
||||
destination = os.path.join(self._settings.global_get_basefolder("plugins"), name)
|
||||
plugin_id, _ = os.path.splitext(name)
|
||||
|
||||
# check python compatibility
|
||||
PYTHON_MISMATCH = {
|
||||
"result": False,
|
||||
"source": source,
|
||||
"source_type": source_type,
|
||||
"reason": "Plugin could not be installed",
|
||||
"faq": "https://faq.octoprint.org/plugin-python-mismatch",
|
||||
}
|
||||
|
||||
try:
|
||||
metadata = octoprint.plugin.core.parse_plugin_metadata(path)
|
||||
except SyntaxError:
|
||||
self._logger.exception(
|
||||
"Installing plugin from {} failed, there's a Python version mismatch".format(
|
||||
source
|
||||
)
|
||||
)
|
||||
result = PYTHON_MISMATCH
|
||||
self._send_result_notification("install", result)
|
||||
return result
|
||||
|
||||
pythoncompat = metadata.get(
|
||||
octoprint.plugin.core.ControlProperties.attr_pythoncompat,
|
||||
octoprint.plugin.core.ControlProperties.default_pythoncompat,
|
||||
)
|
||||
if not is_python_compatible(pythoncompat):
|
||||
self._logger.exception(
|
||||
"Installing plugin from {} failed, there's a Python version mismatch".format(
|
||||
source
|
||||
)
|
||||
)
|
||||
result = PYTHON_MISMATCH
|
||||
self._send_result_notification("install", result)
|
||||
return result
|
||||
|
||||
# copy plugin
|
||||
try:
|
||||
self._log_call(f"cp {path} {destination}")
|
||||
shutil.copy(path, destination)
|
||||
|
||||
@@ -424,7 +424,7 @@ $(function () {
|
||||
self.uploadButton.bind("click", function () {
|
||||
self._markWorking(
|
||||
gettext("Installing plugin..."),
|
||||
gettext("Installing plugin from uploaded archive...")
|
||||
gettext("Installing plugin from uploaded file...")
|
||||
);
|
||||
data.formData = {
|
||||
dependency_links: self.followDependencyLinks()
|
||||
@@ -1217,7 +1217,7 @@ $(function () {
|
||||
if (response.result) {
|
||||
self._markDone();
|
||||
} else {
|
||||
self._markDone(response.reason);
|
||||
self._markDone(response.reason, response.faq);
|
||||
}
|
||||
|
||||
self._displayPluginManagementNotification(response, action, plugin);
|
||||
@@ -1233,7 +1233,8 @@ $(function () {
|
||||
self.logContents.steps.push({
|
||||
action: action,
|
||||
plugin: plugin,
|
||||
result: response.result
|
||||
result: response.result,
|
||||
faq: response.faq
|
||||
});
|
||||
|
||||
var title = gettext("Plugin management log");
|
||||
@@ -1252,6 +1253,7 @@ $(function () {
|
||||
steps = steps.slice(steps.length - 5);
|
||||
}
|
||||
|
||||
var negativeResult = false;
|
||||
_.each(steps, function (step) {
|
||||
var line = undefined;
|
||||
|
||||
@@ -1293,7 +1295,14 @@ $(function () {
|
||||
? '<i class="fa fa-check"></i>'
|
||||
: '<i class="fa fa-remove"></i>'
|
||||
}) +
|
||||
(step.result === false && step.faq
|
||||
? ' (<a href="" target="_blank" rel="noopener noreferer">' +
|
||||
gettext("Why?") +
|
||||
"</a>)"
|
||||
: "") +
|
||||
"</li>";
|
||||
|
||||
negativeResult = negativeResult || step.result === false;
|
||||
});
|
||||
text += "</ul></p>";
|
||||
|
||||
@@ -1385,6 +1394,8 @@ $(function () {
|
||||
type = "warning";
|
||||
}
|
||||
|
||||
if (negativeResult) type = "error";
|
||||
|
||||
var options = {
|
||||
title: title,
|
||||
text: text,
|
||||
@@ -1432,11 +1443,22 @@ $(function () {
|
||||
self.workingDialog.modal({keyboard: false, backdrop: "static", show: true});
|
||||
};
|
||||
|
||||
self._markDone = function (error) {
|
||||
self._markDone = function (error, faq) {
|
||||
self.working(false);
|
||||
if (error) {
|
||||
self.loglines.push({line: gettext("Error!"), stream: "error"});
|
||||
self.loglines.push({line: error, stream: "error"});
|
||||
if (faq) {
|
||||
self.loglines.push({
|
||||
line: _.sprintf(
|
||||
gettext(
|
||||
"You can find more info on this issue in the FAQ at %(url)s"
|
||||
),
|
||||
{url: faq}
|
||||
),
|
||||
stream: "error"
|
||||
});
|
||||
}
|
||||
} else {
|
||||
self.loglines.push({line: gettext("Done!"), stream: "message"});
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
{% macro pluginmanager_throttled() %}
|
||||
<div class="alert" data-bind="visible: throttled">{% trans %}
|
||||
The system OctoPrint is running on is currently throttled. Due to that it's not possible to install new
|
||||
plugins in order to avoid possible issues caused by system instability.
|
||||
plugins in order to avoid possible issues caused by system instability. Read more on
|
||||
this in <a href="https://faq.octoprint.org/pi-issues" target="_blank" rel="noopener noreferrer">the FAQ</a>.
|
||||
{% endtrans %}</div>
|
||||
{% endmacro %}
|
||||
|
||||
@@ -37,7 +38,7 @@
|
||||
{% macro pluginmanager_requesterror() %}
|
||||
<div class="alert" data-bind="visible: requestError()">{% trans %}
|
||||
There appears to have been an error retrieving the plugin data from the backend. Please report this
|
||||
in the bug tracker & be sure to include all requested logs.
|
||||
in the bug tracker & be sure to include all requested information.
|
||||
{% endtrans %}</div>
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
@@ -59,6 +59,9 @@
|
||||
before trying to update. Take a look at the displayed warning in the navigation bar to learn about what is
|
||||
wrong and to get hints on how to solve the problem.
|
||||
</p>
|
||||
<p>
|
||||
Read more on this in <a href="https://faq.octoprint.org/pi-issues" target="_blank" rel="noopener noreferrer">the FAQ</a>.
|
||||
</p>
|
||||
{% endtrans %}</div>
|
||||
<div class="alert" data-bind="visible: printerState.isPrinting()">{% trans %}
|
||||
<p>
|
||||
|
||||
@@ -28,6 +28,7 @@ class TrackingPlugin(
|
||||
octoprint.plugin.AssetPlugin,
|
||||
octoprint.plugin.WizardPlugin,
|
||||
octoprint.plugin.EventHandlerPlugin,
|
||||
octoprint.plugin.SimpleApiPlugin,
|
||||
):
|
||||
def __init__(self):
|
||||
self._environment = None
|
||||
@@ -66,6 +67,7 @@ class TrackingPlugin(
|
||||
"printer_safety_check": True,
|
||||
"throttled": True,
|
||||
"slicing": True,
|
||||
"webui_load": True,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -84,6 +86,26 @@ class TrackingPlugin(
|
||||
# tracking was just enabled, let's start up tracking
|
||||
self._start_tracking()
|
||||
|
||||
##~~ SimpleApiPlugin
|
||||
|
||||
def get_api_commands(self):
|
||||
return {"track": ["event", "payload"]}
|
||||
|
||||
def on_api_command(self, command, data):
|
||||
if command != "track":
|
||||
return
|
||||
|
||||
event = data.pop("event")
|
||||
if event == "webui_load":
|
||||
payload = data.get("payload", {})
|
||||
browser_name = payload.get("browser_name")
|
||||
browser_version = payload.get("browser_version")
|
||||
os_name = payload.get("os_name")
|
||||
os_version = payload.get("os_version")
|
||||
|
||||
if all((browser_name, browser_version, os_name, os_version)):
|
||||
self._track_webui_load(browser_name, browser_version, os_name, os_version)
|
||||
|
||||
##~~ EnvironmentDetectionPlugin
|
||||
|
||||
def on_environment_detected(self, environment, *args, **kwargs):
|
||||
@@ -181,7 +203,7 @@ class TrackingPlugin(
|
||||
##~~ AssetPlugin
|
||||
|
||||
def get_assets(self):
|
||||
return {"js": ["js/usage.js"]}
|
||||
return {"js": ["js/usage.js"], "clientjs": ["clientjs/usage.js"]}
|
||||
|
||||
##~~ WizardPlugin
|
||||
|
||||
@@ -270,6 +292,18 @@ class TrackingPlugin(
|
||||
|
||||
self._track("shutdown")
|
||||
|
||||
def _track_webui_load(self, browser_name, browser_version, os_name, os_version):
|
||||
if not self._settings.get_boolean(["events", "webui_load"]):
|
||||
return
|
||||
|
||||
self._track(
|
||||
"webui_load",
|
||||
browser_name=browser_name,
|
||||
browser_version=browser_version,
|
||||
os_name=os_name,
|
||||
os_version=os_version,
|
||||
)
|
||||
|
||||
def _track_plugin_event(self, event, payload):
|
||||
if not self._settings.get_boolean(["events", "plugin"]):
|
||||
return
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
(function (global, factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["OctoPrintClient"], factory);
|
||||
} else {
|
||||
factory(global.OctoPrintClient);
|
||||
}
|
||||
})(this, function (OctoPrintClient) {
|
||||
var OctoPrintTrackingClient = function (base) {
|
||||
this.base = base;
|
||||
};
|
||||
|
||||
OctoPrintTrackingClient.prototype.track = function (event, payload, opts) {
|
||||
return this.base.simpleApiCommand(
|
||||
"tracking",
|
||||
"track",
|
||||
{event: event, payload: payload},
|
||||
opts
|
||||
);
|
||||
};
|
||||
|
||||
OctoPrintClient.registerPluginComponent("tracking", OctoPrintTrackingClient);
|
||||
return OctoPrintTrackingClient;
|
||||
});
|
||||
@@ -10,6 +10,15 @@ $(function () {
|
||||
self.active = ko.observable();
|
||||
self.required = false;
|
||||
|
||||
self.onStartupComplete = function () {
|
||||
OctoPrint.plugins.tracking.track("webui_load", {
|
||||
browser_name: OctoPrint.coreui.browser.browser_name,
|
||||
browser_version: OctoPrint.coreui.browser.browser_version,
|
||||
os_name: OctoPrint.coreui.browser.os_name,
|
||||
os_version: OctoPrint.coreui.browser.os_version
|
||||
});
|
||||
};
|
||||
|
||||
self.enableUsage = function () {
|
||||
self.settingsViewModel.settings.plugins.tracking.enabled(true);
|
||||
self.decision(true);
|
||||
|
||||
@@ -52,6 +52,9 @@
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: settings.plugins.tracking.events.slicing"> {{ _('Onboard slicing actions') }}
|
||||
</label>
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: settings.plugins.tracking.events.webui_load"> {{ _('Web interface load') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -27,7 +27,7 @@ class VirtualPrinterPlugin(
|
||||
"smoothieTemperatureReporting": False,
|
||||
"klipperTemperatureReporting": False,
|
||||
"reprapfwM114": False,
|
||||
"sdFiles": {"size": True, "longname": False},
|
||||
"sdFiles": {"size": True, "longname": False, "longname_quoted": True},
|
||||
"throttle": 0.01,
|
||||
"sendWait": True,
|
||||
"waitInterval": 1.0,
|
||||
@@ -51,7 +51,9 @@ class VirtualPrinterPlugin(
|
||||
"capabilities": {
|
||||
"AUTOREPORT_TEMP": True,
|
||||
"AUTOREPORT_SD_STATUS": True,
|
||||
"AUTOREPORT_POS": False,
|
||||
"EMERGENCY_PARSER": True,
|
||||
"EXTENDED_M20": False,
|
||||
},
|
||||
"m114FormatString": "X:{x} Y:{y} Z:{z} E:{e[current]} Count: A:{a} B:{b} C:{c}",
|
||||
"m105TargetFormatString": "{heater}:{actual:.2f}/ {target:.2f}",
|
||||
|
||||
@@ -167,6 +167,7 @@ class VirtualPrinter:
|
||||
|
||||
self._temperature_reporter = None
|
||||
self._sdstatus_reporter = None
|
||||
self._pos_reporter = None
|
||||
|
||||
self.current_line = 0
|
||||
self.lastN = 0
|
||||
@@ -577,7 +578,7 @@ class VirtualPrinter:
|
||||
# noinspection PyUnusedLocal
|
||||
def _gcode_M20(self, data: str) -> None:
|
||||
if self._sdCardReady:
|
||||
self._listSd()
|
||||
self._listSd(incl_long="L" in data)
|
||||
|
||||
# noinspection PyUnusedLocal
|
||||
def _gcode_M21(self, data: str) -> None:
|
||||
@@ -660,27 +661,9 @@ class VirtualPrinter:
|
||||
self._busyInterval = interval
|
||||
|
||||
# noinspection PyUnusedLocal
|
||||
def _gcode_M114(self, data: str) -> bool:
|
||||
m114FormatString = self._settings.get(["m114FormatString"])
|
||||
e = {index: value for index, value in enumerate(self._lastE)}
|
||||
e["current"] = self._lastE[self.currentExtruder]
|
||||
e["all"] = " ".join(
|
||||
[
|
||||
"E{}:{}".format(num, self._lastE[self.currentExtruder])
|
||||
for num in range(self.extruderCount)
|
||||
]
|
||||
)
|
||||
output = m114FormatString.format(
|
||||
x=self._lastX,
|
||||
y=self._lastY,
|
||||
z=self._lastZ,
|
||||
e=e,
|
||||
f=self._lastF,
|
||||
a=int(self._lastX * 100),
|
||||
b=int(self._lastY * 100),
|
||||
c=int(self._lastZ * 100),
|
||||
)
|
||||
|
||||
def _gcode_M114(self, data):
|
||||
# type: (str) -> bool
|
||||
output = self._generatePositionOutput()
|
||||
if not self._okBeforeCommandOutput:
|
||||
ok = self._ok()
|
||||
if ok:
|
||||
@@ -705,7 +688,24 @@ class VirtualPrinter:
|
||||
except AttributeError:
|
||||
self._send("echo:")
|
||||
|
||||
def _gcode_M155(self, data: str) -> None:
|
||||
def _gcode_M154(self, data):
|
||||
# type: (str) -> None
|
||||
matchS = re.search(r"S([0-9]+)", data)
|
||||
if matchS is not None:
|
||||
interval = int(matchS.group(1))
|
||||
if self._pos_reporter is not None:
|
||||
self._pos_reporter.cancel()
|
||||
|
||||
if interval > 0:
|
||||
self._pos_reporter = RepeatedTimer(
|
||||
interval, lambda: self._send(self._generatePositionOutput())
|
||||
)
|
||||
self._pos_reporter.start()
|
||||
else:
|
||||
self._pos_reporter = None
|
||||
|
||||
def _gcode_M155(self, data):
|
||||
# type: (str) -> None
|
||||
matchS = re.search(r"S([0-9]+)", data)
|
||||
if matchS is not None:
|
||||
interval = int(matchS.group(1))
|
||||
@@ -1351,10 +1351,13 @@ class VirtualPrinter:
|
||||
except Exception:
|
||||
self._logger.exception("While handling %r", data)
|
||||
|
||||
def _listSd(self):
|
||||
def _listSd(self, incl_long=False):
|
||||
if self._settings.get_boolean(["sdFiles", "size"]):
|
||||
if self._settings.get_boolean(["sdFiles", "longname"]):
|
||||
line = "{dosname} {size} {name}"
|
||||
if self._settings.get_boolean(["sdFiles", "longname"]) or incl_long:
|
||||
if self._settings.get_boolean(["sdFiles", "longname_quoted"]):
|
||||
line = '{dosname} {size} "{name}"'
|
||||
else:
|
||||
line = "{dosname} {size} {name}"
|
||||
else:
|
||||
line = "{dosname} {size}"
|
||||
else:
|
||||
@@ -1433,6 +1436,29 @@ class VirtualPrinter:
|
||||
else:
|
||||
self._send("Not SD printing")
|
||||
|
||||
def _generatePositionOutput(self):
|
||||
# type: () -> str
|
||||
m114FormatString = self._settings.get(["m114FormatString"])
|
||||
e = {index: value for index, value in enumerate(self._lastE)}
|
||||
e["current"] = self._lastE[self.currentExtruder]
|
||||
e["all"] = " ".join(
|
||||
[
|
||||
"E{}:{}".format(num, self._lastE[self.currentExtruder])
|
||||
for num in range(self.extruderCount)
|
||||
]
|
||||
)
|
||||
output = m114FormatString.format(
|
||||
x=self._lastX,
|
||||
y=self._lastY,
|
||||
z=self._lastZ,
|
||||
e=e,
|
||||
f=self._lastF,
|
||||
a=int(self._lastX * 100),
|
||||
b=int(self._lastY * 100),
|
||||
c=int(self._lastZ * 100),
|
||||
)
|
||||
return output
|
||||
|
||||
def _generateTemperatureOutput(self):
|
||||
# type: () -> str
|
||||
if self._settings.get_boolean(["repetierStyleTargetTemperature"]):
|
||||
|
||||
@@ -1341,14 +1341,16 @@ class Server:
|
||||
ReverseProxiedEnvironment,
|
||||
)
|
||||
|
||||
s = settings()
|
||||
app.config["TEMPLATES_AUTO_RELOAD"] = True
|
||||
app.config["JSONIFY_PRETTYPRINT_REGULAR"] = False
|
||||
|
||||
# we must not set this before TEMPLATES_AUTO_RELOAD is set to True or that won't take
|
||||
app.debug = self._debug
|
||||
|
||||
# setup octoprint's flask json serialization/deserialization
|
||||
app.json_encoder = OctoPrintJsonEncoder
|
||||
|
||||
app.debug = self._debug
|
||||
app.config["TEMPLATES_AUTO_RELOAD"] = True
|
||||
app.config["JSONIFY_PRETTYPRINT_REGULAR"] = False
|
||||
s = settings()
|
||||
|
||||
secret_key = s.get(["server", "secretKey"])
|
||||
if not secret_key:
|
||||
@@ -2057,6 +2059,7 @@ class Server:
|
||||
"js/lib/moment-with-locales.min.js",
|
||||
"js/lib/pusher.color.min.js",
|
||||
"js/lib/detectmobilebrowser.js",
|
||||
"js/lib/ua-parser.min.js",
|
||||
"js/lib/md5.min.js",
|
||||
"js/lib/bootstrap-slider-knockout-binding.js",
|
||||
"js/lib/loglevel.min.js",
|
||||
|
||||
@@ -3,6 +3,7 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agp
|
||||
__copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
import logging
|
||||
import re
|
||||
|
||||
from flask import abort, jsonify, request
|
||||
from flask_login import current_user
|
||||
@@ -19,6 +20,7 @@ from octoprint.settings import settings, valid_boolean_trues
|
||||
|
||||
FOLDER_TYPES = ("uploads", "timelapse", "timelapse_tmp", "logs", "watched")
|
||||
FOLDER_MAPPING = {"timelapseTmp": "timelapse_tmp"}
|
||||
TIMELAPSE_BITRATE_PATTERN = re.compile(r"\d+[KMGTPEZY]?i?B?", flags=re.IGNORECASE)
|
||||
|
||||
|
||||
def _lastmodified():
|
||||
@@ -184,6 +186,7 @@ def getSettings():
|
||||
"timeoutSdStatusAutoreport": s.getFloat(
|
||||
["serial", "timeout", "sdStatusAutoreport"]
|
||||
),
|
||||
"timeoutPosAutoreport": s.getFloat(["serial", "timeout", "posAutoreport"]),
|
||||
"timeoutBaudrateDetectionPause": s.getFloat(
|
||||
["serial", "timeout", "baudrateDetectionPause"]
|
||||
),
|
||||
@@ -244,10 +247,14 @@ def getSettings():
|
||||
"capAutoreportSdStatus": s.getBoolean(
|
||||
["serial", "capabilities", "autoreport_sdstatus"]
|
||||
),
|
||||
"capAutoreportPos": s.getBoolean(
|
||||
["serial", "capabilities", "autoreport_pos"]
|
||||
),
|
||||
"capBusyProtocol": s.getBoolean(["serial", "capabilities", "busy_protocol"]),
|
||||
"capEmergencyParser": s.getBoolean(
|
||||
["serial", "capabilities", "emergency_parser"]
|
||||
),
|
||||
"capExtendedM20": s.getBoolean(["serial", "capabilities", "extended_m20"]),
|
||||
"resendRatioThreshold": s.getInt(["serial", "resendRatioThreshold"]),
|
||||
"resendRatioStart": s.getInt(["serial", "resendRatioStart"]),
|
||||
},
|
||||
@@ -559,8 +566,14 @@ def _saveSettings(data):
|
||||
abort(400, description="Invalid webcam.ffmpegCommandline setting")
|
||||
else:
|
||||
s.set(["webcam", "ffmpegCommandline"], commandline)
|
||||
if "bitrate" in data["webcam"]:
|
||||
s.set(["webcam", "bitrate"], data["webcam"]["bitrate"])
|
||||
if "bitrate" in data["webcam"] and data["webcam"]["bitrate"]:
|
||||
bitrate = str(data["webcam"]["bitrate"])
|
||||
if not TIMELAPSE_BITRATE_PATTERN.match(bitrate):
|
||||
abort(
|
||||
400,
|
||||
description="Invalid webcam.bitrate setting, needs to be a valid ffmpeg bitrate",
|
||||
)
|
||||
s.set(["webcam", "bitrate"], bitrate)
|
||||
if "ffmpegThreads" in data["webcam"]:
|
||||
s.setInt(["webcam", "ffmpegThreads"], data["webcam"]["ffmpegThreads"])
|
||||
if "ffmpegVideoCodec" in data["webcam"] and data["webcam"][
|
||||
@@ -700,6 +713,12 @@ def _saveSettings(data):
|
||||
data["serial"]["timeoutSdStatusAutoreport"],
|
||||
min=0.0,
|
||||
)
|
||||
if "timeoutPosAutoreport" in data["serial"]:
|
||||
s.setFloat(
|
||||
["serial", "timeout", "posAutoreport"],
|
||||
data["serial"]["timeoutPosAutoreport"],
|
||||
min=0.0,
|
||||
)
|
||||
if "timeoutBaudrateDetectionPause" in data["serial"]:
|
||||
s.setFloat(
|
||||
["serial", "timeout", "baudrateDetectionPause"],
|
||||
@@ -882,6 +901,11 @@ def _saveSettings(data):
|
||||
["serial", "capabilities", "autoreport_sdstatus"],
|
||||
data["serial"]["capAutoreportSdStatus"],
|
||||
)
|
||||
if "capAutoreportPos" in data["serial"]:
|
||||
s.setBoolean(
|
||||
["serial", "capabilities", "autoreport_pos"],
|
||||
data["serial"]["capAutoreportPos"],
|
||||
)
|
||||
if "capBusyProtocol" in data["serial"]:
|
||||
s.setBoolean(
|
||||
["serial", "capabilities", "busy_protocol"],
|
||||
@@ -892,6 +916,11 @@ def _saveSettings(data):
|
||||
["serial", "capabilities", "emergency_parser"],
|
||||
data["serial"]["capEmergencyParser"],
|
||||
)
|
||||
if "capExtendedM20" in data["serial"]:
|
||||
s.setBoolean(
|
||||
["serial", "capabilities", "extended_m20"],
|
||||
data["serial"]["capExtendedM20"],
|
||||
),
|
||||
if "resendRatioThreshold" in data["serial"]:
|
||||
s.setInt(
|
||||
["serial", "resendRatioThreshold"], data["serial"]["resendRatioThreshold"]
|
||||
|
||||
@@ -3,6 +3,7 @@ __copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms
|
||||
|
||||
import collections
|
||||
import logging
|
||||
import re
|
||||
import threading
|
||||
|
||||
import psutil
|
||||
@@ -12,6 +13,7 @@ from flask_babel import gettext
|
||||
|
||||
from octoprint.access.permissions import Permissions
|
||||
from octoprint.logging import prefix_multilines
|
||||
from octoprint.plugin import plugin_manager
|
||||
from octoprint.server import NO_CONTENT
|
||||
from octoprint.server.api import api
|
||||
from octoprint.server.util.flask import get_remote_address, no_firstrun_access
|
||||
@@ -95,6 +97,7 @@ def performSystemAction():
|
||||
def retrieveSystemCommands():
|
||||
return jsonify(
|
||||
core=_to_client_specs(_get_core_command_specs()),
|
||||
plugin=_to_client_specs(_get_plugin_command_specs()),
|
||||
custom=_to_client_specs(_get_custom_command_specs()),
|
||||
)
|
||||
|
||||
@@ -107,6 +110,8 @@ def retrieveSystemCommandsForSource(source):
|
||||
specs = _get_core_command_specs()
|
||||
elif source == "custom":
|
||||
specs = _get_custom_command_specs()
|
||||
elif source == "plugin":
|
||||
specs = _get_plugin_command_specs()
|
||||
else:
|
||||
abort(404)
|
||||
|
||||
@@ -222,6 +227,8 @@ def _get_command_spec(source, action):
|
||||
return _get_core_command_spec(action)
|
||||
elif source == "custom":
|
||||
return _get_custom_command_spec(action)
|
||||
elif source == "plugin":
|
||||
return _get_plugin_command_spec(action)
|
||||
else:
|
||||
return None
|
||||
|
||||
@@ -285,6 +292,50 @@ def _get_core_command_spec(action):
|
||||
return available_actions[action]
|
||||
|
||||
|
||||
_plugin_action_regex = re.compile(r"[a-z0-9_-]+")
|
||||
|
||||
|
||||
def _get_plugin_command_specs(plugin=None):
|
||||
specs = collections.OrderedDict()
|
||||
|
||||
hooks = plugin_manager().get_hooks("octoprint.system.additional_commands")
|
||||
if plugin is not None:
|
||||
if plugin in hooks:
|
||||
hooks = {plugin: hooks[plugin]}
|
||||
else:
|
||||
hooks = {}
|
||||
|
||||
for name, hook in hooks.items():
|
||||
try:
|
||||
plugin_specs = hook()
|
||||
for spec in plugin_specs:
|
||||
action = spec.get("action")
|
||||
if (
|
||||
not action
|
||||
or action == "divider"
|
||||
or not _plugin_action_regex.match(action)
|
||||
):
|
||||
continue
|
||||
action = name.lower() + ":" + action
|
||||
|
||||
copied = dict(spec)
|
||||
copied["source"] = "plugin"
|
||||
copied["action"] = action
|
||||
specs[action] = copied
|
||||
except Exception:
|
||||
logging.getLogger(__name__).exception(
|
||||
f"Error while fetching additional actions from plugin {name}",
|
||||
extra={"plugin": name},
|
||||
)
|
||||
return specs
|
||||
|
||||
|
||||
def _get_plugin_command_spec(action):
|
||||
plugin = action.split(":", 1)[0]
|
||||
available_actions = _get_plugin_command_specs(plugin=plugin)
|
||||
return available_actions.get(action)
|
||||
|
||||
|
||||
def _get_custom_command_specs():
|
||||
specs = collections.OrderedDict()
|
||||
dividers = 0
|
||||
@@ -304,10 +355,7 @@ def _get_custom_command_specs():
|
||||
|
||||
def _get_custom_command_spec(action):
|
||||
available_actions = _get_custom_command_specs()
|
||||
if action not in available_actions:
|
||||
return None
|
||||
|
||||
return available_actions[action]
|
||||
return available_actions.get(action)
|
||||
|
||||
|
||||
class CommandFailed(Exception):
|
||||
|
||||
@@ -24,6 +24,7 @@ from octoprint.access.users import LoginStatusListener
|
||||
from octoprint.events import Events
|
||||
from octoprint.settings import settings
|
||||
from octoprint.util.json import dump as json_dump
|
||||
from octoprint.util.version import get_python_version_string
|
||||
|
||||
|
||||
class ThreadSafeSession(octoprint.vendor.sockjs.tornado.session.Session):
|
||||
@@ -218,6 +219,7 @@ class PrinterStateConnection(
|
||||
"version": octoprint.server.VERSION,
|
||||
"display_version": octoprint.server.DISPLAY_VERSION,
|
||||
"branch": octoprint.server.BRANCH,
|
||||
"python_version": get_python_version_string(),
|
||||
"plugin_hash": plugin_hash.hexdigest(),
|
||||
"config_hash": config_hash,
|
||||
"debug": octoprint.server.debug,
|
||||
|
||||
+24
-29
@@ -98,6 +98,7 @@ default_settings = {
|
||||
"temperatureAutoreport": 2,
|
||||
"sdStatus": 1,
|
||||
"sdStatusAutoreport": 1,
|
||||
"posAutoreport": 5,
|
||||
"resendOk": 0.5,
|
||||
"baudrateDetectionPause": 1.0,
|
||||
"positionLogWait": 10.0,
|
||||
@@ -152,8 +153,10 @@ default_settings = {
|
||||
"capabilities": {
|
||||
"autoreport_temp": True,
|
||||
"autoreport_sdstatus": True,
|
||||
"autoreport_pos": True,
|
||||
"busy_protocol": True,
|
||||
"emergency_parser": True,
|
||||
"extended_m20": True,
|
||||
},
|
||||
"resendRatioThreshold": 10,
|
||||
"resendRatioStart": 100,
|
||||
@@ -233,7 +236,7 @@ default_settings = {
|
||||
"flipH": False,
|
||||
"flipV": False,
|
||||
"rotate90": False,
|
||||
"ffmpegCommandline": '{ffmpeg} -r {fps} -i "{input}" -vcodec {videocodec} -threads {threads} -b {bitrate} -f {containerformat} -y {filters} "{output}"',
|
||||
"ffmpegCommandline": '{ffmpeg} -r {fps} -i "{input}" -vcodec {videocodec} -threads {threads} -b:v {bitrate} -f {containerformat} -y {filters} "{output}"',
|
||||
"timelapse": {
|
||||
"type": "off",
|
||||
"options": {},
|
||||
@@ -410,6 +413,10 @@ default_settings = {
|
||||
"name": "Suppress SD status messages",
|
||||
"regex": r"(Send: (N\d+\s+)?M27)|(Recv: SD printing byte)|(Recv: Not SD printing)",
|
||||
},
|
||||
{
|
||||
"name": "Suppress position messages",
|
||||
"regex": r"(Send:\s+(N\d+\s+)?M114)|(Recv:\s+(ok\s+)?X:[+-]?([0-9]*[.])?[0-9]+\s+Y:[+-]?([0-9]*[.])?[0-9]+\s+Z:[+-]?([0-9]*[.])?[0-9]+\s+E\d*:[+-]?([0-9]*[.])?[0-9]+).*",
|
||||
},
|
||||
{"name": "Suppress wait responses", "regex": r"Recv: wait"},
|
||||
{
|
||||
"name": "Suppress processing responses",
|
||||
@@ -719,11 +726,17 @@ class Settings:
|
||||
def sanity_check_folders(self, folders=None):
|
||||
if folders is None:
|
||||
folders = default_settings["folder"].keys()
|
||||
|
||||
folder_map = {}
|
||||
for folder in folders:
|
||||
self.getBaseFolder(
|
||||
folder, check_writable=True, deep_check_writable=True, log_error=True
|
||||
folder_map[folder] = self.getBaseFolder(
|
||||
folder, check_writable=True, deep_check_writable=True
|
||||
)
|
||||
|
||||
# validate uniqueness of folder paths
|
||||
if len(folder_map.values()) != len(set(folder_map.values())):
|
||||
raise DuplicateFolderPaths(folders)
|
||||
|
||||
def _get_default_folder(self, type):
|
||||
folder = default_settings["folder"][type]
|
||||
if folder is None:
|
||||
@@ -1010,7 +1023,6 @@ class Settings:
|
||||
|
||||
if migrate:
|
||||
self._migrate_config()
|
||||
self._validate_config()
|
||||
|
||||
self._forget_hashes()
|
||||
|
||||
@@ -1606,15 +1618,6 @@ class Settings:
|
||||
return True
|
||||
return False
|
||||
|
||||
def _validate_config(self):
|
||||
# validate uniqueness of folder paths
|
||||
folder_keys = self.get(["folder"], merged=True).keys()
|
||||
folders = {
|
||||
folder_key: self.getBaseFolder(folder_key) for folder_key in folder_keys
|
||||
}
|
||||
if len(folders.values()) != len(set(folders.values())):
|
||||
raise DuplicateFolderPaths(folders)
|
||||
|
||||
def backup(self, suffix=None, path=None, ext=None, hidden=False):
|
||||
import shutil
|
||||
|
||||
@@ -1876,7 +1879,6 @@ class Settings:
|
||||
type,
|
||||
create=True,
|
||||
allow_fallback=True,
|
||||
log_error=False,
|
||||
check_writable=True,
|
||||
deep_check_writable=False,
|
||||
):
|
||||
@@ -1897,23 +1899,20 @@ class Settings:
|
||||
create=create,
|
||||
check_writable=check_writable,
|
||||
deep_check_writable=deep_check_writable,
|
||||
log_error=log_error,
|
||||
)
|
||||
except Exception:
|
||||
if folder != default_folder and allow_fallback:
|
||||
if log_error:
|
||||
self._logger.error(
|
||||
"Invalid configured {} folder at {}, attempting to "
|
||||
"fall back on default folder at {}".format(
|
||||
type, folder, default_folder
|
||||
)
|
||||
self._logger.exception(
|
||||
"Invalid configured {} folder at {}, attempting to "
|
||||
"fall back on default folder at {}".format(
|
||||
type, folder, default_folder
|
||||
)
|
||||
)
|
||||
_validate_folder(
|
||||
default_folder,
|
||||
create=create,
|
||||
check_writable=check_writable,
|
||||
deep_check_writable=deep_check_writable,
|
||||
log_error=log_error,
|
||||
)
|
||||
folder = default_folder
|
||||
|
||||
@@ -2181,9 +2180,7 @@ def _default_basedir(applicationName):
|
||||
return os.path.expanduser(os.path.join("~", "." + applicationName.lower()))
|
||||
|
||||
|
||||
def _validate_folder(
|
||||
folder, create=True, check_writable=True, deep_check_writable=False, log_error=False
|
||||
):
|
||||
def _validate_folder(folder, create=True, check_writable=True, deep_check_writable=False):
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if not os.path.exists(folder):
|
||||
@@ -2196,8 +2193,7 @@ def _validate_folder(
|
||||
try:
|
||||
os.makedirs(folder)
|
||||
except Exception:
|
||||
if log_error:
|
||||
logger.exception(f"Could not create {folder}")
|
||||
logger.exception(f"Could not create {folder}")
|
||||
raise OSError(
|
||||
"Folder for type {} at {} does not exist and creation failed".format(
|
||||
type, folder
|
||||
@@ -2229,6 +2225,5 @@ def _validate_folder(
|
||||
f.write("test")
|
||||
os.remove(testfile)
|
||||
except Exception:
|
||||
if log_error:
|
||||
logger.exception(f"Could not write test file to {folder}")
|
||||
logger.exception(f"Could not write test file to {testfile}")
|
||||
raise OSError(error)
|
||||
@@ -18,6 +18,7 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) {
|
||||
self._lastProcessingTimesSize = 20;
|
||||
|
||||
self._safeModePopup = undefined;
|
||||
self._python2Popup = undefined;
|
||||
|
||||
self.increaseThrottle = function () {
|
||||
self.setThrottle(self._throttleFactor + 1);
|
||||
@@ -171,7 +172,10 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) {
|
||||
VERSION = data["version"];
|
||||
DISPLAY_VERSION = data["display_version"];
|
||||
BRANCH = data["branch"];
|
||||
PYTHON_VERSION = data["python_version"];
|
||||
|
||||
$("span.version").text(DISPLAY_VERSION);
|
||||
$("span.python_version").text(PYTHON_VERSION);
|
||||
|
||||
// update connectivity state
|
||||
ONLINE = data["online"];
|
||||
@@ -230,6 +234,22 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) {
|
||||
});
|
||||
}
|
||||
|
||||
// process python version
|
||||
if (self._python2Popup) self._python2Popup.remove();
|
||||
if (PYTHON_VERSION && PYTHON_VERSION.startsWith("2.")) {
|
||||
self._python2Popup = new PNotify({
|
||||
title: gettext("You are still running Python 2"),
|
||||
text: _.sprintf(
|
||||
gettext(
|
||||
"<p>Python 2 is end-of-life as of January 1st 2020. While OctoPrint currently still supports running under Python 2, a future version will remove support and require Python 3. You should upgrade as soon as possible!</p><p>Please refer to the FAQ for recommended update workflows:</p>"
|
||||
) +
|
||||
"<p><a href='https://faq.octoprint.org/python3-update' target='_blank' rel='noopener noreferer'>How to migrate to Python 3</a></p>",
|
||||
{reason: _.escape(reason)}
|
||||
),
|
||||
hide: false
|
||||
});
|
||||
}
|
||||
|
||||
// if the offline overlay is still showing, now's a good time to
|
||||
// hide it, plus reload the camera feed if it's currently displayed
|
||||
if ($("#offline_overlay").is(":visible")) {
|
||||
|
||||
@@ -42,7 +42,12 @@ $(function () {
|
||||
opera: false,
|
||||
|
||||
mobile: false,
|
||||
desktop: false
|
||||
desktop: false,
|
||||
|
||||
browser_name: "unknown",
|
||||
browser_version: "unknown",
|
||||
os_name: "unknown",
|
||||
os_version: "unknown"
|
||||
},
|
||||
viewmodels: {},
|
||||
startedUp: false
|
||||
@@ -118,6 +123,12 @@ $(function () {
|
||||
exports.browser.mobile = $.browser.mobile;
|
||||
exports.browser.desktop = !exports.browser.mobile;
|
||||
|
||||
var uap = UAParser();
|
||||
exports.browser.browser_name = uap.browser.name;
|
||||
exports.browser.browser_version = uap.browser.version;
|
||||
exports.browser.os_name = uap.os.name;
|
||||
exports.browser.os_version = uap.os.version;
|
||||
|
||||
if (exports.browser.safari) {
|
||||
$("html").addClass("safari");
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ $(function () {
|
||||
self.printerProfiles = parameters[4];
|
||||
self.access = parameters[5];
|
||||
|
||||
self.allViewModels = undefined;
|
||||
|
||||
self.filesListVisible = ko.observable(true);
|
||||
self.showInternalFilename = ko.observable(true);
|
||||
|
||||
@@ -629,13 +631,32 @@ $(function () {
|
||||
return;
|
||||
}
|
||||
|
||||
var proceed = function (p) {
|
||||
var prevented = false;
|
||||
var callback = function () {
|
||||
OctoPrint.files.select(data.origin, data.path, p);
|
||||
};
|
||||
|
||||
if (p) {
|
||||
callViewModels(self.allViewModels, "onBeforePrintStart", function (
|
||||
method
|
||||
) {
|
||||
prevented = prevented || method(callback) === false;
|
||||
});
|
||||
}
|
||||
|
||||
if (!prevented) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
if (
|
||||
printAfterLoad &&
|
||||
self.listHelper.isSelected(data) &&
|
||||
self.enablePrint(data)
|
||||
) {
|
||||
// file was already selected, just start the print job
|
||||
OctoPrint.job.start();
|
||||
self.printerState.print();
|
||||
} else {
|
||||
// select file, start print job (if requested and within dimensions)
|
||||
var withinPrintDimensions = self.evaluatePrintDimensions(data, true);
|
||||
@@ -650,12 +671,12 @@ $(function () {
|
||||
cancel: gettext("No"),
|
||||
proceed: gettext("Yes"),
|
||||
onproceed: function () {
|
||||
OctoPrint.files.select(data.origin, data.path, print);
|
||||
proceed(print);
|
||||
},
|
||||
nofade: true
|
||||
});
|
||||
} else {
|
||||
OctoPrint.files.select(data.origin, data.path, print);
|
||||
proceed(print);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -944,60 +965,72 @@ $(function () {
|
||||
self.getAdditionalData = function (data) {
|
||||
var output = "";
|
||||
if (data["gcodeAnalysis"]) {
|
||||
if (data["gcodeAnalysis"]["dimensions"]) {
|
||||
var dimensions = data["gcodeAnalysis"]["dimensions"];
|
||||
output +=
|
||||
gettext("Model size") +
|
||||
": " +
|
||||
_.sprintf(
|
||||
"%(width).2fmm × %(depth).2fmm × %(height).2fmm",
|
||||
dimensions
|
||||
);
|
||||
output += "<br>";
|
||||
}
|
||||
if (
|
||||
data["gcodeAnalysis"]["filament"] &&
|
||||
typeof data["gcodeAnalysis"]["filament"] === "object"
|
||||
data["gcodeAnalysis"]["_empty"] ||
|
||||
(data["gcodeAnalysis"]["dimensions"] &&
|
||||
data["gcodeAnalysis"]["dimensions"]["width"] === 0 &&
|
||||
data["gcodeAnalysis"]["dimensions"]["depth"] === 0 &&
|
||||
data["gcodeAnalysis"]["dimensions"]["height"] === 0)
|
||||
) {
|
||||
var filament = data["gcodeAnalysis"]["filament"];
|
||||
if (_.keys(filament).length === 1) {
|
||||
output += gettext("Model contains no extrusion.<br>");
|
||||
} else {
|
||||
if (data["gcodeAnalysis"]["dimensions"]) {
|
||||
var dimensions = data["gcodeAnalysis"]["dimensions"];
|
||||
output +=
|
||||
gettext("Filament") +
|
||||
gettext("Model size") +
|
||||
": " +
|
||||
formatFilament(
|
||||
data["gcodeAnalysis"]["filament"]["tool" + 0]
|
||||
) +
|
||||
"<br>";
|
||||
} else if (_.keys(filament).length > 1) {
|
||||
_.each(filament, function (f, k) {
|
||||
if (
|
||||
!_.startsWith(k, "tool") ||
|
||||
!f ||
|
||||
!f.hasOwnProperty("length") ||
|
||||
f["length"] <= 0
|
||||
)
|
||||
return;
|
||||
_.sprintf(
|
||||
"%(width).2fmm × %(depth).2fmm × %(height).2fmm",
|
||||
dimensions
|
||||
);
|
||||
output += "<br>";
|
||||
}
|
||||
if (
|
||||
data["gcodeAnalysis"]["filament"] &&
|
||||
typeof data["gcodeAnalysis"]["filament"] === "object"
|
||||
) {
|
||||
var filament = data["gcodeAnalysis"]["filament"];
|
||||
if (_.keys(filament).length === 1) {
|
||||
output +=
|
||||
gettext("Filament") +
|
||||
" (" +
|
||||
gettext("Tool") +
|
||||
" " +
|
||||
k.substr("tool".length) +
|
||||
"): " +
|
||||
formatFilament(f) +
|
||||
": " +
|
||||
formatFilament(
|
||||
data["gcodeAnalysis"]["filament"]["tool" + 0]
|
||||
) +
|
||||
"<br>";
|
||||
});
|
||||
} else if (_.keys(filament).length > 1) {
|
||||
_.each(filament, function (f, k) {
|
||||
if (
|
||||
!_.startsWith(k, "tool") ||
|
||||
!f ||
|
||||
!f.hasOwnProperty("length") ||
|
||||
f["length"] <= 0
|
||||
)
|
||||
return;
|
||||
output +=
|
||||
gettext("Filament") +
|
||||
" (" +
|
||||
gettext("Tool") +
|
||||
" " +
|
||||
k.substr("tool".length) +
|
||||
"): " +
|
||||
formatFilament(f) +
|
||||
"<br>";
|
||||
});
|
||||
}
|
||||
}
|
||||
output +=
|
||||
gettext("Estimated print time") +
|
||||
": " +
|
||||
(self.settingsViewModel.appearance_fuzzyTimes()
|
||||
? formatFuzzyPrintTime(
|
||||
data["gcodeAnalysis"]["estimatedPrintTime"]
|
||||
)
|
||||
: formatDuration(
|
||||
data["gcodeAnalysis"]["estimatedPrintTime"]
|
||||
)) +
|
||||
"<br>";
|
||||
}
|
||||
output +=
|
||||
gettext("Estimated print time") +
|
||||
": " +
|
||||
(self.settingsViewModel.appearance_fuzzyTimes()
|
||||
? formatFuzzyPrintTime(
|
||||
data["gcodeAnalysis"]["estimatedPrintTime"]
|
||||
)
|
||||
: formatDuration(data["gcodeAnalysis"]["estimatedPrintTime"])) +
|
||||
"<br>";
|
||||
}
|
||||
if (data["prints"] && data["prints"]["last"]) {
|
||||
output +=
|
||||
@@ -1707,6 +1740,9 @@ $(function () {
|
||||
self.settingsViewModel.settings.appearance.showInternalFilename()
|
||||
);
|
||||
};
|
||||
self.onAllBound = function (allViewModels) {
|
||||
self.allViewModels = allViewModels;
|
||||
};
|
||||
}
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
|
||||
@@ -6,6 +6,8 @@ $(function () {
|
||||
self.settings = parameters[1];
|
||||
self.access = parameters[2];
|
||||
|
||||
self.allViewModels = undefined;
|
||||
|
||||
self.stateString = ko.observable(undefined);
|
||||
self.errorString = ko.observable(undefined);
|
||||
self.hasErrorString = ko.pureComputed(function () {
|
||||
@@ -433,8 +435,25 @@ $(function () {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var proceed = function (p) {
|
||||
var prevented = false;
|
||||
var callback = function () {
|
||||
OctoPrint.job.start();
|
||||
};
|
||||
|
||||
callViewModels(self.allViewModels, "onBeforePrintStart", function (
|
||||
method
|
||||
) {
|
||||
prevented = prevented || method(callback) === false;
|
||||
});
|
||||
|
||||
if (!prevented) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
if (!self.settings.feature_printStartConfirmation()) {
|
||||
OctoPrint.job.start();
|
||||
proceed();
|
||||
} else {
|
||||
showConfirmationDialog({
|
||||
message: gettext(
|
||||
@@ -443,9 +462,7 @@ $(function () {
|
||||
question: gettext("Do you want to start the print job now?"),
|
||||
cancel: gettext("No"),
|
||||
proceed: gettext("Yes"),
|
||||
onproceed: function () {
|
||||
OctoPrint.job.start();
|
||||
},
|
||||
onproceed: proceed,
|
||||
nofade: true
|
||||
});
|
||||
}
|
||||
@@ -479,6 +496,10 @@ $(function () {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
self.onAllBound = function (allViewModels) {
|
||||
self.allViewModels = allViewModels;
|
||||
};
|
||||
}
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
|
||||
@@ -197,6 +197,7 @@ $(function () {
|
||||
self.serial_timeoutTemperatureAutoreport = ko.observable(undefined);
|
||||
self.serial_timeoutSdStatus = ko.observable(undefined);
|
||||
self.serial_timeoutSdStatusAutoreport = ko.observable(undefined);
|
||||
self.serial_timeoutPosAutoreport = ko.observable(undefined);
|
||||
self.serial_timeoutBaudrateDetectionPause = ko.observable(undefined);
|
||||
self.serial_timeoutPositionLogWait = ko.observable(undefined);
|
||||
self.serial_log = ko.observable(undefined);
|
||||
@@ -235,8 +236,10 @@ $(function () {
|
||||
self.serial_maxTimeoutsLong = ko.observable(undefined);
|
||||
self.serial_capAutoreportTemp = ko.observable(undefined);
|
||||
self.serial_capAutoreportSdStatus = ko.observable(undefined);
|
||||
self.serial_capAutoreportPos = ko.observable(undefined);
|
||||
self.serial_capBusyProtocol = ko.observable(undefined);
|
||||
self.serial_capEmergencyParser = ko.observable(undefined);
|
||||
self.serial_capExtendedM20 = ko.observable(undefined);
|
||||
self.serial_sendM112OnError = ko.observable(undefined);
|
||||
self.serial_disableSdPrintingDetection = ko.observable(undefined);
|
||||
self.serial_ackMax = ko.observable(undefined);
|
||||
|
||||
@@ -28,10 +28,21 @@ $(function () {
|
||||
action.actionSource = "core";
|
||||
actions.push(action);
|
||||
});
|
||||
if (response.custom && response.custom.length) {
|
||||
if (
|
||||
(response.custom && response.custom.length) ||
|
||||
(response.plugin && response.plugin.length)
|
||||
) {
|
||||
actions.push({action: "divider"});
|
||||
}
|
||||
}
|
||||
_.each(response.plugin, function (data) {
|
||||
var action = _.extend({}, data);
|
||||
action.actionSource = "plugin";
|
||||
actions.push(action);
|
||||
if (response.custom && response.custom.length) {
|
||||
actions.push({action: "divider"});
|
||||
}
|
||||
});
|
||||
_.each(response.custom, function (data) {
|
||||
var action = _.extend({}, data);
|
||||
action.actionSource = "custom";
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/* UAParser.js v0.7.28
|
||||
Copyright © 2012-2021 Faisal Salman <f@faisalman.com>
|
||||
MIT License */
|
||||
(function(window,undefined){"use strict";var LIBVERSION="0.7.28",EMPTY="",UNKNOWN="?",FUNC_TYPE="function",UNDEF_TYPE="undefined",OBJ_TYPE="object",STR_TYPE="string",MAJOR="major",MODEL="model",NAME="name",TYPE="type",VENDOR="vendor",VERSION="version",ARCHITECTURE="architecture",CONSOLE="console",MOBILE="mobile",TABLET="tablet",SMARTTV="smarttv",WEARABLE="wearable",EMBEDDED="embedded",UA_MAX_LENGTH=255;var AMAZON="Amazon",APPLE="Apple",ASUS="ASUS",BLACKBERRY="BlackBerry",BROWSER="Browser",CHROME="Chrome",EDGE="Edge",FIREFOX="Firefox",GOOGLE="Google",HUAWEI="Huawei",LG="LG",MICROSOFT="Microsoft",MOTOROLA="Motorola",OPERA="Opera",SAMSUNG="Samsung",SONY="Sony",XIAOMI="Xiaomi",ZEBRA="Zebra";var extend=function(regexes,extensions){var mergedRegexes={};for(var i in regexes){if(extensions[i]&&extensions[i].length%2===0){mergedRegexes[i]=extensions[i].concat(regexes[i])}else{mergedRegexes[i]=regexes[i]}}return mergedRegexes},enumerize=function(arr){var enums={};for(var i in arr){enums[arr[i].toUpperCase()]=arr[i]}return enums},has=function(str1,str2){return typeof str1===STR_TYPE?lowerize(str2).indexOf(lowerize(str1))!==-1:false},lowerize=function(str){return str.toLowerCase()},majorize=function(version){return typeof version===STR_TYPE?version.replace(/[^\d\.]/g,EMPTY).split(".")[0]:undefined},trim=function(str,len){if(typeof str===STR_TYPE){str=str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,EMPTY);return typeof len===UNDEF_TYPE?str:str.substring(0,UA_MAX_LENGTH)}};var rgxMapper=function(ua,arrays){var i=0,j,k,p,q,matches,match;while(i<arrays.length&&!matches){var regex=arrays[i],props=arrays[i+1];j=k=0;while(j<regex.length&&!matches){matches=regex[j++].exec(ua);if(!!matches){for(p=0;p<props.length;p++){match=matches[++k];q=props[p];if(typeof q===OBJ_TYPE&&q.length>0){if(q.length==2){if(typeof q[1]==FUNC_TYPE){this[q[0]]=q[1].call(this,match)}else{this[q[0]]=q[1]}}else if(q.length==3){if(typeof q[1]===FUNC_TYPE&&!(q[1].exec&&q[1].test)){this[q[0]]=match?q[1].call(this,match,q[2]):undefined}else{this[q[0]]=match?match.replace(q[1],q[2]):undefined}}else if(q.length==4){this[q[0]]=match?q[3].call(this,match.replace(q[1],q[2])):undefined}}else{this[q]=match?match:undefined}}}}i+=2}},strMapper=function(str,map){for(var i in map){if(typeof map[i]===OBJ_TYPE&&map[i].length>0){for(var j=0;j<map[i].length;j++){if(has(map[i][j],str)){return i===UNKNOWN?undefined:i}}}else if(has(map[i],str)){return i===UNKNOWN?undefined:i}}return str};var oldSafariMap={"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"},windowsVersionMap={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"};var regexes={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[VERSION,[NAME,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[VERSION,[NAME,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[NAME,VERSION],[/opios[\/ ]+([\w\.]+)/i],[VERSION,[NAME,OPERA+" Mini"]],[/\bopr\/([\w\.]+)/i],[VERSION,[NAME,OPERA]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i,/(ba?idubrowser)[\/ ]?([\w\.]+)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale|qqbrowserlite|qq)\/([-\w\.]+)/i,/(weibo)__([\d\.]+)/i],[NAME,VERSION],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[VERSION,[NAME,"UC"+BROWSER]],[/\bqbcore\/([\w\.]+)/i],[VERSION,[NAME,"WeChat(Win) Desktop"]],[/micromessenger\/([\w\.]+)/i],[VERSION,[NAME,"WeChat"]],[/konqueror\/([\w\.]+)/i],[VERSION,[NAME,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[VERSION,[NAME,"IE"]],[/yabrowser\/([\w\.]+)/i],[VERSION,[NAME,"Yandex"]],[/(avast|avg)\/([\w\.]+)/i],[[NAME,/(.+)/,"$1 Secure "+BROWSER],VERSION],[/\bfocus\/([\w\.]+)/i],[VERSION,[NAME,FIREFOX+" Focus"]],[/\bopt\/([\w\.]+)/i],[VERSION,[NAME,OPERA+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[VERSION,[NAME,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[VERSION,[NAME,"Dolphin"]],[/coast\/([\w\.]+)/i],[VERSION,[NAME,OPERA+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[VERSION,[NAME,"MIUI "+BROWSER]],[/fxios\/([-\w\.]+)/i],[VERSION,[NAME,FIREFOX]],[/\bqihu|(qi?ho?o?|360)browser/i],[[NAME,"360 "+BROWSER]],[/(oculus|samsung|sailfish)browser\/([\w\.]+)/i],[[NAME,/(.+)/,"$1 "+BROWSER],VERSION],[/(comodo_dragon)\/([\w\.]+)/i],[[NAME,/_/g," "],VERSION],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i],[NAME,VERSION],[/(metasr)[\/ ]?([\w\.]+)/i,/(lbbrowser)/i],[NAME],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[NAME,"Facebook"],VERSION],[/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(chromium|instagram)[\/ ]([-\w\.]+)/i],[NAME,VERSLine truncated
|
||||
@@ -1,13 +1,19 @@
|
||||
<h3>{{ _('System Information') }}</h3>
|
||||
|
||||
<p>{% trans %}Please copy/paste the following when requesting support on the forums or
|
||||
<p>{% trans %}Please always share a Systeminfo Bundle when requesting support on the forums or
|
||||
when opening a new bug report:{% endtrans %}</p>
|
||||
|
||||
<p data-bind="foreach: systeminfo">
|
||||
<strong data-bind="text: key"></strong>: <span data-bind="text: value"></span><br />
|
||||
</p>
|
||||
<p><a href="{{ url_for('index', _external=True) }}downloads/systeminfo.zip" class="btn btn-primary"><i class="fas fa-download"></i> {{ _('Download Systeminfo Bundle') }}</a></p>
|
||||
|
||||
<p>{% trans %}You can view Systeminfo Bundles at <a href="https://bundleviewer.octoprint.org" target="_blank" rel="noopener noreferrer">bundleviewer.octoprint.org</a>{% endtrans %}</p>
|
||||
|
||||
<a href="{{ url_for('index', _external=True) }}downloads/systeminfo.zip" class="btn btn-primary"><i class="fas fa-download"></i> {{ _('Download Systeminfo Bundle') }}</a>
|
||||
<div class="more">
|
||||
<div><small><a href="javascript:void(0)" class="muted" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', parent: '.more', container: '.hide' }"><i class="fas fa-caret-right"></i> {{ _('More') }}</a></small></div>
|
||||
<div class="hide">
|
||||
<p data-bind="foreach: systeminfo">
|
||||
<strong data-bind="text: key"></strong>: <span data-bind="text: value"></span><br />
|
||||
</p>
|
||||
|
||||
<a href="javascript:void(0)" class="btn" data-bind="click: copySystemInfo"><i class="far fa-copy"></i> {{ _('Copy') }}</a>
|
||||
<a href="javascript:void(0)" class="btn" data-bind="click: copySystemInfo"><i class="far fa-copy"></i> {{ _('Copy') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -55,7 +55,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="settings_dialog_update_detected" class="modal hide fade" data-keyboard="false">
|
||||
<div id="settings_dialog_update_detected" class="modal hide fade-in" data-keyboard="false">
|
||||
<div class="modal-header">
|
||||
<h3>{{ _('Settings update detected') }}</h3>
|
||||
</div>
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: feature_g90InfluencesExtruder" id="settings-g90InfluencesExtruder">
|
||||
{{ _('<code>G90</code>/<code>G91</code> overrides relative extruder mode') }} <span class="label">{{ _('Smoothieware') }}</span> <span class="label">{{ _('Marlin 2+') }}
|
||||
{{ _('<code>G90</code>/<code>G91</code> overrides relative extruder mode') }} <span class="label">{{ _('Smoothieware') }}</span> <span class="label">{{ _('Marlin 2+') }} </span>
|
||||
<span class="help-block">{{ _('This is used by the GCODE analysis in the backend and the viewer in the frontend to interpret your sliced files correctly.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@@ -155,6 +155,16 @@
|
||||
<span class="help-inline">{{ _('Autoreport interval to request from firmware')}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Position interval to request from autoreport capable firmwares. A value of 0 disables autoreporting by the firmware.')|edq }}">
|
||||
<label class="control-label" for="settings-serialTimeoutPosAutoreport">{{ _('Position autoreport interval') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutPosAutoreport" id="settings-serialTimeoutPosAutoreport">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
<span class="help-inline">{{ _('Autoreport interval to request from firmware')}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset id="settings_serial_timeouts_timeouts">
|
||||
<legend>{{ _('Timeouts') }}</legend>
|
||||
@@ -351,6 +361,13 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_capAutoreportPos" id="settings-serialCapAutoreportPos"> {{ _('Support position autoreporting by firmware, if detected') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
@@ -365,6 +382,13 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_capExtendedM20" id="settings-serialCapExtendedM20"> {{ _('Send <code>M20 L</code> instead of <code>M20</code> to use extended SD file lists, if detected as supported by the firmware') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
var VERSION = "{{ version.number|e }}";
|
||||
var DISPLAY_VERSION = "{{ version.display|e }}";
|
||||
var BRANCH = "{{ version.branch|e }}";
|
||||
var PYTHON_VERSION = "{{ python_version|e }}";
|
||||
var LOCALE = "{{ g.locale|e }}";
|
||||
var AVAILABLE_LOCALES = {{ locales|tojson }};
|
||||
var SUPPORTED_FILETYPES = {{ supportedFiletypes|tojson }};
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
<ul class="nav nav-list">
|
||||
<li class="nav-header">{{ _('Navigation') }}</li>
|
||||
<li><a href="#system-commands">{{ _('System commands') }}</a></li>
|
||||
<li><a href="#system-info">{{ _('System info') }}</a></li>
|
||||
<li><a href="#system-info">{{ _('System info bundle') }}</a></li>
|
||||
<li data-bind="visible: printerConnected"><a href="#printer-control">{{ _('Printer control') }}</a></li>
|
||||
<li data-bind="visible: backupSupported"><a href="#backups">{{ _('Backups') }}</a></li>
|
||||
</ul>
|
||||
@@ -78,12 +78,8 @@
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 2em">
|
||||
<h1 id="system-info">{{ _('System info') }}</h1>
|
||||
<p data-bind="foreach: systemInfo">
|
||||
<strong data-bind="text: key"></strong>: <span data-bind="text: value"></span><br />
|
||||
</p>
|
||||
<a href="{{ url_for('index', _external=True) }}downloads/systeminfo.zip" class="btn btn-primary"><i class="fas fa-download"></i> {{ _('Download Systeminfo Bundle') }}</a>
|
||||
<a href="javascript:void(0)" class="btn" data-bind="click: copySystemInfo"><i class="far fa-copy"></i> {{ _('Copy') }}</a>
|
||||
<h1 id="system-info">{{ _('System info bundle') }}</h1>
|
||||
<a href="{{ url_for('index', _external=True) }}downloads/systeminfo.zip" target="_blank" class="btn btn-primary"><i class="fas fa-download"></i> {{ _('Download Systeminfo Bundle') }}</a>
|
||||
</div>
|
||||
|
||||
<div data-bind="visible: printerConnected" style="margin-bottom: 2em">
|
||||
@@ -98,10 +94,10 @@
|
||||
|
||||
<h2>{{ _('Create backup') }}</h2>
|
||||
<form class="form-horizontal" onsubmit="return false;">
|
||||
<div class="control-group">
|
||||
<div class="control-group" title="{{ _('All files in the uploads folder and subfolders. These are the files in the Files List, plus any metadata that has been generated for those files.')|edq }}">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="value: 'uploads', checked: excludeFromBackup"> {{ _('Exclude uploaded files & metadata from backup') }}
|
||||
<input type="checkbox" data-bind="value: 'uploads', checked: excludeFromBackup"> {{ _('Exclude uploaded files (& associated metadata) from backup') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Number of Extruders') }}</label>
|
||||
<div class="controls">
|
||||
<input type="number" class="input-mini text-right" min="1" max="10" data-bind="value: extruders">
|
||||
<input type="number" class="input-mini text-right" min="1" data-bind="value: extruders">
|
||||
<span class="help-block">{{ _('Make sure to specify number of extruders available on your printer or you might run into issues') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1142,6 +1142,9 @@ class TimelapseRenderJob:
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
### Not all players can handle non-mpeg2 in VOB format
|
||||
if not videocodec:
|
||||
videocodec = "libx264"
|
||||
|
||||
if videocodec == "mpeg2video":
|
||||
containerformat = "vob"
|
||||
else:
|
||||
@@ -1152,14 +1155,16 @@ class TimelapseRenderJob:
|
||||
)
|
||||
placeholders = {
|
||||
"ffmpeg": ffmpeg,
|
||||
"fps": str(fps),
|
||||
"fps": str(fps if fps else "25"),
|
||||
"input": input,
|
||||
"output": output,
|
||||
"videocodec": videocodec,
|
||||
"threads": str(threads),
|
||||
"bitrate": str(bitrate),
|
||||
"threads": str(threads if threads else "1"),
|
||||
"bitrate": str(bitrate if bitrate else "10000k"),
|
||||
"containerformat": containerformat,
|
||||
"filters": "-vf " + sarge.shell_quote(filter_string) if filter_string else "",
|
||||
"filters": ("-vf " + sarge.shell_quote(filter_string))
|
||||
if filter_string
|
||||
else "",
|
||||
}
|
||||
|
||||
logger.debug(f"Rendering movie to {output}")
|
||||
|
||||
@@ -737,7 +737,7 @@ msgstr "Erstelle eine neue Sicherung des aktuellen Stands."
|
||||
|
||||
#: src/octoprint/plugins/backup/templates/backup_settings.jinja2:85
|
||||
#: src/octoprint/templates/recovery.jinja2:104
|
||||
msgid "Exclude uploaded files & metadata from backup"
|
||||
msgid "Exclude uploaded files (& associated metadata) from backup"
|
||||
msgstr "Uploads & metadata nicht sichern"
|
||||
|
||||
#: src/octoprint/plugins/backup/templates/backup_settings.jinja2:93
|
||||
|
||||
@@ -3,6 +3,7 @@ This module bundles commonly used utility methods or helper classes that are use
|
||||
OctoPrint's source code.
|
||||
"""
|
||||
|
||||
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
|
||||
|
||||
+121
-49
@@ -452,9 +452,11 @@ class MachineCom:
|
||||
|
||||
CAPABILITY_AUTOREPORT_TEMP = "AUTOREPORT_TEMP"
|
||||
CAPABILITY_AUTOREPORT_SD_STATUS = "AUTOREPORT_SD_STATUS"
|
||||
CAPABILITY_AUTOREPORT_POS = "AUTOREPORT_POS"
|
||||
CAPABILITY_BUSY_PROTOCOL = "BUSY_PROTOCOL"
|
||||
CAPABILITY_EMERGENCY_PARSER = "EMERGENCY_PARSER"
|
||||
CAPABILITY_CHAMBER_TEMP = "CHAMBER_TEMPERATURE"
|
||||
CAPABILITY_EXTENDED_M20 = "EXTENDED_M20"
|
||||
|
||||
CAPABILITY_SUPPORT_ENABLED = "enabled"
|
||||
CAPABILITY_SUPPORT_DETECTED = "detected"
|
||||
@@ -565,6 +567,9 @@ class MachineCom:
|
||||
self.CAPABILITY_AUTOREPORT_SD_STATUS: settings().getBoolean(
|
||||
["serial", "capabilities", "autoreport_sdstatus"]
|
||||
),
|
||||
self.CAPABILITY_AUTOREPORT_POS: settings().getBoolean(
|
||||
["serial", "capabilities", "autoreport_pos"]
|
||||
),
|
||||
self.CAPABILITY_BUSY_PROTOCOL: settings().getBoolean(
|
||||
["serial", "capabilities", "busy_protocol"]
|
||||
),
|
||||
@@ -574,6 +579,9 @@ class MachineCom:
|
||||
self.CAPABILITY_CHAMBER_TEMP: settings().getBoolean(
|
||||
["serial", "capabilities", "chamber_temp"]
|
||||
),
|
||||
self.CAPABILITY_EXTENDED_M20: settings().getBoolean(
|
||||
["serial", "capabilities", "extended_m20"]
|
||||
),
|
||||
}
|
||||
|
||||
last_line_count = settings().getInt(["serial", "lastLineBufferSize"])
|
||||
@@ -597,6 +605,7 @@ class MachineCom:
|
||||
|
||||
self._temperature_autoreporting = False
|
||||
self._sdstatus_autoreporting = False
|
||||
self._pos_autoreporting = False
|
||||
self._busy_protocol_detected = False
|
||||
self._busy_protocol_support = False
|
||||
|
||||
@@ -1633,6 +1642,14 @@ class MachineCom:
|
||||
tags=None,
|
||||
external_sd=False,
|
||||
):
|
||||
cancel_tags = {"trigger:comm.cancel", "trigger:cancel"}
|
||||
abort_heatup_tags = cancel_tags | {
|
||||
"trigger:abort_heatup",
|
||||
}
|
||||
record_position_tags = cancel_tags | {
|
||||
"trigger:record_position",
|
||||
}
|
||||
|
||||
if tags is None:
|
||||
tags = set()
|
||||
|
||||
@@ -1657,42 +1674,47 @@ class MachineCom:
|
||||
self.cancelFileTransfer()
|
||||
return
|
||||
|
||||
def _on_M400_sent():
|
||||
# we don't call on_print_job_cancelled on our callback here
|
||||
# because we do this only after our M114 has been answered
|
||||
# by the firmware
|
||||
self._record_cancel_data = True
|
||||
|
||||
with self._cancel_mutex:
|
||||
if self._cancel_position_timer is not None:
|
||||
self._cancel_position_timer.cancel()
|
||||
self._cancel_position_timer = ResettableTimer(
|
||||
self._timeout_intervals.get("positionLogWait", 10.0),
|
||||
self._cancel_preparation_failed,
|
||||
)
|
||||
self._cancel_position_timer.daemon = True
|
||||
self._cancel_position_timer.start()
|
||||
self.sendCommand(
|
||||
"M114",
|
||||
part_of_job=True,
|
||||
tags=tags
|
||||
| {"trigger:comm.cancel", "trigger:cancel", "trigger:record_position"},
|
||||
)
|
||||
|
||||
self._callback.on_comm_print_job_cancelling(
|
||||
firmware_error=firmware_error, user=user
|
||||
)
|
||||
|
||||
with self._jobLock:
|
||||
pos_autoreporting = self._pos_autoreporting
|
||||
|
||||
self._changeState(self.STATE_CANCELLING)
|
||||
|
||||
def _reenable_pos_autoreport():
|
||||
if pos_autoreporting:
|
||||
self._set_autoreport_pos_interval(tags=record_position_tags)
|
||||
|
||||
def _on_M400_sent():
|
||||
# we don't call on_print_job_cancelled on our callback here
|
||||
# because we do this only after our M114 has been answered
|
||||
# by the firmware
|
||||
self._record_cancel_data = True
|
||||
|
||||
with self._cancel_mutex:
|
||||
if self._cancel_position_timer is not None:
|
||||
self._cancel_position_timer.cancel()
|
||||
self._cancel_position_timer = ResettableTimer(
|
||||
self._timeout_intervals.get("positionLogWait", 10.0),
|
||||
self._cancel_preparation_failed,
|
||||
)
|
||||
self._cancel_position_timer.daemon = True
|
||||
self._cancel_position_timer.start()
|
||||
self.sendCommand(
|
||||
"M114",
|
||||
on_sent=_reenable_pos_autoreport,
|
||||
part_of_job=True,
|
||||
tags=tags | record_position_tags,
|
||||
)
|
||||
|
||||
if self._abort_heatup_on_cancel:
|
||||
# abort any ongoing heatups immediately to get back control over the printer
|
||||
self.sendCommand(
|
||||
"M108",
|
||||
part_of_job=False,
|
||||
tags=tags
|
||||
| {"trigger:comm.cancel", "trigger:cancel", "trigger:abort_heatup"},
|
||||
tags=tags | abort_heatup_tags,
|
||||
force=True,
|
||||
)
|
||||
|
||||
@@ -1701,33 +1723,35 @@ class MachineCom:
|
||||
self.sendCommand(
|
||||
"M25",
|
||||
part_of_job=True,
|
||||
tags=tags | {"trigger:comm.cancel", "trigger:cancel"},
|
||||
tags=tags | cancel_tags,
|
||||
) # pause print
|
||||
self.sendCommand(
|
||||
"M27",
|
||||
part_of_job=True,
|
||||
tags=tags | {"trigger:comm.cancel", "trigger:cancel"},
|
||||
tags=tags | cancel_tags,
|
||||
) # get current byte position in file
|
||||
self.sendCommand(
|
||||
"M26 S0",
|
||||
part_of_job=True,
|
||||
tags=tags | {"trigger:comm.cancel", "trigger:cancel"},
|
||||
tags=tags | cancel_tags,
|
||||
) # reset position in file to byte 0
|
||||
|
||||
if self._log_position_on_cancel and not disable_log_position:
|
||||
with self._action_users_mutex:
|
||||
self._action_users["cancel"] = user
|
||||
|
||||
# disable position autoreporting if enabled
|
||||
if pos_autoreporting:
|
||||
self._set_autoreport_pos_interval(
|
||||
interval=0,
|
||||
part_of_job=True,
|
||||
tags=tags | record_position_tags,
|
||||
)
|
||||
self.sendCommand(
|
||||
"M400",
|
||||
on_sent=_on_M400_sent,
|
||||
part_of_job=True,
|
||||
tags=tags
|
||||
| {
|
||||
"trigger:comm.cancel",
|
||||
"trigger:cancel",
|
||||
"trigger:record_position",
|
||||
},
|
||||
tags=tags | record_position_tags,
|
||||
)
|
||||
self._continue_sending()
|
||||
else:
|
||||
@@ -1777,6 +1801,12 @@ class MachineCom:
|
||||
if not self._currentFile:
|
||||
return
|
||||
|
||||
pause_tags = {"trigger:comm.set_pause", "trigger:pause"}
|
||||
resume_tags = {"trigger:comm.set_pause", "trigger:resume"}
|
||||
record_position_tags = pause_tags | {
|
||||
"trigger:record_position",
|
||||
}
|
||||
|
||||
if tags is None:
|
||||
tags = set()
|
||||
|
||||
@@ -1800,6 +1830,7 @@ class MachineCom:
|
||||
return
|
||||
|
||||
with self._jobLock:
|
||||
pos_autoreporting = self._pos_autoreporting
|
||||
if not pause and self._state in valid_paused_states:
|
||||
if self._pauseWaitStartTime:
|
||||
self._pauseWaitTimeLost = self._pauseWaitTimeLost + (
|
||||
@@ -1817,12 +1848,12 @@ class MachineCom:
|
||||
self.sendCommand(
|
||||
"M24",
|
||||
part_of_job=True,
|
||||
tags=tags | {"trigger:comm.set_pause", "trigger:resume"},
|
||||
tags=tags | resume_tags,
|
||||
)
|
||||
self.sendCommand(
|
||||
"M27",
|
||||
part_of_job=True,
|
||||
tags=tags | {"trigger:comm.set_pause", "trigger:resume"},
|
||||
tags=tags | resume_tags,
|
||||
)
|
||||
|
||||
def finalize():
|
||||
@@ -1843,9 +1874,13 @@ class MachineCom:
|
||||
self.sendCommand(
|
||||
"M25",
|
||||
part_of_job=True,
|
||||
tags=tags | {"trigger:comm.set_pause", "trigger:pause"},
|
||||
tags=tags | pause_tags,
|
||||
) # pause print
|
||||
|
||||
def _reenable_pos_autoreport():
|
||||
if pos_autoreporting:
|
||||
self._set_autoreport_pos_interval(tags=record_position_tags)
|
||||
|
||||
def _on_M400_sent():
|
||||
# we don't call on_print_job_paused on our callback here
|
||||
# because we do this only after our M114 has been answered
|
||||
@@ -1864,29 +1899,27 @@ class MachineCom:
|
||||
self._pause_position_timer.start()
|
||||
self.sendCommand(
|
||||
"M114",
|
||||
on_sent=_reenable_pos_autoreport,
|
||||
part_of_job=True,
|
||||
tags=tags
|
||||
| {
|
||||
"trigger:comm.set_pause",
|
||||
"trigger:pause",
|
||||
"trigger:record_position",
|
||||
},
|
||||
tags=tags | record_position_tags,
|
||||
)
|
||||
|
||||
if self._log_position_on_pause and local_handling:
|
||||
with self._action_users_mutex:
|
||||
self._action_users["pause"] = user
|
||||
|
||||
# disable position autoreporting if enabled
|
||||
if pos_autoreporting:
|
||||
self._set_autoreport_pos_interval(
|
||||
interval=0,
|
||||
part_of_job=True,
|
||||
tags=tags | record_position_tags,
|
||||
)
|
||||
self.sendCommand(
|
||||
"M400",
|
||||
on_sent=_on_M400_sent,
|
||||
part_of_job=True,
|
||||
tags=tags
|
||||
| {
|
||||
"trigger:comm.set_pause",
|
||||
"trigger:pause",
|
||||
"trigger:record_position",
|
||||
},
|
||||
tags=tags | record_position_tags,
|
||||
)
|
||||
self._continue_sending()
|
||||
else:
|
||||
@@ -1933,8 +1966,13 @@ class MachineCom:
|
||||
if tags is None:
|
||||
tags = set()
|
||||
|
||||
if self._capability_supported(self.CAPABILITY_EXTENDED_M20):
|
||||
command = "M20 L"
|
||||
else:
|
||||
command = "M20"
|
||||
|
||||
self.sendCommand(
|
||||
"M20",
|
||||
command,
|
||||
tags=tags
|
||||
| {
|
||||
"trigger:comm.refresh_sd_files",
|
||||
@@ -2370,6 +2408,9 @@ class MachineCom:
|
||||
filename = filename.lower()
|
||||
self._sdFiles.append((filename, size))
|
||||
if longname is not None:
|
||||
if longname[0] == '"' and longname[-1] == '"':
|
||||
# apparently some firmwares enclose the long name in quotes...
|
||||
longname = longname[1:-1]
|
||||
self._sdFilesMap[filename] = longname
|
||||
continue
|
||||
|
||||
@@ -2715,6 +2756,11 @@ class MachineCom:
|
||||
"Firmware states that it supports sd status autoreporting"
|
||||
)
|
||||
self._set_autoreport_sdstatus_interval()
|
||||
elif capability == self.CAPABILITY_AUTOREPORT_POS and enabled:
|
||||
self._logger.info(
|
||||
"Firmware states that it supports position autoreporting"
|
||||
)
|
||||
self._set_autoreport_pos_interval()
|
||||
elif (
|
||||
capability == self.CAPABILITY_EMERGENCY_PARSER and enabled
|
||||
):
|
||||
@@ -3443,6 +3489,20 @@ class MachineCom:
|
||||
tags={"trigger:comm.set_autoreport_sdstatus_interval"},
|
||||
)
|
||||
|
||||
def _set_autoreport_pos_interval(self, interval=None, part_of_job=False, tags=None):
|
||||
if tags is None:
|
||||
tags = set()
|
||||
if interval is None:
|
||||
try:
|
||||
interval = int(self._timeout_intervals.get("posAutoreport", 5))
|
||||
except Exception:
|
||||
interval = 5
|
||||
self.sendCommand(
|
||||
f"M154 S{interval}",
|
||||
part_of_job=part_of_job,
|
||||
tags=tags | {"trigger:comm.set_autoreport_pos_interval"},
|
||||
)
|
||||
|
||||
def _set_busy_protocol_interval(self, interval=None, callback=None):
|
||||
if interval is None:
|
||||
try:
|
||||
@@ -3515,6 +3575,8 @@ class MachineCom:
|
||||
self._set_autoreport_temperature_interval()
|
||||
if self._sdstatus_autoreporting:
|
||||
self._set_autoreport_sdstatus_interval()
|
||||
if self._pos_autoreporting:
|
||||
self._set_autoreport_pos_interval()
|
||||
if self._busy_protocol_support:
|
||||
self._set_busy_protocol_interval()
|
||||
|
||||
@@ -5104,6 +5166,16 @@ class MachineCom:
|
||||
self.CAPABILITY_AUTOREPORT_SD_STATUS, False
|
||||
) and (interval > 0)
|
||||
|
||||
def _gcode_M154_sending(
|
||||
self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs
|
||||
):
|
||||
match = regexes_parameters["intS"].search(cmd)
|
||||
if match:
|
||||
interval = int(match.group("value"))
|
||||
self._pos_autoreporting = self._firmware_capabilities.get(
|
||||
self.CAPABILITY_AUTOREPORT_SD_STATUS, False
|
||||
) and (interval > 0)
|
||||
|
||||
def _gcode_M33_sending(
|
||||
self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs
|
||||
):
|
||||
|
||||
@@ -224,7 +224,7 @@ class gcode:
|
||||
self._layers = []
|
||||
self._current_layer = None
|
||||
|
||||
def _track_layer(self, pos):
|
||||
def _track_layer(self, pos, arc=None):
|
||||
if not self._incl_layers:
|
||||
return
|
||||
|
||||
@@ -234,6 +234,14 @@ class gcode:
|
||||
|
||||
elif self._current_layer:
|
||||
self._current_layer["minmax"].record(pos)
|
||||
if arc is not None:
|
||||
self._addArcMinMax(
|
||||
self._current_layer["minmax"],
|
||||
arc["startAngle"],
|
||||
arc["endAngle"],
|
||||
arc["center"],
|
||||
arc["radius"],
|
||||
)
|
||||
|
||||
def _track_command(self):
|
||||
if self._current_layer:
|
||||
@@ -489,6 +497,117 @@ class gcode:
|
||||
if e:
|
||||
self._track_layer(pos)
|
||||
|
||||
if gcode in ("G2", "G3"): # Arc Move
|
||||
x = getCodeFloat(line, "X")
|
||||
y = getCodeFloat(line, "Y")
|
||||
z = getCodeFloat(line, "Z")
|
||||
e = getCodeFloat(line, "E")
|
||||
i = getCodeFloat(line, "I")
|
||||
j = getCodeFloat(line, "J")
|
||||
r = getCodeFloat(line, "R")
|
||||
f = getCodeFloat(line, "F")
|
||||
|
||||
# this is a move or print head stays on position
|
||||
move = (
|
||||
x is not None
|
||||
or y is not None
|
||||
or z is not None
|
||||
or i is not None
|
||||
or j is not None
|
||||
or r is not None
|
||||
)
|
||||
|
||||
oldPos = pos
|
||||
|
||||
# Use new coordinates if provided. If not provided, use prior coordinates (minus tool offset)
|
||||
# in absolute and 0.0 in relative mode.
|
||||
newPos = Vector3D(
|
||||
x * scale if x is not None else (0.0 if relativeMode else pos.x),
|
||||
y * scale if y is not None else (0.0 if relativeMode else pos.y),
|
||||
z * scale if z is not None else (0.0 if relativeMode else pos.z),
|
||||
)
|
||||
|
||||
if relativeMode:
|
||||
# Relative mode: add to current position
|
||||
pos += newPos
|
||||
else:
|
||||
# Absolute mode: apply tool offsets
|
||||
pos = newPos
|
||||
|
||||
if f is not None and f != 0:
|
||||
feedrate = f
|
||||
|
||||
# get radius and offset
|
||||
i = 0 if i is None else i
|
||||
j = 0 if j is None else j
|
||||
r = math.sqrt(i * i + j * j) if r is None else r
|
||||
|
||||
# calculate angles
|
||||
centerArc = Vector3D(oldPos.x + i, oldPos.y + j, oldPos.z)
|
||||
startAngle = math.atan2(oldPos.y - centerArc.y, oldPos.x - centerArc.x)
|
||||
endAngle = math.atan2(pos.y - centerArc.y, pos.x - centerArc.x)
|
||||
|
||||
if gcode == "G2":
|
||||
startAngle, endAngle = endAngle, startAngle
|
||||
if startAngle < 0:
|
||||
startAngle += math.pi * 2
|
||||
if endAngle < 0:
|
||||
endAngle += math.pi * 2
|
||||
|
||||
# from now on we only think in counter-clockwise direction
|
||||
|
||||
if e is not None:
|
||||
if relativeMode or relativeE:
|
||||
# e is already relative, nothing to do
|
||||
pass
|
||||
else:
|
||||
e -= currentE[currentExtruder]
|
||||
|
||||
# If move with extrusion, calculate new min/max coordinates of model
|
||||
if e > 0 and move:
|
||||
# extrusion and move -> oldPos & pos relevant for print area & dimensions
|
||||
self._minMax.record(oldPos)
|
||||
self._minMax.record(pos)
|
||||
self._addArcMinMax(
|
||||
self._minMax, startAngle, endAngle, centerArc, r
|
||||
)
|
||||
|
||||
totalExtrusion[currentExtruder] += e
|
||||
currentE[currentExtruder] += e
|
||||
maxExtrusion[currentExtruder] = max(
|
||||
maxExtrusion[currentExtruder], totalExtrusion[currentExtruder]
|
||||
)
|
||||
|
||||
if currentExtruder == 0 and len(currentE) > 1 and duplicationMode:
|
||||
# Copy first extruder length to other extruders
|
||||
for i in range(1, len(currentE)):
|
||||
totalExtrusion[i] += e
|
||||
currentE[i] += e
|
||||
maxExtrusion[i] = max(maxExtrusion[i], totalExtrusion[i])
|
||||
else:
|
||||
e = 0
|
||||
|
||||
# move time in x, y, z, will be 0 if no movement happened
|
||||
moveTimeXYZ = abs((oldPos - pos).length / feedrate)
|
||||
|
||||
# time needed for extruding, will be 0 if no extrusion happened
|
||||
extrudeTime = abs(e / feedrate)
|
||||
|
||||
# time to add is maximum of both
|
||||
totalMoveTimeMinute += max(moveTimeXYZ, extrudeTime)
|
||||
|
||||
# process layers if there's extrusion
|
||||
if e:
|
||||
self._track_layer(
|
||||
pos,
|
||||
{
|
||||
"startAngle": startAngle,
|
||||
"endAngle": endAngle,
|
||||
"center": centerArc,
|
||||
"radius": r,
|
||||
},
|
||||
)
|
||||
|
||||
elif gcode == "G4": # Delay
|
||||
S = getCodeFloat(line, "S")
|
||||
if S is not None:
|
||||
@@ -642,6 +761,30 @@ class gcode:
|
||||
)
|
||||
}
|
||||
|
||||
def _intersectsAngle(self, start, end, angle):
|
||||
if end < start and angle == 0:
|
||||
# angle crosses 0 degrees
|
||||
return True
|
||||
else:
|
||||
return start <= angle <= end
|
||||
|
||||
def _addArcMinMax(self, minmax, startAngle, endAngle, centerArc, radius):
|
||||
startDeg = math.degrees(startAngle)
|
||||
endDeg = math.degrees(endAngle)
|
||||
|
||||
if self._intersectsAngle(startDeg, endDeg, 0):
|
||||
# arc crosses positive x
|
||||
minmax.max.x = max(minmax.max.x, centerArc.x + radius)
|
||||
if self._intersectsAngle(startDeg, endDeg, 90):
|
||||
# arc crosses positive y
|
||||
minmax.max.y = max(minmax.max.y, centerArc.y + radius)
|
||||
if self._intersectsAngle(startDeg, endDeg, 180):
|
||||
# arc crosses negative x
|
||||
minmax.min.x = min(minmax.min.x, centerArc.x - radius)
|
||||
if self._intersectsAngle(startDeg, endDeg, 270):
|
||||
# arc crosses negative y
|
||||
minmax.min.y = min(minmax.min.y, centerArc.y - radius)
|
||||
|
||||
def get_result(self):
|
||||
result = {
|
||||
"total_time": self.totalMoveTimeMinute,
|
||||
|
||||
@@ -737,7 +737,7 @@ msgstr "Erstelle eine neue Sicherung des aktuellen Stands."
|
||||
|
||||
#: src/octoprint/plugins/backup/templates/backup_settings.jinja2:85
|
||||
#: src/octoprint/templates/recovery.jinja2:104
|
||||
msgid "Exclude uploaded files & metadata from backup"
|
||||
msgid "Exclude uploaded files (& associated metadata) from backup"
|
||||
msgstr "Uploads & metadata nicht sichern"
|
||||
|
||||
#: src/octoprint/plugins/backup/templates/backup_settings.jinja2:93
|
||||
|
||||
@@ -803,7 +803,7 @@ msgstr ""
|
||||
|
||||
#: src/octoprint/plugins/backup/templates/backup_settings.jinja2:85
|
||||
#: src/octoprint/templates/recovery.jinja2:104
|
||||
msgid "Exclude uploaded files & metadata from backup"
|
||||
msgid "Exclude uploaded files (& associated metadata) from backup"
|
||||
msgstr ""
|
||||
|
||||
#: src/octoprint/plugins/backup/templates/backup_settings.jinja2:93
|
||||
|
||||
Reference in new issue
Block a user