From 323d7ecb0d5726e28713f6676037187c9f25b46e Mon Sep 17 00:00:00 2001 From: Ben Sycha Date: Fri, 25 Jun 2021 12:40:55 +0100 Subject: [PATCH 1/5] =?UTF-8?q?=F0=9F=93=9D=20add=20instructions=20for=20s?= =?UTF-8?q?etting=20up=20vscode=20IDE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AUTHORS.md | 1 + docs/development/environment.rst | 98 ++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) diff --git a/AUTHORS.md b/AUTHORS.md index 7aecc1391..34651f849 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -141,6 +141,7 @@ date of first contribution): * [Joe Martella](https://github.com/martellaj) * [Scott Lahteine](https://github.com/thinkyhead) * [Karthikeyan Singaravelan](https://github.com/tirkarthi) + * [Ben Sycha](https://github.com/Sycha) 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 diff --git a/docs/development/environment.rst b/docs/development/environment.rst index 851bb5aec..7da2b4c72 100644 --- a/docs/development/environment.rst +++ b/docs/development/environment.rst @@ -387,3 +387,101 @@ Otherwise go through Settings. Make sure you are running a PyCharm version of 2016.1 or later, or manually fix `a debugger bug contained in earlier versions `_ or plugin management will not work in your developer install when running OctoPrint from PyCharm in debug mode. + +Visual Studio Code (vscode) +--------------------------- + - Install Visual Studio from https://code.visualstudio.com/Download + - Open folder select OctoPrint checkout folder (e.g. ``~/devel/OctoPrint`` or ``C:\Devel\OctoPrint``) + settings.json + + - Create a directory '.vscode' if not already present in the root of the project + + - Create the following files inside the .vscode directory + + settings.json + .. code-block:: json + + { + "python.defaultInterpreterPath": "venv3/bin/python", + "python.formatting.provider": "black", + "python.formatting.blackArgs": [ + "--config", + "black.toml" + ], + "editor.formatOnSave": true, + "python.sortImports.args": [ + "--profile=black", + ], + "[python]": { + "editor.codeActionsOnSave": { + "source.organizeImports": true + } + }, + "python.linting.pylintEnabled": false, + "python.linting.flake8Enabled": true, + "python.linting.enabled": true + } + + tasks.json + .. code-block:: json + + { + "version": "2.0.0", + "tasks": [ + { + "label": "clean build artifacts", + "type": "shell", + "command": "python ./setup.py clean" + }, + { + "label": "build docs", + "type": "shell", + "command": "sphinx-build -b html ./docs ./docs/_build" + } + ] + } + + + launch.json + .. code-block:: json + + { + "version": "0.2.0", + "configurations": [ + { + "name": "Octoprint", + "type": "python", + "request": "launch", + "module": "octoprint", + "args": [ + "serve", + "--debug" + ], + "cwd": "${workspaceFolder}/src", + "preLaunchTask": "clean build artifacts" + } + ] + } + + In the terminal install the python extension by running this command: + .. code-block:: bash + + code --install-extension ms-python.python + + In vscode terminal, or with venv active install code formatter black and linter flake8 by running: + .. code-block:: bash + + python -m pip install -U black flake8 flake8-bugbear + + Summary of vscode config: + + * Pressing f5 will now start OctoPrint in debug + + * Your terminal inside vscode uses the virtrual python environment + + * Saving a file will run an auto formatter and import sort + + * Ctrl + shift + b can be used to run the 'build docs' task to rebuild the documentation + + + From e993405785dc0b6ed09266d27e38860763a7fcad Mon Sep 17 00:00:00 2001 From: Ben Sycha Date: Tue, 20 Jul 2021 16:22:44 +0100 Subject: [PATCH 2/5] Apply suggestions from code review Fix typos and remove irrelevant line Co-authored-by: Charlie Powell <31997505+cp2004@users.noreply.github.com> --- docs/development/environment.rst | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/development/environment.rst b/docs/development/environment.rst index 7da2b4c72..b6e56e1d7 100644 --- a/docs/development/environment.rst +++ b/docs/development/environment.rst @@ -390,9 +390,8 @@ Otherwise go through Settings. Visual Studio Code (vscode) --------------------------- - - Install Visual Studio from https://code.visualstudio.com/Download + - Install Visual Studio Code from https://code.visualstudio.com/Download - Open folder select OctoPrint checkout folder (e.g. ``~/devel/OctoPrint`` or ``C:\Devel\OctoPrint``) - settings.json - Create a directory '.vscode' if not already present in the root of the project @@ -449,7 +448,7 @@ Visual Studio Code (vscode) "version": "0.2.0", "configurations": [ { - "name": "Octoprint", + "name": "OctoPrint", "type": "python", "request": "launch", "module": "octoprint", @@ -477,11 +476,10 @@ Visual Studio Code (vscode) * Pressing f5 will now start OctoPrint in debug - * Your terminal inside vscode uses the virtrual python environment + * Your terminal inside vscode uses the virtual python environment * Saving a file will run an auto formatter and import sort * Ctrl + shift + b can be used to run the 'build docs' task to rebuild the documentation - From 161e21fe0f6344ec3b9b9b541e9b2c472087ba77 Mon Sep 17 00:00:00 2001 From: Ben Sycha Date: Tue, 20 Jul 2021 17:39:01 +0100 Subject: [PATCH 3/5] Apply suggestions from code review to fix RST formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Gina Häußge --- docs/development/environment.rst | 117 ++++++++++++++++--------------- 1 file changed, 60 insertions(+), 57 deletions(-) diff --git a/docs/development/environment.rst b/docs/development/environment.rst index b6e56e1d7..47379244c 100644 --- a/docs/development/environment.rst +++ b/docs/development/environment.rst @@ -390,96 +390,99 @@ Otherwise go through Settings. Visual Studio Code (vscode) --------------------------- - - Install Visual Studio Code from https://code.visualstudio.com/Download + + - Install Visual Studio Code from `code.visualstudio.com `_ - Open folder select OctoPrint checkout folder (e.g. ``~/devel/OctoPrint`` or ``C:\Devel\OctoPrint``) - - Create a directory '.vscode' if not already present in the root of the project + - Create a directory ``.vscode`` if not already present in the root of the project - - Create the following files inside the .vscode directory + - Create the following files inside the ``.vscode`` directory settings.json .. code-block:: json - { - "python.defaultInterpreterPath": "venv3/bin/python", - "python.formatting.provider": "black", - "python.formatting.blackArgs": [ - "--config", - "black.toml" - ], - "editor.formatOnSave": true, - "python.sortImports.args": [ - "--profile=black", - ], - "[python]": { - "editor.codeActionsOnSave": { - "source.organizeImports": true - } - }, - "python.linting.pylintEnabled": false, - "python.linting.flake8Enabled": true, - "python.linting.enabled": true - } + { + "python.defaultInterpreterPath": "venv3/bin/python", + "python.formatting.provider": "black", + "python.formatting.blackArgs": [ + "--config", + "black.toml" + ], + "editor.formatOnSave": true, + "python.sortImports.args": [ + "--profile=black", + ], + "[python]": { + "editor.codeActionsOnSave": { + "source.organizeImports": true + } + }, + "python.linting.pylintEnabled": false, + "python.linting.flake8Enabled": true, + "python.linting.enabled": true + } tasks.json .. code-block:: json - { - "version": "2.0.0", - "tasks": [ - { - "label": "clean build artifacts", - "type": "shell", - "command": "python ./setup.py clean" - }, - { - "label": "build docs", - "type": "shell", - "command": "sphinx-build -b html ./docs ./docs/_build" - } - ] - } + { + "version": "2.0.0", + "tasks": [ + { + "label": "clean build artifacts", + "type": "shell", + "command": "python ./setup.py clean" + }, + { + "label": "build docs", + "type": "shell", + "command": "sphinx-build -b html ./docs ./docs/_build" + } + ] + } launch.json .. code-block:: json - { - "version": "0.2.0", - "configurations": [ - { - "name": "OctoPrint", - "type": "python", - "request": "launch", - "module": "octoprint", - "args": [ - "serve", - "--debug" - ], - "cwd": "${workspaceFolder}/src", - "preLaunchTask": "clean build artifacts" - } - ] - } + { + "version": "0.2.0", + "configurations": [ + { + "name": "OctoPrint", + "type": "python", + "request": "launch", + "module": "octoprint", + "args": [ + "serve", + "--debug" + ], + "cwd": "${workspaceFolder}/src", + "preLaunchTask": "clean build artifacts" + } + ] + } In the terminal install the python extension by running this command: + .. code-block:: bash code --install-extension ms-python.python In vscode terminal, or with venv active install code formatter black and linter flake8 by running: + .. code-block:: bash python -m pip install -U black flake8 flake8-bugbear Summary of vscode config: - * Pressing f5 will now start OctoPrint in debug + * Pressing ``F5`` will now start OctoPrint in debug mode * Your terminal inside vscode uses the virtual python environment * Saving a file will run an auto formatter and import sort - * Ctrl + shift + b can be used to run the 'build docs' task to rebuild the documentation + * ``Ctrl+Shift+B`` can be used to run the ``build docs`` task to rebuild the documentation From 464f0cd83fd6f6d0db054f3b087b77165b025c2c Mon Sep 17 00:00:00 2001 From: Charlie Powell <31997505+cp2004@users.noreply.github.com> Date: Wed, 21 Jul 2021 15:26:37 +0100 Subject: [PATCH 4/5] :pencil2: Additional file information properties documented Closes #2682 --- docs/api/datamodel.rst | 64 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/docs/api/datamodel.rst b/docs/api/datamodel.rst index 703c19c4e..da82c02e7 100644 --- a/docs/api/datamodel.rst +++ b/docs/api/datamodel.rst @@ -365,6 +365,14 @@ Files - 0..1 - :ref:`GCODE analysis information ` - Information from the analysis of the GCODE file, if available. Left out in abridged version. + * - ``prints`` + - 0..1 + - :ref:`Print history information ` + - Information about previous prints of the file. Left out if the file has never been printed. + * - ``statistics`` + - 0..1 + - :ref:`Print statistics information ` + - Statistics about the file, based on the previous print times. Left out if the file has never been printed. .. _sec-api-datamodel-files-fileabridged: @@ -506,6 +514,62 @@ References - The model from which this file was generated (e.g. an STL, currently not used). Never present for folders. +.. _sec-api-datamodel-files-prints: + +Print History +------------- + +.. list-table:: + :widths: 15 5 10 30 + :header-rows: 1 + + * - Name + - Multiplicity + - Type + - Description + * - ``success`` + - 1 + - Number + - Number of successful prints + * - ``failure`` + - 1 + - Number + - Number of failed prints + * - ``last.date`` + - 1 + - Unix Timestamp + - Last date this file was printed + * - ``last.printTime`` + - 1 + - Float + - Last print time in seconds + * - ``last.success`` + - 1 + - Boolean + - Whether the last print was a success or not + +.. _sec-api-datamodel-files-stats: + +Print Statistics +---------------- + +.. list-table:: + :widths: 15 5 10 30 + :header-rows: 1 + + * - Name + - Multiplicity + - Type + - Description + * - ``averagePrintTime`` + - 1 + - Object + - Object that maps printer profile names to the last print time of the file, in seconds + * - ``lastPrintTime`` + - 1 + - Object + - Object that maps printer profile names to the average print time of the file, in seconds + .. _sec-api-datamodel-access: Access control From 19388fc11f6fb62b8840d51ded7498c7b0028e49 Mon Sep 17 00:00:00 2001 From: Charlie Powell <31997505+cp2004@users.noreply.github.com> Date: Wed, 21 Jul 2021 14:51:51 +0100 Subject: [PATCH 5/5] :pencil2: Add link to data model for printer profiles for gcode scripts Closes #3603 --- docs/features/gcode_scripts.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/features/gcode_scripts.rst b/docs/features/gcode_scripts.rst index d836d3fad..a15cc7f79 100644 --- a/docs/features/gcode_scripts.rst +++ b/docs/features/gcode_scripts.rst @@ -70,7 +70,8 @@ Context All GCODE scripts have access to the following template variables through the template context: * ``printer_profile``: The currently selected :ref:`Printer Profile `, including - information such as the extruder count, the build volume size, the filament diameter etc. + information such as the extruder count, the build volume size, the filament diameter etc. The individual properties + follow the common data model for :ref:`printer profiles `. * ``last_position``: Last position reported by the printer via `M114` (might be unset if no `M114` was sent so far!). Consists of ``x``, ``y``, ``z`` and ``e`` coordinates as received by the printer and tracked values for ``f`` and current tool ``t`` taken from commands sent through OctoPrint. All of these coordinates might be ``None`` if no