Merge branch 'maintenance' of github.com:foosel/OctoPrint into maintenance
This commit is contained in:
commit
c6bb825f7e
60 files changed
+2517
-1211
No files matched your search
@@ -86,6 +86,7 @@ date of first contribution):
|
||||
* [Peter Backx](https://github.com/pbackx)
|
||||
* [Josh Major](https://github.com/astateofblank)
|
||||
* ["alex-gh"](https://github.com/alex-gh)
|
||||
* [Bernd Zeimetz](https://github.com/bzed)
|
||||
|
||||
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
|
||||
|
||||
+5
-168
@@ -4,172 +4,9 @@
|
||||
Log file management
|
||||
*******************
|
||||
|
||||
.. note::
|
||||
Log file management (and logging configuration) was moved into a bundled plugin in OctoPrint 1.3.7. Refer to
|
||||
:ref:`the Logging's plugins API <sec-bundledplugins-logging-api>` for the API documentation.
|
||||
|
||||
All log file management operations require admin rights.
|
||||
|
||||
.. contents::
|
||||
|
||||
.. _sec-api-logs-list:
|
||||
|
||||
Retrieve a list of available log files
|
||||
======================================
|
||||
|
||||
.. http:get:: /api/logs
|
||||
|
||||
Retrieve information regarding all log files currently available and regarding the disk space still available
|
||||
in the system on the location the log files are being stored.
|
||||
|
||||
Returns a :ref:`Logfile Retrieve response <sec-api-logs-datamodel-retrieveresponse>`.
|
||||
|
||||
**Example**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/logs HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"files" : [
|
||||
{
|
||||
"date" : 1393158814,
|
||||
"name" : "octoprint.log",
|
||||
"size" : 43712,
|
||||
"refs": {
|
||||
"resource": "http://example.com/api/logs/octoprint.log",
|
||||
"download": "http://example.com/downloads/logs/octoprint.log"
|
||||
}
|
||||
},
|
||||
{
|
||||
"date" : 1392628936,
|
||||
"name" : "octoprint.log.2014-02-17",
|
||||
"size" : 13205,
|
||||
"refs": {
|
||||
"resource": "http://example.com/api/logs/octoprint.log.2014-02-17",
|
||||
"download": "http://example.com/downloads/logs/octoprint.log.2014-02-17"
|
||||
}
|
||||
},
|
||||
{
|
||||
"date" : 1393158814,
|
||||
"name" : "serial.log",
|
||||
"size" : 1798419,
|
||||
"refs": {
|
||||
"resource": "http://example.com/api/logs/serial.log",
|
||||
"download": "http://example.com/downloads/logs/serial.log"
|
||||
}
|
||||
}
|
||||
],
|
||||
"free": 12237201408
|
||||
}
|
||||
|
||||
:statuscode 200: No error
|
||||
:statuscode 403: If the given API token did not have admin rights associated with it
|
||||
|
||||
.. _sec-api-logs-delete:
|
||||
|
||||
Delete a specific logfile
|
||||
=========================
|
||||
|
||||
.. http:delete:: /api/logs/(path:filename)
|
||||
|
||||
Delete the selected log file with name `filename`.
|
||||
|
||||
Returns a :http:statuscode:`204` after successful deletion.
|
||||
|
||||
**Example Request**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
DELETE /api/logs/octoprint.log.2014-02-17 HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
:param filename: The filename of the log file to delete
|
||||
:statuscode 204: No error
|
||||
:statuscode 403: If the given API token did not have admin rights associated with it
|
||||
:statuscode 404: If the file was not found
|
||||
|
||||
.. _sec-api-logs-datamodel:
|
||||
|
||||
Data model
|
||||
==========
|
||||
|
||||
.. _sec-api-logs-datamodel-retrieveresponse:
|
||||
|
||||
Logfile Retrieve Response
|
||||
-------------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``files``
|
||||
- 0..*
|
||||
- Array of :ref:`File information items <sec-api-logs-datamodel-fileinfo>`
|
||||
- The list of requested files. Might be an empty list if no files are available
|
||||
* - ``free``
|
||||
- 1
|
||||
- String
|
||||
- The amount of disk space in bytes available in the local disk space (refers to OctoPrint's ``logs`` folder).
|
||||
|
||||
.. _sec-api-logs-datamodel-fileinfo:
|
||||
|
||||
File information
|
||||
----------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``name``
|
||||
- 1
|
||||
- String
|
||||
- The name of the file
|
||||
* - ``size``
|
||||
- 1
|
||||
- Number
|
||||
- The size of the file in bytes.
|
||||
* - ``date``
|
||||
- 1
|
||||
- Unix timestamp
|
||||
- The timestamp when this file was last modified.
|
||||
* - ``refs``
|
||||
- 1
|
||||
- :ref:`sec-api-logs-datamodel-ref`
|
||||
- References relevant to this file
|
||||
|
||||
.. _sec-api-logs-datamodel-ref:
|
||||
|
||||
References
|
||||
----------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``resource``
|
||||
- 1
|
||||
- URL
|
||||
- The resource that represents the file (e.g. for deleting)
|
||||
* - ``download``
|
||||
- 1
|
||||
- URL
|
||||
- The download URL for the file
|
||||
The former endpoints ``/api/logs`` and ``api/logs/<path>`` are marked as deprecated but still work for now. New
|
||||
client implementations should directly use the new endpoints provided by the bundled plugin. Existing implementations
|
||||
should adapt their endpoints as soon as possible.
|
||||
@@ -1,4 +1,4 @@
|
||||
.. _sec-bundledplugins_cura:
|
||||
.. _sec-bundledplugins-cura:
|
||||
|
||||
Cura
|
||||
====
|
||||
|
||||
@@ -9,5 +9,6 @@ Bundled Plugins
|
||||
|
||||
cura.rst
|
||||
discovery.rst
|
||||
logging.rst
|
||||
pluginmanager.rst
|
||||
softwareupdate.rst
|
||||
@@ -0,0 +1,238 @@
|
||||
.. _sec-bundledplugins-logging:
|
||||
|
||||
Logging
|
||||
=======
|
||||
|
||||
The OctoPrint Logging plugin comes bundled with OctoPrint starting with version 1.3.7.
|
||||
|
||||
It implements the log management functionality that was formerly part of the core application and adds features to
|
||||
configure logging levels for sub modules through the included settings dialog.
|
||||
|
||||
.. _fig-bundledplugins-logging-settings:
|
||||
.. figure:: ../images/bundledplugins-logging-settings.png
|
||||
:align: center
|
||||
:alt: Logging plugin
|
||||
|
||||
The settings dialog of the Logging plugin
|
||||
|
||||
.. _sec-bundledplugins-logging-api:
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
.. note::
|
||||
|
||||
All log file management operations require admin rights.
|
||||
|
||||
.. _sec-bundledplugins-logging-api-list_logs:
|
||||
|
||||
Retrieve a list of available log files
|
||||
++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
.. http:get:: /plugin/logging/logs
|
||||
|
||||
Retrieve information regarding all log files currently available and regarding the disk space still available
|
||||
in the system on the location the log files are being stored.
|
||||
|
||||
Returns a :ref:`Logfile Retrieve response <sec-bundledplugins-logging-api-datamodel-retrieveresponse>`.
|
||||
|
||||
**Example**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /plugin/logging/logs HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"files" : [
|
||||
{
|
||||
"date" : 1393158814,
|
||||
"name" : "octoprint.log",
|
||||
"size" : 43712,
|
||||
"refs": {
|
||||
"resource": "http://example.com/plugin/logging/logs/octoprint.log",
|
||||
"download": "http://example.com/downloads/logs/octoprint.log"
|
||||
}
|
||||
},
|
||||
{
|
||||
"date" : 1392628936,
|
||||
"name" : "octoprint.log.2014-02-17",
|
||||
"size" : 13205,
|
||||
"refs": {
|
||||
"resource": "http://example.com/plugin/logging/logs/octoprint.log.2014-02-17",
|
||||
"download": "http://example.com/downloads/logs/octoprint.log.2014-02-17"
|
||||
}
|
||||
},
|
||||
{
|
||||
"date" : 1393158814,
|
||||
"name" : "serial.log",
|
||||
"size" : 1798419,
|
||||
"refs": {
|
||||
"resource": "http://example.com/plugin/logging/logs/serial.log",
|
||||
"download": "http://example.com/downloads/logs/serial.log"
|
||||
}
|
||||
}
|
||||
],
|
||||
"free": 12237201408
|
||||
}
|
||||
|
||||
:statuscode 200: No error
|
||||
:statuscode 403: If the given API token did not have admin rights associated with it
|
||||
|
||||
.. _sec-bundledplugins-logging-api-delete_logs:
|
||||
|
||||
Delete a specific logfile
|
||||
+++++++++++++++++++++++++
|
||||
|
||||
.. http:delete:: /plugin/logging/logs/(path:filename)
|
||||
|
||||
Delete the selected log file with name `filename`.
|
||||
|
||||
Returns a :http:statuscode:`204` after successful deletion.
|
||||
|
||||
**Example Request**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
DELETE /plugin/logging/logs/octoprint.log.2014-02-17 HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
:param filename: The filename of the log file to delete
|
||||
:statuscode 204: No error
|
||||
:statuscode 403: If the given API token did not have admin rights associated with it
|
||||
:statuscode 404: If the file was not found
|
||||
|
||||
.. _sec-bundledplugins-logging-api-datamodel:
|
||||
|
||||
Data model
|
||||
++++++++++
|
||||
|
||||
.. _sec-bundledplugins-logging-api-datamodel-retrieveresponse:
|
||||
|
||||
Logfile Retrieve Response
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``files``
|
||||
- 0..*
|
||||
- Array of :ref:`File information items <sec-bundledplugins-logging-api-datamodel-fileinfo>`
|
||||
- The list of requested files. Might be an empty list if no files are available
|
||||
* - ``free``
|
||||
- 1
|
||||
- String
|
||||
- The amount of disk space in bytes available in the local disk space (refers to OctoPrint's ``logs`` folder).
|
||||
|
||||
.. _sec-bundledplugins-logging-api-datamodel-fileinfo:
|
||||
|
||||
File information
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``name``
|
||||
- 1
|
||||
- String
|
||||
- The name of the file
|
||||
* - ``size``
|
||||
- 1
|
||||
- Number
|
||||
- The size of the file in bytes.
|
||||
* - ``date``
|
||||
- 1
|
||||
- Unix timestamp
|
||||
- The timestamp when this file was last modified.
|
||||
* - ``refs``
|
||||
- 1
|
||||
- :ref:`References <sec-bundledplugins-logging-api-datamodel-ref>`
|
||||
- References relevant to this file
|
||||
|
||||
.. _sec-bundledplugins-logging-api-datamodel-ref:
|
||||
|
||||
References
|
||||
~~~~~~~~~~
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``resource``
|
||||
- 1
|
||||
- URL
|
||||
- The resource that represents the file (e.g. for deleting)
|
||||
* - ``download``
|
||||
- 1
|
||||
- URL
|
||||
- The download URL for the file
|
||||
|
||||
.. _sec-bundledplugins-logging-jsclientlib:
|
||||
|
||||
JS Client Library
|
||||
-----------------
|
||||
|
||||
:mod:`OctoPrintClient.plugins.logging`
|
||||
--------------------------------------
|
||||
|
||||
.. note::
|
||||
|
||||
All methods here require that the used API token or a the existing browser session
|
||||
has admin rights.
|
||||
|
||||
.. js:function:: OctoPrintClient.plugins.logging.listLogs(opts)
|
||||
|
||||
Retrieves a list of log files.
|
||||
|
||||
See :ref:`Retrieve a list of available log files <sec-bundledplugins-logging-api-list_logs>` for details.
|
||||
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrintClient.plugins.logging.deleteLog(path, opts)
|
||||
|
||||
Deletes the specified log ``path``.
|
||||
|
||||
See :ref:`Delete a specific log file <sec-bundledplugins-logging-api-delete_logs>` for details.
|
||||
|
||||
:param string path: The path to the log file to delete
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrintClient.plugins.logging.downloadLog(path, opts)
|
||||
|
||||
Downloads the specified log ``file``.
|
||||
|
||||
See :js:func:`OctoPrint.download` for more details on the underlying library download mechanism.
|
||||
|
||||
:param string path: The path to the log file to download
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. _sec-bundledplugins-logging-sourcecode:
|
||||
|
||||
Source Code
|
||||
-----------
|
||||
|
||||
The source of the Logging plugin is bundled with OctoPrint and can be found in its source repository under ``src/octoprint/plugins/logging``.
|
||||
@@ -213,6 +213,17 @@ Version checks
|
||||
information and whether the current version is up-to-date or not, see
|
||||
below for details.
|
||||
|
||||
* ``always_current``: Always reports that no update is necessary. Useful for debugging
|
||||
software update mechanisms during development. Additional config parameters:
|
||||
|
||||
* ``current_version``: Version to report for both local and remote version.
|
||||
|
||||
* ``never_current``: Always reports that an update is necessary. Useful for debugging
|
||||
software update mechanisms during development. Additional config parameters:
|
||||
|
||||
* ``local_version``: Current local version. Defaults to ``1.0.0``.
|
||||
* ``remote_version``: Remote version to offer update to. Defaults to ``1.0.1``.
|
||||
|
||||
.. _sec-bundledplugins-softwareupdate-configuration-updatemethods:
|
||||
|
||||
Update methods
|
||||
|
||||
@@ -36,7 +36,7 @@ Use the following settings to enable access control:
|
||||
|
||||
# If set to true, will automatically log on clients originating from any of the networks defined in
|
||||
# "localNetworks" as the user defined in "autologinAs". Defaults to false.
|
||||
autologinLocal: true
|
||||
autologinLocal: false
|
||||
|
||||
# The name of the user to automatically log on clients originating from "localNetworks" as. Must
|
||||
# be the name of one of your configured users.
|
||||
@@ -51,6 +51,17 @@ Use the following settings to enable access control:
|
||||
- 127.0.0.0/8
|
||||
- 192.168.1.0/24
|
||||
|
||||
# Whether to trust Basic Authentication headers. If you have setup Basic Authentication in front of
|
||||
# OctoPrint and the user names you use there match OctoPrint accounts, by setting this to true users will
|
||||
# be logged into OctoPrint as the user user during Basic Authentication. Your should ONLY ENABLE THIS if your
|
||||
# OctoPrint instance is only accessible through a connection locked down through Basic Authentication!
|
||||
trustBasicAuthentication: false
|
||||
|
||||
# Whether to also check the password provided through Basic Authentication if the Basic Authentication
|
||||
# header is to be trusted. Disabling this will only match the user name in the Basic Authentication
|
||||
# header and login the user without further checks. Use with caution.
|
||||
checkBasicAuthenticationPassword: true
|
||||
|
||||
.. _sec-configuration-config_yaml-api:
|
||||
|
||||
API
|
||||
@@ -522,52 +533,16 @@ Use the following settings to enable or disable OctoPrint features:
|
||||
.. code-block:: yaml
|
||||
|
||||
feature:
|
||||
|
||||
# Whether to enable the gcode viewer in the UI or not
|
||||
gCodeVisualizer: true
|
||||
|
||||
# Whether to enable the temperature graph in the UI or not
|
||||
temperatureGraph: true
|
||||
|
||||
# Specifies whether OctoPrint should wait for the start response from the printer before trying to send commands
|
||||
# during connect.
|
||||
waitForStartOnConnect: false
|
||||
|
||||
# Specifies whether OctoPrint should send linenumber + checksum with every printer command. Needed for
|
||||
# successful communication with Repetier firmware
|
||||
alwaysSendChecksum: false
|
||||
|
||||
# Specifies whether OctoPrint should also send linenumber + checksum with commands that are *not*
|
||||
# detected as valid GCODE (as in, they do not match the regular expression "^\s*([GM]\d+|T)").
|
||||
sendChecksumWithUnknownCommands: false
|
||||
|
||||
# Specifies whether OctoPrint should also use up acknowledgments ("ok") for commands that are *not*
|
||||
# detected as valid GCODE (as in, they do not match the regular expression "^\s*([GM]\d+|T)").
|
||||
unknownCommandsNeedAck: false
|
||||
|
||||
# Whether to ignore the first ok after a resend response. Needed for successful communication with
|
||||
# Repetier firmware
|
||||
swallowOkAfterResend: false
|
||||
|
||||
# Specifies whether support for SD printing and file management should be enabled
|
||||
sdSupport: true
|
||||
|
||||
# Specifies whether firmware expects relative paths for selecting SD files
|
||||
sdRelativePath: false
|
||||
|
||||
# Whether to always assume that an SD card is present in the printer.
|
||||
# Needed by some firmwares which don't report the SD card status properly.
|
||||
sdAlwaysAvailable: false
|
||||
|
||||
# Whether the printer sends repetier style target temperatures in the format
|
||||
# TargetExtr0:<temperature>
|
||||
# instead of attaching that information to the regular M105 responses
|
||||
repetierTargetTemp: false
|
||||
|
||||
# Whether to enable external heatup detection (to detect heatup triggered e.g. through the printer's LCD panel or
|
||||
# while printing from SD) or not. Causes issues with Repetier's "first ok then response" approach to
|
||||
# communication, so disable for printers running Repetier firmware.
|
||||
externalHeatupDetection: true
|
||||
|
||||
# Whether to enable the keyboard control feature in the control tab
|
||||
keyboardControl: true
|
||||
|
||||
@@ -575,28 +550,16 @@ Use the following settings to enable or disable OctoPrint features:
|
||||
# notifications instead (false)
|
||||
pollWatched: false
|
||||
|
||||
# Whether to ignore identical resends from the printer (true, repetier) or not (false)
|
||||
ignoreIdenticalResends: false
|
||||
|
||||
# If ignoredIdenticalResends is true, how many consecutive identical resends to ignore
|
||||
identicalResendsCount: 7
|
||||
|
||||
# Whether to support F on its own as a valid GCODE command (true) or not (false)
|
||||
supportFAsCommand: false
|
||||
|
||||
# Whether to enable model size detection and warning (true) or not (false)
|
||||
modelSizeDetection: true
|
||||
|
||||
# Whether to attempt to auto detect the firmware of the printer and adjust settings
|
||||
# accordingly (true) or not and rely on manual configuration (false)
|
||||
firmwareDetection: true
|
||||
|
||||
# Whether to show a confirmation on print cancelling (true) or not (false)
|
||||
printCancelConfirmation: true
|
||||
|
||||
# Whether to block all sending to the printer while a G4 (dwell) command is active (true, repetier)
|
||||
# or not (false)
|
||||
blockWhileDwelling: false
|
||||
# Commands that should never be auto-uppercased when sent to the printer through the Terminal tab.
|
||||
# Defaults to only M117.
|
||||
autoUppercaseBlacklist:
|
||||
- M117
|
||||
|
||||
.. _sec-configuration-config_yaml-folder:
|
||||
|
||||
@@ -800,6 +763,10 @@ Use the following settings to configure the serial connection to the printer:
|
||||
# Defaults to 30 sec
|
||||
communication: 30
|
||||
|
||||
# Timeout during serial communication when busy protocol support is detected, in seconds.
|
||||
# Defaults to 3 sec
|
||||
communicationBusy: 3
|
||||
|
||||
# Timeout after which to query temperature when no target is set
|
||||
temperature: 5
|
||||
|
||||
@@ -824,7 +791,7 @@ Use the following settings to configure the serial connection to the printer:
|
||||
|
||||
# Maximum number of write attempts to serial during which nothing can be written before the communication
|
||||
# with the printer is considered dead and OctoPrint will disconnect with an error
|
||||
maxWritePasses:
|
||||
maxWritePasses: 5
|
||||
|
||||
# Use this to define additional patterns to consider for serial port listing. Must be a valid
|
||||
# "glob" pattern (see http://docs.python.org/2/library/glob.html). Defaults to not set.
|
||||
@@ -858,10 +825,6 @@ Use the following settings to configure the serial connection to the printer:
|
||||
helloCommand:
|
||||
- M110 N0
|
||||
|
||||
# Commands that should never be auto-uppercased when sent to the printer. Defaults to only M117.
|
||||
autoUppercaseBlacklist:
|
||||
- M117
|
||||
|
||||
# Whether to disconnect on errors or not
|
||||
disconnectOnErrors: true
|
||||
|
||||
@@ -872,6 +835,60 @@ Use the following settings to configure the serial connection to the printer:
|
||||
# impact, leave on if possible please
|
||||
logResends: true
|
||||
|
||||
# Specifies whether OctoPrint should wait for the start response from the printer before trying to send commands
|
||||
# during connect.
|
||||
waitForStartOnConnect: false
|
||||
|
||||
# Specifies whether OctoPrint should send linenumber + checksum with every printer command. Needed for
|
||||
# successful communication with Repetier firmware
|
||||
alwaysSendChecksum: false
|
||||
|
||||
# Specifies whether OctoPrint should also send linenumber + checksum with commands that are *not*
|
||||
# detected as valid GCODE (as in, they do not match the regular expression "^\s*([GM]\d+|T)").
|
||||
sendChecksumWithUnknownCommands: false
|
||||
|
||||
# Specifies whether OctoPrint should also use up acknowledgments ("ok") for commands that are *not*
|
||||
# detected as valid GCODE (as in, they do not match the regular expression "^\s*([GM]\d+|T)").
|
||||
unknownCommandsNeedAck: false
|
||||
|
||||
# Whether to ignore the first ok after a resend response. Needed for successful communication with
|
||||
# Repetier firmware
|
||||
swallowOkAfterResend: false
|
||||
|
||||
# Specifies whether firmware expects relative paths for selecting SD files
|
||||
sdRelativePath: false
|
||||
|
||||
# Whether to always assume that an SD card is present in the printer.
|
||||
# Needed by some firmwares which don't report the SD card status properly.
|
||||
sdAlwaysAvailable: false
|
||||
|
||||
# Whether the printer sends repetier style target temperatures in the format
|
||||
# TargetExtr0:<temperature>
|
||||
# instead of attaching that information to the regular M105 responses
|
||||
repetierTargetTemp: false
|
||||
|
||||
# Whether to enable external heatup detection (to detect heatup triggered e.g. through the printer's LCD panel or
|
||||
# while printing from SD) or not. Causes issues with Repetier's "first ok then response" approach to
|
||||
# communication, so disable for printers running Repetier firmware.
|
||||
externalHeatupDetection: true
|
||||
|
||||
# Whether to ignore identical resends from the printer (true, repetier) or not (false)
|
||||
ignoreIdenticalResends: false
|
||||
|
||||
# If ignoredIdenticalResends is true, how many consecutive identical resends to ignore
|
||||
identicalResendsCount: 7
|
||||
|
||||
# Whether to support F on its own as a valid GCODE command (true) or not (false)
|
||||
supportFAsCommand: false
|
||||
|
||||
# Whether to attempt to auto detect the firmware of the printer and adjust settings
|
||||
# accordingly (true) or not and rely on manual configuration (false)
|
||||
firmwareDetection: true
|
||||
|
||||
# Whether to block all sending to the printer while a G4 (dwell) command is active (true, repetier)
|
||||
# or not (false)
|
||||
blockWhileDwelling: false
|
||||
|
||||
# Whether to support resends without follow-up ok or not
|
||||
supportResendsWithoutOk: false
|
||||
|
||||
@@ -879,6 +896,14 @@ Use the following settings to configure the serial connection to the printer:
|
||||
# the responds skips on the ok)
|
||||
triggerOkForM29: true
|
||||
|
||||
capabilities:
|
||||
|
||||
# Whether to enable temperature autoreport in the firmware if its support is detected
|
||||
autoreport_temp: true
|
||||
|
||||
# Whether to shorten the communication timeout if the firmware seems to support the busy protocol
|
||||
busy_protocol: true
|
||||
|
||||
.. _sec-configuration-config_yaml-server:
|
||||
|
||||
Server
|
||||
|
||||
@@ -21,16 +21,20 @@ Action commands are a feature defined for the GCODE based RepRap communication p
|
||||
|
||||
OctoPrint out of the box supports handling of the above mentioned commands:
|
||||
|
||||
cancel
|
||||
When this command is received from the printer, OctoPrint will cancel a current print job like if the
|
||||
"Cancel" button had been clicked.
|
||||
|
||||
pause
|
||||
When this command is received from the printer, OctoPrint will pause streaming of a current print job just like if the
|
||||
When this command is received from the printer, OctoPrint will pause a current print job just like if the
|
||||
"Pause" button had been clicked.
|
||||
|
||||
resume
|
||||
When this command is received from the printer, OctoPrint will resume streaming of a current print job just like if
|
||||
When this command is received from the printer, OctoPrint will resume a current print job just like if
|
||||
the "Resume" button had been clicked.
|
||||
|
||||
disconnect
|
||||
When this command is Received from the printer, OctoPrint will immediately disconnect from it.
|
||||
When this command is received from the printer, OctoPrint will immediately disconnect from it.
|
||||
|
||||
Support for additional commands may be added by plugins by implementing a handler for the
|
||||
:ref:`octoprint.comm.protocol.action <sec-plugins-hook-comm-protocol-action>` hook.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 68 KiB |
@@ -3,37 +3,9 @@
|
||||
:mod:`OctoPrintClient.logs`
|
||||
---------------------------
|
||||
|
||||
.. note::
|
||||
|
||||
All methods here require that the used API token or a the existing browser session
|
||||
has admin rights.
|
||||
|
||||
.. js:function:: OctoPrintClient.logs.list(opts)
|
||||
|
||||
Retrieves a list of log files.
|
||||
|
||||
See :ref:`Retrieve a list of available log files <sec-api-logs-list>` for details.
|
||||
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrintClient.logs.delete(path, opts)
|
||||
|
||||
Deletes the specified log ``path``.
|
||||
|
||||
See :ref:`Delete a specific log file <sec-api-logs-delete>` for details.
|
||||
|
||||
:param string path: The path to the log file to delete
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrintClient.logs.download(path, opts)
|
||||
|
||||
Downloads the specified log ``file``.
|
||||
|
||||
See :js:func:`OctoPrint.download` for more details on the underlying library download mechanism.
|
||||
|
||||
:param string path: The path to the log file to download
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
Log file management (and logging configuration) was moved into a bundled plugin in OctoPrint 1.3.7. Refer to
|
||||
:ref:`the Logging's plugins JS Client Library <sec-bundledplugins-logging-jsclientlib>` for the JS Client documentation.
|
||||
|
||||
The former module ``OctoPrintClient.logs`` and its methods are marked as deprecated but still work for now. New
|
||||
client implementations should directly use the new module provided by the bundled plugin. Existing implementations
|
||||
should adapt their used module as soon as possible.
|
||||
+38
-3
@@ -420,7 +420,7 @@ This describes actually four hooks:
|
||||
* ``octoprint.comm.protocol.gcode.sending``
|
||||
* ``octoprint.comm.protocol.gcode.sent``
|
||||
|
||||
.. py:function:: protocol_gcodephase_hook(comm_instance, phase, cmd, cmd_type, gcode, subcode=None, *args, **kwargs)
|
||||
.. py:function:: protocol_gcodephase_hook(comm_instance, phase, cmd, cmd_type, gcode, subcode=None, tags=None, *args, **kwargs)
|
||||
|
||||
Pre- and postprocess commands as they progress through the various phases of being sent to the printer. The phases
|
||||
are the following:
|
||||
@@ -443,7 +443,39 @@ This describes actually four hooks:
|
||||
the communication layer or before they are actually sent over the serial port, or to react to the queuing or sending
|
||||
of commands after the fact. The hook handler will be called with the processing ``phase``, the ``cmd`` to be sent to
|
||||
the printer as well as the ``cmd_type`` parameter used for enqueuing (OctoPrint will make sure that the send queue
|
||||
will never contain more than one line with the same ``cmd_type``) and the detected gcode command (if it is one).
|
||||
will never contain more than one line with the same ``cmd_type``) and the detected ``gcode`` command (if it is one)
|
||||
as well as its ``subcode`` (if it has one). OctoPrint will also provide any ``tags`` attached to the command throughout
|
||||
its lifecycle.
|
||||
|
||||
Tags are arbitrary strings that can be attached to a command as it moves through the various phases and can be used to e.g.
|
||||
distinguish between commands that originated in a printed file (``source:file``) vs. a configured GCODE script
|
||||
(``source:script``) vs. an API call (``source:api``) vs. a plugin (``source:plugin`` or ``source:rewrite`` and
|
||||
``plugin:<plugin identifier>``). If during development you want to get an idea of the various possible tags, set
|
||||
the logger ``octoprint.util.comm.command_phases`` to ``DEBUG``, connect to a printer (real or virtual) and take a
|
||||
look at your ``octoprint.log`` during serial traffic:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
2018-02-16 18:20:31,213 - octoprint.util.comm.command_phases - DEBUG - phase: queuing | command: T0 | gcode: T | tags: [ api:printer.command, source:api, trigger:printer.commands ]
|
||||
2018-02-16 18:20:31,216 - octoprint.util.comm.command_phases - DEBUG - phase: queued | command: M117 Before T! | gcode: M117 | tags: [ api:printer.command, phase:queuing, plugin:multi_gcode_test, source:api, source:rewrite, trigger:printer.commands ]
|
||||
2018-02-16 18:20:31,217 - octoprint.util.comm.command_phases - DEBUG - phase: sending | command: M117 Before T! | gcode: M117 | tags: [ api:printer.command, phase:queuing, plugin:multi_gcode_test, source:api, source:rewrite, trigger:printer.commands ]
|
||||
2018-02-16 18:20:31,217 - octoprint.util.comm.command_phases - DEBUG - phase: queued | command: T0 | gcode: T | tags: [ api:printer.command, source:api, trigger:printer.commands ]
|
||||
2018-02-16 18:20:31,219 - octoprint.util.comm.command_phases - DEBUG - phase: queued | command: M117 After T! | gcode: M117 | tags: [ api:printer.command, phase:queuing, plugin:multi_gcode_test, source:api, source:rewrite, trigger:printer.commands ]
|
||||
2018-02-16 18:20:31,220 - octoprint.util.comm.command_phases - DEBUG - phase: sent | command: M117 Before T! | gcode: M117 | tags: [ api:printer.command, phase:queuing, plugin:multi_gcode_test, source:api, source:rewrite, trigger:printer.commands ]
|
||||
2018-02-16 18:20:31,230 - tornado.access - INFO - 204 POST /api/printer/command (127.0.0.1) 23.00ms
|
||||
2018-02-16 18:20:31,232 - tornado.access - INFO - 200 POST /api/printer/command (127.0.0.1) 25.00ms
|
||||
2018-02-16 18:20:31,232 - octoprint.util.comm.command_phases - DEBUG - phase: sending | command: T0 | gcode: T | tags: [ api:printer.command, source:api, trigger:printer.commands ]
|
||||
2018-02-16 18:20:31,234 - octoprint.util.comm.command_phases - DEBUG - phase: sent | command: T0 | gcode: T | tags: [ api:printer.command, source:api, trigger:printer.commands ]
|
||||
2018-02-16 18:20:31,242 - octoprint.util.comm.command_phases - DEBUG - phase: sending | command: M117 After T! | gcode: M117 | tags: [ api:printer.command, phase:queuing, plugin:multi_gcode_test, source:api, source:rewrite, trigger:printer.commands ]
|
||||
2018-02-16 18:20:31,243 - octoprint.util.comm.command_phases - DEBUG - phase: sent | command: M117 After T! | gcode: M117 | tags: [ api:printer.command, phase:queuing, plugin:multi_gcode_test, source:api, source:rewrite, trigger:printer.commands ]
|
||||
2018-02-16 18:20:38,552 - octoprint.util.comm.command_phases - DEBUG - phase: queuing | command: G91 | gcode: G91 | tags: [ api:printer.printhead, source:api, trigger:printer.commands, trigger:printer.jog ]
|
||||
2018-02-16 18:20:38,552 - octoprint.util.comm.command_phases - DEBUG - phase: queued | command: G91 | gcode: G91 | tags: [ api:printer.printhead, source:api, trigger:printer.commands, trigger:printer.jog ]
|
||||
2018-02-16 18:20:38,553 - octoprint.util.comm.command_phases - DEBUG - phase: sending | command: G91 | gcode: G91 | tags: [ api:printer.printhead, source:api, trigger:printer.commands, trigger:printer.jog ]
|
||||
2018-02-16 18:20:38,553 - octoprint.util.comm.command_phases - DEBUG - phase: queuing | command: G1 X10 F6000 | gcode: G1 | tags: [ api:printer.printhead, source:api, trigger:printer.commands, trigger:printer.jog ]
|
||||
2018-02-16 18:20:38,555 - octoprint.util.comm.command_phases - DEBUG - phase: queued | command: G1 X10 F6000 | gcode: G1 | tags: [ api:printer.printhead, source:api, trigger:printer.commands, trigger:printer.jog ]
|
||||
2018-02-16 18:20:38,556 - octoprint.util.comm.command_phases - DEBUG - phase: sent | command: G91 | gcode: G91 | tags: [ api:printer.printhead, source:api, trigger:printer.commands, trigger:printer.jog ]
|
||||
2018-02-16 18:20:38,556 - octoprint.util.comm.command_phases - DEBUG - phase: queuing | command: G90 | gcode: G90 | tags: [ api:printer.printhead, source:api, trigger:printer.commands, trigger:printer.jog ]
|
||||
2018-02-16 18:20:38,558 - octoprint.util.comm.command_phases - DEBUG - phase: queued | command: G90 | gcode: G90 | tags: [ api:printer.printhead, source:api, trigger:printer.commands, trigger:printer.jog ]
|
||||
|
||||
Defining a ``cmd_type`` other than None will make sure OctoPrint takes care of only having one command of that type
|
||||
in its sending queue. Predefined types are ``temperature_poll`` for temperature polling via ``M105`` and
|
||||
@@ -482,6 +514,8 @@ This describes actually four hooks:
|
||||
should use this option.
|
||||
* A 2-tuple consisting of a rewritten version of the ``cmd`` and the ``cmd_type``, e.g. ``return "M105", "temperature_poll"``.
|
||||
Handlers which wish to rewrite both the command and the command type should use this option.
|
||||
* A 3-tuple consisting of a rewritten version of the ``cmd``, the ``cmd_type`` and any additional ``tags`` you might
|
||||
want to attach to the lifecycle of the command in a set, e.g. ``return "M105", "temperature_poll", {"my_custom_tag"}``
|
||||
* **"queuing" phase only**: A list of any of the above to allow for expanding one command into
|
||||
many. The following example shows how any queued command could be turned into a sequence of a temperature query,
|
||||
line number reset, display of the ``gcode`` on the printer's display and finally the actual command (this example
|
||||
@@ -489,7 +523,7 @@ This describes actually four hooks:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def rewrite_foo(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **kwargs):
|
||||
def rewrite_foo(self, comm_instance, phase, cmd, cmd_type, gcode, subcode=None, tags=None *args, **kwargs):
|
||||
if gcode or not cmd.startswith("@foo"):
|
||||
return
|
||||
|
||||
@@ -524,6 +558,7 @@ This describes actually four hooks:
|
||||
:param str gcode: Parsed GCODE command, e.g. ``G0`` or ``M110``, may also be None if no known command could be parsed
|
||||
:param str subcode: Parsed subcode of the GCODE command, e.g. ``1`` for ``M80.1``. Will be None if no subcode was provided
|
||||
or no command could be parsed.
|
||||
:param set tags: Tags attached to the command
|
||||
:return: None, 1-tuple, 2-tuple or string, see the description above for details.
|
||||
|
||||
.. _sec-plugins-hook-comm-protocol-gcode-received:
|
||||
|
||||
@@ -30,7 +30,7 @@ INSTALL_REQUIRES = [
|
||||
"Flask-Babel>=0.9,<0.10",
|
||||
"Flask-Assets>=0.10,<0.11",
|
||||
"markdown>=2.6.4,<2.7",
|
||||
"pyserial>=2.7,<2.8",
|
||||
"pyserial>=2.7,<3.5",
|
||||
"netaddr>=0.7.17,<0.8",
|
||||
"watchdog>=0.8.3,<0.9",
|
||||
"sarge>=0.1.4,<0.2",
|
||||
|
||||
@@ -322,12 +322,9 @@ def init_pluginsystem(settings, safe_mode=False, ignore_blacklist=True, connecti
|
||||
plugin_validators = []
|
||||
if safe_mode:
|
||||
def validator(phase, plugin_info):
|
||||
if phase == "after_load":
|
||||
if phase in ("before_import", "before_load", "before_enable"):
|
||||
setattr(plugin_info, "safe_mode_victim", not plugin_info.bundled)
|
||||
setattr(plugin_info, "safe_mode_enabled", False)
|
||||
elif phase == "before_enable":
|
||||
if not plugin_info.bundled:
|
||||
setattr(plugin_info, "safe_mode_enabled", True)
|
||||
return False
|
||||
return True
|
||||
plugin_validators.append(validator)
|
||||
@@ -440,7 +437,7 @@ def get_plugin_blacklist(settings, connectivity_checker=None):
|
||||
result.append((entry["plugin"], version))
|
||||
else:
|
||||
logger.debug("Blacklisted plugin: {}".format(entry["plugin"]))
|
||||
result.append(entry["key"])
|
||||
result.append(entry["plugin"])
|
||||
|
||||
return result
|
||||
|
||||
|
||||
+118
-35
@@ -144,6 +144,7 @@ class PluginInfo(object):
|
||||
self.origin = None
|
||||
self.enabled = True
|
||||
self.blacklisted = False
|
||||
self.forced_disabled = False
|
||||
self.bundled = False
|
||||
self.loaded = False
|
||||
self.managable = True
|
||||
@@ -156,10 +157,15 @@ class PluginInfo(object):
|
||||
self._url = url
|
||||
self._license = license
|
||||
|
||||
self._cached_parsed_metadata = None
|
||||
|
||||
def validate(self, phase, additional_validators=None):
|
||||
result = True
|
||||
|
||||
if phase == "before_load":
|
||||
if phase == "before_import":
|
||||
result = not self.forced_disabled and not self.blacklisted and result
|
||||
|
||||
elif phase == "before_load":
|
||||
# if the plugin still uses __plugin_init__, log a deprecation warning and move it to __plugin_load__
|
||||
if hasattr(self.instance, self.__class__.attr_init):
|
||||
if not hasattr(self.instance, self.__class__.attr_load):
|
||||
@@ -193,7 +199,7 @@ class PluginInfo(object):
|
||||
|
||||
if additional_validators is not None:
|
||||
for validator in additional_validators:
|
||||
result = result and validator(phase, self)
|
||||
result = validator(phase, self) and result
|
||||
|
||||
return result
|
||||
|
||||
@@ -288,7 +294,9 @@ class PluginInfo(object):
|
||||
Returns:
|
||||
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))
|
||||
return self._get_instance_attribute(self.__class__.attr_name,
|
||||
defaults=(self._name, self.key),
|
||||
incl_metadata=True)
|
||||
|
||||
@property
|
||||
def description(self):
|
||||
@@ -300,7 +308,9 @@ class PluginInfo(object):
|
||||
Returns:
|
||||
str or None: Description of the plugin.
|
||||
"""
|
||||
return self._get_instance_attribute(self.__class__.attr_description, default=self._description)
|
||||
return self._get_instance_attribute(self.__class__.attr_description,
|
||||
default=self._description,
|
||||
incl_metadata=True)
|
||||
|
||||
@property
|
||||
def disabling_discouraged(self):
|
||||
@@ -324,7 +334,9 @@ class PluginInfo(object):
|
||||
Returns:
|
||||
str or None: Version of the plugin.
|
||||
"""
|
||||
return self._version if self._version is not None else self._get_instance_attribute(self.__class__.attr_version, default=self._version)
|
||||
return self._version if self._version is not None else self._get_instance_attribute(self.__class__.attr_version,
|
||||
default=self._version,
|
||||
incl_metadata=True)
|
||||
|
||||
@property
|
||||
def author(self):
|
||||
@@ -335,7 +347,9 @@ class PluginInfo(object):
|
||||
Returns:
|
||||
str or None: Author of the plugin.
|
||||
"""
|
||||
return self._get_instance_attribute(self.__class__.attr_author, default=self._author)
|
||||
return self._get_instance_attribute(self.__class__.attr_author,
|
||||
default=self._author,
|
||||
incl_metadata=True)
|
||||
|
||||
@property
|
||||
def url(self):
|
||||
@@ -346,7 +360,9 @@ class PluginInfo(object):
|
||||
Returns:
|
||||
str or None: Website URL for the plugin.
|
||||
"""
|
||||
return self._get_instance_attribute(self.__class__.attr_url, default=self._url)
|
||||
return self._get_instance_attribute(self.__class__.attr_url,
|
||||
default=self._url,
|
||||
incl_metadata=True)
|
||||
|
||||
@property
|
||||
def license(self):
|
||||
@@ -357,7 +373,9 @@ class PluginInfo(object):
|
||||
Returns:
|
||||
str or None: License of the plugin.
|
||||
"""
|
||||
return self._get_instance_attribute(self.__class__.attr_license, default=self._license)
|
||||
return self._get_instance_attribute(self.__class__.attr_license,
|
||||
default=self._license,
|
||||
incl_metadata=True)
|
||||
|
||||
@property
|
||||
def hooks(self):
|
||||
@@ -448,15 +466,69 @@ class PluginInfo(object):
|
||||
"""
|
||||
return self._get_instance_attribute(self.__class__.attr_disable, default=lambda: True)
|
||||
|
||||
def _get_instance_attribute(self, attr, default=None, defaults=None):
|
||||
def _get_instance_attribute(self, attr, default=None, defaults=None, incl_metadata=False):
|
||||
if self.instance is None or not hasattr(self.instance, attr):
|
||||
if defaults is not None:
|
||||
if incl_metadata and attr in self._parsed_metadata:
|
||||
return self._parsed_metadata[attr]
|
||||
|
||||
elif defaults is not None:
|
||||
for value in defaults:
|
||||
if callable(value):
|
||||
value = value()
|
||||
if value is not None:
|
||||
return value
|
||||
|
||||
return default
|
||||
|
||||
return getattr(self.instance, attr)
|
||||
|
||||
@property
|
||||
def _parsed_metadata(self):
|
||||
if self._cached_parsed_metadata is None:
|
||||
self._cached_parsed_metadata = self._parse_metadata()
|
||||
return self._cached_parsed_metadata
|
||||
|
||||
def _parse_metadata(self):
|
||||
result = dict()
|
||||
try:
|
||||
import ast
|
||||
|
||||
path = self.location
|
||||
if os.path.isdir(path):
|
||||
path = os.path.join(self.location, "__init__.py")
|
||||
|
||||
if not os.path.isfile(path):
|
||||
return result
|
||||
|
||||
with open(path, "rb") as f:
|
||||
root = ast.parse(f.read())
|
||||
|
||||
assignments = filter(lambda x: isinstance(x, ast.Assign) and x.targets,
|
||||
root.body)
|
||||
|
||||
def extract_target_ids(node):
|
||||
return map(lambda x: x.id,
|
||||
filter(lambda x: isinstance(x, ast.Name), node.targets))
|
||||
|
||||
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):
|
||||
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
|
||||
except:
|
||||
pass
|
||||
|
||||
return result
|
||||
|
||||
|
||||
class PluginManager(object):
|
||||
"""
|
||||
@@ -602,14 +674,13 @@ class PluginManager(object):
|
||||
# plugin is already defined, ignore it
|
||||
continue
|
||||
|
||||
plugin = self._import_plugin_from_module(key, folder=folder)
|
||||
bundled = flagged_readonly
|
||||
|
||||
plugin = self._import_plugin_from_module(key, folder=folder, bundled=bundled)
|
||||
if plugin:
|
||||
plugin.origin = FolderOrigin("folder", folder)
|
||||
plugin.managable = not flagged_readonly and not actual_readonly
|
||||
plugin.bundled = flagged_readonly
|
||||
|
||||
plugin.enabled = False
|
||||
|
||||
result[key] = plugin
|
||||
except:
|
||||
self.logger.exception("Error processing folder entry {!r} from folder {}".format(entry, folder))
|
||||
@@ -676,6 +747,7 @@ class PluginManager(object):
|
||||
plugin = self._import_plugin_from_module(key, **kwargs)
|
||||
if plugin:
|
||||
plugin.origin = EntryPointOrigin("entry_point", group, module_name, package_name, version)
|
||||
plugin.enabled = False
|
||||
|
||||
# plugin is manageable if its location is writable and OctoPrint
|
||||
# is either not running from a virtual env or the plugin is
|
||||
@@ -685,19 +757,19 @@ class PluginManager(object):
|
||||
plugin.managable = os.access(plugin.location, os.W_OK) \
|
||||
and (not self._python_virtual_env
|
||||
or is_sub_path_of(plugin.location, self._python_prefix)
|
||||
or is_editable_install(self._python_install_dir,
|
||||
package_name,
|
||||
module_name,
|
||||
plugin.location))
|
||||
or is_editable_install(self._python_install_dir,
|
||||
package_name,
|
||||
module_name,
|
||||
plugin.location))
|
||||
|
||||
plugin.enabled = False
|
||||
result[key] = plugin
|
||||
except:
|
||||
self.logger.exception("Error processing entry point {!r} for group {}".format(entry_point, group))
|
||||
|
||||
return result
|
||||
|
||||
def _import_plugin_from_module(self, key, folder=None, module_name=None, name=None, version=None, summary=None, author=None, url=None, license=None):
|
||||
def _import_plugin_from_module(self, key, folder=None, module_name=None, name=None, version=None, summary=None,
|
||||
author=None, url=None, license=None, bundled=False):
|
||||
# TODO error handling
|
||||
try:
|
||||
if folder:
|
||||
@@ -710,14 +782,34 @@ class PluginManager(object):
|
||||
self.logger.warn("Could not locate plugin {key}".format(key=key))
|
||||
return None
|
||||
|
||||
# Create a simple dummy entry first ...
|
||||
plugin = PluginInfo(key, module[1], None, name=name, version=version, description=summary, author=author,
|
||||
url=url, license=license)
|
||||
plugin.bundled = bundled
|
||||
|
||||
if self._is_plugin_disabled(key):
|
||||
self.logger.info("Plugin {} is disabled.".format(plugin))
|
||||
plugin.forced_disabled = True
|
||||
|
||||
if self._is_plugin_blacklisted(key) or (version is not None and self._is_plugin_version_blacklisted(key, version)):
|
||||
plugin = PluginInfo(key, module[1], None, name=name, version=version, description=summary, author=author, url=url, license=license)
|
||||
self.logger.warn("Plugin {} is blacklisted.".format(plugin))
|
||||
plugin.blacklisted = True
|
||||
self.logger.warn("Plugin {} is blacklisted. Not importing it, only registering a dummy entry.".format(plugin))
|
||||
|
||||
if not plugin.validate("before_import", additional_validators=self.plugin_validators):
|
||||
return plugin
|
||||
|
||||
plugin = self._import_plugin(key, *module, name=name, version=version, summary=summary, author=author, url=url, license=license)
|
||||
if plugin is None:
|
||||
# ... then create and return the real one
|
||||
return self._import_plugin(key, *module,
|
||||
name=name, version=version, summary=summary, author=author, url=url,
|
||||
license=license, bundled=bundled)
|
||||
|
||||
def _import_plugin(self, key, f, filename, description, name=None, version=None, summary=None, author=None, url=None, license=None, bundled=False):
|
||||
try:
|
||||
instance = imp.load_module(key, f, filename, description)
|
||||
plugin = PluginInfo(key, filename, instance, name=name, version=version, description=summary, author=author, url=url, license=license)
|
||||
plugin.bundled = bundled
|
||||
except:
|
||||
self.logger.exception("Error loading plugin {key}".format(key=key))
|
||||
return None
|
||||
|
||||
if plugin.check():
|
||||
@@ -726,15 +818,6 @@ class PluginManager(object):
|
||||
self.logger.warn("Plugin \"{plugin}\" did not pass check".format(plugin=str(plugin)))
|
||||
return None
|
||||
|
||||
|
||||
def _import_plugin(self, key, f, filename, description, name=None, version=None, summary=None, author=None, url=None, license=None):
|
||||
try:
|
||||
instance = imp.load_module(key, f, filename, description)
|
||||
return PluginInfo(key, filename, instance, name=name, version=version, description=summary, author=author, url=url, license=license)
|
||||
except:
|
||||
self.logger.exception("Error loading plugin {key}".format(key=key))
|
||||
return None
|
||||
|
||||
def _is_plugin_disabled(self, key):
|
||||
return key in self.plugin_disabled_list or key.endswith('disabled')
|
||||
|
||||
@@ -765,7 +848,7 @@ class PluginManager(object):
|
||||
# 1st pass: loading the plugins
|
||||
for name, plugin in plugins.items():
|
||||
try:
|
||||
if not plugin.blacklisted:
|
||||
if not plugin.blacklisted and not plugin.forced_disabled:
|
||||
self.load_plugin(name, plugin, startup=startup, initialize_implementation=initialize_implementations)
|
||||
except PluginNeedsRestart:
|
||||
pass
|
||||
@@ -779,7 +862,7 @@ class PluginManager(object):
|
||||
# 2nd pass: enabling those plugins that need enabling
|
||||
for name, plugin in plugins.items():
|
||||
try:
|
||||
if plugin.loaded and not self._is_plugin_disabled(name):
|
||||
if plugin.loaded and not plugin.forced_disabled:
|
||||
if plugin.blacklisted:
|
||||
self.logger.warn("Plugin {} is blacklisted. Not enabling it.".format(plugin))
|
||||
continue
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
import octoprint.plugin
|
||||
from octoprint.settings import settings
|
||||
|
||||
from octoprint.server import NO_CONTENT, admin_permission
|
||||
from octoprint.server.util.flask import redirect_to_tornado, restricted_access
|
||||
|
||||
from flask import request, jsonify, url_for, make_response
|
||||
from werkzeug.utils import secure_filename
|
||||
from werkzeug.exceptions import BadRequest
|
||||
import yaml
|
||||
|
||||
import os
|
||||
|
||||
try:
|
||||
from os import scandir
|
||||
except ImportError:
|
||||
from scandir import scandir
|
||||
|
||||
class LoggingPlugin(octoprint.plugin.AssetPlugin,
|
||||
octoprint.plugin.SettingsPlugin,
|
||||
octoprint.plugin.TemplatePlugin,
|
||||
octoprint.plugin.BlueprintPlugin):
|
||||
@octoprint.plugin.BlueprintPlugin.route("/", methods=["GET"])
|
||||
@restricted_access
|
||||
@admin_permission.require(403)
|
||||
def get_all(self):
|
||||
files = self._getLogFiles()
|
||||
free, total = self._get_usage()
|
||||
loggers = self._get_available_loggers()
|
||||
levels = self._get_logging_levels()
|
||||
return jsonify(logs=dict(files=files, free=free, total=total),
|
||||
setup=dict(loggers=loggers, levels=levels))
|
||||
|
||||
@octoprint.plugin.BlueprintPlugin.route("/logs", methods=["GET"])
|
||||
@restricted_access
|
||||
@admin_permission.require(403)
|
||||
def get_log_files(self):
|
||||
files = self._getLogFiles()
|
||||
free, total = self._get_usage()
|
||||
return jsonify(files=files, free=free, total=total)
|
||||
|
||||
@octoprint.plugin.BlueprintPlugin.route("/logs/<path:filename>", methods=["GET"])
|
||||
@restricted_access
|
||||
@admin_permission.require(403)
|
||||
def download_log(self, filename):
|
||||
return redirect_to_tornado(request, url_for("index") + "downloads/logs/" + filename)
|
||||
|
||||
@octoprint.plugin.BlueprintPlugin.route("/logs/<path:filename>", methods=["DELETE"])
|
||||
@restricted_access
|
||||
@admin_permission.require(403)
|
||||
def delete_log(self, filename):
|
||||
secure = os.path.join(settings().getBaseFolder("logs"), secure_filename(filename))
|
||||
if not os.path.exists(secure):
|
||||
return make_response("File not found: %s" % filename, 404)
|
||||
|
||||
os.remove(secure)
|
||||
|
||||
return NO_CONTENT
|
||||
|
||||
@octoprint.plugin.BlueprintPlugin.route("/setup", methods=["GET"])
|
||||
@restricted_access
|
||||
@admin_permission.require(403)
|
||||
def get_logging_setup(self):
|
||||
loggers = self._get_available_loggers()
|
||||
levels = self._get_logging_levels()
|
||||
return jsonify(loggers=loggers, levels=levels)
|
||||
|
||||
@octoprint.plugin.BlueprintPlugin.route("/setup/levels", methods=["GET"])
|
||||
@restricted_access
|
||||
@admin_permission.require(403)
|
||||
def get_logging_levels_api(self):
|
||||
return jsonify(self._get_logging_levels())
|
||||
|
||||
@octoprint.plugin.BlueprintPlugin.route("/setup/levels", methods=["PUT"])
|
||||
@restricted_access
|
||||
@admin_permission.require(403)
|
||||
def set_logging_levels_api(self):
|
||||
if not "application/json" in request.headers["Content-Type"]:
|
||||
return make_response("Expected content-type JSON", 400)
|
||||
|
||||
try:
|
||||
json_data = request.json
|
||||
except BadRequest:
|
||||
return make_response("Malformed JSON body in request", 400)
|
||||
|
||||
if not isinstance(json_data, dict):
|
||||
return make_response("Invalid log level configuration", 400)
|
||||
|
||||
# TODO validate further
|
||||
|
||||
self._set_logging_levels(json_data)
|
||||
return self.get_logging_levels_api()
|
||||
|
||||
def _get_usage(self):
|
||||
import psutil
|
||||
usage = psutil.disk_usage(settings().getBaseFolder("logs"))
|
||||
return usage.free, usage.total
|
||||
|
||||
def _getLogFiles(self):
|
||||
files = []
|
||||
basedir = settings().getBaseFolder("logs")
|
||||
for entry in scandir(basedir):
|
||||
files.append({
|
||||
"name": entry.name,
|
||||
"date": int(entry.stat().st_mtime),
|
||||
"size": entry.stat().st_size,
|
||||
"refs": {
|
||||
"resource": url_for(".download_log", filename=entry.name, _external=True),
|
||||
"download": url_for("index", _external=True) + "downloads/logs/" + entry.name
|
||||
}
|
||||
})
|
||||
|
||||
return files
|
||||
|
||||
def _get_available_loggers(self):
|
||||
return filter(lambda x: self._is_managed_logger(x), self._logger.manager.loggerDict.keys())
|
||||
|
||||
def _get_logging_file(self):
|
||||
# TODO this might not be the logging config we are actually using here (command line parameter...)
|
||||
return os.path.join(self._settings.getBaseFolder("base"), "logging.yaml")
|
||||
|
||||
def _get_logging_config(self):
|
||||
logging_file = self._get_logging_file()
|
||||
|
||||
config_from_file = {}
|
||||
if os.path.exists(logging_file) and os.path.isfile(logging_file):
|
||||
import yaml
|
||||
with open(logging_file, "r") as f:
|
||||
config_from_file = yaml.safe_load(f)
|
||||
return config_from_file
|
||||
|
||||
def _get_logging_levels(self):
|
||||
config = self._get_logging_config()
|
||||
if config is None or not isinstance(config, dict):
|
||||
return dict()
|
||||
|
||||
return dict((key, value.get("level"))
|
||||
for key, value in config.get("loggers", dict()).items()
|
||||
if isinstance(value, dict) and "level" in value)
|
||||
|
||||
def _set_logging_levels(self, new_levels):
|
||||
import logging
|
||||
|
||||
config = self._get_logging_config()
|
||||
|
||||
# clear all configured logging levels
|
||||
if config.has_key("loggers"):
|
||||
purge = []
|
||||
for component in config["loggers"]:
|
||||
if not self._is_managed_logger(component): continue
|
||||
try:
|
||||
del config["loggers"][component]["level"]
|
||||
self._logger.manager.loggerDict[component].setLevel(logging.INFO)
|
||||
except:
|
||||
pass
|
||||
if len(config["loggers"][component]) == 0:
|
||||
purge.append(component)
|
||||
else:
|
||||
config["loggers"] = dict()
|
||||
|
||||
# update all logging levels
|
||||
for logger, level in new_levels.items():
|
||||
if not config["loggers"].has_key(logger):
|
||||
config["loggers"][logger] = dict()
|
||||
config["loggers"][logger]["level"] = level
|
||||
|
||||
# delete empty entries
|
||||
config["loggers"] = {k: v for k, v in config["loggers"].items() if len(v)}
|
||||
|
||||
# save
|
||||
with octoprint.util.atomic_write(self._get_logging_file(), "wb", max_permissions=0o666) as f:
|
||||
yaml.safe_dump(config, f, default_flow_style=False, indent=" ", allow_unicode=True)
|
||||
|
||||
# set runtime logging levels now
|
||||
for logger, level in new_levels.items():
|
||||
level = logging.getLevelName(level)
|
||||
|
||||
self._logger.info("Setting logger {} level to {}".format(logger, level))
|
||||
self._logger.manager.loggerDict[logger].setLevel(level)
|
||||
|
||||
def _is_managed_logger(self, logger):
|
||||
return logger and (logger.startswith("octoprint") or logger.startswith("tornado"))
|
||||
|
||||
def get_template_configs(self):
|
||||
return [
|
||||
dict(type="settings", custom_bindings=True)
|
||||
]
|
||||
|
||||
def get_assets(self):
|
||||
return dict(js=["js/logging.js"],
|
||||
less=["less/logging.less"],
|
||||
css=["css/logging.css"])
|
||||
|
||||
__plugin_name__ = "Logging"
|
||||
__plugin_author__ = "Shawn Bruce, based on work by Gina Häußge and Marc Hannappel"
|
||||
__plugin_description__ = "Provides access to OctoPrint's logs and logging configuration."
|
||||
__plugin_implementation__ = LoggingPlugin()
|
||||
@@ -0,0 +1,214 @@
|
||||
(function (global, factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["OctoPrintClient"], factory);
|
||||
} else {
|
||||
factory(global.OctoPrintClient);
|
||||
}
|
||||
})(this, function(OctoPrintClient) {
|
||||
|
||||
var OctoPrintLoggingClient = function(base) {
|
||||
this.base = base;
|
||||
|
||||
this.baseUrl = this.base.getBlueprintUrl("logging");
|
||||
this.logsUrl = this.baseUrl + "logs";
|
||||
this.setupUrl = this.baseUrl + "setup";
|
||||
};
|
||||
|
||||
OctoPrintLoggingClient.prototype.get = function(opts) {
|
||||
return this.base.get(this.baseUrl, opts);
|
||||
};
|
||||
|
||||
OctoPrintLoggingClient.prototype.listLogs = function(opts) {
|
||||
return this.base.get(this.logsUrl, opts);
|
||||
};
|
||||
|
||||
OctoPrintLoggingClient.prototype.deleteLog = function(file, opts) {
|
||||
var fileUrl = this.logsUrl + "/" + file;
|
||||
return this.base.delete(fileUrl, opts);
|
||||
};
|
||||
|
||||
OctoPrintLoggingClient.prototype.downloadLog = function(file, opts) {
|
||||
var fileUrl = this.logsUrl + "/" + file;
|
||||
return this.base.download(fileUrl, opts);
|
||||
};
|
||||
|
||||
OctoPrintLoggingClient.prototype.updateLevels = function(config, opts) {
|
||||
return this.base.putJson(this.setupUrl + "/levels", config, opts);
|
||||
};
|
||||
|
||||
//~~ wrapper for backwards compatibility
|
||||
|
||||
var DeprecatedOctoPrintLogsClient = function(base) {
|
||||
this.base = base;
|
||||
this.wrapped = this.base.plugins.logging;
|
||||
};
|
||||
|
||||
DeprecatedOctoPrintLogsClient.prototype.list = function(opts) {
|
||||
log.warn("OctoPrintClient.logs.list has been deprecated as of OctoPrint 1.3.7, use OctoPrintClient.plugins.logging.listLogs instead");
|
||||
return this.wrapped.listLogs(opts);
|
||||
};
|
||||
|
||||
DeprecatedOctoPrintLogsClient.prototype.delete = function(file, opts) {
|
||||
log.warn("OctoPrintClient.logs.delete has been deprecated as of OctoPrint 1.3.7, use OctoPrintClient.plugins.logging.deleteLog instead");
|
||||
return this.wrapped.deleteLog(file, opts);
|
||||
};
|
||||
|
||||
DeprecatedOctoPrintLogsClient.prototype.download = function(file, opts) {
|
||||
log.warn("OctoPrintClient.logs.download has been deprecated as of OctoPrint 1.3.7, use OctoPrintClient.plugins.logging.downloadLog instead");
|
||||
return this.wrapped.downloadLog(file, opts);
|
||||
};
|
||||
|
||||
// register plugin component
|
||||
OctoPrintClient.registerPluginComponent("logging", OctoPrintLoggingClient);
|
||||
|
||||
// also register deprecated client under old endpoint
|
||||
OctoPrintClient.registerComponent("logs", DeprecatedOctoPrintLogsClient);
|
||||
|
||||
return OctoPrintLoggingClient;
|
||||
});
|
||||
|
||||
$(function() {
|
||||
function LoggingViewModel(parameters) {
|
||||
var self = this;
|
||||
|
||||
self.loginState = parameters[0];
|
||||
self.availableLoggers = ko.observableArray();
|
||||
self.availableLoggersName = ko.observable();
|
||||
self.availableLoggersLevel = ko.observable();
|
||||
self.configuredLoggers = ko.observableArray();
|
||||
self.configuredLoggersChanged = false;
|
||||
|
||||
self.availableLoggersSorted = ko.computed(function() {
|
||||
return _.sortBy(self.availableLoggers());
|
||||
});
|
||||
|
||||
self.configuredLoggersSorted = ko.computed(function() {
|
||||
return _.sortBy(self.configuredLoggers(), function (o) {
|
||||
o.level();
|
||||
return o.component;
|
||||
});
|
||||
});
|
||||
|
||||
// initialize list helper
|
||||
self.listHelper = new ItemListHelper(
|
||||
"logFiles",
|
||||
{
|
||||
"name": function(a, b) {
|
||||
// sorts ascending
|
||||
if (a["name"].toLocaleLowerCase() < b["name"].toLocaleLowerCase()) return -1;
|
||||
if (a["name"].toLocaleLowerCase() > b["name"].toLocaleLowerCase()) return 1;
|
||||
return 0;
|
||||
},
|
||||
"modification": function(a, b) {
|
||||
// sorts descending
|
||||
if (a["date"] > b["date"]) return -1;
|
||||
if (a["date"] < b["date"]) return 1;
|
||||
return 0;
|
||||
},
|
||||
"size": function(a, b) {
|
||||
// sorts descending
|
||||
if (a["size"] > b["size"]) return -1;
|
||||
if (a["size"] < b["size"]) return 1;
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
{
|
||||
},
|
||||
"name",
|
||||
[],
|
||||
[],
|
||||
CONFIG_LOGFILESPERPAGE
|
||||
);
|
||||
|
||||
self.requestData = function() {
|
||||
OctoPrint.plugins.logging.get()
|
||||
.done(self.fromResponse);
|
||||
};
|
||||
|
||||
self.fromResponse = function(response) {
|
||||
self.fromLogsResponse(response.logs);
|
||||
self.fromSetupResponse(response.setup);
|
||||
};
|
||||
|
||||
self.fromLogsResponse = function(response) {
|
||||
if (!response) return;
|
||||
|
||||
var files = response.files;
|
||||
if (files === undefined)
|
||||
return;
|
||||
|
||||
self.listHelper.updateItems(files);
|
||||
};
|
||||
|
||||
self.fromSetupResponse = function(response) {
|
||||
if (!response) return;
|
||||
|
||||
// levels
|
||||
var levels = [];
|
||||
var configuredLoggers = [];
|
||||
_.each(response.levels, function(level, logger) {
|
||||
var item = {component: logger, level: ko.observable(level)};
|
||||
item.level.subscribe(function() {
|
||||
self.configuredLoggersHasChanged();
|
||||
});
|
||||
levels.push(item);
|
||||
configuredLoggers.push(logger);
|
||||
});
|
||||
self.configuredLoggers(levels);
|
||||
|
||||
// loggers
|
||||
var availableLoggers = _.without(response.loggers, configuredLoggers);
|
||||
self.availableLoggers(availableLoggers);
|
||||
};
|
||||
|
||||
self.configuredLoggersHasChanged = function () {
|
||||
self.configuredLoggersChanged = true;
|
||||
};
|
||||
|
||||
self.addLogger = function() {
|
||||
var component = self.availableLoggersName();
|
||||
var level = self.availableLoggersLevel();
|
||||
|
||||
self.configuredLoggers.push({component: component, level: ko.observable(level)});
|
||||
self.availableLoggers.remove(component);
|
||||
|
||||
self.configuredLoggersHasChanged();
|
||||
};
|
||||
|
||||
self.removeLogger = function(logger) {
|
||||
self.configuredLoggers.remove(logger);
|
||||
self.availableLoggers.push(logger.component);
|
||||
|
||||
self.configuredLoggersHasChanged();
|
||||
};
|
||||
|
||||
self.removeFile = function(filename) {
|
||||
OctoPrint.plugins.logging.deleteLog(filename)
|
||||
.done(self.requestData);
|
||||
};
|
||||
|
||||
self.onSettingsShown = function() {
|
||||
self.requestData();
|
||||
};
|
||||
|
||||
self.onSettingsBeforeSave = function () {
|
||||
if ( self.configuredLoggersChanged ) {
|
||||
console.log("ConfiguredLoggers has changed. Saving!");
|
||||
var levels = {};
|
||||
_.each(self.configuredLoggers(), function(data) {
|
||||
levels[data.component] = data.level();
|
||||
});
|
||||
OctoPrint.plugins.logging.updateLevels(levels);
|
||||
} else {
|
||||
console.log("ConfiguredLoggers has not changed. Not saving.");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
construct: LoggingViewModel,
|
||||
additionalNames: ["logsViewModel"],
|
||||
dependencies: ["loginStateViewModel"],
|
||||
elements: ["#settings_plugin_logging"]
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
table {
|
||||
th, td {
|
||||
&.settings_logs_name {
|
||||
text-overflow: ellipsis;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
&.settings_logs_size {
|
||||
text-align: right;
|
||||
width: 70px;
|
||||
}
|
||||
|
||||
&.settings_logs_date {
|
||||
text-align: left;
|
||||
width: 130px;
|
||||
}
|
||||
|
||||
&.settings_logs_action {
|
||||
width: 70px;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #000;
|
||||
|
||||
&.disabled {
|
||||
color: #ccc;
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<h3>{{ _('Logs') }}</h3>
|
||||
|
||||
<div class="pull-right">
|
||||
<small>
|
||||
{{ _('Sort by') }}: <a href="#" data-bind="click: function() { listHelper.changeSorting('name'); }">{{ _('Name') }} ({{ _('ascending') }})</a> | <a href="#" data-bind="click: function() { listHelper.changeSorting('modification'); }">{{ _('Modification date') }} ({{ _('descending') }})</a> | <a href="#" data-bind="click: function() { listHelper.changeSorting('size'); }">{{ _('Size') }} ({{ _('descending') }})</a>
|
||||
</small>
|
||||
</div>
|
||||
<table class="table table-striped table-hover table-condensed table-hover" id="log_files">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="settings_logs_name">{{ _('Name') }}</th>
|
||||
<th class="settings_logs_size">{{ _('Size') }}</th>
|
||||
<th class="settings_logs_date">{{ _('Date') }}</th>
|
||||
<th class="settings_logs_action">{{ _('Action') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-bind="foreach: listHelper.paginatedItems">
|
||||
<tr data-bind="attr: {title: name}">
|
||||
<td class="settings_logs_name" data-bind="text: name"></td>
|
||||
<td class="settings_logs_size" data-bind="text: formatSize(size)"></td>
|
||||
<td class="settings_logs_date" data-bind="text: formatDate(date)"></td>
|
||||
<td class="settings_logs_action">
|
||||
<a href="#" class="icon-trash" data-bind="click: function() { if ($root.loginState.isUser()) { $parent.removeFile($data.name); } else { return; } }, css: {disabled: !$root.loginState.isUser()}"></a> | <a href="#" class="icon-download" data-bind="attr: {href: refs.download}"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="pagination pagination-mini pagination-centered">
|
||||
<ul>
|
||||
<li data-bind="css: {disabled: listHelper.currentPage() === 0}">
|
||||
<a href="#" data-bind="click: listHelper.prevPage">«</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul data-bind="foreach: listHelper.pages">
|
||||
<li data-bind="css: { active: $data.number === $root.listHelper.currentPage(), disabled: $data.number === -1 }">
|
||||
<a href="#" data-bind="text: $data.text, click: function() { $root.listHelper.changePage($data.number); }"></a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li data-bind="css: {disabled: listHelper.currentPage() === listHelper.lastPage()}">
|
||||
<a href="#" data-bind="click: listHelper.nextPage">»</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<h3>{{ _('Logging Levels') }}</h3>
|
||||
<form class="form-horizontal">
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span8"><h5>{{ _('Name') }}</h5></div>
|
||||
<div class="span2"><h5>{{ _('Level') }}</h5></div>
|
||||
</div>
|
||||
<div data-bind="foreach: configuredLoggersSorted">
|
||||
<div class="row-fluid" style="margin-bottom: 5px">
|
||||
<div class="span8">
|
||||
<span data-bind="text: component"></span>
|
||||
</div>
|
||||
<div class="span3">
|
||||
<select data-bind="value: level, event: { change: $parent.configuredLoggersHasChanged }" class="input-medium">
|
||||
<option value="DEBUG">DEBUG</option>
|
||||
<option value="INFO">INFO</option>
|
||||
<option value="WARNING">WARNING</option>
|
||||
<option value="ERROR">ERROR</option>
|
||||
<option value="CRITICAL">CRITICAL</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="span1">
|
||||
<a title="{{ _('Remove') }}" class="btn btn-danger" data-bind="click: $parent.removeLogger"><i class="icon-trash"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="row-fluid" style="margin-bottom: 5px">
|
||||
<div class="span8">
|
||||
<select class="input-block-level" data-bind="options: availableLoggersSorted, value: availableLoggersName"></select>
|
||||
</div>
|
||||
<div class="span3">
|
||||
<select class="input-medium" data-bind="value: availableLoggersLevel">
|
||||
<option value="DEBUG">DEBUG</option>
|
||||
<option value="INFO">INFO</option>
|
||||
<option value="WARNING">WARNING</option>
|
||||
<option value="ERROR">ERROR</option>
|
||||
<option value="CRITICAL">CRITICAL</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="span1">
|
||||
<a title="{{ _('Add') }}" class="btn btn-primary" data-bind="click: $root.addLogger"><i class="icon-plus"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -561,13 +561,14 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
if plugin.key == "pluginmanager":
|
||||
return make_response("Can't enable/disable Plugin Manager", 400)
|
||||
|
||||
pending = ((command == "disable" and plugin.key in self._pending_enable) or (command == "enable" and plugin.key in self._pending_disable))
|
||||
safe_mode_victim = getattr(plugin, "safe_mode_victim", False)
|
||||
|
||||
needs_restart = self._plugin_manager.is_restart_needing_plugin(plugin)
|
||||
needs_refresh = plugin.implementation and isinstance(plugin.implementation, octoprint.plugin.ReloadNeedingPlugin)
|
||||
needs_reconnect = self._plugin_manager.has_any_of_hooks(plugin, self._reconnect_hooks) and self._printer.is_operational()
|
||||
|
||||
pending = ((command == "disable" and plugin.key in self._pending_enable) or (command == "enable" and plugin.key in self._pending_disable))
|
||||
safe_mode_victim = getattr(plugin, "safe_mode_victim", False)
|
||||
needs_restart_api = (needs_restart or safe_mode_victim) and not pending
|
||||
needs_restart_api = (needs_restart or safe_mode_victim or plugin.forced_disabled) and not pending
|
||||
needs_refresh_api = needs_refresh and not pending
|
||||
needs_reconnect_api = needs_reconnect and not pending
|
||||
|
||||
@@ -677,12 +678,12 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
self._settings.global_set(["plugins", "_disabled"], disabled_list)
|
||||
self._settings.save(force=True)
|
||||
|
||||
if not needs_restart and not getattr(plugin, "safe_mode_victim", False):
|
||||
if not needs_restart and not plugin.forced_disabled and not getattr(plugin, "safe_mode_victim", False):
|
||||
self._plugin_manager.enable_plugin(plugin.key)
|
||||
else:
|
||||
if plugin.key in self._pending_disable:
|
||||
self._pending_disable.remove(plugin.key)
|
||||
elif (not plugin.enabled and not getattr(plugin, "safe_mode_enabled", False)) and plugin.key not in self._pending_enable:
|
||||
elif not plugin.enabled and plugin.key not in self._pending_enable:
|
||||
self._pending_enable.add(plugin.key)
|
||||
|
||||
def _mark_plugin_disabled(self, plugin, needs_restart=False):
|
||||
@@ -692,12 +693,12 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
self._settings.global_set(["plugins", "_disabled"], disabled_list)
|
||||
self._settings.save(force=True)
|
||||
|
||||
if not needs_restart and not getattr(plugin, "safe_mode_victim", False):
|
||||
if not needs_restart and not plugin.forced_disabled and not getattr(plugin, "safe_mode_victim", False):
|
||||
self._plugin_manager.disable_plugin(plugin.key)
|
||||
else:
|
||||
if plugin.key in self._pending_enable:
|
||||
self._pending_enable.remove(plugin.key)
|
||||
elif (plugin.enabled or getattr(plugin, "safe_mode_enabled", False)) and plugin.key not in self._pending_disable:
|
||||
elif (plugin.enabled or plugin.forced_disabled or getattr(plugin, "safe_mode_victim", False)) and plugin.key not in self._pending_disable:
|
||||
self._pending_disable.add(plugin.key)
|
||||
|
||||
def _fetch_all_data(self, async=False):
|
||||
@@ -920,10 +921,10 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
managable=plugin.managable,
|
||||
enabled=plugin.enabled,
|
||||
blacklisted=plugin.blacklisted,
|
||||
forced_disabled=plugin.forced_disabled,
|
||||
safe_mode_victim=getattr(plugin, "safe_mode_victim", False),
|
||||
safe_mode_enabled=getattr(plugin, "safe_mode_enabled", False),
|
||||
pending_enable=(not plugin.enabled and not getattr(plugin, "safe_mode_enabled", False) and plugin.key in self._pending_enable),
|
||||
pending_disable=((plugin.enabled or getattr(plugin, "safe_mode_enabled", False)) and plugin.key in self._pending_disable),
|
||||
pending_enable=(not plugin.enabled and not getattr(plugin, "safe_mode_victim", False) and plugin.key in self._pending_enable),
|
||||
pending_disable=((plugin.enabled or getattr(plugin, "safe_mode_victim", False)) and plugin.key in self._pending_disable),
|
||||
pending_install=(self._plugin_manager.is_plugin_marked(plugin.key, "installed")),
|
||||
pending_uninstall=(self._plugin_manager.is_plugin_marked(plugin.key, "uninstalled")),
|
||||
origin=plugin.origin.type,
|
||||
|
||||
@@ -222,7 +222,7 @@ $(function() {
|
||||
|
||||
self.enableToggle = function(data) {
|
||||
var command = self._getToggleCommand(data);
|
||||
var not_safemode_victim = !data.safe_mode_victim || data.safe_mode_enabled;
|
||||
var not_safemode_victim = !data.safe_mode_victim;
|
||||
var not_blacklisted = !data.blacklisted;
|
||||
return self.enableManagement() && (command == "disable" || (not_safemode_victim && not_blacklisted)) && data.key != 'pluginmanager';
|
||||
};
|
||||
@@ -462,7 +462,7 @@ $(function() {
|
||||
};
|
||||
|
||||
if (self._getToggleCommand(data) == "enable") {
|
||||
if (data.safe_mode_victim && !data.safe_mode_enabled) return;
|
||||
if (data.safe_mode_victim) return;
|
||||
OctoPrint.plugins.pluginmanager.enable(data.key)
|
||||
.done(onSuccess)
|
||||
.fail(onError);
|
||||
@@ -857,7 +857,8 @@ $(function() {
|
||||
};
|
||||
|
||||
self._getToggleCommand = function(data) {
|
||||
var disable = (data.enabled || data.pending_enable || (data.safe_mode_victim && data.safe_mode_enabled)) && !data.pending_disable;
|
||||
var disable = (data.enabled || (data.safe_mode_victim && !data.forced_disabled) || data.pending_enable)
|
||||
&& !data.pending_disable;
|
||||
return disable ? "disable" : "enable";
|
||||
};
|
||||
|
||||
@@ -873,7 +874,7 @@ $(function() {
|
||||
if (command == "enable") {
|
||||
if (data.blacklisted) {
|
||||
return gettext("Blacklisted");
|
||||
} else if (data.safe_mode_victim && !data.safe_mode_enabled) {
|
||||
} else if (data.safe_mode_victim) {
|
||||
return gettext("Disabled due to active safe mode");
|
||||
} else {
|
||||
return gettext("Enable Plugin");
|
||||
|
||||
@@ -523,7 +523,7 @@ $(function() {
|
||||
self.updateInProgress = false;
|
||||
self._showPopup({
|
||||
title: gettext("Update not started!"),
|
||||
text: gettext("The update could not be started. Is it already active? Please consult the log for details."),
|
||||
text: gettext("The update could not be started. Is it already active? Please consult octoprint.log for details."),
|
||||
type: "error",
|
||||
hide: false,
|
||||
buttons: {
|
||||
@@ -719,7 +719,7 @@ $(function() {
|
||||
self.waitingForRestart = true;
|
||||
self.restartTimeout = setTimeout(function() {
|
||||
title = gettext("Restart failed");
|
||||
text = gettext("The server apparently did not restart by itself, you'll have to do it manually. Please consult the log file on what went wrong.");
|
||||
text = gettext("The server apparently did not restart by itself, you'll have to do it manually. Please consult octoprint.log on what went wrong.");
|
||||
|
||||
self._showPopup({
|
||||
title: title,
|
||||
@@ -762,9 +762,9 @@ $(function() {
|
||||
}
|
||||
case "restart_failed": {
|
||||
restartType = messageData.restart_type;
|
||||
text = gettext("Restarting OctoPrint failed, please restart it manually. You might also want to consult the log file on what went wrong here.");
|
||||
text = gettext("Restarting OctoPrint failed, please restart it manually. You might also want to consult octoprint.log on what went wrong here.");
|
||||
if (restartType === "environment") {
|
||||
text = gettext("Rebooting the server failed, please reboot it manually. You might also want to consult the log file on what went wrong here.");
|
||||
text = gettext("Rebooting the server failed, please reboot it manually. You might also want to consult octoprint.log on what went wrong here.");
|
||||
}
|
||||
|
||||
title = gettext("Restart failed");
|
||||
@@ -800,7 +800,7 @@ $(function() {
|
||||
}
|
||||
case "error": {
|
||||
title = gettext("Update failed!");
|
||||
text = gettext("The update did not finish successfully. Please consult the log for details.");
|
||||
text = gettext("The update did not finish successfully. Please consult octoprint.log and plugin_softwareupdate_console.log for details.");
|
||||
self._showPopup({
|
||||
title: title,
|
||||
text: text,
|
||||
|
||||
@@ -16,6 +16,8 @@ logger = logging.getLogger("octoprint.plugins.softwareupdate.updaters.pip")
|
||||
console_logger = logging.getLogger("octoprint.plugins.softwareupdate.updaters.pip.console")
|
||||
|
||||
_ALREADY_INSTALLED = "Requirement already satisfied (use --upgrade to upgrade)"
|
||||
_POTENTIAL_EGG_PROBLEM_POSIX = "No such file or directory"
|
||||
_POTENTIAL_EGG_PROBLEM_WINDOWS = "The system cannot find the file specified"
|
||||
|
||||
_pip_callers = dict()
|
||||
_pip_version_dependency_links = pkg_resources.parse_version("1.5")
|
||||
@@ -42,6 +44,10 @@ def perform_update(target, check, target_version, log_cb=None, online=True, forc
|
||||
if "pip_command" in check:
|
||||
pip_command = check["pip_command"]
|
||||
|
||||
pip_working_directory = None
|
||||
if "pip_cwd" in check:
|
||||
pip_working_directory = check["pip_cwd"]
|
||||
|
||||
if not online and not check.get("offline", False):
|
||||
raise exceptions.CannotUpdateOffline()
|
||||
|
||||
@@ -58,6 +64,9 @@ def perform_update(target, check, target_version, log_cb=None, online=True, forc
|
||||
def _log_stderr(*lines):
|
||||
_log(lines, prefix="!", stream="stderr")
|
||||
|
||||
def _log_message(*lines):
|
||||
_log(lines, prefix="#", stream="message")
|
||||
|
||||
def _log(lines, prefix=None, stream=None):
|
||||
if log_cb is None:
|
||||
return
|
||||
@@ -72,23 +81,43 @@ def perform_update(target, check, target_version, log_cb=None, online=True, forc
|
||||
|
||||
logger.debug(u"Target: %s, executing pip install %s" % (target, install_arg))
|
||||
pip_args = ["install", install_arg]
|
||||
pip_kwargs = dict()
|
||||
if pip_working_directory is not None:
|
||||
pip_kwargs.update(cwd=pip_working_directory)
|
||||
|
||||
if "dependency_links" in check and check["dependency_links"]:
|
||||
pip_args += ["--process-dependency-links"]
|
||||
|
||||
returncode, stdout, stderr = pip_caller.execute(*pip_args)
|
||||
returncode, stdout, stderr = pip_caller.execute(*pip_args, **pip_kwargs)
|
||||
if returncode != 0:
|
||||
raise exceptions.UpdateError("Error while executing pip install", (stdout, stderr))
|
||||
|
||||
# This could be caused by an issue with pip/setuptools: If something (target or dependency of target) was
|
||||
# installed as an egg at an earlier date (e.g. thanks to just running python setup.py install), pip install
|
||||
# will throw an error after updating that something to a newer (non-egg) version since it will still have
|
||||
# the egg on its sys.path and expect to read data from it. Running the exact same command a second time
|
||||
# solved this during hunt for a workaround, so this is what we'll now do if it indeed looks like this
|
||||
# specific problem
|
||||
def is_egg_problem(line):
|
||||
return (_POTENTIAL_EGG_PROBLEM_POSIX in line or _POTENTIAL_EGG_PROBLEM_WINDOWS in line) and ".egg" in line
|
||||
|
||||
if any(map(lambda x: is_egg_problem(x), stderr)) or any(map(lambda x: is_egg_problem(x), stdout)):
|
||||
_log_message(u"This looks like an error caused by a specific issue in upgrading Python \"eggs\"",
|
||||
u"via current versions of pip.",
|
||||
u"Performing a second install attempt as a work around.")
|
||||
returncode, stdout, stderr = pip_caller.execute(*pip_args, **pip_kwargs)
|
||||
if returncode != 0:
|
||||
raise exceptions.UpdateError("Error while executing pip install", (stdout, stderr))
|
||||
else:
|
||||
raise exceptions.UpdateError("Error while executing pip install", (stdout, stderr))
|
||||
|
||||
if not force and any(map(lambda x: x.strip().startswith(_ALREADY_INSTALLED) and (install_arg in x or install_arg in x.lower()), stdout)):
|
||||
logger.debug(u"Looks like we were already installed in this version. Forcing a reinstall.")
|
||||
_log_message(u"Looks like we were already installed in this version. Forcing a reinstall.")
|
||||
force = True
|
||||
|
||||
if force:
|
||||
logger.debug(u"Target: %s, executing pip install %s --ignore-reinstalled --force-reinstall --no-deps" % (target, install_arg))
|
||||
pip_args += ["--ignore-installed", "--force-reinstall", "--no-deps"]
|
||||
|
||||
returncode, stdout, stderr = pip_caller.execute(*pip_args)
|
||||
|
||||
returncode, stdout, stderr = pip_caller.execute(*pip_args, **pip_kwargs)
|
||||
if returncode != 0:
|
||||
raise exceptions.UpdateError("Error while executing pip install --force-reinstall", (stdout, stderr))
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ __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"
|
||||
|
||||
from . import commandline, git_commit, github_commit, github_release, bitbucket_commit, python_checker
|
||||
from . import commandline, git_commit, github_commit, github_release, bitbucket_commit, python_checker, never_current, always_current
|
||||
|
||||
def log_github_ratelimit(logger, r):
|
||||
ratelimit = r.headers["X-RateLimit-Limit"] if "X-RateLimit-Limit" in r.headers else "?"
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
def get_latest(target, check, online=True):
|
||||
current_version = check.get("current_version", "1.0.0")
|
||||
|
||||
information = dict(local=dict(name=current_version, value=current_version),
|
||||
remote=dict(name=current_version, value=current_version))
|
||||
|
||||
return information, True
|
||||
@@ -0,0 +1,14 @@
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
def get_latest(target, check, online=True):
|
||||
local_version = check.get("local_version", "1.0.0")
|
||||
remote_version = check.get("remote_version", "1.0.1")
|
||||
|
||||
information = dict(local=dict(name=local_version, value=local_version),
|
||||
remote=dict(name=remote_version, value=remote_version))
|
||||
|
||||
return information, False
|
||||
@@ -114,6 +114,7 @@ class VirtualPrinter(object):
|
||||
self._sendWait = settings().getBoolean(["devel", "virtualPrinter", "sendWait"])
|
||||
self._sendBusy = settings().getBoolean(["devel", "virtualPrinter", "sendBusy"])
|
||||
self._waitInterval = settings().getFloat(["devel", "virtualPrinter", "waitInterval"])
|
||||
self._busyInterval = settings().getFloat(["devel", "virtualPrinter", "busyInterval"])
|
||||
|
||||
self._echoOnM117 = settings().getBoolean(["devel", "virtualPrinter", "echoOnM117"])
|
||||
|
||||
@@ -427,6 +428,11 @@ class VirtualPrinter(object):
|
||||
filename = data.split(None, 1)[1].strip()
|
||||
self._deleteSdFile(filename)
|
||||
|
||||
def _gcode_M113(self, data):
|
||||
interval = int(re.search("S([0-9]+)", data).group(1))
|
||||
if 0 <= interval <= 60:
|
||||
self._busyInterval = interval
|
||||
|
||||
def _gcode_M114(self, data):
|
||||
if settings().getBoolean(["devel", "virtualPrinter", "reprapfwM114"]):
|
||||
output = "X:{} Y:{} Z:{} {}".format(self._lastX,
|
||||
@@ -536,10 +542,10 @@ class VirtualPrinter(object):
|
||||
elif matchS:
|
||||
_timeout = float(matchS.group(1))
|
||||
|
||||
if self._sendBusy:
|
||||
if self._sendBusy and self._busyInterval > 0:
|
||||
until = time.time() + _timeout
|
||||
while time.time() < until:
|
||||
time.sleep(1.0)
|
||||
time.sleep(self._busyInterval)
|
||||
self._send("busy:processing")
|
||||
else:
|
||||
time.sleep(_timeout)
|
||||
@@ -1035,19 +1041,26 @@ class VirtualPrinter(object):
|
||||
def _waitForHeatup(self, heater, only_wait_if_higher):
|
||||
delta = 1
|
||||
delay = 1
|
||||
last_busy = time.time()
|
||||
|
||||
try:
|
||||
if heater.startswith("tool"):
|
||||
toolNum = int(heater[len("tool"):])
|
||||
while not self._killed and (self.temp[toolNum] < self.targetTemp[toolNum] - delta or (not only_wait_if_higher and self.temp[toolNum] > self.targetTemp[toolNum] + delta)):
|
||||
self._simulateTemps(delta=delta)
|
||||
self._output("T:%0.2f" % self.temp[toolNum])
|
||||
time.sleep(delay)
|
||||
test = lambda: self.temp[toolNum] < self.targetTemp[toolNum] - delta or (not only_wait_if_higher and self.temp[toolNum] > self.targetTemp[toolNum] + delta)
|
||||
output = lambda: "T:%0.2f" % self.temp[toolNum]
|
||||
elif heater == "bed":
|
||||
while not self._killed and (self.bedTemp < self.bedTargetTemp - delta or (not only_wait_if_higher and self.bedTemp > self.bedTargetTemp + delta)):
|
||||
self._simulateTemps(delta=delta)
|
||||
self._output("B:%0.2f" % self.bedTemp)
|
||||
time.sleep(delay)
|
||||
test = lambda: self.bedTemp < self.bedTargetTemp - delta or (not only_wait_if_higher and self.bedTemp > self.bedTargetTemp + delta)
|
||||
output = lambda: "B:%0.2f" % self.bedTemp
|
||||
else:
|
||||
return
|
||||
|
||||
while not self._killed and test():
|
||||
self._simulateTemps(delta=delta)
|
||||
self._output(output())
|
||||
if self._sendBusy and time.time() - last_busy >= self._busyInterval:
|
||||
self._output("echo:busy: processing")
|
||||
last_busy = time.time()
|
||||
time.sleep(delay)
|
||||
except AttributeError:
|
||||
if self.outgoing is not None:
|
||||
raise
|
||||
|
||||
@@ -51,7 +51,7 @@ class PrinterInterface(object):
|
||||
"""Regex for valid heater identifiers."""
|
||||
|
||||
@classmethod
|
||||
def get_connection_options(cls):
|
||||
def get_connection_options(cls, *args, **kwargs):
|
||||
"""
|
||||
Retrieves the available ports, baudrates, preferred port and baudrate for connecting to the printer.
|
||||
|
||||
@@ -75,7 +75,7 @@ class PrinterInterface(object):
|
||||
"autoconnect": settings().getBoolean(["serial", "autoconnect"])
|
||||
}
|
||||
|
||||
def connect(self, port=None, baudrate=None, profile=None):
|
||||
def connect(self, port=None, baudrate=None, profile=None, *args, **kwargs):
|
||||
"""
|
||||
Connects to the printer, using the specified serial ``port``, ``baudrate`` and printer ``profile``. If a
|
||||
connection is already established, that connection will be closed prior to connecting anew with the provided
|
||||
@@ -89,13 +89,13 @@ class PrinterInterface(object):
|
||||
"""
|
||||
pass
|
||||
|
||||
def disconnect(self):
|
||||
def disconnect(self, *args, **kwargs):
|
||||
"""
|
||||
Disconnects from the printer. Does nothing if no connection is currently established.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_transport(self):
|
||||
def get_transport(self, *args, **kwargs):
|
||||
"""
|
||||
Returns the communication layer's transport object, if a connection is currently established.
|
||||
|
||||
@@ -107,7 +107,34 @@ class PrinterInterface(object):
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def fake_ack(self):
|
||||
def job_on_hold(self, blocking=True, *args, **kwargs):
|
||||
"""
|
||||
Contextmanager that allows executing code while printing while making sure that no commands from the file
|
||||
being printed are continued to be sent to the printer. Note that this will only work for local files,
|
||||
NOT SD files.
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
with printer.job_on_hold():
|
||||
park_printhead()
|
||||
take_snapshot()
|
||||
send_printhead_back()
|
||||
|
||||
It should be used sparingly and only for very specific situations (such as parking the print head somewhere,
|
||||
taking a snapshot from the webcam, then continuing). If you abuse this, you WILL cause print quality issues!
|
||||
|
||||
A lock is in place that ensures that the context can only actually be held by one thread at a time. If you
|
||||
don't want to block on acquire, be sure to set ``blocking`` to ``False`` and catch the ``RuntimeException`` thrown
|
||||
if the lock can't be acquired.
|
||||
|
||||
Args:
|
||||
blocking (bool): Whether to block while attempting to acquire the lock (default) or not
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def fake_ack(self, *args, **kwargs):
|
||||
"""
|
||||
Fakes an acknowledgment for the communication layer. If the communication between OctoPrint and the printer
|
||||
gets stuck due to lost "ok" responses from the server due to communication issues, this can be used to get
|
||||
@@ -115,17 +142,18 @@ class PrinterInterface(object):
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def commands(self, commands):
|
||||
def commands(self, commands, tags=None, *args, **kwargs):
|
||||
"""
|
||||
Sends the provided ``commands`` to the printer.
|
||||
|
||||
Arguments:
|
||||
commands (str, list): The commands to send. Might be a single command provided just as a string or a list
|
||||
of multiple commands to send in order.
|
||||
tags (set of str): An optional set of tags to attach to the command(s) throughout their lifecycle
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def script(self, name, context=None):
|
||||
def script(self, name, context=None, tags=None, *args, **kwargs):
|
||||
"""
|
||||
Sends the GCODE script ``name`` to the printer.
|
||||
|
||||
@@ -137,13 +165,14 @@ class PrinterInterface(object):
|
||||
Arguments:
|
||||
name (str): The name of the GCODE script to render.
|
||||
context (dict): An optional context of additional template variables to provide to the renderer.
|
||||
tags (set of str): An optional set of tags to attach to the command(s) throughout their lifecycle
|
||||
|
||||
Raises:
|
||||
UnknownScriptException: There is no GCODE script with name ``name``
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def jog(self, axes, relative=True, speed=None, *args, **kwargs):
|
||||
def jog(self, axes, relative=True, speed=None, tags=None, *args, **kwargs):
|
||||
"""
|
||||
Jogs the specified printer ``axis`` by the specified ``amount`` in mm.
|
||||
|
||||
@@ -154,38 +183,42 @@ class PrinterInterface(object):
|
||||
speed (int, bool or None): Speed at which to jog (F parameter). If set to ``False`` no speed will be set
|
||||
specifically. If set to ``None`` (or left out) the minimum of all involved axes speeds from the printer
|
||||
profile will be used.
|
||||
tags (set of str): An optional set of tags to attach to the command(s) throughout their lifecycle
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def home(self, axes):
|
||||
def home(self, axes, tags=None, *args, **kwargs):
|
||||
"""
|
||||
Homes the specified printer ``axes``.
|
||||
|
||||
Arguments:
|
||||
axes (str, list): The axis or axes to home, each of which must converted to lower case must match one of
|
||||
"x", "y", "z" and "e"
|
||||
tags (set of str): An optional set of tags to attach to the command(s) throughout their lifecycle
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def extrude(self, amount):
|
||||
def extrude(self, amount, tags=None, *args, **kwargs):
|
||||
"""
|
||||
Extrude ``amount`` millimeters of material from the tool.
|
||||
|
||||
Arguments:
|
||||
amount (int, float): The amount of material to extrude in mm
|
||||
tags (set of str): An optional set of tags to attach to the command(s) throughout their lifecycle
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def change_tool(self, tool):
|
||||
def change_tool(self, tool, tags=None, *args, **kwargs):
|
||||
"""
|
||||
Switch the currently active ``tool`` (for which extrude commands will apply).
|
||||
|
||||
Arguments:
|
||||
tool (str): The tool to switch to, matching the regex "tool[0-9]+" (e.g. "tool0", "tool1", ...)
|
||||
tags (set of str): An optional set of tags to attach to the command(s) throughout their lifecycle
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def set_temperature(self, heater, value):
|
||||
def set_temperature(self, heater, value, tags=None, *args, **kwargs):
|
||||
"""
|
||||
Sets the target temperature on the specified ``heater`` to the given ``value`` in celsius.
|
||||
|
||||
@@ -194,10 +227,11 @@ class PrinterInterface(object):
|
||||
temperature or something matching the regular expression "tool[0-9]+" (e.g. "tool0", "tool1", ...) for
|
||||
the hotends of the printer
|
||||
value (int, float): The temperature in celsius to set the target temperature to.
|
||||
tags (set of str): An optional set of tags to attach to the command(s) throughout their lifecycle
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def set_temperature_offset(self, offsets=None):
|
||||
def set_temperature_offset(self, offsets=None, tags=None, *args, **kwargs):
|
||||
"""
|
||||
Sets the temperature ``offsets`` to apply to target temperatures read from a GCODE file while printing.
|
||||
|
||||
@@ -205,30 +239,33 @@ class PrinterInterface(object):
|
||||
offsets (dict): A dictionary specifying the offsets to apply. Keys must match the format for the ``heater``
|
||||
parameter to :func:`set_temperature`, so "bed" for the offset for the bed target temperature and
|
||||
"tool[0-9]+" for the offsets to the hotend target temperatures.
|
||||
tags (set of str): An optional set of tags to attach to the command(s) throughout their lifecycle
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def feed_rate(self, factor):
|
||||
def feed_rate(self, factor, tags=None, *args, **kwargs):
|
||||
"""
|
||||
Sets the ``factor`` for the printer's feed rate.
|
||||
|
||||
Arguments:
|
||||
factor (int, float): The factor for the feed rate to send to the firmware. Percentage expressed as either an
|
||||
int between 0 and 100 or a float between 0 and 1.
|
||||
tags (set of str): An optional set of tags to attach to the command(s) throughout their lifecycle
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def flow_rate(self, factor):
|
||||
def flow_rate(self, factor, tags=None, *args, **kwargs):
|
||||
"""
|
||||
Sets the ``factor`` for the printer's flow rate.
|
||||
|
||||
Arguments:
|
||||
factor (int, float): The factor for the flow rate to send to the firmware. Percentage expressed as either an
|
||||
int between 0 and 100 or a float between 0 and 1.
|
||||
tags (set of str): An optional set of tags to attach to the command(s) throughout their lifecycle
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def can_modify_file(self, path, sd):
|
||||
def can_modify_file(self, path, sd, *args, **kwargs):
|
||||
"""
|
||||
Determines whether the ``path`` (on the printer's SD if ``sd`` is True) may be modified (updated or deleted)
|
||||
or not.
|
||||
@@ -254,7 +291,7 @@ class PrinterInterface(object):
|
||||
"""
|
||||
return not (self.is_current_file(path, sd) and (self.is_printing() or self.is_paused()))
|
||||
|
||||
def is_current_file(self, path, sd):
|
||||
def is_current_file(self, path, sd, *args, **kwargs):
|
||||
"""
|
||||
Returns whether the provided ``path`` (on the printer's SD if ``sd`` is True) is the currently selected
|
||||
file for printing.
|
||||
@@ -286,7 +323,7 @@ class PrinterInterface(object):
|
||||
|
||||
return False
|
||||
|
||||
def select_file(self, path, sd, printAfterSelect=False, pos=None):
|
||||
def select_file(self, path, sd, printAfterSelect=False, pos=None, tags=None, *args, **kwargs):
|
||||
"""
|
||||
Selects the specified ``path`` for printing, specifying if the file is to be found on the ``sd`` or not.
|
||||
Optionally can also directly start the print after selecting the file.
|
||||
@@ -297,6 +334,7 @@ class PrinterInterface(object):
|
||||
sd (boolean): Indicates whether the file is on the printer's SD card or not.
|
||||
printAfterSelect (boolean): Indicates whether a print should be started
|
||||
after the file is selected.
|
||||
tags (set of str): An optional set of tags to attach to the command(s) throughout their lifecycle
|
||||
|
||||
Raises:
|
||||
InvalidFileType: if the file is not a machinecode file and hence cannot be printed
|
||||
@@ -305,53 +343,68 @@ class PrinterInterface(object):
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def unselect_file(self):
|
||||
def unselect_file(self, *args, **kwargs):
|
||||
"""
|
||||
Unselects and currently selected file.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def start_print(self):
|
||||
def start_print(self, tags=None, *args, **kwargs):
|
||||
"""
|
||||
Starts printing the currently selected file. If no file is currently selected, does nothing.
|
||||
|
||||
Arguments:
|
||||
tags (set of str): An optional set of tags to attach to the command(s) throughout their lifecycle
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def pause_print(self):
|
||||
def pause_print(self, tags=None, *args, **kwargs):
|
||||
"""
|
||||
Pauses the current print job if it is currently running, does nothing otherwise.
|
||||
|
||||
Arguments:
|
||||
tags (set of str): An optional set of tags to attach to the command(s) throughout their lifecycle
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def resume_print(self):
|
||||
def resume_print(self, tags=None, *args, **kwargs):
|
||||
"""
|
||||
Resumes the current print job if it is currently paused, does nothing otherwise.
|
||||
|
||||
Arguments:
|
||||
tags (set of str): An optional set of tags to attach to the command(s) throughout their lifecycle
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def toggle_pause_print(self):
|
||||
def toggle_pause_print(self, tags=None, *args, **kwargs):
|
||||
"""
|
||||
Pauses the current print job if it is currently running or resumes it if it is currently paused.
|
||||
|
||||
Arguments:
|
||||
tags (set of str): An optional set of tags to attach to the command(s) throughout their lifecycle
|
||||
"""
|
||||
if self.is_printing():
|
||||
self.pause_print()
|
||||
self.pause_print(tags=tags)
|
||||
elif self.is_paused():
|
||||
self.resume_print()
|
||||
self.resume_print(tags=tags)
|
||||
|
||||
def cancel_print(self):
|
||||
def cancel_print(self, tags=None, *args, **kwargs):
|
||||
"""
|
||||
Cancels the current print job.
|
||||
|
||||
Arguments:
|
||||
tags (set of str): An optional set of tags to attach to the command(s) throughout their lifecycle
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_state_string(self):
|
||||
def get_state_string(self, *args, **kwargs):
|
||||
"""
|
||||
Returns:
|
||||
(str) A human readable string corresponding to the current communication state.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_state_id(self):
|
||||
def get_state_id(self, *args, **kwargs):
|
||||
"""
|
||||
Identifier of the current communication state.
|
||||
|
||||
@@ -376,35 +429,35 @@ class PrinterInterface(object):
|
||||
(str) A unique identifier corresponding to the current communication state.
|
||||
"""
|
||||
|
||||
def get_current_data(self):
|
||||
def get_current_data(self, *args, **kwargs):
|
||||
"""
|
||||
Returns:
|
||||
(dict) The current state data.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_current_job(self):
|
||||
def get_current_job(self, *args, **kwargs):
|
||||
"""
|
||||
Returns:
|
||||
(dict) The data of the current job.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_current_temperatures(self):
|
||||
def get_current_temperatures(self, *args, **kwargs):
|
||||
"""
|
||||
Returns:
|
||||
(dict) The current temperatures.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_temperature_history(self):
|
||||
def get_temperature_history(self, *args, **kwargs):
|
||||
"""
|
||||
Returns:
|
||||
(list) The temperature history.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_current_connection(self):
|
||||
def get_current_connection(self, *args, **kwargs):
|
||||
"""
|
||||
Returns:
|
||||
(tuple) The current connection information as a 4-tuple ``(connection_string, port, baudrate, printer_profile)``.
|
||||
@@ -412,49 +465,49 @@ class PrinterInterface(object):
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def is_closed_or_error(self):
|
||||
def is_closed_or_error(self, *args, **kwargs):
|
||||
"""
|
||||
Returns:
|
||||
(boolean) Whether the printer is currently disconnected and/or in an error state.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def is_operational(self):
|
||||
def is_operational(self, *args, **kwargs):
|
||||
"""
|
||||
Returns:
|
||||
(boolean) Whether the printer is currently connected and available.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def is_printing(self):
|
||||
def is_printing(self, *args, **kwargs):
|
||||
"""
|
||||
Returns:
|
||||
(boolean) Whether the printer is currently printing.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def is_paused(self):
|
||||
def is_paused(self, *args, **kwargs):
|
||||
"""
|
||||
Returns:
|
||||
(boolean) Whether the printer is currently paused.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def is_error(self):
|
||||
def is_error(self, *args, **kwargs):
|
||||
"""
|
||||
Returns:
|
||||
(boolean) Whether the printer is currently in an error state.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def is_ready(self):
|
||||
def is_ready(self, *args, **kwargs):
|
||||
"""
|
||||
Returns:
|
||||
(boolean) Whether the printer is currently operational and ready for new print jobs (not printing).
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def register_callback(self, callback):
|
||||
def register_callback(self, callback, *args, **kwargs):
|
||||
"""
|
||||
Registers a :class:`PrinterCallback` with the instance.
|
||||
|
||||
@@ -463,7 +516,7 @@ class PrinterInterface(object):
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def unregister_callback(self, callback):
|
||||
def unregister_callback(self, callback, *args, **kwargs):
|
||||
"""
|
||||
Unregisters a :class:`PrinterCallback` from the instance.
|
||||
|
||||
|
||||
@@ -126,14 +126,14 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
|
||||
#~~ handling of PrinterCallbacks
|
||||
|
||||
def register_callback(self, callback):
|
||||
def register_callback(self, callback, *args, **kwargs):
|
||||
if not isinstance(callback, PrinterCallback):
|
||||
self._logger.warn("Registering an object as printer callback which doesn't implement the PrinterCallback interface")
|
||||
|
||||
self._callbacks.append(callback)
|
||||
self._sendInitialStateUpdate(callback)
|
||||
|
||||
def unregister_callback(self, callback):
|
||||
def unregister_callback(self, callback, *args, **kwargs):
|
||||
if callback in self._callbacks:
|
||||
self._callbacks.remove(callback)
|
||||
|
||||
@@ -196,7 +196,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
|
||||
#~~ PrinterInterface implementation
|
||||
|
||||
def connect(self, port=None, baudrate=None, profile=None):
|
||||
def connect(self, port=None, baudrate=None, profile=None, *args, **kwargs):
|
||||
"""
|
||||
Connects to the printer. If port and/or baudrate is provided, uses these settings, otherwise autodetection
|
||||
will be attempted.
|
||||
@@ -215,7 +215,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
|
||||
self._comm = comm.MachineCom(port, baudrate, callbackObject=self, printerProfileManager=self._printerProfileManager)
|
||||
|
||||
def disconnect(self):
|
||||
def disconnect(self, *args, **kwargs):
|
||||
"""
|
||||
Closes the connection to the printer.
|
||||
"""
|
||||
@@ -225,7 +225,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
else:
|
||||
eventManager().fire(Events.DISCONNECTED)
|
||||
|
||||
def get_transport(self):
|
||||
def get_transport(self, *args, **kwargs):
|
||||
|
||||
if self._comm is None:
|
||||
return None
|
||||
@@ -233,13 +233,18 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
return self._comm.getTransport()
|
||||
getTransport = util.deprecated("getTransport has been renamed to get_transport", since="1.2.0-dev-590", includedoc="Replaced by :func:`get_transport`")
|
||||
|
||||
def fake_ack(self):
|
||||
def job_on_hold(self, blocking=None, *args, **kwargs):
|
||||
if self._comm is None:
|
||||
raise RuntimeError("No connection to the printer")
|
||||
return self._comm.job_on_hold(blocking=blocking)
|
||||
|
||||
def fake_ack(self, *args, **kwargs):
|
||||
if self._comm is None:
|
||||
return
|
||||
|
||||
self._comm.fakeOk()
|
||||
|
||||
def commands(self, commands):
|
||||
def commands(self, commands, *args, **kwargs):
|
||||
"""
|
||||
Sends one or more gcode commands to the printer.
|
||||
"""
|
||||
@@ -250,16 +255,18 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
commands = [commands]
|
||||
|
||||
for command in commands:
|
||||
self._comm.sendCommand(command)
|
||||
self._comm.sendCommand(command, tags=kwargs.get("tags", set()) | {"trigger:printer.commands"})
|
||||
|
||||
def script(self, name, context=None, must_be_set=True):
|
||||
def script(self, name, context=None, must_be_set=True, *args, **kwargs):
|
||||
if self._comm is None:
|
||||
return
|
||||
|
||||
if name is None or not name:
|
||||
raise ValueError("name must be set")
|
||||
|
||||
result = self._comm.sendGcodeScript(name, replacements=context)
|
||||
result = self._comm.sendGcodeScript(name,
|
||||
replacements=context,
|
||||
tags=kwargs.get("tags", set()) | {"trigger:printer.script"})
|
||||
if not result and must_be_set:
|
||||
raise UnknownScript(name)
|
||||
|
||||
@@ -298,9 +305,9 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
else:
|
||||
commands = ["G90", command]
|
||||
|
||||
self.commands(commands)
|
||||
self.commands(commands, tags=kwargs.get("tags", set()) | {"trigger:printer.jog"})
|
||||
|
||||
def home(self, axes):
|
||||
def home(self, axes, *args, **kwargs):
|
||||
if not isinstance(axes, (list, tuple)):
|
||||
if isinstance(axes, (str, unicode)):
|
||||
axes = [axes]
|
||||
@@ -311,24 +318,26 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
if len(axes) != len(validated_axes):
|
||||
raise ValueError("axes contains invalid axes: {axes}".format(axes=axes))
|
||||
|
||||
self.commands(["G91", "G28 %s" % " ".join(map(lambda x: "%s0" % x.upper(), validated_axes)), "G90"])
|
||||
self.commands(["G91", "G28 %s" % " ".join(map(lambda x: "%s0" % x.upper(), validated_axes)), "G90"],
|
||||
tags=kwargs.get("tags", set) | {"trigger:printer.home"})
|
||||
|
||||
def extrude(self, amount):
|
||||
def extrude(self, amount, *args, **kwargs):
|
||||
if not isinstance(amount, (int, long, float)):
|
||||
raise ValueError("amount must be a valid number: {amount}".format(amount=amount))
|
||||
|
||||
printer_profile = self._printerProfileManager.get_current_or_default()
|
||||
extrusion_speed = printer_profile["axes"]["e"]["speed"]
|
||||
self.commands(["G91", "G1 E%s F%d" % (amount, extrusion_speed), "G90"])
|
||||
self.commands(["G91", "G1 E%s F%d" % (amount, extrusion_speed), "G90"],
|
||||
tags=kwargs.get("tags", set()) | {"trigger:printer.extrude"})
|
||||
|
||||
def change_tool(self, tool):
|
||||
def change_tool(self, tool, *args, **kwargs):
|
||||
if not PrinterInterface.valid_tool_regex.match(tool):
|
||||
raise ValueError("tool must match \"tool[0-9]+\": {tool}".format(tool=tool))
|
||||
|
||||
tool_num = int(tool[len("tool"):])
|
||||
self.commands("T%d" % tool_num)
|
||||
self.commands("T%d" % tool_num, tags=kwargs.get("tags", set()) | {"trigger:printer.change_tool"})
|
||||
|
||||
def set_temperature(self, heater, value):
|
||||
def set_temperature(self, heater, value, *args, **kwargs):
|
||||
if not PrinterInterface.valid_heater_regex.match(heater):
|
||||
raise ValueError("heater must match \"tool[0-9]+\" or \"bed\": {heater}".format(heater=heater))
|
||||
|
||||
@@ -341,14 +350,17 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
shared_nozzle = printer_profile["extruder"]["sharedNozzle"]
|
||||
if extruder_count > 1 and not shared_nozzle:
|
||||
toolNum = int(heater[len("tool"):])
|
||||
self.commands("M104 T{} S{}".format(toolNum, value))
|
||||
self.commands("M104 T{} S{}".format(toolNum, value),
|
||||
tags=kwargs.get("tags", set()) | {"trigger:printer.set_temperature"})
|
||||
else:
|
||||
self.commands("M104 S{}".format(value))
|
||||
self.commands("M104 S{}".format(value),
|
||||
tags=kwargs.get("tags", set()) | {"trigger:printer.set_temperature"})
|
||||
|
||||
elif heater == "bed":
|
||||
self.commands("M140 S{}".format(value))
|
||||
self.commands("M140 S{}".format(value),
|
||||
tags=kwargs.get("tags", set()) | {"trigger:printer.set_temperature"})
|
||||
|
||||
def set_temperature_offset(self, offsets=None):
|
||||
def set_temperature_offset(self, offsets=None, *args, **kwargs):
|
||||
if offsets is None:
|
||||
offsets = dict()
|
||||
|
||||
@@ -381,15 +393,17 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
|
||||
return factor
|
||||
|
||||
def feed_rate(self, factor):
|
||||
def feed_rate(self, factor, *args, **kwargs):
|
||||
factor = self._convert_rate_value(factor, min=50, max=200)
|
||||
self.commands("M220 S%d" % factor)
|
||||
self.commands("M220 S%d" % factor,
|
||||
tags=kwargs.get("tags", set()) | {"trigger:printer.feed_rate"})
|
||||
|
||||
def flow_rate(self, factor):
|
||||
def flow_rate(self, factor, *args, **kwargs):
|
||||
factor = self._convert_rate_value(factor, min=75, max=125)
|
||||
self.commands("M221 S%d" % factor)
|
||||
self.commands("M221 S%d" % factor,
|
||||
tags=kwargs.get("tags", set()) | {"trigger:printer.flow_rate"})
|
||||
|
||||
def select_file(self, path, sd, printAfterSelect=False, pos=None):
|
||||
def select_file(self, path, sd, printAfterSelect=False, pos=None, *args, **kwargs):
|
||||
if self._comm is None or (self._comm.isBusy() or self._comm.isStreaming()):
|
||||
self._logger.info("Cannot load file: printer not connected or currently busy")
|
||||
return
|
||||
@@ -408,11 +422,12 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
|
||||
self._printAfterSelect = printAfterSelect
|
||||
self._posAfterSelect = pos
|
||||
self._comm.selectFile("/" + path if sd else path, sd)
|
||||
self._comm.selectFile("/" + path if sd else path, sd,
|
||||
tags=kwargs.get("tags", set()) | {"trigger:printer.select_file"})
|
||||
self._updateProgressData()
|
||||
self._setCurrentZ(None)
|
||||
|
||||
def unselect_file(self):
|
||||
def unselect_file(self, *args, **kwargs):
|
||||
if self._comm is not None and (self._comm.isBusy() or self._comm.isStreaming()):
|
||||
return
|
||||
|
||||
@@ -430,7 +445,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
|
||||
return self._comm.getFilePosition()
|
||||
|
||||
def start_print(self, pos=None):
|
||||
def start_print(self, pos=None, *args, **kwargs):
|
||||
"""
|
||||
Starts the currently loaded print job.
|
||||
Only starts if the printer is connected and operational, not currently printing and a printjob is loaded
|
||||
@@ -463,9 +478,10 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
self._lastProgressReport = None
|
||||
self._updateProgressData()
|
||||
self._setCurrentZ(None)
|
||||
self._comm.startPrint(pos=pos)
|
||||
self._comm.startPrint(pos=pos,
|
||||
tags=kwargs.get("tags", set()) | {"trigger:printer.start_print"})
|
||||
|
||||
def pause_print(self):
|
||||
def pause_print(self, *args, **kwargs):
|
||||
"""
|
||||
Pause the current printjob.
|
||||
"""
|
||||
@@ -475,9 +491,9 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
if self._comm.isPaused():
|
||||
return
|
||||
|
||||
self._comm.setPause(True)
|
||||
self._comm.setPause(True, tags=kwargs.get("tags", set()) | {"trigger:printer.pause_print"})
|
||||
|
||||
def resume_print(self):
|
||||
def resume_print(self, *args, **kwargs):
|
||||
"""
|
||||
Resume the current printjob.
|
||||
"""
|
||||
@@ -487,9 +503,9 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
if not self._comm.isPaused():
|
||||
return
|
||||
|
||||
self._comm.setPause(False)
|
||||
self._comm.setPause(False, tags=kwargs.get("tags", set()) | {"trigger:printer.resume_print"})
|
||||
|
||||
def cancel_print(self):
|
||||
def cancel_print(self, *args, **kwargs):
|
||||
"""
|
||||
Cancel the current printjob.
|
||||
"""
|
||||
@@ -498,28 +514,28 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
|
||||
# tell comm layer to cancel - will also trigger our cancelled handler
|
||||
# for further processing
|
||||
self._comm.cancelPrint()
|
||||
self._comm.cancelPrint(tags=kwargs.get("tags", set()) | {"trigger:printer.cancel_print"})
|
||||
|
||||
def get_state_string(self, state=None):
|
||||
def get_state_string(self, state=None, *args, **kwargs):
|
||||
if self._comm is None:
|
||||
return "Offline"
|
||||
else:
|
||||
return self._comm.getStateString(state=state)
|
||||
|
||||
def get_state_id(self, state=None):
|
||||
def get_state_id(self, state=None, *args, **kwargs):
|
||||
if self._comm is None:
|
||||
return "OFFLINE"
|
||||
else:
|
||||
return self._comm.getStateId(state=state)
|
||||
|
||||
def get_current_data(self):
|
||||
def get_current_data(self, *args, **kwargs):
|
||||
return self._stateMonitor.get_current_data()
|
||||
|
||||
def get_current_job(self):
|
||||
def get_current_job(self, *args, **kwargs):
|
||||
currentData = self._stateMonitor.get_current_data()
|
||||
return currentData["job"]
|
||||
|
||||
def get_current_temperatures(self):
|
||||
def get_current_temperatures(self, *args, **kwargs):
|
||||
if self._comm is not None:
|
||||
offsets = self._comm.getOffsets()
|
||||
else:
|
||||
@@ -542,10 +558,10 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
|
||||
return result
|
||||
|
||||
def get_temperature_history(self):
|
||||
def get_temperature_history(self, *args, **kwargs):
|
||||
return self._temps
|
||||
|
||||
def get_current_connection(self):
|
||||
def get_current_connection(self, *args, **kwargs):
|
||||
if self._comm is None:
|
||||
return "Closed", None, None, None
|
||||
|
||||
@@ -553,25 +569,25 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
printer_profile = self._printerProfileManager.get_current_or_default()
|
||||
return self._comm.getStateString(), port, baudrate, printer_profile
|
||||
|
||||
def is_closed_or_error(self):
|
||||
def is_closed_or_error(self, *args, **kwargs):
|
||||
return self._comm is None or self._comm.isClosedOrError()
|
||||
|
||||
def is_operational(self):
|
||||
def is_operational(self, *args, **kwargs):
|
||||
return self._comm is not None and self._comm.isOperational()
|
||||
|
||||
def is_printing(self):
|
||||
def is_printing(self, *args, **kwargs):
|
||||
return self._comm is not None and self._comm.isPrinting()
|
||||
|
||||
def is_paused(self):
|
||||
def is_paused(self, *args, **kwargs):
|
||||
return self._comm is not None and self._comm.isPaused()
|
||||
|
||||
def is_error(self):
|
||||
def is_error(self, *args, **kwargs):
|
||||
return self._comm is not None and self._comm.isError()
|
||||
|
||||
def is_ready(self):
|
||||
def is_ready(self, *args, **kwargs):
|
||||
return self.is_operational() and not self.is_printing() and not self._comm.isStreaming()
|
||||
|
||||
def is_sd_ready(self):
|
||||
def is_sd_ready(self, *args, **kwargs):
|
||||
if not settings().getBoolean(["feature", "sdSupport"]) or self._comm is None:
|
||||
return False
|
||||
else:
|
||||
@@ -579,12 +595,12 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
|
||||
#~~ sd file handling
|
||||
|
||||
def get_sd_files(self):
|
||||
def get_sd_files(self, *args, **kwargs):
|
||||
if self._comm is None or not self._comm.isSdReady():
|
||||
return []
|
||||
return map(lambda x: (x[0][1:], x[1]), self._comm.getSdFiles())
|
||||
|
||||
def add_sd_file(self, filename, absolutePath, on_success=None, on_failure=None):
|
||||
def add_sd_file(self, filename, absolutePath, on_success=None, on_failure=None, *args, **kwargs):
|
||||
if not self._comm or self._comm.isBusy() or not self._comm.isSdReady():
|
||||
self._logger.error("No connection to printer or printer is busy")
|
||||
return
|
||||
@@ -604,26 +620,28 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
# probably something else added through a plugin, use it's basename as-is
|
||||
remoteName = os.path.basename(filename)
|
||||
self._timeEstimationData = TimeEstimationHelper()
|
||||
self._comm.startFileTransfer(absolutePath, filename, "/" + remoteName, special=not valid_file_type(filename, "gcode"))
|
||||
self._comm.startFileTransfer(absolutePath, filename, "/" + remoteName,
|
||||
special=not valid_file_type(filename, "gcode"),
|
||||
tags=kwargs.get("tags", set()) | {"trigger:printer.add_sd_file"})
|
||||
|
||||
return remoteName
|
||||
|
||||
def delete_sd_file(self, filename):
|
||||
def delete_sd_file(self, filename, *args, **kwargs):
|
||||
if not self._comm or not self._comm.isSdReady():
|
||||
return
|
||||
self._comm.deleteSdFile("/" + filename)
|
||||
self._comm.deleteSdFile("/" + filename, tags=kwargs.get("tags", set()) | {"trigger:printer.delete_sd_file"})
|
||||
|
||||
def init_sd_card(self):
|
||||
def init_sd_card(self, *args, **kwargs):
|
||||
if not self._comm or self._comm.isSdReady():
|
||||
return
|
||||
self._comm.initSdCard()
|
||||
self._comm.initSdCard(tags=kwargs.get("tags", set()) | {"trigger:printer.init_sd_card"})
|
||||
|
||||
def release_sd_card(self):
|
||||
def release_sd_card(self, *args, **kwargs):
|
||||
if not self._comm or not self._comm.isSdReady():
|
||||
return
|
||||
self._comm.releaseSdCard()
|
||||
self._comm.releaseSdCard(tags=kwargs.get("tags", set()) | {"trigger:printer.release_sd_card"})
|
||||
|
||||
def refresh_sd_files(self, blocking=False):
|
||||
def refresh_sd_files(self, blocking=False, *args, **kwargs):
|
||||
"""
|
||||
Refreshes the list of file stored on the SD card attached to printer (if available and printer communication
|
||||
available). Optional blocking parameter allows making the method block (max 10s) until the file list has been
|
||||
@@ -632,9 +650,9 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
if not self._comm or not self._comm.isSdReady():
|
||||
return
|
||||
self._sdFilelistAvailable.clear()
|
||||
self._comm.refreshSdFiles()
|
||||
self._comm.refreshSdFiles(tags=kwargs.get("tags", set()) | {"trigger:printer.refresh_sd_files"})
|
||||
if blocking:
|
||||
self._sdFilelistAvailable.wait(10000)
|
||||
self._sdFilelistAvailable.wait(kwargs.get("timeout", 10000))
|
||||
|
||||
#~~ state monitoring
|
||||
|
||||
|
||||
@@ -147,6 +147,8 @@ def load_user(id):
|
||||
|
||||
return None
|
||||
|
||||
def load_user_from_request(request):
|
||||
return util.get_user_for_authorization_header(request.headers.get('Authorization'))
|
||||
|
||||
def unauthorized_user():
|
||||
from flask import abort
|
||||
@@ -348,8 +350,37 @@ class Server(object):
|
||||
"""Factory for injections for all OctoPrintPlugins"""
|
||||
if not isinstance(implementation, octoprint.plugin.OctoPrintPlugin):
|
||||
return None
|
||||
|
||||
components_copy = dict(components)
|
||||
if "printer" in components:
|
||||
import wrapt
|
||||
import functools
|
||||
|
||||
def tagwrap(f):
|
||||
@functools.wraps(f)
|
||||
def wrapper(*args, **kwargs):
|
||||
tags = kwargs.get("tags", set()) | {"source:plugin",
|
||||
"plugin:{}".format(name)}
|
||||
kwargs["tags"] = tags
|
||||
return f(*args, **kwargs)
|
||||
setattr(wrapper, "__tagwrapped__", True)
|
||||
return wrapper
|
||||
|
||||
class TaggedFuncsPrinter(wrapt.ObjectProxy):
|
||||
def __getattribute__(self, attr):
|
||||
__wrapped__ = super(TaggedFuncsPrinter, self).__getattribute__("__wrapped__")
|
||||
item = getattr(__wrapped__, attr)
|
||||
if callable(item) \
|
||||
and ("tags" in item.__code__.co_varnames or "kwargs" in item.__code__.co_varnames) \
|
||||
and not getattr(item, "__tagwrapped__", False):
|
||||
return tagwrap(item)
|
||||
else:
|
||||
return item
|
||||
|
||||
components_copy["printer"] = TaggedFuncsPrinter(components["printer"])
|
||||
|
||||
props = dict()
|
||||
props.update(components)
|
||||
props.update(components_copy)
|
||||
props.update(dict(
|
||||
data_folder=os.path.join(self._settings.getBaseFolder("data"), name)
|
||||
))
|
||||
@@ -446,6 +477,11 @@ class Server(object):
|
||||
loginManager.session_protection = "strong"
|
||||
loginManager.user_callback = load_user
|
||||
loginManager.unauthorized_callback = unauthorized_user
|
||||
|
||||
# login users authenticated by basic auth
|
||||
if self._settings.get(["accessControl", "trustBasicAuthentication"]):
|
||||
loginManager.request_callback = load_user_from_request
|
||||
|
||||
if not userManager.enabled:
|
||||
loginManager.anonymous_user = users.DummyUser
|
||||
principals.identity_loaders.appendleft(users.dummy_identity_loader)
|
||||
@@ -505,7 +541,7 @@ class Server(object):
|
||||
server_routes = self._router.urls + [
|
||||
# various downloads
|
||||
# .mpg and .mp4 timelapses:
|
||||
(r"/downloads/timelapse/([^/]*\.mp[g4])", util.tornado.LargeResponseHandler, joined_dict(dict(path=self._settings.getBaseFolder("timelapse")),
|
||||
(r"/downloads/timelapse/([^/]*\.m(.*))", util.tornado.LargeResponseHandler, joined_dict(dict(path=self._settings.getBaseFolder("timelapse")),
|
||||
download_handler_kwargs,
|
||||
no_hidden_files_validator)),
|
||||
(r"/downloads/files/local/(.*)", util.tornado.LargeResponseHandler, joined_dict(dict(path=self._settings.getBaseFolder("uploads"),
|
||||
@@ -527,7 +563,11 @@ class Server(object):
|
||||
# online indicators - text file with "online" as content and a transparent gif
|
||||
(r"/online.txt", util.tornado.StaticDataHandler, dict(data="online\n")),
|
||||
(r"/online.gif", util.tornado.StaticDataHandler, dict(data=bytes(base64.b64decode("R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")),
|
||||
content_type="image/gif"))
|
||||
content_type="image/gif")),
|
||||
|
||||
# deprecated endpoints
|
||||
(r"/api/logs", util.tornado.DeprecatedEndpointHandler, dict(url="/plugin/logging/logs")),
|
||||
(r"/api/logs/(.*)", util.tornado.DeprecatedEndpointHandler, dict(url="/plugin/logging/logs/{0}")),
|
||||
]
|
||||
|
||||
# fetch additional routes from plugins
|
||||
@@ -1223,7 +1263,6 @@ class Server(object):
|
||||
"js/app/client/files.js",
|
||||
"js/app/client/job.js",
|
||||
"js/app/client/languages.js",
|
||||
"js/app/client/logs.js",
|
||||
"js/app/client/printer.js",
|
||||
"js/app/client/printerprofiles.js",
|
||||
"js/app/client/settings.js",
|
||||
|
||||
@@ -19,7 +19,7 @@ import octoprint.server
|
||||
import octoprint.plugin
|
||||
from octoprint.server import admin_permission, NO_CONTENT
|
||||
from octoprint.settings import settings as s, valid_boolean_trues
|
||||
from octoprint.server.util import noCachingExceptGetResponseHandler, enforceApiKeyRequestHandler, loginFromApiKeyRequestHandler, corsRequestHandler, corsResponseHandler
|
||||
from octoprint.server.util import noCachingExceptGetResponseHandler, enforceApiKeyRequestHandler, loginFromApiKeyRequestHandler, loginFromAuthorizationHeaderRequestHandler, corsRequestHandler, corsResponseHandler
|
||||
from octoprint.server.util.flask import restricted_access, get_json_command_from_request, passive_login
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ from . import files as api_files
|
||||
from . import settings as api_settings
|
||||
from . import timelapse as api_timelapse
|
||||
from . import users as api_users
|
||||
from . import log as api_logs
|
||||
from . import slicing as api_slicing
|
||||
from . import printer_profiles as api_printer_profiles
|
||||
from . import languages as api_languages
|
||||
@@ -47,6 +46,7 @@ api.after_request(noCachingExceptGetResponseHandler)
|
||||
|
||||
api.before_request(corsRequestHandler)
|
||||
api.before_request(enforceApiKeyRequestHandler)
|
||||
api.before_request(loginFromAuthorizationHeaderRequestHandler)
|
||||
api.before_request(loginFromApiKeyRequestHandler)
|
||||
api.after_request(corsResponseHandler)
|
||||
|
||||
|
||||
@@ -325,7 +325,7 @@ def uploadGcodeFile(target):
|
||||
"""
|
||||
|
||||
if destination == FileDestinations.SDCARD and octoprint.filemanager.valid_file_type(filename, "machinecode"):
|
||||
return filename, printer.add_sd_file(filename, absFilename, selectAndOrPrint)
|
||||
return filename, printer.add_sd_file(filename, absFilename, selectAndOrPrint, tags={"source:api", "api:files.sd"})
|
||||
else:
|
||||
selectAndOrPrint(filename, absFilename, destination)
|
||||
return filename
|
||||
@@ -743,7 +743,7 @@ def deleteGcodeFile(filename, target):
|
||||
|
||||
# delete it
|
||||
if target == FileDestinations.SDCARD:
|
||||
printer.delete_sd_file(filename)
|
||||
printer.delete_sd_file(filename, tags={"source:api", "api:files.sd"})
|
||||
else:
|
||||
fileManager.remove_file(target, filename)
|
||||
|
||||
|
||||
@@ -32,30 +32,32 @@ def controlJob():
|
||||
|
||||
activePrintjob = printer.is_printing() or printer.is_paused()
|
||||
|
||||
tags = {"source:api", "api:job"}
|
||||
|
||||
if command == "start":
|
||||
if activePrintjob:
|
||||
return make_response("Printer already has an active print job, did you mean 'restart'?", 409)
|
||||
printer.start_print()
|
||||
printer.start_print(tags=tags)
|
||||
elif command == "restart":
|
||||
if not printer.is_paused():
|
||||
return make_response("Printer does not have an active print job or is not paused", 409)
|
||||
printer.start_print()
|
||||
printer.start_print(tags=tags)
|
||||
elif command == "pause":
|
||||
if not activePrintjob:
|
||||
return make_response("Printer is neither printing nor paused, 'pause' command cannot be performed", 409)
|
||||
action = data.get("action", "toggle")
|
||||
if action == "toggle":
|
||||
printer.toggle_pause_print()
|
||||
printer.toggle_pause_print(tags=tags)
|
||||
elif action == "pause":
|
||||
printer.pause_print()
|
||||
printer.pause_print(tags=tags)
|
||||
elif action == "resume":
|
||||
printer.resume_print()
|
||||
printer.resume_print(tags=tags)
|
||||
else:
|
||||
return make_response("Unknown action '{}', allowed values for action parameter are 'pause', 'resume' and 'toggle'".format(action), 400)
|
||||
elif command == "cancel":
|
||||
if not activePrintjob:
|
||||
return make_response("Printer is neither printing nor paused, 'cancel' command cannot be performed", 409)
|
||||
printer.cancel_print()
|
||||
printer.cancel_print(tags=tags)
|
||||
return NO_CONTENT
|
||||
|
||||
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__author__ = "Marc Hannappel Salandora"
|
||||
__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 os
|
||||
try:
|
||||
from os import scandir
|
||||
except ImportError:
|
||||
from scandir import scandir
|
||||
|
||||
from flask import request, jsonify, url_for, make_response
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
from octoprint.settings import settings
|
||||
|
||||
from octoprint.server import NO_CONTENT, admin_permission
|
||||
from octoprint.server.util.flask import redirect_to_tornado, restricted_access
|
||||
from octoprint.server.api import api
|
||||
|
||||
|
||||
@api.route("/logs", methods=["GET"])
|
||||
@restricted_access
|
||||
@admin_permission.require(403)
|
||||
def getLogFiles():
|
||||
import psutil
|
||||
usage = psutil.disk_usage(settings().getBaseFolder("logs"))
|
||||
|
||||
files = _getLogFiles()
|
||||
|
||||
return jsonify(files=files, free=usage.free, total=usage.total)
|
||||
|
||||
|
||||
@api.route("/logs/<path:filename>", methods=["GET"])
|
||||
@restricted_access
|
||||
@admin_permission.require(403)
|
||||
def downloadLog(filename):
|
||||
return redirect_to_tornado(request, url_for("index") + "downloads/logs/" + filename)
|
||||
|
||||
|
||||
@api.route("/logs/<path:filename>", methods=["DELETE"])
|
||||
@restricted_access
|
||||
@admin_permission.require(403)
|
||||
def deleteLog(filename):
|
||||
secure = os.path.join(settings().getBaseFolder("logs"), secure_filename(filename))
|
||||
if not os.path.exists(secure):
|
||||
return make_response("File not found: %s" % filename, 404)
|
||||
|
||||
os.remove(secure)
|
||||
|
||||
return NO_CONTENT
|
||||
|
||||
|
||||
def _getLogFiles():
|
||||
files = []
|
||||
basedir = settings().getBaseFolder("logs")
|
||||
for entry in scandir(basedir):
|
||||
files.append({
|
||||
"name": entry.name,
|
||||
"date": int(entry.stat().st_mtime),
|
||||
"size": entry.stat().st_size,
|
||||
"refs": {
|
||||
"resource": url_for(".downloadLog", filename=entry.name, _external=True),
|
||||
"download": url_for("index", _external=True) + "downloads/logs/" + entry.name
|
||||
}
|
||||
})
|
||||
|
||||
return files
|
||||
|
||||
@@ -75,6 +75,8 @@ def printerToolCommand():
|
||||
|
||||
validation_regex = re.compile("tool\d+")
|
||||
|
||||
tags = {"source:api", "api:printer.tool"}
|
||||
|
||||
##~~ tool selection
|
||||
if command == "select":
|
||||
tool = data["tool"]
|
||||
@@ -83,7 +85,7 @@ def printerToolCommand():
|
||||
if not tool.startswith("tool"):
|
||||
return make_response("Invalid tool for selection: %s" % tool, 400)
|
||||
|
||||
printer.change_tool(tool)
|
||||
printer.change_tool(tool, tags=tags)
|
||||
|
||||
##~~ temperature
|
||||
elif command == "target":
|
||||
@@ -100,7 +102,7 @@ def printerToolCommand():
|
||||
|
||||
# perform the actual temperature commands
|
||||
for tool in validated_values.keys():
|
||||
printer.set_temperature(tool, validated_values[tool])
|
||||
printer.set_temperature(tool, validated_values[tool], tags=tags)
|
||||
|
||||
##~~ temperature offset
|
||||
elif command == "offset":
|
||||
@@ -129,14 +131,14 @@ def printerToolCommand():
|
||||
amount = data["amount"]
|
||||
if not isinstance(amount, (int, long, float)):
|
||||
return make_response("Not a number for extrusion amount: %r" % amount, 400)
|
||||
printer.extrude(amount)
|
||||
printer.extrude(amount, tags=tags)
|
||||
|
||||
elif command == "flowrate":
|
||||
factor = data["factor"]
|
||||
if not isinstance(factor, (int, long, float)):
|
||||
return make_response("Not a number for flow rate: %r" % factor, 400)
|
||||
try:
|
||||
printer.flow_rate(factor)
|
||||
printer.flow_rate(factor, tags=tags)
|
||||
except ValueError as e:
|
||||
return make_response("Invalid value for flow rate: %s" % str(e), 400)
|
||||
|
||||
@@ -171,6 +173,8 @@ def printerBedCommand():
|
||||
if response is not None:
|
||||
return response
|
||||
|
||||
tags = {"source:api", "api:printer.bed"}
|
||||
|
||||
##~~ temperature
|
||||
if command == "target":
|
||||
target = data["target"]
|
||||
@@ -180,7 +184,7 @@ def printerBedCommand():
|
||||
return make_response("Not a number: %r" % target, 400)
|
||||
|
||||
# perform the actual temperature command
|
||||
printer.set_temperature("bed", target)
|
||||
printer.set_temperature("bed", target, tags=tags)
|
||||
|
||||
##~~ temperature offset
|
||||
elif command == "offset":
|
||||
@@ -232,6 +236,8 @@ def printerPrintheadCommand():
|
||||
# do not jog when a print job is running or we don't have a connection
|
||||
return make_response("Printer is not operational or currently printing", 409)
|
||||
|
||||
tags = {"source:api", "api:printer.printhead"}
|
||||
|
||||
valid_axes = ["x", "y", "z"]
|
||||
##~~ jog command
|
||||
if command == "jog":
|
||||
@@ -248,7 +254,7 @@ def printerPrintheadCommand():
|
||||
speed = data.get("speed", None)
|
||||
|
||||
# execute the jog commands
|
||||
printer.jog(validated_values, relative=not absolute, speed=speed)
|
||||
printer.jog(validated_values, relative=not absolute, speed=speed, tags=tags)
|
||||
|
||||
##~~ home command
|
||||
elif command == "home":
|
||||
@@ -260,14 +266,14 @@ def printerPrintheadCommand():
|
||||
validated_values.append(axis)
|
||||
|
||||
# execute the home command
|
||||
printer.home(validated_values)
|
||||
printer.home(validated_values, tags=tags)
|
||||
|
||||
elif command == "feedrate":
|
||||
factor = data["factor"]
|
||||
if not isinstance(factor, (int, long, float)):
|
||||
return make_response("Not a number for feed rate: %r" % factor, 400)
|
||||
try:
|
||||
printer.feed_rate(factor)
|
||||
printer.feed_rate(factor, tags=tags)
|
||||
except ValueError as e:
|
||||
return make_response("Invalid value for feed rate: %s" % str(e), 400)
|
||||
|
||||
@@ -295,12 +301,14 @@ def printerSdCommand():
|
||||
if response is not None:
|
||||
return response
|
||||
|
||||
tags = {"source:api", "api:printer.sd"}
|
||||
|
||||
if command == "init":
|
||||
printer.init_sd_card()
|
||||
printer.init_sd_card(tags=tags)
|
||||
elif command == "refresh":
|
||||
printer.refresh_sd_files()
|
||||
printer.refresh_sd_files(tags=tags)
|
||||
elif command == "release":
|
||||
printer.release_sd_card()
|
||||
printer.release_sd_card(tags=tags)
|
||||
|
||||
return NO_CONTENT
|
||||
|
||||
@@ -341,6 +349,8 @@ def printerCommand():
|
||||
if "parameters" in data:
|
||||
parameters = data["parameters"]
|
||||
|
||||
tags = {"source:api", "api:printer.command"}
|
||||
|
||||
if "command" in data or "commands" in data:
|
||||
if "command" in data:
|
||||
commands = [data["command"]]
|
||||
@@ -356,7 +366,7 @@ def printerCommand():
|
||||
commandToSend = command % parameters
|
||||
commandsToSend.append(commandToSend)
|
||||
|
||||
printer.commands(commandsToSend)
|
||||
printer.commands(commandsToSend, tags=tags)
|
||||
|
||||
elif "script" in data:
|
||||
script_name = data["script"]
|
||||
@@ -365,7 +375,7 @@ def printerCommand():
|
||||
context["context"] = data["context"]
|
||||
|
||||
try:
|
||||
printer.script(script_name, context=context)
|
||||
printer.script(script_name, context=context, tags=tags)
|
||||
except UnknownScript:
|
||||
return make_response("Unknown script: {script_name}".format(**locals()), 404)
|
||||
|
||||
|
||||
@@ -114,23 +114,13 @@ def getSettings():
|
||||
"sizeThreshold": s.getInt(["gcodeViewer", "sizeThreshold"]),
|
||||
"mobileSizeThreshold": s.getInt(["gcodeViewer", "mobileSizeThreshold"]),
|
||||
"temperatureGraph": s.getBoolean(["feature", "temperatureGraph"]),
|
||||
"waitForStart": s.getBoolean(["feature", "waitForStartOnConnect"]),
|
||||
"alwaysSendChecksum": s.getBoolean(["feature", "alwaysSendChecksum"]),
|
||||
"neverSendChecksum": s.getBoolean(["feature", "neverSendChecksum"]),
|
||||
"sdSupport": s.getBoolean(["feature", "sdSupport"]),
|
||||
"sdRelativePath": s.getBoolean(["feature", "sdRelativePath"]),
|
||||
"sdAlwaysAvailable": s.getBoolean(["feature", "sdAlwaysAvailable"]),
|
||||
"swallowOkAfterResend": s.getBoolean(["feature", "swallowOkAfterResend"]),
|
||||
"repetierTargetTemp": s.getBoolean(["feature", "repetierTargetTemp"]),
|
||||
"externalHeatupDetection": s.getBoolean(["feature", "externalHeatupDetection"]),
|
||||
"keyboardControl": s.getBoolean(["feature", "keyboardControl"]),
|
||||
"pollWatched": s.getBoolean(["feature", "pollWatched"]),
|
||||
"ignoreIdenticalResends": s.getBoolean(["feature", "ignoreIdenticalResends"]),
|
||||
"modelSizeDetection": s.getBoolean(["feature", "modelSizeDetection"]),
|
||||
"firmwareDetection": s.getBoolean(["feature", "firmwareDetection"]),
|
||||
"printCancelConfirmation": s.getBoolean(["feature", "printCancelConfirmation"]),
|
||||
"blockWhileDwelling": s.getBoolean(["feature", "blockWhileDwelling"]),
|
||||
"g90InfluencesExtruder": s.getBoolean(["feature", "g90InfluencesExtruder"]),
|
||||
"autoUppercaseBlacklist": s.get(["feature", "autoUppercaseBlacklist"]),
|
||||
"legacyPluginAssets": s.getBoolean(["feature", "legacyPluginAssets"])
|
||||
},
|
||||
"serial": {
|
||||
@@ -142,6 +132,7 @@ def getSettings():
|
||||
"timeoutConnection": s.getFloat(["serial", "timeout", "connection"]),
|
||||
"timeoutDetection": s.getFloat(["serial", "timeout", "detection"]),
|
||||
"timeoutCommunication": s.getFloat(["serial", "timeout", "communication"]),
|
||||
"timeoutCommunicationBusy": s.getFloat(["serial", "timeout", "communicationBusy"]),
|
||||
"timeoutTemperature": s.getFloat(["serial", "timeout", "temperature"]),
|
||||
"timeoutTemperatureTargetSet": s.getFloat(["serial", "timeout", "temperatureTargetSet"]),
|
||||
"timeoutTemperatureAutoreport": s.getFloat(["serial", "timeout", "temperatureAutoreport"]),
|
||||
@@ -155,13 +146,25 @@ def getSettings():
|
||||
"ignoreErrorsFromFirmware": s.getBoolean(["serial", "ignoreErrorsFromFirmware"]),
|
||||
"disconnectOnErrors": s.getBoolean(["serial", "disconnectOnErrors"]),
|
||||
"triggerOkForM29": s.getBoolean(["serial", "triggerOkForM29"]),
|
||||
"autoUppercaseBlacklist": s.get(["serial", "autoUppercaseBlacklist"]),
|
||||
"logPositionOnPause": s.getBoolean(["serial", "logPositionOnPause"]),
|
||||
"logPositionOnCancel": s.getBoolean(["serial", "logPositionOnCancel"]),
|
||||
"supportResendsWithoutOk": s.getBoolean(["serial", "supportResendsWithoutOk"]),
|
||||
"waitForStart": s.getBoolean(["serial", "waitForStartOnConnect"]),
|
||||
"alwaysSendChecksum": s.getBoolean(["serial", "alwaysSendChecksum"]),
|
||||
"neverSendChecksum": s.getBoolean(["serial", "neverSendChecksum"]),
|
||||
"sdRelativePath": s.getBoolean(["serial", "sdRelativePath"]),
|
||||
"sdAlwaysAvailable": s.getBoolean(["serial", "sdAlwaysAvailable"]),
|
||||
"swallowOkAfterResend": s.getBoolean(["serial", "swallowOkAfterResend"]),
|
||||
"repetierTargetTemp": s.getBoolean(["serial", "repetierTargetTemp"]),
|
||||
"externalHeatupDetection": s.getBoolean(["serial", "externalHeatupDetection"]),
|
||||
"ignoreIdenticalResends": s.getBoolean(["serial", "ignoreIdenticalResends"]),
|
||||
"firmwareDetection": s.getBoolean(["serial", "firmwareDetection"]),
|
||||
"blockWhileDwelling": s.getBoolean(["serial", "blockWhileDwelling"]),
|
||||
"maxTimeoutsIdle": s.getInt(["serial", "maxCommunicationTimeouts", "idle"]),
|
||||
"maxTimeoutsPrinting": s.getInt(["serial", "maxCommunicationTimeouts", "printing"]),
|
||||
"maxTimeoutsLong": s.getInt(["serial", "maxCommunicationTimeouts", "long"])
|
||||
"maxTimeoutsLong": s.getInt(["serial", "maxCommunicationTimeouts", "long"]),
|
||||
"capAutoreportTemp": s.getBoolean(["serial", "capabilities", "autoreport_temp"]),
|
||||
"capBusyProtocol": s.getBoolean(["serial", "capabilities", "busy_protocol"])
|
||||
},
|
||||
"folder": {
|
||||
"uploads": s.getBaseFolder("uploads"),
|
||||
@@ -342,24 +345,14 @@ def _saveSettings(data):
|
||||
if "sizeThreshold" in data["feature"]: s.setInt(["gcodeViewer", "sizeThreshold"], data["feature"]["sizeThreshold"])
|
||||
if "mobileSizeThreshold" in data["feature"]: s.setInt(["gcodeViewer", "mobileSizeThreshold"], data["feature"]["mobileSizeThreshold"])
|
||||
if "temperatureGraph" in data["feature"]: s.setBoolean(["feature", "temperatureGraph"], data["feature"]["temperatureGraph"])
|
||||
if "waitForStart" in data["feature"]: s.setBoolean(["feature", "waitForStartOnConnect"], data["feature"]["waitForStart"])
|
||||
if "alwaysSendChecksum" in data["feature"]: s.setBoolean(["feature", "alwaysSendChecksum"], data["feature"]["alwaysSendChecksum"])
|
||||
if "neverSendChecksum" in data["feature"]: s.setBoolean(["feature", "neverSendChecksum"], data["feature"]["neverSendChecksum"])
|
||||
if "sdSupport" in data["feature"]: s.setBoolean(["feature", "sdSupport"], data["feature"]["sdSupport"])
|
||||
if "sdRelativePath" in data["feature"]: s.setBoolean(["feature", "sdRelativePath"], data["feature"]["sdRelativePath"])
|
||||
if "sdAlwaysAvailable" in data["feature"]: s.setBoolean(["feature", "sdAlwaysAvailable"], data["feature"]["sdAlwaysAvailable"])
|
||||
if "swallowOkAfterResend" in data["feature"]: s.setBoolean(["feature", "swallowOkAfterResend"], data["feature"]["swallowOkAfterResend"])
|
||||
if "repetierTargetTemp" in data["feature"]: s.setBoolean(["feature", "repetierTargetTemp"], data["feature"]["repetierTargetTemp"])
|
||||
if "externalHeatupDetection" in data["feature"]: s.setBoolean(["feature", "externalHeatupDetection"], data["feature"]["externalHeatupDetection"])
|
||||
if "keyboardControl" in data["feature"]: s.setBoolean(["feature", "keyboardControl"], data["feature"]["keyboardControl"])
|
||||
if "pollWatched" in data["feature"]: s.setBoolean(["feature", "pollWatched"], data["feature"]["pollWatched"])
|
||||
if "ignoreIdenticalResends" in data["feature"]: s.setBoolean(["feature", "ignoreIdenticalResends"], data["feature"]["ignoreIdenticalResends"])
|
||||
if "modelSizeDetection" in data["feature"]: s.setBoolean(["feature", "modelSizeDetection"], data["feature"]["modelSizeDetection"])
|
||||
if "firmwareDetection" in data["feature"]: s.setBoolean(["feature", "firmwareDetection"], data["feature"]["firmwareDetection"])
|
||||
if "printCancelConfirmation" in data["feature"]: s.setBoolean(["feature", "printCancelConfirmation"], data["feature"]["printCancelConfirmation"])
|
||||
if "blockWhileDwelling" in data["feature"]: s.setBoolean(["feature", "blockWhileDwelling"], data["feature"]["blockWhileDwelling"])
|
||||
if "g90InfluencesExtruder" in data["feature"]: s.setBoolean(["feature", "g90InfluencesExtruder"], data["feature"]["g90InfluencesExtruder"])
|
||||
if "legacyPluginAssets" in data["feature"]: s.setBoolean(["feature", "legacyPluginAssets"], data["feature"]["legacyPluginAssets"])
|
||||
if "autoUppercaseBlacklist" in data["feature"] and isinstance(data["feature"]["autoUppercaseBlacklist"], (list, tuple)): s.set(["feature", "autoUppercaseBlacklist"], data["feature"]["autoUppercaseBlacklist"])
|
||||
|
||||
if "serial" in data.keys():
|
||||
if "autoconnect" in data["serial"]: s.setBoolean(["serial", "autoconnect"], data["serial"]["autoconnect"])
|
||||
@@ -368,6 +361,7 @@ def _saveSettings(data):
|
||||
if "timeoutConnection" in data["serial"]: s.setFloat(["serial", "timeout", "connection"], data["serial"]["timeoutConnection"])
|
||||
if "timeoutDetection" in data["serial"]: s.setFloat(["serial", "timeout", "detection"], data["serial"]["timeoutDetection"])
|
||||
if "timeoutCommunication" in data["serial"]: s.setFloat(["serial", "timeout", "communication"], data["serial"]["timeoutCommunication"])
|
||||
if "timeoutCommunicationBusy" in data["serial"]: s.setFloat(["serial", "timeout", "communicationBusy"], data["serial"]["timeoutCommunicationBusy"])
|
||||
if "timeoutTemperature" in data["serial"]: s.setFloat(["serial", "timeout", "temperature"], data["serial"]["timeoutTemperature"])
|
||||
if "timeoutTemperatureTargetSet" in data["serial"]: s.setFloat(["serial", "timeout", "temperatureTargetSet"], data["serial"]["timeoutTemperatureTargetSet"])
|
||||
if "timeoutTemperatureAutoreport" in data["serial"]: s.setFloat(["serial", "timeout", "temperatureAutoreport"], data["serial"]["timeoutTemperatureAutoreport"])
|
||||
@@ -380,13 +374,25 @@ def _saveSettings(data):
|
||||
if "ignoreErrorsFromFirmware" in data["serial"]: s.setBoolean(["serial", "ignoreErrorsFromFirmware"], data["serial"]["ignoreErrorsFromFirmware"])
|
||||
if "disconnectOnErrors" in data["serial"]: s.setBoolean(["serial", "disconnectOnErrors"], data["serial"]["disconnectOnErrors"])
|
||||
if "triggerOkForM29" in data["serial"]: s.setBoolean(["serial", "triggerOkForM29"], data["serial"]["triggerOkForM29"])
|
||||
if "autoUppercaseBlacklist" in data["serial"] and isinstance(data["serial"]["autoUppercaseBlacklist"], (list, tuple)): s.set(["serial", "autoUppercaseBlacklist"], data["serial"]["autoUppercaseBlacklist"])
|
||||
if "supportResendsWithoutOk" in data["serial"]: s.setBoolean(["serial", "supportResendsWithoutOk"], data["serial"]["supportResendsWithoutOk"])
|
||||
if "waitForStart" in data["serial"]: s.setBoolean(["serial", "waitForStartOnConnect"], data["serial"]["waitForStart"])
|
||||
if "alwaysSendChecksum" in data["serial"]: s.setBoolean(["serial", "alwaysSendChecksum"], data["serial"]["alwaysSendChecksum"])
|
||||
if "neverSendChecksum" in data["serial"]: s.setBoolean(["serial", "neverSendChecksum"], data["serial"]["neverSendChecksum"])
|
||||
if "sdRelativePath" in data["serial"]: s.setBoolean(["serial", "sdRelativePath"], data["serial"]["sdRelativePath"])
|
||||
if "sdAlwaysAvailable" in data["serial"]: s.setBoolean(["serial", "sdAlwaysAvailable"], data["serial"]["sdAlwaysAvailable"])
|
||||
if "swallowOkAfterResend" in data["serial"]: s.setBoolean(["serial", "swallowOkAfterResend"], data["serial"]["swallowOkAfterResend"])
|
||||
if "repetierTargetTemp" in data["serial"]: s.setBoolean(["serial", "repetierTargetTemp"], data["serial"]["repetierTargetTemp"])
|
||||
if "externalHeatupDetection" in data["serial"]: s.setBoolean(["serial", "externalHeatupDetection"], data["serial"]["externalHeatupDetection"])
|
||||
if "ignoreIdenticalResends" in data["serial"]: s.setBoolean(["serial", "ignoreIdenticalResends"], data["serial"]["ignoreIdenticalResends"])
|
||||
if "firmwareDetection" in data["serial"]: s.setBoolean(["serial", "firmwareDetection"], data["serial"]["firmwareDetection"])
|
||||
if "blockWhileDwelling" in data["serial"]: s.setBoolean(["serial", "blockWhileDwelling"], data["serial"]["blockWhileDwelling"])
|
||||
if "logPositionOnPause" in data["serial"]: s.setBoolean(["serial", "logPositionOnPause"], data["serial"]["logPositionOnPause"])
|
||||
if "logPositionOnCancel" in data["serial"]: s.setBoolean(["serial", "logPositionOnCancel"], data["serial"]["logPositionOnCancel"])
|
||||
if "maxTimeoutsIdle" in data["serial"]: s.setInt(["serial", "maxCommunicationTimeouts", "idle"], data["serial"]["maxTimeoutsIdle"])
|
||||
if "maxTimeoutsPrinting" in data["serial"]: s.setInt(["serial", "maxCommunicationTimeouts", "printing"], data["serial"]["maxTimeoutsPrinting"])
|
||||
if "maxTimeoutsLong" in data["serial"]: s.setInt(["serial", "maxCommunicationTimeouts", "long"], data["serial"]["maxTimeoutsLong"])
|
||||
if "capAutoreportTemp" in data["serial"]: s.setBoolean(["serial", "capabilities", "autoreport_temp"], data["serial"]["capAutoreportTemp"])
|
||||
if "capBusyProtocol" in data["serial"]: s.setBoolean(["serial", "capabilities", "busy_protocol"], data["serial"]["capBusyProtocol"])
|
||||
|
||||
oldLog = s.getBoolean(["serial", "log"])
|
||||
if "log" in data["serial"]: s.setBoolean(["serial", "log"], data["serial"]["log"])
|
||||
|
||||
@@ -128,7 +128,7 @@ def downloadTimelapse(filename):
|
||||
@api.route("/timelapse/<filename>", methods=["DELETE"])
|
||||
@restricted_access
|
||||
def deleteTimelapse(filename):
|
||||
if util.is_allowed_file(filename, ["mpg", "mpeg", "mp4"]):
|
||||
if util.is_allowed_file(filename, ["mpg", "mpeg", "mp4", "m4v", "mkv"]):
|
||||
timelapse_folder = settings().getBaseFolder("timelapse")
|
||||
full_path = os.path.realpath(os.path.join(timelapse_folder, filename))
|
||||
if full_path.startswith(timelapse_folder) and os.path.exists(full_path):
|
||||
|
||||
@@ -5,6 +5,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 base64
|
||||
|
||||
from octoprint.settings import settings
|
||||
import octoprint.timelapse
|
||||
import octoprint.server
|
||||
@@ -68,11 +70,36 @@ def loginFromApiKeyRequestHandler():
|
||||
return
|
||||
|
||||
user = get_user_for_apikey(apikey)
|
||||
if user is not None and _flask.ext.login.login_user(user, remember=False):
|
||||
if not loginUser(user):
|
||||
return _flask.make_response("Invalid API key", 403)
|
||||
|
||||
|
||||
def loginFromAuthorizationHeaderRequestHandler():
|
||||
"""
|
||||
``before_request`` handler for creating login sessions based on the Authorization header.
|
||||
"""
|
||||
|
||||
authorization_header = get_authorization_header(_flask.request)
|
||||
user = get_user_for_authorization_header(authorization_header)
|
||||
loginUser(user)
|
||||
|
||||
|
||||
def loginUser(user, remember=False):
|
||||
"""
|
||||
Logs the provided ``user`` into Flask Login and Principal if not None and active
|
||||
|
||||
Args:
|
||||
user: the User to login. May be None in which case the login will fail
|
||||
remember: Whether to set the ``remember`` flag on the Flask Login operation
|
||||
|
||||
Returns: (bool) True if the login succeeded, False otherwise
|
||||
|
||||
"""
|
||||
if user is not None and user.is_active() and _flask.ext.login.login_user(user, remember=remember):
|
||||
_flask.ext.principal.identity_changed.send(_flask.current_app._get_current_object(),
|
||||
identity=_flask.ext.principal.Identity(user.get_id()))
|
||||
else:
|
||||
return _flask.make_response("Invalid API key", 403)
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def corsRequestHandler():
|
||||
@@ -171,6 +198,36 @@ def get_user_for_apikey(apikey):
|
||||
return None
|
||||
|
||||
|
||||
def get_user_for_authorization_header(header):
|
||||
if not settings().getBoolean(["accessControl", "trustBasicAuthentication"]):
|
||||
return None
|
||||
|
||||
if header is None:
|
||||
return None
|
||||
|
||||
if not header.startswith("Basic "):
|
||||
# we currently only support Basic Authentication
|
||||
return None
|
||||
|
||||
header = header.replace('Basic ', '', 1)
|
||||
try:
|
||||
header = base64.b64decode(header)
|
||||
except TypeError:
|
||||
return None
|
||||
|
||||
name, password = header.split(':', 1)
|
||||
if not octoprint.server.userManager.enabled:
|
||||
return None
|
||||
|
||||
user = octoprint.server.userManager.findUser(userid=name)
|
||||
if settings().getBoolean(["accessControl", "checkBasicAuthenticationPassword"]) \
|
||||
and not octoprint.server.userManager.checkPassword(name, password):
|
||||
# password check enabled and password don't match
|
||||
return None
|
||||
|
||||
return user
|
||||
|
||||
|
||||
def get_api_key(request):
|
||||
# Check Flask GET/POST arguments
|
||||
if hasattr(request, "values") and "apikey" in request.values:
|
||||
@@ -188,6 +245,11 @@ def get_api_key(request):
|
||||
return None
|
||||
|
||||
|
||||
def get_authorization_header(request):
|
||||
# Tornado and Flask headers
|
||||
return request.headers.get("Authorization")
|
||||
|
||||
|
||||
def get_plugin_hash():
|
||||
from octoprint.plugin import plugin_manager
|
||||
|
||||
|
||||
@@ -1324,7 +1324,6 @@ def collect_core_assets(enable_gcodeviewer=True, preferred_stylesheet="css"):
|
||||
'js/app/viewmodels/terminal.js',
|
||||
'js/app/viewmodels/timelapse.js',
|
||||
'js/app/viewmodels/users.js',
|
||||
'js/app/viewmodels/log.js',
|
||||
'js/app/viewmodels/usersettings.js',
|
||||
'js/app/viewmodels/wizard.js',
|
||||
'js/app/viewmodels/about.js'
|
||||
|
||||
@@ -1075,6 +1075,26 @@ class StaticDataHandler(RequestlessExceptionLoggingMixin, tornado.web.RequestHan
|
||||
self.finish()
|
||||
|
||||
|
||||
class DeprecatedEndpointHandler(tornado.web.RequestHandler):
|
||||
def initialize(self, url):
|
||||
self._url = url
|
||||
self._logger = logging.getLogger(__name__)
|
||||
|
||||
def _handle_method(self, *args, **kwargs):
|
||||
to_url = self._url.format(*args)
|
||||
self._logger.info("Redirecting deprecated endpoint {} to {}".format(self.request.path, to_url))
|
||||
self.redirect(to_url, permanent=True)
|
||||
|
||||
# make all http methods trigger _handle_method
|
||||
get = _handle_method
|
||||
post = _handle_method
|
||||
put = _handle_method
|
||||
patch = _handle_method
|
||||
delete = _handle_method
|
||||
head = _handle_method
|
||||
options = _handle_method
|
||||
|
||||
|
||||
class GlobalHeaderTransform(tornado.web.OutputTransform):
|
||||
|
||||
HEADERS = dict()
|
||||
|
||||
@@ -473,7 +473,7 @@ def _process_templates():
|
||||
else:
|
||||
# Finally everything else
|
||||
return u"2:{}".format(to_unicode(d[0]))
|
||||
|
||||
|
||||
template_sorting = dict(
|
||||
navbar=dict(add="prepend", key=None),
|
||||
sidebar=dict(add="append", key="name"),
|
||||
@@ -535,7 +535,7 @@ def _process_templates():
|
||||
# sidebar
|
||||
|
||||
templates["sidebar"]["entries"]= dict(
|
||||
connection=(gettext("Connection"), dict(template="sidebar/connection.jinja2", _div="connection", icon="signal", styles_wrapper=["display: none"], data_bind="visible: loginState.isUser")),
|
||||
connection=(gettext("Connection"), dict(template="sidebar/connection.jinja2", _div="connection", icon="signal", styles_wrapper=["display: none"], data_bind="visible: loginState.isUser", template_header="sidebar/connection_header.jinja2")),
|
||||
state=(gettext("State"), dict(template="sidebar/state.jinja2", _div="state", icon="info-circle")),
|
||||
files=(gettext("Files"), dict(template="sidebar/files.jinja2", _div="files", icon="list", classes_content=["overflow_visible"], template_header="sidebar/files_header.jinja2"))
|
||||
)
|
||||
@@ -573,7 +573,6 @@ def _process_templates():
|
||||
accesscontrol=(gettext("Access Control"), dict(template="dialogs/settings/accesscontrol.jinja2", _div="settings_users", custom_bindings=False)),
|
||||
folders=(gettext("Folders"), dict(template="dialogs/settings/folders.jinja2", _div="settings_folders", custom_bindings=False)),
|
||||
appearance=(gettext("Appearance"), dict(template="dialogs/settings/appearance.jinja2", _div="settings_appearance", custom_bindings=False)),
|
||||
logs=(gettext("Logs"), dict(template="dialogs/settings/logs.jinja2", _div="settings_logs")),
|
||||
server=(gettext("Server"), dict(template="dialogs/settings/server.jinja2", _div="settings_server", custom_bindings=False)),
|
||||
)
|
||||
|
||||
|
||||
+75
-22
@@ -43,7 +43,7 @@ try:
|
||||
except ImportError:
|
||||
from chainmap import ChainMap
|
||||
|
||||
from octoprint.util import atomic_write, is_hidden_path, dict_merge
|
||||
from octoprint.util import atomic_write, is_hidden_path, dict_merge, CaseInsensitiveSet
|
||||
|
||||
_APPNAME = "OctoPrint"
|
||||
|
||||
@@ -94,6 +94,7 @@ default_settings = {
|
||||
"detection": 0.5,
|
||||
"connection": 10,
|
||||
"communication": 30,
|
||||
"communicationBusy": 3,
|
||||
"temperature": 5,
|
||||
"temperatureTargetSet": 2,
|
||||
"temperatureAutoreport": 2,
|
||||
@@ -113,10 +114,30 @@ default_settings = {
|
||||
"disconnectOnErrors": True,
|
||||
"ignoreErrorsFromFirmware": False,
|
||||
"logResends": True,
|
||||
"autoUppercaseBlacklist": ["M117"],
|
||||
"supportResendsWithoutOk": False,
|
||||
"logPositionOnPause": True,
|
||||
"logPositionOnCancel": True,
|
||||
"waitForStartOnConnect": False,
|
||||
"alwaysSendChecksum": False,
|
||||
"neverSendChecksum": False,
|
||||
"sendChecksumWithUnknownCommands": False,
|
||||
"unknownCommandsNeedAck": False,
|
||||
"sdRelativePath": False,
|
||||
"sdAlwaysAvailable": False,
|
||||
"swallowOkAfterResend": True,
|
||||
"repetierTargetTemp": False,
|
||||
"externalHeatupDetection": True,
|
||||
"supportWait": True,
|
||||
"ignoreIdenticalResends": False,
|
||||
"identicalResendsCountdown": 7,
|
||||
"supportFAsCommand": False,
|
||||
"firmwareDetection": True,
|
||||
"blockWhileDwelling": False,
|
||||
|
||||
"capabilities": {
|
||||
"autoreport_temp": True,
|
||||
"busy_protocol": True
|
||||
},
|
||||
|
||||
# command specific flags
|
||||
"triggerOkForM29": True
|
||||
@@ -204,27 +225,12 @@ default_settings = {
|
||||
},
|
||||
"feature": {
|
||||
"temperatureGraph": True,
|
||||
"waitForStartOnConnect": False,
|
||||
"alwaysSendChecksum": False,
|
||||
"neverSendChecksum": False,
|
||||
"sendChecksumWithUnknownCommands": False,
|
||||
"unknownCommandsNeedAck": False,
|
||||
"sdSupport": True,
|
||||
"sdRelativePath": False,
|
||||
"sdAlwaysAvailable": False,
|
||||
"swallowOkAfterResend": True,
|
||||
"repetierTargetTemp": False,
|
||||
"externalHeatupDetection": True,
|
||||
"supportWait": True,
|
||||
"keyboardControl": True,
|
||||
"pollWatched": False,
|
||||
"ignoreIdenticalResends": False,
|
||||
"identicalResendsCountdown": 7,
|
||||
"supportFAsCommand": False,
|
||||
"modelSizeDetection": True,
|
||||
"firmwareDetection": True,
|
||||
"printCancelConfirmation": True,
|
||||
"blockWhileDwelling": False,
|
||||
"autoUppercaseBlacklist": ["M117"],
|
||||
"g90InfluencesExtruder": False,
|
||||
"legacyPluginAssets": False # TODO remove again in 1.3.8
|
||||
},
|
||||
@@ -273,7 +279,7 @@ default_settings = {
|
||||
"settings": [
|
||||
"section_printer", "serial", "printerprofiles", "temperatures", "terminalfilters", "gcodescripts",
|
||||
"section_features", "features", "webcam", "accesscontrol", "gcodevisualizer", "api",
|
||||
"section_octoprint", "server", "folders", "appearance", "logs", "plugin_pluginmanager", "plugin_softwareupdate", "plugin_announcements"
|
||||
"section_octoprint", "server", "folders", "appearance", "plugin_logging", "plugin_pluginmanager", "plugin_softwareupdate", "plugin_announcements"
|
||||
],
|
||||
"usersettings": ["access", "interface"],
|
||||
"wizard": ["access"],
|
||||
@@ -301,7 +307,9 @@ default_settings = {
|
||||
"userfile": None,
|
||||
"autologinLocal": False,
|
||||
"localNetworks": ["127.0.0.0/8"],
|
||||
"autologinAs": None
|
||||
"autologinAs": None,
|
||||
"trustBasicAuthentication": False,
|
||||
"checkBasicAuthenticationPassword": True
|
||||
},
|
||||
"slicing": {
|
||||
"enabled": True,
|
||||
@@ -381,6 +389,7 @@ default_settings = {
|
||||
"firmwareName": "Virtual Marlin 1.0",
|
||||
"sharedNozzle": False,
|
||||
"sendBusy": False,
|
||||
"busyInterval": 2.0,
|
||||
"simulateReset": True,
|
||||
"resetLines": ['start', 'Marlin: Virtual Marlin!', '\x80', 'SD card ok'],
|
||||
"preparedOks": [],
|
||||
@@ -405,7 +414,7 @@ default_settings = {
|
||||
}
|
||||
"""The default settings of the core application."""
|
||||
|
||||
valid_boolean_trues = [True, "true", "yes", "y", "1"]
|
||||
valid_boolean_trues = CaseInsensitiveSet(True, "true", "yes", "y", "1", 1)
|
||||
""" Values that are considered to be equivalent to the boolean ``True`` value, used for type conversion in various places."""
|
||||
|
||||
|
||||
@@ -899,7 +908,8 @@ class Settings(object):
|
||||
self._migrate_reverse_proxy_config,
|
||||
self._migrate_printer_parameters,
|
||||
self._migrate_gcode_scripts,
|
||||
self._migrate_core_system_commands
|
||||
self._migrate_core_system_commands,
|
||||
self._migrate_serial_features
|
||||
)
|
||||
|
||||
for migrate in migrators:
|
||||
@@ -1163,6 +1173,49 @@ class Settings(object):
|
||||
|
||||
return changed
|
||||
|
||||
def _migrate_serial_features(self, config):
|
||||
"""
|
||||
Migrates feature flags identified as serial specific from the feature to the serial config tree and vice versa.
|
||||
|
||||
If a flag already exists in the target tree, only deletes the copy in the source tree.
|
||||
"""
|
||||
changed = False
|
||||
|
||||
FEATURE_TO_SERIAL = ("waitForStartOnConnect", "alwaysSendChecksum", "neverSendChecksum",
|
||||
"sendChecksumWithUnknownCommands", "unknownCommandsNeedAck", "sdRelativePath",
|
||||
"sdAlwaysAvailable", "swallowOkAfterResend", "repetierTargetTemp",
|
||||
"externalHeatupDetection", "supportWait", "ignoreIdenticalResends",
|
||||
"identicalResendsCountdown", "supportFAsCommand", "firmwareDetection",
|
||||
"blockWhileDwelling")
|
||||
SERIAL_TO_FEATURE = ("autoUppercaseBlacklist",)
|
||||
|
||||
def migrate_key(key, source, target):
|
||||
if source in config and key in config[source]:
|
||||
if config.get(target) is None:
|
||||
# make sure we have a serial tree
|
||||
config[target] = dict()
|
||||
if key not in config[target]:
|
||||
# only copy over if it's not there yet
|
||||
config[target][key] = config[source][key]
|
||||
# delete feature flag
|
||||
del config[source][key]
|
||||
return True
|
||||
return False
|
||||
|
||||
for key in FEATURE_TO_SERIAL:
|
||||
changed = migrate_key(key, "feature", "serial") or changed
|
||||
|
||||
for key in SERIAL_TO_FEATURE:
|
||||
changed = migrate_key(key, "serial", "feature") or changed
|
||||
|
||||
if changed:
|
||||
# let's make a backup of our current config, in case someone wants to roll back to an
|
||||
# earlier version and needs a backup of their flags
|
||||
backup_path = self.backup("serial_feature_migration")
|
||||
self._logger.info("Made a copy of the current config at {} to allow recovery of serial feature flags".format(backup_path))
|
||||
|
||||
return changed
|
||||
|
||||
def backup(self, suffix, path=None):
|
||||
import shutil
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn.active,.btn:active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:focus,.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class*=" icon-"],.btn-large [class^=icon-]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class*=" icon-"],.btn-small [class^=icon-]{margin-top:0}.btn-mini [class*=" icon-"],.btn-mini [class^=icon-]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type=submit].btn-block,input[type=reset].btn-block,input[type=button].btn-block{width:100%}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary.active,.btn-primary:active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning.active,.btn-warning:active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#da4f49;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-repeaLine truncated
|
||||
.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn.active,.btn:active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:focus,.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class*=" icon-"],.btn-large [class^=icon-]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class*=" icon-"],.btn-small [class^=icon-]{margin-top:0}.btn-mini [class*=" icon-"],.btn-mini [class^=icon-]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type=submit].btn-block,input[type=reset].btn-block,input[type=button].btn-block{width:100%}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary.active,.btn-primary:active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning.active,.btn-warning:active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#da4f49;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-repeaLine truncated
|
||||
@@ -1,30 +0,0 @@
|
||||
(function (global, factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["OctoPrintClient"], factory);
|
||||
} else {
|
||||
factory(global.OctoPrintClient);
|
||||
}
|
||||
})(this, function(OctoPrintClient) {
|
||||
var url = "api/logs";
|
||||
|
||||
var OctoPrintLogsClient = function(base) {
|
||||
this.base = base;
|
||||
};
|
||||
|
||||
OctoPrintLogsClient.prototype.list = function(opts) {
|
||||
return this.base.get(url, opts);
|
||||
};
|
||||
|
||||
OctoPrintLogsClient.prototype.delete = function(file, opts) {
|
||||
var fileUrl = url + "/" + file;
|
||||
return this.base.delete(fileUrl, opts);
|
||||
};
|
||||
|
||||
OctoPrintLogsClient.prototype.download = function(file, opts) {
|
||||
var fileUrl = url + "/" + file;
|
||||
return this.base.download(fileUrl, opts);
|
||||
};
|
||||
|
||||
OctoPrintClient.registerComponent("logs", OctoPrintLogsClient);
|
||||
return OctoPrintLogsClient;
|
||||
});
|
||||
@@ -33,7 +33,7 @@ $(function() {
|
||||
};
|
||||
|
||||
self.showTab = function(tab) {
|
||||
$("a[href=#" + tab + "]", self.aboutTabs).tab("show");
|
||||
$('a[href="#' + tab + '"]', self.aboutTabs).tab("show");
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
$(function() {
|
||||
function LogViewModel(parameters) {
|
||||
var self = this;
|
||||
|
||||
self.loginState = parameters[0];
|
||||
|
||||
// initialize list helper
|
||||
self.listHelper = new ItemListHelper(
|
||||
"logFiles",
|
||||
{
|
||||
"name": function(a, b) {
|
||||
// sorts ascending
|
||||
if (a["name"].toLocaleLowerCase() < b["name"].toLocaleLowerCase()) return -1;
|
||||
if (a["name"].toLocaleLowerCase() > b["name"].toLocaleLowerCase()) return 1;
|
||||
return 0;
|
||||
},
|
||||
"modification": function(a, b) {
|
||||
// sorts descending
|
||||
if (a["date"] > b["date"]) return -1;
|
||||
if (a["date"] < b["date"]) return 1;
|
||||
return 0;
|
||||
},
|
||||
"size": function(a, b) {
|
||||
// sorts descending
|
||||
if (a["size"] > b["size"]) return -1;
|
||||
if (a["size"] < b["size"]) return 1;
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
{
|
||||
},
|
||||
"name",
|
||||
[],
|
||||
[],
|
||||
CONFIG_LOGFILESPERPAGE
|
||||
);
|
||||
|
||||
self.requestData = function() {
|
||||
OctoPrint.logs.list()
|
||||
.done(self.fromResponse);
|
||||
};
|
||||
|
||||
self.fromResponse = function(response) {
|
||||
var files = response.files;
|
||||
if (files === undefined)
|
||||
return;
|
||||
|
||||
self.listHelper.updateItems(files);
|
||||
};
|
||||
|
||||
self.removeFile = function(filename) {
|
||||
OctoPrint.logs.delete(filename)
|
||||
.done(self.requestData);
|
||||
};
|
||||
|
||||
self.onSettingsShown = function() {
|
||||
self.requestData();
|
||||
};
|
||||
}
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
construct: LogViewModel,
|
||||
dependencies: ["loginStateViewModel"],
|
||||
elements: ["#logs"]
|
||||
});
|
||||
});
|
||||
@@ -134,22 +134,13 @@ $(function() {
|
||||
self.feature_sizeThreshold_str = sizeObservable(self.feature_sizeThreshold);
|
||||
self.feature_mobileSizeThreshold_str = sizeObservable(self.feature_mobileSizeThreshold);
|
||||
self.feature_temperatureGraph = ko.observable(undefined);
|
||||
self.feature_waitForStart = ko.observable(undefined);
|
||||
self.feature_sendChecksum = ko.observable("print");
|
||||
self.feature_sdSupport = ko.observable(undefined);
|
||||
self.feature_sdRelativePath = ko.observable(undefined);
|
||||
self.feature_sdAlwaysAvailable = ko.observable(undefined);
|
||||
self.feature_swallowOkAfterResend = ko.observable(undefined);
|
||||
self.feature_repetierTargetTemp = ko.observable(undefined);
|
||||
self.feature_disableExternalHeatupDetection = ko.observable(undefined);
|
||||
self.feature_keyboardControl = ko.observable(undefined);
|
||||
self.feature_pollWatched = ko.observable(undefined);
|
||||
self.feature_ignoreIdenticalResends = ko.observable(undefined);
|
||||
self.feature_modelSizeDetection = ko.observable(undefined);
|
||||
self.feature_firmwareDetection = ko.observable(undefined);
|
||||
self.feature_printCancelConfirmation = ko.observable(undefined);
|
||||
self.feature_blockWhileDwelling = ko.observable(undefined);
|
||||
self.feature_g90InfluencesExtruder = ko.observable(undefined);
|
||||
self.feature_autoUppercaseBlacklist = ko.observable(undefined);
|
||||
self.feature_legacyPluginAssets = ko.observable(undefined);
|
||||
|
||||
self.serial_port = ko.observable();
|
||||
@@ -160,6 +151,7 @@ $(function() {
|
||||
self.serial_timeoutConnection = ko.observable(undefined);
|
||||
self.serial_timeoutDetection = ko.observable(undefined);
|
||||
self.serial_timeoutCommunication = ko.observable(undefined);
|
||||
self.serial_timeoutCommunicationBusy = ko.observable(undefined);
|
||||
self.serial_timeoutTemperature = ko.observable(undefined);
|
||||
self.serial_timeoutTemperatureTargetSet = ko.observable(undefined);
|
||||
self.serial_timeoutTemperatureAutoreport = ko.observable(undefined);
|
||||
@@ -173,13 +165,24 @@ $(function() {
|
||||
self.serial_ignoreErrorsFromFirmware = ko.observable(undefined);
|
||||
self.serial_disconnectOnErrors = ko.observable(undefined);
|
||||
self.serial_triggerOkForM29 = ko.observable(undefined);
|
||||
self.serial_autoUppercaseBlacklist = ko.observable(undefined);
|
||||
self.serial_waitForStart = ko.observable(undefined);
|
||||
self.serial_sendChecksum = ko.observable("print");
|
||||
self.serial_sdRelativePath = ko.observable(undefined);
|
||||
self.serial_sdAlwaysAvailable = ko.observable(undefined);
|
||||
self.serial_swallowOkAfterResend = ko.observable(undefined);
|
||||
self.serial_repetierTargetTemp = ko.observable(undefined);
|
||||
self.serial_disableExternalHeatupDetection = ko.observable(undefined);
|
||||
self.serial_ignoreIdenticalResends = ko.observable(undefined);
|
||||
self.serial_firmwareDetection = ko.observable(undefined);
|
||||
self.serial_blockWhileDwelling = ko.observable(undefined);
|
||||
self.serial_supportResendsWithoutOk = ko.observable(undefined);
|
||||
self.serial_logPositionOnPause = ko.observable(undefined);
|
||||
self.serial_logPositionOnCancel = ko.observable(undefined);
|
||||
self.serial_maxTimeoutsIdle = ko.observable(undefined);
|
||||
self.serial_maxTimeoutsPrinting = ko.observable(undefined);
|
||||
self.serial_maxTimeoutsLong = ko.observable(undefined);
|
||||
self.serial_capAutoreportTemp = ko.observable(undefined);
|
||||
self.serial_capBusyProtocol = ko.observable(undefined);
|
||||
|
||||
self.folder_uploads = ko.observable(undefined);
|
||||
self.folder_timelapse = ko.observable(undefined);
|
||||
@@ -245,6 +248,25 @@ $(function() {
|
||||
self.server_onlineCheckBroken(false);
|
||||
};
|
||||
|
||||
self.observableCopies = {
|
||||
"feature_waitForStart": "serial_waitForStart",
|
||||
"feature_sendChecksum": "serial_sendChecksum",
|
||||
"feature_sdRelativePath": "serial_sdRelativePath",
|
||||
"feature_sdAlwaysAvailable": "serial_sdAlwaysAvailable",
|
||||
"feature_swallowOkAfterResend": "serial_swallowOkAfterResend",
|
||||
"feature_repetierTargetTemp": "serial_repetierTargetTemp",
|
||||
"feature_disableExternalHeatupDetection": "serial_disableExternalHeatupDetection",
|
||||
"feature_ignoreIdenticalResends": "serial_ignoreIdenticalResends",
|
||||
"feature_firmwareDetection": "serial_firmwareDetection",
|
||||
"feature_blockWhileDwelling": "serial_blockWhileDwelling",
|
||||
"serial_": "feature_"
|
||||
};
|
||||
_.each(self.observableCopies, function(value, key) {
|
||||
if (self.hasOwnProperty(value)) {
|
||||
self[key] = self[value];
|
||||
}
|
||||
});
|
||||
|
||||
self.addTemperatureProfile = function() {
|
||||
self.temperature_profiles.push({name: "New", extruder:0, bed:0});
|
||||
};
|
||||
@@ -664,16 +686,16 @@ $(function() {
|
||||
// some special read functions for various observables
|
||||
var specialMappings = {
|
||||
feature: {
|
||||
externalHeatupDetection: function() { return !self.feature_disableExternalHeatupDetection()},
|
||||
alwaysSendChecksum: function() { return self.feature_sendChecksum() == "always"},
|
||||
neverSendChecksum: function() { return self.feature_sendChecksum() == "never"}
|
||||
autoUppercaseBlacklist: function() { return splitTextToArray(self.feature_autoUppercaseBlacklist(), ",", true) }
|
||||
},
|
||||
serial: {
|
||||
additionalPorts : function() { return commentableLinesToArray(self.serial_additionalPorts()) },
|
||||
additionalBaudrates: function() { return _.map(splitTextToArray(self.serial_additionalBaudrates(), ",", true, function(item) { return !isNaN(parseInt(item)); }), function(item) { return parseInt(item); }) },
|
||||
longRunningCommands: function() { return splitTextToArray(self.serial_longRunningCommands(), ",", true) },
|
||||
checksumRequiringCommands: function() { return splitTextToArray(self.serial_checksumRequiringCommands(), ",", true) },
|
||||
autoUppercaseBlacklist: function() { return splitTextToArray(self.serial_autoUppercaseBlacklist(), ",", true) }
|
||||
externalHeatupDetection: function() { return !self.serial_disableExternalHeatupDetection()},
|
||||
alwaysSendChecksum: function() { return self.serial_sendChecksum() == "always"},
|
||||
neverSendChecksum: function() { return self.serial_sendChecksum() == "never"}
|
||||
},
|
||||
scripts: {
|
||||
gcode: function() {
|
||||
@@ -711,6 +733,11 @@ $(function() {
|
||||
observable = keyPrefix + "_" + observable;
|
||||
}
|
||||
|
||||
if (self.observableCopies.hasOwnProperty(observable)) {
|
||||
// only a copy, skip
|
||||
return;
|
||||
}
|
||||
|
||||
if (mapping && mapping[key] && _.isFunction(mapping[key])) {
|
||||
result[key] = mapping[key]();
|
||||
flag = true;
|
||||
@@ -776,16 +803,16 @@ $(function() {
|
||||
}
|
||||
},
|
||||
feature: {
|
||||
externalHeatupDetection: function(value) { self.feature_disableExternalHeatupDetection(!value) },
|
||||
alwaysSendChecksum: function(value) { if (value) { self.feature_sendChecksum("always")}},
|
||||
neverSendChecksum: function(value) { if (value) { self.feature_sendChecksum("never")}}
|
||||
autoUppercaseBlacklist: function(value) { self.feature_autoUppercaseBlacklist(value.join(", "))}
|
||||
},
|
||||
serial: {
|
||||
additionalPorts : function(value) { self.serial_additionalPorts(value.join("\n"))},
|
||||
additionalBaudrates: function(value) { self.serial_additionalBaudrates(value.join(", "))},
|
||||
longRunningCommands: function(value) { self.serial_longRunningCommands(value.join(", "))},
|
||||
checksumRequiringCommands: function(value) { self.serial_checksumRequiringCommands(value.join(", "))},
|
||||
autoUppercaseBlacklist: function(value) { self.serial_autoUppercaseBlacklist(value.join(", "))}
|
||||
externalHeatupDetection: function(value) { self.serial_disableExternalHeatupDetection(!value) },
|
||||
alwaysSendChecksum: function(value) { if (value) { self.serial_sendChecksum("always")}},
|
||||
neverSendChecksum: function(value) { if (value) { self.serial_sendChecksum("never")}}
|
||||
},
|
||||
terminalFilters: function(value) { self.terminalFilters($.extend(true, [], value)) },
|
||||
temperature: {
|
||||
@@ -805,6 +832,11 @@ $(function() {
|
||||
observable = keyPrefix + "_" + observable;
|
||||
}
|
||||
|
||||
if (self.observableCopies.hasOwnProperty(observable)) {
|
||||
// only a copy, skip
|
||||
return;
|
||||
}
|
||||
|
||||
var haveLocalVersion = local && local.hasOwnProperty(key);
|
||||
|
||||
if (mapping && mapping[key] && _.isFunction(mapping[key]) && !haveLocalVersion) {
|
||||
@@ -917,6 +949,11 @@ $(function() {
|
||||
|
||||
self._resetScrollPosition = function() {
|
||||
$('#settings_dialog_content', self.settingsDialog).scrollTop(0);
|
||||
|
||||
// also reset any contained tabs/pills/lists to first pane
|
||||
$('#settings_dialog_content ul.nav-pills a[data-toggle="tab"]:first', self.settingsDialog).tab("show");
|
||||
$('#settings_dialog_content ul.nav-list a[data-toggle="tab"]:first', self.settingsDialog).tab("show");
|
||||
$('#settings_dialog_content ul.nav-tabs a[data-toggle="tab"]:first', self.settingsDialog).tab("show");
|
||||
};
|
||||
|
||||
self.selectTab = function(tab) {
|
||||
@@ -926,7 +963,7 @@ $(function() {
|
||||
}
|
||||
$('ul.nav-list a[href="' + tab + '"]', self.settingsDialog).tab("show");
|
||||
} else {
|
||||
$('ul.nav-list a:first', self.settingsDialog).tab("show");
|
||||
$('ul.nav-list a[data-toggle="tab"]:first', self.settingsDialog).tab("show");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -329,7 +329,12 @@ $(function() {
|
||||
yaxis: {
|
||||
min: 0,
|
||||
max: Math.max(Math.max.apply(null, plotInfo.max) * 1.1, 310),
|
||||
ticks: 10
|
||||
ticks: 10,
|
||||
tickFormatter: function(val, axis) {
|
||||
if (val === undefined || val === 0)
|
||||
return "";
|
||||
return val + "°C";
|
||||
}
|
||||
},
|
||||
xaxis: {
|
||||
mode: "time",
|
||||
@@ -347,7 +352,8 @@ $(function() {
|
||||
// convert to minutes
|
||||
var diffInMins = Math.round(diff / (60 * 1000));
|
||||
if (diffInMins === 0) {
|
||||
return gettext("just now");
|
||||
// don't write anything for "just now"
|
||||
return "";
|
||||
} else if (diffInMins < 0) {
|
||||
// we can't look into the future
|
||||
return "";
|
||||
|
||||
@@ -125,7 +125,7 @@ $(function() {
|
||||
});
|
||||
|
||||
self.blacklist=[];
|
||||
self.settings.serial_autoUppercaseBlacklist.subscribe(function(newValue) {
|
||||
self.settings.feature_autoUppercaseBlacklist.subscribe(function(newValue) {
|
||||
self.blacklist = splitTextToArray(newValue, ",", true);
|
||||
});
|
||||
|
||||
@@ -277,6 +277,17 @@ $(function() {
|
||||
}
|
||||
};
|
||||
|
||||
self.terminalScrollEvent = _.throttle(function () {
|
||||
if (self.autoscrollEnabled()) {
|
||||
var container = self.fancyFunctionality() ? $("#terminal-output") : $("#terminal-output-lowfi");
|
||||
var maxScroll = container[0].scrollHeight - container[0].offsetHeight;
|
||||
|
||||
if (container.scrollTop() <= maxScroll ) {
|
||||
self.autoscrollEnabled(false);
|
||||
}
|
||||
}
|
||||
}, 250);
|
||||
|
||||
self.gotoTerminalCommand = function() {
|
||||
// skip if user highlights text.
|
||||
var sel = getSelection().toString();
|
||||
@@ -289,6 +300,10 @@ $(function() {
|
||||
|
||||
self.toggleAutoscroll = function() {
|
||||
self.autoscrollEnabled(!self.autoscrollEnabled());
|
||||
|
||||
if (self.autoscrollEnabled()) {
|
||||
self.updateOutput();
|
||||
}
|
||||
};
|
||||
|
||||
self.selectAll = function() {
|
||||
@@ -306,7 +321,15 @@ $(function() {
|
||||
};
|
||||
|
||||
self.copyAll = function() {
|
||||
copyToClipboard(self.plainLogLines().join("\n"));
|
||||
var lines;
|
||||
|
||||
if (self.fancyFunctionality()) {
|
||||
lines = _.map(self.log(), "line");
|
||||
} else {
|
||||
lines = self.plainLogLines();
|
||||
}
|
||||
|
||||
copyToClipboard(lines.join("\n"));
|
||||
};
|
||||
|
||||
// command matching regex
|
||||
|
||||
@@ -364,27 +364,6 @@ table {
|
||||
.actioncol;
|
||||
}
|
||||
|
||||
// log files
|
||||
&.settings_logs_name {
|
||||
text-overflow: ellipsis;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
&.settings_logs_size {
|
||||
text-align: right;
|
||||
width: 70px;
|
||||
}
|
||||
|
||||
&.settings_logs_date {
|
||||
text-align: left;
|
||||
width: 130px;
|
||||
}
|
||||
|
||||
&.settings_logs_action {
|
||||
width: 70px;
|
||||
.actioncol;
|
||||
}
|
||||
|
||||
// Printer profiles
|
||||
&.settings_printerProfiles_profiles_name {
|
||||
text-overflow: ellipsis;
|
||||
|
||||
@@ -48,87 +48,19 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: feature_waitForStart" id="settings-featureWaitForStart"> {{ _('Wait for <code>start</code> on connect') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<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="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>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="control-group" title="{{ _('Commands to not completely auto uppercase in the terminal tab') }}">
|
||||
<label class="control-label" for="settings-featureAutoUppercaseBlacklist">{{ _('Terminal Auto Uppercase Blacklist') }}</label>
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: feature_firmwareDetection" id="settings-firmwareDetection"> {{ _('Enable automatic firmware detection') }}
|
||||
<span class="help-block">{% trans %}
|
||||
If enabled, OctoPrint will try to figure out your printer's firmware automatically and adjust some communication parameters based on that.
|
||||
If that doesn't work out, or you want more granular control, uncheck this and the parameters in question will become visible for you to adjust.
|
||||
{% endtrans %}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div data-bind="visible: !feature_firmwareDetection()">
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: feature_sdRelativePath" id="settings-sdRelativePath"> {{ _('Select SD files by relative path') }} <span class="label">{{ _('RepRap Firmware') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: feature_sdAlwaysAvailable" id="settings-featureSdAlwaysAvailable"> {{ _('Always assume SD card is present') }} <span class="label">{{ _('Repetier') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: feature_ignoreIdenticalResends" id="settings-ignoreIdenticalResends"> {{ _('Ignore consecutive resend requests for the same line') }} <span class="label">{{ _('Repetier') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: feature_repetierTargetTemp" id="settings-featureRepetierTargetTemp"> {{ _('Support <code>TargetExtr%%n</code>/<code>TargetBed</code> target temperature format') }} <span class="label">{{ _('Repetier') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: feature_disableExternalHeatupDetection" id="settings-featureExternalHeatupDetection"> {{ _('Disable detection of external heatups') }} <span class="label">{{ _('Repetier') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: feature_blockWhileDwelling" id="settings-featureBlockWhileDwelling"> {{ _('Actively pause communication during <code>G4</code> dwell command') }} <span class="label">{{ _('Repetier') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Send a checksum with the command')}}</label>
|
||||
<div class="controls">
|
||||
<label class="radio">
|
||||
<input type="radio" name="sendChecksumGroup" value="print" data-bind="checked: feature_sendChecksum" id="settings-featureSendChecksumPrint"> {{ _('When printing') }}
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input type="radio" name="sendChecksumGroup" value="always" data-bind="checked: feature_sendChecksum" id="settings-featureSendChecksumAlways"> {{ _('Always') }} <span class="label">{{ _('Repetier') }}</span>
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input type="radio" name="sendChecksumGroup" value="never" data-bind="checked: feature_sendChecksum" id="settings-featureSendChecksumNever"> {{ _('Never') }}
|
||||
</label>
|
||||
</div>
|
||||
<input type="text" class="input-block-level" id="settings-featureAutoUppercaseBlacklist" data-bind="value: feature_autoUppercaseBlacklist">
|
||||
<span class="help-block">{{ _('Use this to specify the commands that should not have their parameters automatically uppercased in the terminal tab. Just the G or M code, comma separated.') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -1,46 +0,0 @@
|
||||
<div id="logs">
|
||||
<h1>{{ _('Logs') }}</h1>
|
||||
|
||||
<div class="pull-right">
|
||||
<small>
|
||||
{{ _('Sort by') }}: <a href="#" data-bind="click: function() { listHelper.changeSorting('name'); }">{{ _('Name') }} ({{ _('ascending') }})</a> | <a href="#" data-bind="click: function() { listHelper.changeSorting('modification'); }">{{ _('Modification date') }} ({{ _('descending') }})</a> | <a href="#" data-bind="click: function() { listHelper.changeSorting('size'); }">{{ _('Size') }} ({{ _('descending') }})</a>
|
||||
</small>
|
||||
</div>
|
||||
<table class="table table-striped table-hover table-condensed table-hover" id="log_files">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="settings_logs_name">{{ _('Name') }}</th>
|
||||
<th class="settings_logs_size">{{ _('Size') }}</th>
|
||||
<th class="settings_logs_date">{{ _('Date') }}</th>
|
||||
<th class="settings_logs_action">{{ _('Action') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-bind="foreach: listHelper.paginatedItems">
|
||||
<tr data-bind="attr: {title: name}">
|
||||
<td class="settings_logs_name" data-bind="text: name"></td>
|
||||
<td class="settings_logs_size" data-bind="text: formatSize(size)"></td>
|
||||
<td class="settings_logs_date" data-bind="text: formatDate(date)"></td>
|
||||
<td class="settings_logs_action">
|
||||
<a href="#" class="fa fa-trash-o" data-bind="click: function() { if ($root.loginState.isUser()) { $parent.removeFile($data.name); } else { return; } }, css: {disabled: !$root.loginState.isUser()}"></a> | <a href="#" class="fa fa-download" data-bind="attr: {href: refs.download}"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="pagination pagination-mini pagination-centered">
|
||||
<ul>
|
||||
<li data-bind="css: {disabled: listHelper.currentPage() === 0}">
|
||||
<a href="#" data-bind="click: listHelper.prevPage">«</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul data-bind="foreach: listHelper.pages">
|
||||
<li data-bind="css: { active: $data.number === $root.listHelper.currentPage(), disabled: $data.number === -1 }">
|
||||
<a href="#" data-bind="text: $data.text, click: function() { $root.listHelper.changePage($data.number); }"></a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li data-bind="css: {disabled: listHelper.currentPage() === listHelper.lastPage()}">
|
||||
<a href="#" data-bind="click: listHelper.nextPage">»</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,197 +1,341 @@
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group" title="{{ _('Serial port to connect to, setting this to AUTO will make OctoPrint try to automatically find the right setting') }}">
|
||||
<label class="control-label" for="settings-serialPort">{{ _('Serial Port') }}</label>
|
||||
<div class="controls">
|
||||
<select id="settings-serialPort" data-bind="options: serial_portOptions, optionsCaption: 'AUTO', value: serial_port"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Serial baud rate to connect with, setting this to AUTO will make OctoPrint try to automatically find the right setting') }}">
|
||||
<label class="control-label" for="settings-baudrate">{{ _('Baudrate') }}</label>
|
||||
<div class="controls">
|
||||
<select id="settings-baudrate" data-bind="options: serial_baudrateOptions, optionsCaption: 'AUTO', value: serial_baudrate"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Makes OctoPrint try to connect to the printer automatically during start up') }}">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_autoconnect" id="settings-serialAutoconnect"> {{ _('Auto-connect to printer on server start') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Interval in which to poll for the temperature information from the printer') }}">
|
||||
<label class="control-label" for="settings-serialTimeoutTemperature">{{ _('Temperature interval (polling)') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="1" class="input-mini text-right" data-bind="value: serial_timeoutTemperature" id="settings-serialTimeoutTemperature">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
<span class="help-inline">{{ _('When printing or idle')}}</span>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="1" class="input-mini text-right" data-bind="value: serial_timeoutTemperatureTargetSet" id="settings-serialTimeoutTemperatureTargetSet">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
<span class="help-inline">{{ _('When a target temperature is set')}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Temperature report interval to request from autoreport capable firmwares. A value of 0 disables autoreporting by the firmware and forces polling.') }}">
|
||||
<label class="control-label">{{ _('Temperature interval (autoreport)') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutTemperatureAutoreport" id="settings-serialTimeoutTemperatureAutoreport">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
<span class="help-inline">{{ _('Autoreport interval to request from firmware')}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Interval in which to poll for the SD printing status information from the printer while printing') }}">
|
||||
<label class="control-label" for="settings-serialTimeoutSdStatus">{{ _('SD status 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_timeoutSdStatus" id="settings-serialTimeoutSdStatus">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Time after which the communication with your printer will be considered timed out if nothing was sent by your printer (and an attempt to get it talking again will be done). Increase this if your printer takes longer than this for some moves.') }}">
|
||||
<label class="control-label" for="settings-serialTimeoutCommunication">{{ _('Communication timeout') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutCommunication" id="settings-serialTimeoutCommunication">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Time after which a connection attempt to the printer will be considered as having failed') }}">
|
||||
<label class="control-label" for="settings-serialTimeoutConnection">{{ _('Connection timeout') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutConnection" id="settings-serialTimeoutConnection">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Time after which to consider an auto detection attempt to have failed if no successful connection is detected') }}">
|
||||
<label class="control-label" for="settings-serialTimeoutDetection">{{ _('Autodetection timeout') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutDetection" id="settings-serialTimeoutDetection">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_log" id="settings-serialLog"> {{ _('Log communication to serial.log (might negatively impact performance)') }} <span class="label label-important">{{ _('Warning') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-serialAdditionalPorts">{{ _('Additional serial ports') }}</label>
|
||||
<div class="controls">
|
||||
<textarea rows="4" class="block" id="settings-serialAdditionalPorts" data-bind="value: serial_additionalPorts"></textarea>
|
||||
<span class="help-inline">{{ _('Use this to define additional <a href="%%(glob_url)s">glob patterns</a> matching serial ports to list for connecting against, e.g. <code>/dev/ttyAMA*</code>. One entry per line.')|format(glob_url="http://docs.python.org/2/library/glob.html") }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-serialAdditionalBaudrates">{{ _('Additional baud rates') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" id="settings-serialAdditionalBaudrates" data-bind="value: serial_additionalBaudrates">
|
||||
<span class="help-inline">{{ _('Use this to define additional serial port baud rates to list for connecting with, e.g. <code>123456</code>. Comma separated.')|format(glob_url="http://docs.python.org/2/library/glob.html") }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_disconnectOnErrors" id="settings-disconnectOnErrors"> {{ _('Not only cancel ongoing prints but also disconnect on unhandled errors from the firmware.') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_ignoreErrorsFromFirmware" id="settings-ignoreErrorsFromFirmware"> {{ _('Ignore any unhandled errors from the firmware. Only use this if your firmware sends stuff prefixed with "Error" that is not an actual error. Might mask printer issues, be careful!') }} <span class="label label-important">{{ _('Warning') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="nav nav-pills">
|
||||
<li class="active"><a href="#settings_serial_general" data-toggle="tab">{{ _('General') }}</a></li>
|
||||
<li><a href="#settings_serial_timeouts" data-toggle="tab">{{ _('Intervals & timeouts') }}</a></li>
|
||||
<li><a href="#settings_serial_protocol" data-toggle="tab">{{ _('Firmware & protocol') }}</a></li>
|
||||
<li><a href="#settings_serial_behaviour" data-toggle="tab">{{ _('Behaviour') }}</a></li>
|
||||
</ul>
|
||||
|
||||
<div>
|
||||
<div><small><a href="#" class="muted" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', container: '#settings_serialConnection .hide' }"><i class="fa fa-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
|
||||
<div class="hide">
|
||||
<div class="control-group" title="{{ _('Command to send to the firmware on first handshake attempt.') }}">
|
||||
<label class="control-label" for="settings-serialHelloCommand">{{ _('"Hello" command') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" id="settings-serialHelloCommand" data-bind="value: serial_helloCommand">
|
||||
<span class="help-inline">{{ _('Use this to specify a different command than the default <code>M110</code> to send to the printer on initial connection to trigger a communication handshake.') }}</span>
|
||||
<div class="tab-content">
|
||||
<div id="settings_serial_general" class="tab-pane active">
|
||||
<fieldset>
|
||||
<legend>{{ _('Connection') }}</legend>
|
||||
<div class="control-group" title="{{ _('Serial port to connect to, setting this to AUTO will make OctoPrint try to automatically find the right setting') }}">
|
||||
<label class="control-label" for="settings-serialPort">{{ _('Serial Port') }}</label>
|
||||
<div class="controls">
|
||||
<select id="settings-serialPort" data-bind="options: serial_portOptions, optionsCaption: 'AUTO', value: serial_port"></select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Commands that are know to run long and hence should suppress communication timeouts from being triggered.') }}">
|
||||
<label class="control-label" for="settings-serialLongRunningCommands">{{ _('Long running commands') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" id="settings-serialLongRunningCommands" data-bind="value: serial_longRunningCommands">
|
||||
<span class="help-inline">{{ _('Use this to specify the commands known to take a long time to complete without output from your printer and hence might cause timeout issues. Just the G or M code, comma separated.') }}</span>
|
||||
<div class="control-group" title="{{ _('Serial baud rate to connect with, setting this to AUTO will make OctoPrint try to automatically find the right setting') }}">
|
||||
<label class="control-label" for="settings-baudrate">{{ _('Baudrate') }}</label>
|
||||
<div class="controls">
|
||||
<select id="settings-baudrate" data-bind="options: serial_baudrateOptions, optionsCaption: 'AUTO', value: serial_baudrate"></select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Commands that always require a line number and checksum to be sent with them.') }}">
|
||||
<label class="control-label" for="settings-checksumRequiringCommands">{{ _('Commands that always require a checksum') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" id="settings-checksumRequiringCommands" data-bind="value: serial_checksumRequiringCommands">
|
||||
<span class="help-inline">{{ _('Use this to specify which commands <strong>always</strong> need to be sent with a checksum. Comma separated list.') }}</span>
|
||||
<div class="control-group" title="{{ _('Makes OctoPrint try to connect to the printer automatically during start up') }}">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_autoconnect" id="settings-serialAutoconnect"> {{ _('Auto-connect to printer on server start') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Commands to not completely auto uppercase in the terminal tab') }}">
|
||||
<label class="control-label" for="settings-serialAutoUppercaseBlacklist">{{ _('Terminal Auto Uppercase Blacklist') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" id="settings-serialAutoUppercaseBlacklist" data-bind="value: serial_autoUppercaseBlacklist">
|
||||
<span class="help-inline">{{ _('Use this to specify the commands that should not have their parameters automatically uppercased in the terminal tab. Just the G or M code, comma separated.') }}</span>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-serialAdditionalPorts">{{ _('Additional serial ports') }}</label>
|
||||
<div class="controls">
|
||||
<textarea rows="4" class="block" id="settings-serialAdditionalPorts" data-bind="value: serial_additionalPorts"></textarea>
|
||||
<span class="help-inline">{{ _('Use this to define additional <a href="%%(glob_url)s">glob patterns</a> matching serial ports to list for connecting against, e.g. <code>/dev/ttyAMA*</code>. One entry per line.')|format(glob_url="http://docs.python.org/2/library/glob.html") }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_triggerOkForM29" id="settings-triggerOkForM29"> {{ _('Generate additional <code>ok</code> for <code>M29</code>') }} <span class="label">{{ _('Most Marlin < v1.1.0') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_supportResendsWithoutOk" id="settings-supportResendsWithoutOk"> {{ _('Simulate an additional <code>ok</code> for resend requests') }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_logPositionOnPause" id="settings-logPositionOnPause"> {{ _('Log position on pause') }} <span class="label label-important">{{ _('Warning') }}</span>
|
||||
<span class="help-block">{{ _('If you disabled this, the <code>pause_position</code> placeholders in your pause/resume GCODE scripts will stay unpopulated! However, pausing speed might improve slightly.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_logPositionOnCancel" id="settings-logPositionOnCancel"> {{ _('Log position on cancel') }} <span class="label label-important">{{ _('Warning') }}</span>
|
||||
<span class="help-block">{{ _('If you disabled this, the <code>cancel_position</code> placeholders in your cancel GCODE script and the corresponding data in the print recovery data will stay unpopulated! However, cancelling speed might improve slightly.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Maximum consecutive communication timeouts while idle. More than this and the printer will be considered to be gone. Set to 0 to disable.') }}">
|
||||
<label class="control-label" for="settings-serialMaxTimeoutsIdle">{{ _('Max. consecutive timeouts while idle') }}</label>
|
||||
<div class="controls">
|
||||
<input type="number" min="0" class="input-mini text-right" id="settings-serialMaxTimeoutsIdle" data-bind="value: serial_maxTimeoutsIdle">
|
||||
<span class="help-block">{{ _('Set to 0 to disable consecutive timeout detection and handling.') }}</span>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-serialAdditionalBaudrates">{{ _('Additional baud rates') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" id="settings-serialAdditionalBaudrates" data-bind="value: serial_additionalBaudrates">
|
||||
<span class="help-inline">{{ _('Use this to define additional serial port baud rates to list for connecting with, e.g. <code>123456</code>. Comma separated.')|format(glob_url="http://docs.python.org/2/library/glob.html") }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Maximum consecutive communication timeouts while printing. More than this and the printer will be considered to be gone. Set to 0 to disable.') }}">
|
||||
<label class="control-label" for="settings-serialMaxTimeoutsPrinting">{{ _('Max. consecutive timeouts while printing') }}</label>
|
||||
<div class="controls">
|
||||
<input type="number" min="0" class="input-mini text-right" id="settings-serialMaxTimeoutsPrinting" data-bind="value: serial_maxTimeoutsPrinting">
|
||||
<span class="help-block">{{ _('Set to 0 to disable consecutive timeout detection and handling.') }}</span>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>{{ _('Serial logging') }}</legend>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_log" id="settings-serialLog"> {{ _('Log communication to <code>serial.log</code>') }} <span class="label label-important">{{ _('Warning') }}</span>
|
||||
<span class="help-block">{{ _('While this can negatively impact performance, a <code>serial.log</code> can be incredibly useful for debugging any issues observed in the communication between OctoPrint and your printer.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Maximum consecutive communication timeouts while a long running command is active. More than this and the printer will be considered to be gone. Set to 0 to disable.') }}">
|
||||
<label class="control-label" for="settings-serialMaxTimeoutsLong">{{ _('Max. consecutive timeouts during long running commands') }}</label>
|
||||
<div class="controls">
|
||||
<input type="number" min="0" class="input-mini text-right" id="settings-serialMaxTimeoutsLong" data-bind="value: serial_maxTimeoutsLong">
|
||||
<span class="help-block">{{ _('Set to 0 to disable consecutive timeout detection and handling.') }}</span>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div id="settings_serial_timeouts" class="tab-pane">
|
||||
<fieldset id="settings_serial_timeouts_intervals">
|
||||
<legend>{{ _('Query intervals') }}</legend>
|
||||
<div class="control-group" title="{{ _('Interval in which to poll for the temperature information from the printer') }}">
|
||||
<label class="control-label" for="settings-serialTimeoutTemperature">{{ _('Temperature interval (polling)') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="1" class="input-mini text-right" data-bind="value: serial_timeoutTemperature" id="settings-serialTimeoutTemperature">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
<span class="help-inline">{{ _('When printing or idle')}}</span>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="1" class="input-mini text-right" data-bind="value: serial_timeoutTemperatureTargetSet" id="settings-serialTimeoutTemperatureTargetSet">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
<span class="help-inline">{{ _('When a target temperature is set')}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Temperature report interval to request from autoreport capable firmwares. A value of 0 disables autoreporting by the firmware and forces polling.') }}">
|
||||
<label class="control-label">{{ _('Temperature interval (autoreport)') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutTemperatureAutoreport" id="settings-serialTimeoutTemperatureAutoreport">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
<span class="help-inline">{{ _('Autoreport interval to request from firmware')}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Interval in which to poll for the SD printing status information from the printer while printing') }}">
|
||||
<label class="control-label" for="settings-serialTimeoutSdStatus">{{ _('SD status 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_timeoutSdStatus" id="settings-serialTimeoutSdStatus">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset id="settings_serial_timeouts_timeouts">
|
||||
<legend>{{ _('Timeouts') }}</legend>
|
||||
<div class="control-group" title="{{ _('Time after which the communication with your printer will be considered timed out if nothing was sent by your printer (and an attempt to get it talking again will be done). Increase this if your printer takes longer than this for some moves.') }}">
|
||||
<label class="control-label" for="settings-serialTimeoutCommunication">{{ _('Communication timeout') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutCommunication" id="settings-serialTimeoutCommunication">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
<span class="help-inline">{{ _('<code>busy</code> protocol support not detected')}}</span>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutCommunicationBusy" id="settings-serialTimeoutCommunicationBusy">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
<span class="help-inline">{{ _('<code>busy</code> protocol support detected')}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Time after which a connection attempt to the printer will be considered as having failed') }}">
|
||||
<label class="control-label" for="settings-serialTimeoutConnection">{{ _('Connection timeout') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutConnection" id="settings-serialTimeoutConnection">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Time after which to consider an auto detection attempt to have failed if no successful connection is detected') }}">
|
||||
<label class="control-label" for="settings-serialTimeoutDetection">{{ _('Autodetection timeout') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutDetection" id="settings-serialTimeoutDetection">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div><small><a href="#" class="muted" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', container: '#settings_serial_timeouts_timeouts .hide' }"><i class="fa fa-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
|
||||
<div class="hide">
|
||||
<div class="control-group" title="{{ _('Maximum consecutive communication timeouts while idle. More than this and the printer will be considered to be gone. Set to 0 to disable.') }}">
|
||||
<label class="control-label" for="settings-serialMaxTimeoutsIdle">{{ _('Max. consecutive timeouts while idle') }}</label>
|
||||
<div class="controls">
|
||||
<input type="number" min="0" class="input-mini text-right" id="settings-serialMaxTimeoutsIdle" data-bind="value: serial_maxTimeoutsIdle">
|
||||
<span class="help-block">{{ _('Set to 0 to disable consecutive timeout detection and handling.') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Maximum consecutive communication timeouts while printing. More than this and the printer will be considered to be gone. Set to 0 to disable.') }}">
|
||||
<label class="control-label" for="settings-serialMaxTimeoutsPrinting">{{ _('Max. consecutive timeouts while printing') }}</label>
|
||||
<div class="controls">
|
||||
<input type="number" min="0" class="input-mini text-right" id="settings-serialMaxTimeoutsPrinting" data-bind="value: serial_maxTimeoutsPrinting">
|
||||
<span class="help-block">{{ _('Set to 0 to disable consecutive timeout detection and handling.') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Maximum consecutive communication timeouts while a long running command is active. More than this and the printer will be considered to be gone. Set to 0 to disable.') }}">
|
||||
<label class="control-label" for="settings-serialMaxTimeoutsLong">{{ _('Max. consecutive timeouts during long running commands') }}</label>
|
||||
<div class="controls">
|
||||
<input type="number" min="0" class="input-mini text-right" id="settings-serialMaxTimeoutsLong" data-bind="value: serial_maxTimeoutsLong">
|
||||
<span class="help-block">{{ _('Set to 0 to disable consecutive timeout detection and handling.') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div id="settings_serial_protocol" class="tab-pane">
|
||||
<fieldset id="settings_serial_protocol_firmware">
|
||||
<legend>{{ _('Firmware specific settings') }}</legend>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_firmwareDetection" id="settings-serialFirmwareDetection"> {{ _('Enable automatic firmware detection') }}
|
||||
<span class="help-block">{% trans %}
|
||||
If enabled, OctoPrint will try to figure out your printer's firmware automatically and adjust some communication parameters based on that.
|
||||
If that doesn't work out, or you want more granular control, uncheck this and the parameters in question will become visible for you to adjust.
|
||||
{% endtrans %}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div data-bind="visible: !serial_firmwareDetection()">
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_sdRelativePath" id="settings-serialSdRelativePath"> {{ _('Select SD files by relative path') }} <span class="label">{{ _('RepRap Firmware') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_sdAlwaysAvailable" id="settings-serialSdAlwaysAvailable"> {{ _('Always assume SD card is present') }} <span class="label">{{ _('Repetier') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_ignoreIdenticalResends" id="settings-serialIgnoreIdenticalResends"> {{ _('Ignore consecutive resend requests for the same line') }} <span class="label">{{ _('Repetier') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_repetierTargetTemp" id="settings-serialRepetierTargetTemp"> {{ _('Support <code>TargetExtr%%n</code>/<code>TargetBed</code> target temperature format') }} <span class="label">{{ _('Repetier') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_disableExternalHeatupDetection" id="settings-serialExternalHeatupDetection"> {{ _('Disable detection of external heatups') }} <span class="label">{{ _('Repetier') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_blockWhileDwelling" id="settings-serialBlockWhileDwelling"> {{ _('Actively pause communication during <code>G4</code> dwell command') }} <span class="label">{{ _('Repetier') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Send a checksum with the command')}}</label>
|
||||
<div class="controls">
|
||||
<label class="radio">
|
||||
<input type="radio" name="sendChecksumGroup" value="print" data-bind="checked: serial_sendChecksum" id="settings-serialSendChecksumPrint"> {{ _('When printing') }}
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input type="radio" name="sendChecksumGroup" value="always" data-bind="checked: serial_sendChecksum" id="settings-serialSendChecksumAlways"> {{ _('Always') }} <span class="label">{{ _('Repetier') }}</span>
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input type="radio" name="sendChecksumGroup" value="never" data-bind="checked: serial_sendChecksum" id="settings-serialSendChecksumNever"> {{ _('Never') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div><small><a href="#" class="muted" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', container: '#settings_serial_protocol_firmware .hide' }"><i class="fa fa-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
|
||||
<div class="hide">
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_capAutoreportTemp" id="settings-serialCapAutoreportTemp"> {{ _('Support temperature autoreporting by firmware, if detected') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_capBusyProtocol" id="settings-serialCapBusyProtocol"> {{ _('Support <code>busy</code> protocol, if detected') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_triggerOkForM29" id="settings-serialTriggerOkForM29"> {{ _('Simulate <code>ok</code> for <code>M29</code>') }}
|
||||
<span class="help-block">{{ _('Most Marlin forks that were derived from Marlin versions < v1.1.0 do not send an acknowledging <code>ok</code> for a <code>M29</code>. Check this if you run into communication stalls following streaming of a file to your printer\'s SD.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_supportResendsWithoutOk" id="settings-serialSupportResendsWithoutOk"> {{ _('Simulate <code>ok</code> for resend requests') }}
|
||||
<span class="help-block">{{ _('Some Marlin forks do not send an acknowledging <code>ok</code> with their resend requests. Check this if you run into communication stalls following resend requests due to that.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset id="settings_serial_protocol_finetuning">
|
||||
<legend>{{ _('Protocol fine tuning') }}</legend>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_waitForStart" id="settings-serialWaitForStart"> {{ _('Wait for <code>start</code> on connect') }}
|
||||
<span class="help-block">{{ _('Try checking this if you run into connection timeouts due to your printer taking too long to respond to OctoPrint\' handshake attempts on connect.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div><small><a href="#" class="muted" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', container: '#settings_serial_protocol_finetuning .hide' }"><i class="fa fa-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
|
||||
<div class="hide">
|
||||
<div class="control-group" title="{{ _('Command to send to the firmware on first handshake attempt.') }}">
|
||||
<label class="control-label" for="settings-serialHelloCommand">{{ _('"Hello" command') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" id="settings-serialHelloCommand" data-bind="value: serial_helloCommand">
|
||||
<span class="help-inline">{{ _('Use this to specify a different command than the default <code>M110</code> to send to the printer on initial connection to trigger a communication handshake.') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Commands that are know to run long and hence should suppress communication timeouts from being triggered.') }}">
|
||||
<label class="control-label" for="settings-serialLongRunningCommands">{{ _('Long running commands') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" id="settings-serialLongRunningCommands" data-bind="value: serial_longRunningCommands">
|
||||
<span class="help-inline">{{ _('Use this to specify the commands known to take a long time to complete without output from your printer and hence might cause timeout issues. Just the G or M code, comma separated.') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Commands that always require a line number and checksum to be sent with them.') }}">
|
||||
<label class="control-label" for="settings-checksumRequiringCommands">{{ _('Commands that always require a checksum') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" id="settings-checksumRequiringCommands" data-bind="value: serial_checksumRequiringCommands">
|
||||
<span class="help-inline">{{ _('Use this to specify which commands <strong>always</strong> need to be sent with a checksum. Comma separated list.') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div id="settings_serial_behaviour" class="tab-pane">
|
||||
<fieldset>
|
||||
<legend>{{ _('Error handling') }}</legend>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_disconnectOnErrors" id="settings-serialDisconnectOnErrors"> {{ _('Not only cancel ongoing prints but also disconnect on unhandled errors from the firmware.') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_ignoreErrorsFromFirmware" id="settings-serialIgnoreErrorsFromFirmware"> {{ _('Ignore any unhandled errors from the firmware. Only use this if your firmware sends stuff prefixed with "Error" that is not an actual error. Might mask printer issues, be careful!') }} <span class="label label-important">{{ _('Warning') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>{{ _('Event based position logging') }}</legend>
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_logPositionOnPause" id="settings-serialLogPositionOnPause"> {{ _('Log position on pause') }} <span class="label label-important">{{ _('Warning') }}</span>
|
||||
<span class="help-block">{{ _('If you disable this, the <code>pause_position</code> placeholders in your pause/resume GCODE scripts will stay unpopulated! However, pausing speed might improve slightly.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_logPositionOnCancel" id="settings-serialLogPositionOnCancel"> {{ _('Log position on cancel') }} <span class="label label-important">{{ _('Warning') }}</span>
|
||||
<span class="help-block">{{ _('If you disable this, the <code>cancel_position</code> placeholders in your cancel GCODE script and the corresponding data in the print recovery data will stay unpopulated! However, cancelling speed might improve slightly.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
@@ -0,0 +1,5 @@
|
||||
<div class="refresh-trigger accordion-heading-button btn-group">
|
||||
<a href="#" data-bind="click: function() { $root.requestData(); }" title="{{ _('Refresh connection options') }}">
|
||||
<i class="fa fa-refresh"></i>
|
||||
</a>
|
||||
</div>
|
||||
@@ -1,5 +1,5 @@
|
||||
<div class="terminal">
|
||||
<pre id="terminal-output" class="pre-scrollable pre-output" data-bind="foreach: displayedLines, visible: fancyFunctionality(), click: function(){ gotoTerminalCommand(); }"><span data-bind="text: line, css: {muted: type == 'filtered' || type == 'cut'}"></span></pre>
|
||||
<pre id="terminal-output" class="pre-scrollable pre-output" data-bind="foreach: displayedLines, visible: fancyFunctionality(), click: function(){ gotoTerminalCommand(); }, event: { scroll: terminalScrollEvent }"><span data-bind="text: line, css: {muted: type == 'filtered' || type == 'cut'}"></span></pre>
|
||||
<pre id="terminal-output-lowfi" style="display: none" class="pre-scrollable" data-bind="text: plainLogOutput, visible: !fancyFunctionality()"></pre>
|
||||
<div id="terminal-sendpanel" style="display: none;" data-bind="visible: loginState.isUser">
|
||||
<div class="input-block-level input-append">
|
||||
|
||||
@@ -86,7 +86,7 @@ def get_finished_timelapses():
|
||||
files = []
|
||||
basedir = settings().getBaseFolder("timelapse")
|
||||
for entry in scandir(basedir):
|
||||
if not fnmatch.fnmatch(entry.name, "*.mp[g4]"):
|
||||
if not fnmatch.fnmatch(entry.name, "*.m*"):
|
||||
continue
|
||||
files.append({
|
||||
"name": entry.name,
|
||||
|
||||
@@ -1167,7 +1167,7 @@ class ResettableTimer(threading.Thread):
|
||||
on_cancelled (callable): Callback to call when the timer finishes due to being cancelled.
|
||||
on_reset (callable): Callback to call when the timer is reset.
|
||||
"""
|
||||
|
||||
|
||||
def __init__(self, interval, function, args=None, kwargs=None, on_reset=None, on_cancelled=None):
|
||||
threading.Thread.__init__(self)
|
||||
self._event = threading.Event()
|
||||
@@ -1501,3 +1501,26 @@ class ConnectivityChecker(object):
|
||||
"online" if new_value else "offline"))
|
||||
if callable(self._on_change):
|
||||
self._on_change(old_value, new_value)
|
||||
|
||||
|
||||
class CaseInsensitiveSet(collections.Set):
|
||||
"""
|
||||
Basic case insensitive set
|
||||
|
||||
Any str or unicode values will be stored and compared in lower case. Other value types are left as-is.
|
||||
"""
|
||||
|
||||
def __init__(self, *args):
|
||||
self.data = set([x.lower() if isinstance(x, (str, unicode)) else x for x in args])
|
||||
|
||||
def __contains__(self, item):
|
||||
if isinstance(item, (str, unicode)):
|
||||
return item.lower() in self.data
|
||||
else:
|
||||
return item in self.data
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self.data)
|
||||
|
||||
def __len__(self):
|
||||
return len(self.data)
|
||||
+392
-158
File diff suppressed because it is too large.
Load diff
@@ -3,7 +3,7 @@ import os
|
||||
import sys
|
||||
|
||||
"""
|
||||
This "python package" doesn't actually install. This is intenional. It is merely
|
||||
This "python package" doesn't actually install. This is intentional. It is merely
|
||||
used to figure out some information about the environment a specific pip call
|
||||
is running under (installation dir, whether it belongs to a virtual environment,
|
||||
whether the install location is writable by the current user), and for that it
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
import unittest
|
||||
import ddt
|
||||
|
||||
import octoprint.settings
|
||||
|
||||
@ddt.ddt
|
||||
class TestHelpers(unittest.TestCase):
|
||||
|
||||
@ddt.data(
|
||||
(True, True),
|
||||
("true", True),
|
||||
("True", True),
|
||||
("tRuE", True),
|
||||
("yes", True),
|
||||
("YES", True),
|
||||
("y", True),
|
||||
("Y", True),
|
||||
("1", True),
|
||||
(1, True),
|
||||
|
||||
(False, False),
|
||||
("Truuuuuuuuue", False),
|
||||
("Nope", False),
|
||||
(None, False)
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_valid_boolean_trues(self, value, expected):
|
||||
self.assertEqual(expected, value in octoprint.settings.valid_boolean_trues)
|
||||
@@ -0,0 +1,25 @@
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import
|
||||
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
|
||||
import unittest
|
||||
import ddt
|
||||
|
||||
import octoprint.util
|
||||
|
||||
@ddt.ddt
|
||||
class TestCaseInsensitiveSet(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.set = octoprint.util.CaseInsensitiveSet("A", "FoO", True, 23)
|
||||
|
||||
@ddt.data("A", "a", "foo", True, 23)
|
||||
def test_contained(self, value):
|
||||
self.assertTrue(value in self.set)
|
||||
|
||||
@ddt.data("b", "fnord", False, 42)
|
||||
def test_not_contained(self, value):
|
||||
self.assertFalse(value in self.set)
|
||||
Reference in new issue
Block a user