Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7affce2f64 | ||
|
|
809c452285 | ||
|
|
157408b53a | ||
|
|
d8694107b7 | ||
|
|
30e43f9c41 | ||
|
|
3899626870 | ||
|
|
d504157c6f | ||
|
|
ad68b05f7d | ||
|
|
7eb7acf3af | ||
|
|
d974ab0979 | ||
|
|
89d972ff40 | ||
|
|
4fede5a9c6 | ||
|
|
7971bc91b2 | ||
|
|
2523cf81ba | ||
|
|
8a61e4517f | ||
|
|
f32c977381 | ||
|
|
2de863c5db | ||
|
|
09e5676009 | ||
|
|
5f835edf2e | ||
|
|
83790fcd64 | ||
|
|
6dd2dcee16 | ||
|
|
a91a354fa9 | ||
|
|
4bf3d698e3 | ||
|
|
868dc6d7a9 | ||
|
|
1ddb187518 | ||
|
|
b7badcbf02 | ||
|
|
684d12e60e | ||
|
|
87ddcac2fc | ||
|
|
e3383fe4c1 | ||
|
|
292856e1bd | ||
|
|
6307b765e3 | ||
|
|
a30e41f0b4 | ||
|
|
51341f6722 | ||
|
|
fb15751703 | ||
|
|
a0105bcb2f | ||
|
|
d2910de121 | ||
|
|
c5be9908c5 | ||
|
|
c35b7a66b0 | ||
|
|
9692b709aa | ||
|
|
5acb04c180 | ||
|
|
87234bda05 | ||
|
|
644329c0b8 | ||
|
|
ce67e28f96 | ||
|
|
b4699825d6 | ||
|
|
2d76aa029a | ||
|
|
8864884c67 | ||
|
|
a332b71463 | ||
|
|
62a51bb061 | ||
|
|
01ab61b8b1 | ||
|
|
d49cd209e1 | ||
|
|
d60ab8cd9e | ||
|
|
ce9c9bea6a | ||
|
|
858d87a732 | ||
|
|
ea28900913 |
No files matched your search
+59
-3
@@ -1,6 +1,62 @@
|
||||
# OctoPrint Changelog
|
||||
|
||||
## 1.1.0
|
||||
## 1.1.2 (2015-03-23)
|
||||
|
||||
### Improvements
|
||||
|
||||
* Added deletion of `*.pyc` files to `python setup.py clean` command, should help tremendously when switching branches (backported
|
||||
from [9e014eb](https://github.com/foosel/OctoPrint/commit/9e014eba1feffde11ed0601d9c911b8cac9f3fb0))
|
||||
* Increased default communication and connection timeouts
|
||||
* [#706](https://github.com/foosel/OctoPrint/issues/706) - Do not truncate error reported from printer
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* [#539](https://github.com/foosel/OctoPrint/issues/539) - Limit maximum number of tools, sanity check tool numbers in
|
||||
GCODE files against upper limit and refuse to create 10000 tools due to weird slicers. (backported from `devel`)
|
||||
* [#634](https://github.com/foosel/OctoPrint/pull/634) - Fixed missing `branch` fields in version dicts generated
|
||||
by versioneer
|
||||
* [#679](https://github.com/foosel/OctoPrint/issues/679) - Fix error where API state is requested and printer is offline
|
||||
(backport of [619fe9a](https://github.com/foosel/OctoPrint/commit/619fe9a0e78826bd1524b235a910156439bcb6d7)).
|
||||
* [#719](https://github.com/foosel/OctoPrint/issues/719) - Properly center print bed in GCODE viewer
|
||||
* [#780](https://github.com/foosel/OctoPrint/issues/780) - Always (re)set file position in SD files to 0 so that reprints
|
||||
work correctly (backported from ``devel``)
|
||||
* [#801](https://github.com/foosel/OctoPrint/issues/801) - Fixed setting of bed temperature offset
|
||||
* [IRC] - Don't hiccup on slic3r ``filament_diameter`` comments generated for multi extruder setups
|
||||
* [ML] - Fixed relative URL to SockJS endpoint, wasn't yet using the proper base url
|
||||
* [unreported] & [#698](https://github.com/foosel/OctoPrint/issues/698) - Generated URLs now take X-Forwarded-Host header
|
||||
sent by proxies into account for included host and port, also fixed [#698](https://github.com/foosel/OctoPrint/issues/698)
|
||||
introduced by this
|
||||
* [unreported] Fixed a bug causing gcodeInterpreter to hiccup on GCODES containing invalid coordinates such as Xnan or
|
||||
Yinf (backported from `devel`)
|
||||
* Small fixes for timelapse creation:
|
||||
- [#344](https://github.com/foosel/OctoPrint/issues/344) - Made timelapses capable of coping with missing captures in between by decrementing the image counter again if there
|
||||
was an error fetching the latest image from the snapshot URL (backport of [1a7a468](https://github.com/foosel/OctoPrint/commit/1a7a468eb65fdf2a13b4c7a7723280e822c9c34b)
|
||||
and [bf9d5ef](https://github.com/foosel/OctoPrint/commit/bf9d5efe43a1e57aacd8512125082ddca06b4efc))
|
||||
- [#693](https://github.com/foosel/OctoPrint/issues/693) - Try not to capture an image if image counter is still unset
|
||||
- [unreported] Synchronize image counter decrementing as well as incrementing to prevent rare race conditions when generating the
|
||||
image file names
|
||||
|
||||
([Commits](https://github.com/foosel/OctoPrint/compare/1.1.1...1.1.2))
|
||||
|
||||
## 1.1.1 (2014-10-27)
|
||||
|
||||
### Improvements
|
||||
|
||||
* The API is now enabled by default and the API key -- if not yet set -- will be automatically generated on first
|
||||
server start and written back into ``config.yaml``
|
||||
* Event subscriptions are now enabled by default (it was an accident that they weren't)
|
||||
* Generate the key used for session hashing individually for each server instance
|
||||
* Generate the salt used for hashing user passwords individually for each server instance
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* [#580](https://github.com/foosel/OctoPrint/issues/580) - Properly unset job data when instructed so by callers
|
||||
* [#604](https://github.com/foosel/OctoPrint/issues/604) - Properly initialize settings basedir on server startup
|
||||
* [IRC] Also allow downloading .g files via Tornado
|
||||
|
||||
([Commits](https://github.com/foosel/OctoPrint/compare/1.1.0...1.1.1))
|
||||
|
||||
## 1.1.0 (2014-09-03)
|
||||
|
||||
### New Features
|
||||
|
||||
@@ -70,6 +126,6 @@
|
||||
|
||||
([Commits](https://github.com/foosel/OctoPrint/compare/1.0.0...1.1.0))
|
||||
|
||||
## 1.0.0
|
||||
## 1.0.0 (2014-06-22)
|
||||
|
||||
First release with new versioning scheme.
|
||||
First release with new versioning scheme.
|
||||
+40
-8
@@ -1,17 +1,49 @@
|
||||
Issues, Tickets, however you may call them
|
||||
------------------------------------------
|
||||
|
||||
- If you want to report a bug, **READ [How to file a bug report](https://github.com/foosel/OctoPrint/wiki/How-to-file-a-bug-report)!** Tickets will be automatically checked if they comply with the requirements outlined in that wiki node! Other then what's written in there you don't have to do anything special with your ticket.
|
||||
Read the following short instructions **fully** and **follow them** if you want your ticket to be taken care of and not closed again directly! They are linked on top of every new issue form, so don't say nobody warned you afterwards.
|
||||
|
||||
- **Read the [FAQ](https://github.com/foosel/OctoPrint/wiki/FAQ)**
|
||||
- Always create **one ticket for one purpose**. So don't mix two or more feature requests, support requests, bugs etc into one ticket. If you do, your ticket will be closed!
|
||||
- If you want to report a bug, **READ AND FOLLOW [How to file a bug report](https://github.com/foosel/OctoPrint/wiki/How-to-file-a-bug-report)!** Tickets will be automatically checked if they comply with the requirements outlined in that wiki node! Other then what's written in there (**and really EVERYTHING that is written in there!**) you don't have to do anything special with your ticket. Listen to what GitIssueBot might have to say to you!
|
||||
- If you want to post a **request** of any kind (feature request, documentation request, ...), **add [Request] to your issue's title!**
|
||||
- If you need **support** with a problem of your installation (e.g. if you have problems getting the webcam to work), **add [Support] to your issue's title!**
|
||||
- If you have a general **question**, **add [Question] to your issue's title!**
|
||||
- If you have another reason for creating a ticket that doesn't fit any of the above categories, **add [Misc] to your issue's title!**
|
||||
- If you need **support** with a problem of your installation (e.g. if you have problems getting the webcam to work) or have a general **question**, the issue tracker is not the right place. Consult the [Mailinglist](https://groups.google.com/group/octoprint) or the [Google+ Community](https://plus.google.com/communities/102771308349328485741) instead!
|
||||
- If you are a developer that wants to brainstorm a pull request or possible changes to the plugin system, **add [Brainstorming] to your issue's title!** (see below).
|
||||
- If you have another reason for creating a ticket that doesn't fit any of the above categories, it's something better suited for the [Mailinglist](https://groups.google.com/group/octoprint) or the [Google+ Community](https://plus.google.com/communities/102771308349328485741).
|
||||
|
||||
Following these guidelines (**especially EVERYTHING mentioned in ["How to file a bug report"](https://github.com/foosel/OctoPrint/wiki/How-to-file-a-bug-report)**) is necessary so the tickets stay manageable - you are not the only one with an open issue, so please respect that you have to **play by the rules** so that your problem can be taken care of. Tickets not playing by the rules **will be closed without further investigation!**.
|
||||
|
||||
Pull Requests
|
||||
-------------
|
||||
|
||||
1. Please create all pull requests against the `devel` branch.
|
||||
2. Create **one pull request per feature/bug fix**.
|
||||
3. Create a custom branch for your feature/bug fix and use that as base for your pull request. Pull requests directly against your version of `devel` will be closed.
|
||||
4. In your pull request's description, state what your pull request is doing, as in, what feature does it implement, what bug does it fix.
|
||||
1. If you want to add a new feature to OctoPrint, **please always first consider if it wouldn't be better suited for a
|
||||
plugin.** As a general rule of thumb, any feature that is only of interest to a small sub group should be moved into a
|
||||
plugin. If the current plugin system doesn't allow you to implement your feature as a plugin, create a "Brainstorming"
|
||||
ticket to get the discussion going how best to solve *this* in OctoPrint's plugin system - maybe that's the actual PR
|
||||
you have been waiting for to contribute :)
|
||||
2. If you plan to make **any large changes to the code or appearance, please open a "Brainstorming" ticket first** so that
|
||||
we can determine if it's a good time for your specific pull request. It might be that I'm currently in the process of
|
||||
making heavy changes to the code locations you'd target as well, or your approach doesn't fit the general "project
|
||||
vision", and that would just cause unnecessary work and frustration for everyone or possibly get the PR rejected.
|
||||
3. When adding code to OctoPrint, make sure you **follow the current coding style**. That means tabs instead of spaces in the
|
||||
python files (yes, I know that this goes against PEP-8, I don't care) and space instead of tabs in the Javascript sources,
|
||||
english language (that means code, variables, comments!), comments where necessary (tell why the code does something like
|
||||
it does it, structure your code), following the general architecture. If your PR needs to make changes to the Stylesheets,
|
||||
change the ``.less`` files from which the CSS is compiled. PRs that contain direct changes to the compiled
|
||||
CSS will be closed.
|
||||
4. **Test your changes thoroughly**. That also means testing with usage scenarios you don't normally use, e.g. if you only
|
||||
use access control, test without and vice versa. If you only test with your printer, test with the virtual printer and
|
||||
vice versa. State in your pull request how your tested your changes.
|
||||
5. Please create all pull requests **against the `devel` branch**.
|
||||
6. Create **one pull request per feature/bug fix**.
|
||||
7. Create a **custom branch** for your feature/bug fix and use that as base for your pull request. Pull requests directly
|
||||
against your version of `devel` will be closed.
|
||||
7. In your pull request's description, **state what your pull request is doing**, as in, what feature does it implement, what
|
||||
bug does it fix. The more thoroughly you explain your intent behind the PR here, the higher the chances it will get merged
|
||||
fast.
|
||||
|
||||
History
|
||||
-------
|
||||
|
||||
* 2015-01-23: More guidelines for creating pull requests, support/questions redirected to Mailinglist/G+ community
|
||||
* 2015-01-27: Added another explicit link to the FAQ
|
||||
@@ -29,43 +29,45 @@ OctoPrint via `setup.py`:
|
||||
|
||||
python setup.py install
|
||||
|
||||
You should also do this after pulling from the repository, since the dependencies might have changed.
|
||||
You should also do this every time after pulling from the repository, since the dependencies might have changed.
|
||||
|
||||
OctoPrint currently only supports Python 2.7.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
From the source directory you can start the server via
|
||||
Running the `setup.py` script installs the `octoprint` script in your Python installation's scripts folder
|
||||
(which depending on whether you installed OctoPrint globally or into a virtual env will be on your `PATH` or not). The
|
||||
following usage examples assume that said `octoprint` script is on your `PATH`.
|
||||
|
||||
./run
|
||||
You can start the server via
|
||||
|
||||
octoprint
|
||||
|
||||
By default it binds to all interfaces on port 5000 (so pointing your browser to `http://127.0.0.1:5000`
|
||||
will do the trick). If you want to change that, use the additional command line parameters `host` and `port`,
|
||||
which accept the host ip to bind to and the numeric port number respectively. If for example you want the server
|
||||
to only listen on the local interface on port 8080, the command line would be
|
||||
|
||||
./run --host=127.0.0.1 --port=8080
|
||||
octoprint --host=127.0.0.1 --port=8080
|
||||
|
||||
Alternatively, the host and port on which to bind can be defined via the configuration.
|
||||
|
||||
If you want to run OctoPrint as a daemon (only supported on Linux), use
|
||||
|
||||
./run --daemon {start|stop|restart} [--pid PIDFILE]
|
||||
octoprint --daemon {start|stop|restart} [--pid PIDFILE]
|
||||
|
||||
If you do not supply a custom pidfile location via `--pid PIDFILE`, it will be created at `/tmp/octoprint.pid`.
|
||||
|
||||
You can also specify the configfile or the base directory (for basing off the `uploads`, `timelapse` and `logs` folders),
|
||||
e.g.:
|
||||
|
||||
./run --config /path/to/another/config.yaml --basedir /path/to/my/basedir
|
||||
octoprint --config /path/to/another/config.yaml --basedir /path/to/my/basedir
|
||||
|
||||
See `run --help` for further information.
|
||||
|
||||
Running the `setup.py` script also installs the `octoprint` startup script in your Python installation's scripts folder
|
||||
(which depending on whether you installed OctoPrint globally or into a virtual env will be on your `PATH` or not). The
|
||||
examples above also work with that startup script as it excepts the same parameters as `run`.
|
||||
See `octoprint --help` for further information.
|
||||
|
||||
OctoPrint also ships with a `run` script in its source directory. You can also invoke that to start up the server, it
|
||||
takes the same command line arguments as the `octoprint` script.
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
@@ -75,4 +77,5 @@ which is located at `~/.octoprint` on Linux, at `%APPDATA%/OctoPrint` on Windows
|
||||
at `~/Library/Application Support/OctoPrint` on MacOS.
|
||||
|
||||
A comprehensive overview of all available configuration settings can be found
|
||||
[on the wiki](https://github.com/foosel/OctoPrint/wiki/Configuration).
|
||||
[on the wiki](https://github.com/foosel/OctoPrint/wiki/Configuration). Please note that the most commonly used
|
||||
configuration settings can also easily be edited from OctoPrint's settings dialog.
|
||||
@@ -0,0 +1,351 @@
|
||||
.. _sec-api-datamodel:
|
||||
|
||||
*****************
|
||||
Common data model
|
||||
*****************
|
||||
|
||||
.. contents::
|
||||
|
||||
.. _sec-api-datamodel-printer:
|
||||
|
||||
Printer related
|
||||
===============
|
||||
|
||||
.. _sec-api-datamodel-printer-state:
|
||||
|
||||
Printer State
|
||||
-------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``text``
|
||||
- 1
|
||||
- String
|
||||
- A textual representation of the current state of the printer, e.g. "Operational" or "Printing"
|
||||
* - ``flags``
|
||||
- 1
|
||||
- Printer state flags
|
||||
- A couple of boolean printer state flags
|
||||
* - ``flags.operational``
|
||||
- 1
|
||||
- Boolean
|
||||
- ``true`` if the printer is operational, ``false`` otherwise
|
||||
* - ``flags.paused``
|
||||
- 1
|
||||
- Boolean
|
||||
- ``true`` if the printer is currently paused, ``false`` otherwise
|
||||
* - ``flags.printing``
|
||||
- 1
|
||||
- Boolean
|
||||
- ``true`` if the printer is currently printing, ``false`` otherwise
|
||||
* - ``flags.sdReady``
|
||||
- 1
|
||||
- Boolean
|
||||
- ``true`` if the printer's SD card is available and initialized, ``false`` otherwise. This is redundant information
|
||||
to :ref:`the SD State <sec-api-printer-datamodel-sdstate>`.
|
||||
* - ``flags.error``
|
||||
- 1
|
||||
- Boolean
|
||||
- ``true`` if an unrecoverable error occurred, ``false`` otherwise
|
||||
* - ``flags.ready``
|
||||
- 1
|
||||
- Boolean
|
||||
- ``true`` if the printer is operational and no data is currently being streamed to SD, so ready to receive instructions
|
||||
* - ``flags.closedOrError``
|
||||
- 1
|
||||
- Boolean
|
||||
- ``true`` if the printer is disconnected (possibly due to an error), ``false`` otherwise
|
||||
|
||||
.. _sec-api-datamodel-printer-tempdata:
|
||||
|
||||
Temperature Data
|
||||
----------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``actual``
|
||||
- 1
|
||||
- Number
|
||||
- Current temperature
|
||||
* - ``target``
|
||||
- 1
|
||||
- Number
|
||||
- Target temperature, may be ``null`` if no target temperature is set.
|
||||
* - ``offset``
|
||||
- 0..1
|
||||
- Number
|
||||
- Currently configured temperature offset to apply, will be left out for historic temperature information.
|
||||
|
||||
.. _sec-api-datamodel-printer-temphistory:
|
||||
|
||||
Historic Temperature Data Point
|
||||
-------------------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``time``
|
||||
- 1
|
||||
- Unix Timestamp
|
||||
- Timestamp of this data point
|
||||
* - ``tool{n}``
|
||||
- 0..*
|
||||
- :ref:`Temperature Data <sec-api-datamodel-printer-tempdata>`
|
||||
- Temperature stats for tool *n*. Enumeration starts at 0 for the first tool. Not included if querying only
|
||||
bed state.
|
||||
* - ``bed``
|
||||
- 0..*
|
||||
- :ref:`Temperature Data <sec-api-datamodel-printer-tempdata>`
|
||||
- Temperature stats for the printer's heated bed. Not included if querying only tool state.
|
||||
|
||||
.. _sec-api-datamodel-printer-tempoffset:
|
||||
|
||||
Temperature offset
|
||||
------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``tool{n}``
|
||||
- 0..1
|
||||
- Number
|
||||
- Temperature offset for tool *n*. Enumeration starts at 0 for the first tool.
|
||||
* - ``bed``
|
||||
- 0..1
|
||||
- Number
|
||||
- Temperature offset for the printer's heated bed.
|
||||
|
||||
|
||||
.. _sec-api-datamodel-jobs:
|
||||
|
||||
Job related
|
||||
===========
|
||||
|
||||
.. _sec-api-datamodel-jobs-job:
|
||||
|
||||
Job information
|
||||
---------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``file``
|
||||
- 1
|
||||
- :ref:`File information (abridged) <sec-api-datamodel-files-file>`
|
||||
- The file that is the target of the current print job
|
||||
* - ``estimatedPrintTime``
|
||||
- 0..1
|
||||
- Integer
|
||||
- The estimated print time for the file, in seconds.
|
||||
* - ``lastPrintTime``
|
||||
- 0..1
|
||||
- Integer
|
||||
- The print time of the last print of the file, in seconds.
|
||||
* - ``filament``
|
||||
- 0..1
|
||||
- Object
|
||||
- Information regarding the estimated filament usage of the print job
|
||||
* - ``filament.length``
|
||||
- 0..1
|
||||
- Integer
|
||||
- Length of filament used, in mm
|
||||
* - ``filament.volume``
|
||||
- 0..1
|
||||
- Float
|
||||
- Volume of filament used, in cm³
|
||||
|
||||
.. _sec-api-datamodel-jobs-progress:
|
||||
|
||||
Progress information
|
||||
--------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``completion``
|
||||
- 1
|
||||
- Float
|
||||
- Percentage of completion of the current print job
|
||||
* - ``filepos``
|
||||
- 1
|
||||
- Integer
|
||||
- Current position in the file being printed, in bytes from the beginning
|
||||
* - ``printTime``
|
||||
- 1
|
||||
- Integer
|
||||
- Time already spent printing, in seconds
|
||||
* - ``printTimeLeft``
|
||||
- 1
|
||||
- Integer
|
||||
- Estimate of time left to print, in seconds
|
||||
|
||||
.. _sec-api-datamodel-files:
|
||||
|
||||
File related
|
||||
============
|
||||
|
||||
.. _sec-api-datamodel-files-file:
|
||||
|
||||
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``
|
||||
- 0..1
|
||||
- Number
|
||||
- The size of the file in bytes. Only available for ``local`` files.
|
||||
* - ``date``
|
||||
- 0..1
|
||||
- Unix timestamp
|
||||
- The timestamp when this file was uploaded. Only available for ``local`` files.
|
||||
* - ``origin``
|
||||
- 1
|
||||
- String, either ``local`` or ``sdcard``
|
||||
- The origin of the file, ``local`` when stored in OctoPrint's ``uploads`` folder, ``sdcard`` when stored on the
|
||||
printer's SD card (if available)
|
||||
* - ``refs``
|
||||
- 0..1
|
||||
- :ref:`sec-api-datamodel-files-ref`
|
||||
- References relevant to this file, left out in abridged version
|
||||
* - ``gcodeAnalysis``
|
||||
- 0..1
|
||||
- :ref:`GCODE analysis information <sec-api-datamodel-files-gcodeanalysis>`
|
||||
- Information from the analysis of the GCODE file, if available. Left out in abridged version.
|
||||
* - ``prints``
|
||||
- 0..1
|
||||
- :ref:`Print history <sec-api-datamodel-files-prints>`
|
||||
- Information regarding prints of this file, if available. Left out in abridged version.
|
||||
|
||||
.. _sec-api-datamodel-files-gcodeanalysis:
|
||||
|
||||
GCODE analysis information
|
||||
--------------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``estimatedPrintTime``
|
||||
- 0..1
|
||||
- Integer
|
||||
- The estimated print time of the file, in seconds
|
||||
* - ``filament``
|
||||
- 0..1
|
||||
- Object
|
||||
- The estimated usage of filament
|
||||
* - ``filament.length``
|
||||
- 0..1
|
||||
- Integer
|
||||
- The length of filament used, in mm
|
||||
* - ``filament.volume``
|
||||
- 0..1
|
||||
- Float
|
||||
- The volume of filament used, in cm³
|
||||
|
||||
|
||||
.. _sec-api-datamodel-files-prints:
|
||||
|
||||
Print history
|
||||
-------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``failure``
|
||||
- 1
|
||||
- Number
|
||||
- The number of failed prints on record for the file
|
||||
* - ``success``
|
||||
- 1
|
||||
- Number
|
||||
- The number of successful prints on record for the file
|
||||
* - ``last``
|
||||
- 0..1
|
||||
- Object
|
||||
- Information regarding the last print on record for the file
|
||||
* - ``last.date``
|
||||
- 1
|
||||
- Unix timestamp
|
||||
- Timestamp when this file was printed last
|
||||
* - ``last.success``
|
||||
- 1
|
||||
- Boolean
|
||||
- Whether the last print on record was a success (``true``) or not (``false``)
|
||||
|
||||
.. _sec-api-datamodel-files-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 issuing commands to or for deleting)
|
||||
* - ``download``
|
||||
- 0..1
|
||||
- URL
|
||||
- The download URL for the file
|
||||
* - ``model``
|
||||
- 0..1
|
||||
- URL
|
||||
- The model from which this file was generated (e.g. an STL, currently not used)
|
||||
@@ -14,3 +14,4 @@ API Documentation
|
||||
printer.rst
|
||||
job.rst
|
||||
logs.rst
|
||||
datamodel.rst
|
||||
+626
-85
@@ -16,15 +16,167 @@ Printer control is mostly achieved through the use of commands, issued to resour
|
||||
printer. OctoPrint currently knows the following components:
|
||||
|
||||
Print head
|
||||
Print head commands allow jogging and homing the print head in all three axes. See :ref:`sec-api-printer-printheadcommand`.
|
||||
Heater
|
||||
Heater commands allow setting the temperature and temperature offsets for the printer's hotend and bed. Currently
|
||||
OctoPrint only supports one hotend heater (this will change in the future). See :ref:`sec-api-printer-heatercommand`.
|
||||
Feeder
|
||||
Feeder commands allow extrusion/extraction of filament. Currently OctoPrint only supports one feeder (this will
|
||||
change in a future version). See :ref:`sec-api-printer-feedercommand`.
|
||||
Print head commands allow jogging and homing the print head in all three axes. Querying the resource is currently
|
||||
not supported.
|
||||
See :ref:`sec-api-printer-printheadcommand`.
|
||||
Tool
|
||||
Tool commands allow setting the temperature and temperature offsets for the printer's hotends/tools. Querying the
|
||||
corresponding resource returns temperature information including an optional history.
|
||||
See :ref:`sec-api-printer-toolcommand`.
|
||||
Bed
|
||||
Bed commands allow setting the temperature and temperature offset for the printer's heated bed. Querying the
|
||||
corresponding resource returns temperature information including an optional history.
|
||||
See :ref:`sec-api-printer-bedcommand`.
|
||||
SD card
|
||||
SD commands allow initialization, refresh and release of the printer's SD card (if available). See :ref:`sec-api-printer-sdcommand`.
|
||||
SD commands allow initialization, refresh and release of the printer's SD card (if available). Querying the
|
||||
corresponding resource returns the current SD card state.
|
||||
See :ref:`sec-api-printer-sdcommand`.
|
||||
|
||||
Besides that, OctoPrint also provides a :ref:`full state report of the printer <sec-api-printer-state>`.
|
||||
|
||||
.. _sec-api-printer-state:
|
||||
|
||||
Retrieve the current printer state
|
||||
==================================
|
||||
|
||||
.. http:get:: /api/printer
|
||||
|
||||
Retrieves the current state of the printer. Returned information includes:
|
||||
|
||||
* temperature information (see also :ref:`Retrieve the current tool state <sec-api-printer-toolstate>` and
|
||||
:ref:`Retrieve the current bed state <sec-api-printer-bedstate>`)
|
||||
* sd state (if available, see also :ref:`Retrieve the current SD state <sec-api-printer-sdstate>`)
|
||||
* general printer state
|
||||
|
||||
Temperature information can also be made to include the printer's temperature history by supplying the ``history``
|
||||
query parameter. The amount of data points to return here can be limited using the ``limit`` query parameter.
|
||||
|
||||
Clients can specific a list of attributes to not return in the response (e.g. if they don't need it) via the
|
||||
``exclude`` query parameter.
|
||||
|
||||
Returns a :http:statuscode:`200` with a :ref:`Full State Response <sec-api-printer-datamodel-fullstate>` in the
|
||||
body upon success.
|
||||
|
||||
**Example 1**
|
||||
|
||||
Include temperature history data, but limit it to two entries.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/printer?history=true&limit=2 HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"temperature": {
|
||||
"tool0": {
|
||||
"actual": 214.8821,
|
||||
"target": 220.0,
|
||||
"offset": 0
|
||||
},
|
||||
"tool1": {
|
||||
"actual": 25.3,
|
||||
"target": null,
|
||||
"offset": 0
|
||||
},
|
||||
"bed": {
|
||||
"actual": 50.221,
|
||||
"target": 70.0,
|
||||
"offset": 5
|
||||
},
|
||||
"history": [
|
||||
{
|
||||
"time": 1395651928,
|
||||
"tool0": {
|
||||
"actual": 214.8821,
|
||||
"target": 220.0
|
||||
},
|
||||
"tool1": {
|
||||
"actual": 25.3,
|
||||
"target": null
|
||||
},
|
||||
"bed": {
|
||||
"actual": 50.221,
|
||||
"target": 70.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"time": 1395651926,
|
||||
"tool0": {
|
||||
"actual": 212.32,
|
||||
"target": 220.0
|
||||
},
|
||||
"tool1": {
|
||||
"actual": 25.1,
|
||||
"target": null
|
||||
},
|
||||
"bed": {
|
||||
"actual": 49.1123,
|
||||
"target": 70.0
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"sd": {
|
||||
"ready": true
|
||||
},
|
||||
"state": {
|
||||
"text": "Operational",
|
||||
"flags": {
|
||||
"operational": true,
|
||||
"paused": false,
|
||||
"printing": false,
|
||||
"sdReady": true,
|
||||
"error": false,
|
||||
"ready": true,
|
||||
"closedOrError": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
**Example 2**
|
||||
|
||||
Exclude temperature and sd data.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/printer?exclude=temperature,sd HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"state": {
|
||||
"text": "Operational",
|
||||
"flags": {
|
||||
"operational": true,
|
||||
"paused": false,
|
||||
"printing": false,
|
||||
"sdReady": true,
|
||||
"error": false,
|
||||
"ready": true,
|
||||
"closedOrError": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:query exclude: An optional comma-separated list of fields to exclude from the response (e.g. if not needed by
|
||||
the client). Valid values to supply here are ``temperature``, ``sd`` and ``state``.
|
||||
:query history: If set to ``true`` (or: ``yes``, ``y``, ``1``), history information will be included in the response
|
||||
too. If no ``limit`` parameter is given, all available temperature history data will be returned.
|
||||
:query limit: If set to an integer (``n``), only the last ``n`` data points from the printer's temperature history
|
||||
will be returned. Will be ignored if ``history`` is not enabled.
|
||||
:statuscode 200: No error
|
||||
:statuscode 409: If the printer is not operational.
|
||||
|
||||
.. _sec-api-printer-printheadcommand:
|
||||
|
||||
@@ -70,6 +222,10 @@ Issue a print head command
|
||||
"z": 0.02
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example Home Request**
|
||||
|
||||
Home the X and Y axes.
|
||||
@@ -86,6 +242,10 @@ Issue a print head command
|
||||
"axes": ["x", "y"]
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
:json string command: The command to issue, either ``jog`` or ``home``.
|
||||
:json number x: ``jog`` command: The amount to travel on the X axis in mm.
|
||||
:json number y: ``jog`` command: The amount to travel on the Y axis in mm.
|
||||
@@ -96,67 +256,70 @@ Issue a print head command
|
||||
request.
|
||||
:statuscode 409: If the printer is not operational or currently printing.
|
||||
|
||||
.. _sec-api-printer-heatercommand:
|
||||
.. _sec-api-printer-toolcommand:
|
||||
|
||||
Issue a heater command
|
||||
======================
|
||||
Issue a tool command
|
||||
====================
|
||||
|
||||
.. todo::
|
||||
.. http:post:: /api/printer/tool
|
||||
|
||||
Update to current implementation!
|
||||
Tool commands allow setting the temperature and temperature offsets for the printer's tools (hotends), selecting
|
||||
the current tool and extruding/retracting from the currently selected tool. Available commands are:
|
||||
|
||||
.. http:post:: /api/printer/heater
|
||||
target
|
||||
Sets the given target temperature on the printer's tools. Additional parameters:
|
||||
|
||||
Heater commands allow setting the temperature and temperature offsets for the printer's hotend and bed. Available
|
||||
commands are:
|
||||
|
||||
temp
|
||||
Sets the given target temperature on the printer's hotend and/or bed. Additional parameters:
|
||||
|
||||
* ``targets``: Target temperature(s) to set, allowed properties are:
|
||||
|
||||
* ``hotend``: New target temperature of the printer's hotend in centigrade.
|
||||
* ``bed``: New target temperature of the printer's bed in centigrade.
|
||||
* ``targets``: Target temperature(s) to set, properties must match the format ``tool{n}`` with ``n`` being the
|
||||
tool's index starting with 0.
|
||||
|
||||
offset
|
||||
Sets the given temperature offset on the printer's hotend and/or bed. Additional parameters:
|
||||
Sets the given temperature offset on the printer's tools. Additional parameters:
|
||||
|
||||
* ``offsets``: Offset(s) to set, allowed properties are:
|
||||
* ``offsets``: Offset(s) to set, properties must match the format ``tool{n}`` with ``n`` being the tool's index
|
||||
starting with 0.
|
||||
|
||||
* ``hotend``: New offset of the printer's hotend temperature in centigrade, max/min of +/-50°C.
|
||||
* ``bed``: New offset of the printer's bed temperature in centigrade, max/min of +/-50°C.
|
||||
select
|
||||
Selects the printer's current tool. Additional parameters:
|
||||
|
||||
All of these commands may only be sent if the printer is currently operational and not printing. Otherwise a
|
||||
:http:statuscode:`409` is returned.
|
||||
* ``tool``: Tool to select, format ``tool{n}`` with ``n`` being the tool's index starting with 0.
|
||||
|
||||
extrude
|
||||
Extrudes the given amount of filament from the currently selected tool. Additional parameters:
|
||||
|
||||
* ``amount``: The amount of filament to extrude in mm. May be negative to retract.
|
||||
|
||||
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
|
||||
|
||||
**Example Target Temperature Request**
|
||||
|
||||
Set the printer's hotend target temperature to 220°C and the bed target temperature to 75°C.
|
||||
Set the target temperature for the printer's first hotend to 220°C and the printer's second extruder to 205°C.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/heater HTTP/1.1
|
||||
POST /api/printer/tool HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "temp",
|
||||
"temps": {
|
||||
"hotend": 220,
|
||||
"bed": 75
|
||||
"command": "target",
|
||||
"targets": {
|
||||
"tool0": 220,
|
||||
"tool1": 205
|
||||
}
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example Offset Temperature Request**
|
||||
|
||||
Set the offset for hotend temperatures to +10°C and for bed temperatures to -5°C.
|
||||
Set the offset for temperatures on ``tool0`` to +10°C and on ``tool1`` to -5°C.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/heater HTTP/1.1
|
||||
POST /api/printer/tool HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
@@ -164,62 +327,62 @@ Issue a heater command
|
||||
{
|
||||
"command": "offset",
|
||||
"offsets": {
|
||||
"hotend": 10,
|
||||
"bed": -5
|
||||
"tool0": 10,
|
||||
"tool1": -5
|
||||
}
|
||||
}
|
||||
|
||||
:json string command: The command to issue, either ``temp`` or ``offset``
|
||||
:json object temps: ``temp`` command: The target temperatures to set. Valid properties are ``hotend`` and ``bed``
|
||||
:json object offsets: ``offset`` command: The offset temperature to set. Valid properties are ``hotend`` and ``bed``
|
||||
:statuscode 204: No error
|
||||
:statuscode 400: If ``temps`` or ``offsets`` contains a property other than ``hotend`` or ``bed``, the
|
||||
target or offset temperature is not a valid number or outside of the supported range, or if the
|
||||
request is otherwise invalid.
|
||||
:statuscode 409: If the printer is not operational.
|
||||
.. sourcecode:: http
|
||||
|
||||
.. _sec-api-printer-feedercommand:
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
Issue a feeder command
|
||||
======================
|
||||
**Example Tool Select Request**
|
||||
|
||||
.. http:post:: /api/printer/feeder
|
||||
|
||||
Feeder commands allow extrusion/extraction of filament. Available commands are:
|
||||
|
||||
extrude
|
||||
Extrudes the given amount of filament. Additional parameters:
|
||||
|
||||
* ``amount``: The amount of filament to extrude in mm. May be negative to retract.
|
||||
|
||||
All of these commands may only be sent if the printer is currently operational and not printing. Otherwise a
|
||||
:http:statuscode:`409` is returned.
|
||||
|
||||
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
|
||||
|
||||
**Example Extrude Request**
|
||||
|
||||
Extrudes 1mm of filament
|
||||
Select the second hotend of the printer for any following ``extrude`` commands.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/feeder HTTP/1.1
|
||||
POST /api/printer/tool HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "select",
|
||||
"tool": "tool1"
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example Extrude Request**
|
||||
|
||||
Extrude 5mm on the currently selected tool.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/tool HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "extrude",
|
||||
"amount": 1
|
||||
"amount": 5
|
||||
}
|
||||
|
||||
**Example Retract Request**
|
||||
|
||||
Retracts 3mm of filament
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/feeder HTTP/1.1
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example Retract Request**
|
||||
|
||||
Retract 3mm of filament on the currently selected tool.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/tool HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
@@ -229,16 +392,239 @@ Issue a feeder command
|
||||
"amount": -3
|
||||
}
|
||||
|
||||
:json string command: The command to issue, only ``extrude`` is supported right now.
|
||||
:json number amount: ``extrude`` command: The amount of filament to extrude/retract in mm.
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
:json string command: The command to issue, either ``target``, ``offset``, ``select`` or ``extrude``.
|
||||
:json object targets: ``target`` command: The target temperatures to set. Valid properties have to match the format ``tool{n}``.
|
||||
:json object offsets: ``offset`` command: The offset temperature to set. Valid properties have to match the format ``tool{n}``.
|
||||
:json object tool: ``select`` command: The tool to select, value has to match the format ``tool{n}``.
|
||||
:json object amount: ``extrude`` command: The amount of filament to extrude from the currently selected tool.
|
||||
:json number factor: ``flowrate`` command: The factor to apply to the flow rate, percentage between 75 and 125% as integer or float.
|
||||
:statuscode 204: No error
|
||||
:statuscode 400: If the value given for `amount` is not a valid number or the request is otherwise invalid.
|
||||
:statuscode 409: If the printer is not operational or currently printing.
|
||||
|
||||
.. _sec-api-printer-toolstate:
|
||||
|
||||
Retrieve the current tool state
|
||||
===============================
|
||||
|
||||
.. http:get:: /api/printer/tool
|
||||
|
||||
Retrieves the current temperature data (actual, target and offset) plus optionally a (limited) history (actual, target,
|
||||
timestamp) for all of the printer's available tools.
|
||||
|
||||
It's also possible to retrieve the temperature history by supplying the ``history`` query parameter set to ``true``. The
|
||||
amount of returned history data points can be limited using the ``limit`` query parameter.
|
||||
|
||||
Returns a :http:statuscode:`200` with a Temperature Response in the body upon success.
|
||||
|
||||
.. note::
|
||||
If you want both tool and bed temperature information at the same time, take a look at
|
||||
:ref:`Retrieve the current printer state <sec-api-printer-state>`.
|
||||
|
||||
**Example**
|
||||
|
||||
Query the tool temperature data and also include the temperature history but limit it to two entries.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/printer/tool?history=true&limit=2 HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"tool0": {
|
||||
"actual": 214.8821,
|
||||
"target": 220.0,
|
||||
"offset": 0
|
||||
},
|
||||
"tool1": {
|
||||
"actual": 25.3,
|
||||
"target": null,
|
||||
"offset": 0
|
||||
},
|
||||
"history": [
|
||||
{
|
||||
"time": 1395651928,
|
||||
"tool0": {
|
||||
"actual": 214.8821,
|
||||
"target": 220.0
|
||||
},
|
||||
"tool1": {
|
||||
"actual": 25.3,
|
||||
"target": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"time": 1395651926,
|
||||
"tool0": {
|
||||
"actual": 212.32,
|
||||
"target": 220.0
|
||||
},
|
||||
"tool1": {
|
||||
"actual": 25.1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
:query history: If set to ``true`` (or: ``yes``, ``y``, ``1``), history information will be included in the response
|
||||
too. If no ``limit`` parameter is given, all available temperature history data will be returned.
|
||||
:query limit: If set to an integer (``n``), only the last ``n`` data points from the printer's temperature history
|
||||
will be returned. Will be ignored if ``history`` is not enabled.
|
||||
:statuscode 200: No error
|
||||
:statuscode 409: If the printer is not operational.
|
||||
|
||||
.. _sec-api-printer-bedcommand:
|
||||
|
||||
Issue a bed command
|
||||
===================
|
||||
|
||||
.. http:post:: /api/printer/bed
|
||||
|
||||
Bed commands allow setting the temperature and temperature offsets for the printer's heated bed. Available commands
|
||||
are:
|
||||
|
||||
target
|
||||
Sets the given target temperature on the printer's tools. Additional parameters:
|
||||
|
||||
* ``target``: Target temperature to set.
|
||||
|
||||
offset
|
||||
Sets the given temperature offset on the printer's tools. Additional parameters:
|
||||
|
||||
* ``offset``: Offset to set.
|
||||
|
||||
All of these commands may only be sent if the printer is currently operational. Otherwise a :http:statuscode:`409`
|
||||
is returned.
|
||||
|
||||
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
|
||||
|
||||
**Example Target Temperature Request**
|
||||
|
||||
Set the target temperature for the printer's heated bed to 75°C.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/bed HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "target",
|
||||
"target": 75
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example Offset Temperature Request**
|
||||
|
||||
Set the temperature offset for the heated bed to -5°C.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/bed HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "offset",
|
||||
"offset": -5
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
:json string command: The command to issue, either ``target`` or ``offset``.
|
||||
:json object target: ``target`` command: The target temperature to set.
|
||||
:json object offset: ``offset`` command: The offset temperature to set.
|
||||
:statuscode 204: No error
|
||||
:statuscode 400: If ``target`` or ``offset`` is not a valid number or outside of the supported range, or if the
|
||||
request is otherwise invalid.
|
||||
:statuscode 409: If the printer is not operational.
|
||||
|
||||
.. _sec-api-printer-bedstate:
|
||||
|
||||
Retrieve the current bed state
|
||||
==============================
|
||||
|
||||
.. http:get:: /api/printer/bed
|
||||
|
||||
Retrieves the current temperature data (actual, target and offset) plus optionally a (limited) history (actual, target,
|
||||
timestamp) for the printer's heated bed.
|
||||
|
||||
It's also possible to retrieve the temperature history by supplying the ``history`` query parameter set to ``true``. The
|
||||
amount of returned history data points can be limited using the ``limit`` query parameter.
|
||||
|
||||
Returns a :http:statuscode:`200` with a Temperature Response in the body upon success.
|
||||
|
||||
.. note::
|
||||
If you want both tool and bed temperature information at the same time, take a look at
|
||||
:ref:`Retrieve the current printer state <sec-api-printer-state>`.
|
||||
|
||||
**Example**
|
||||
|
||||
Query the bed temperature data and also include the temperature history but limit it to two entries.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/printer/bed?history=true&limit=2 HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"bed": {
|
||||
"actual": 50.221,
|
||||
"target": 70.0,
|
||||
"offset": 5
|
||||
},
|
||||
"history": [
|
||||
{
|
||||
"time": 1395651928,
|
||||
"bed": {
|
||||
"actual": 50.221,
|
||||
"target": 70.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"time": 1395651926,
|
||||
"bed": {
|
||||
"actual": 49.1123,
|
||||
"target": 70.0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
:query history: If set to ``true`` (or: ``yes``, ``y``, ``1``), history information will be included in the response
|
||||
too. If no ``limit`` parameter is given, all available temperature history data will be returned.
|
||||
:query limit: If set to an integer (``n``), only the last ``n`` data points from the printer's temperature history
|
||||
will be returned. Will be ignored if ``history`` is not enabled.
|
||||
:statuscode 200: No error
|
||||
:statuscode 409: If the printer is not operational.
|
||||
|
||||
.. _sec-api-printer-sdcommand:
|
||||
|
||||
Issue a SD command
|
||||
==================
|
||||
Issue an SD command
|
||||
===================
|
||||
|
||||
.. http:post:: /api/printer/sd
|
||||
|
||||
@@ -279,6 +665,10 @@ Issue a SD command
|
||||
"command": "init"
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example Refresh Request**
|
||||
|
||||
.. sourcecode:: http
|
||||
@@ -292,6 +682,10 @@ Issue a SD command
|
||||
"command": "refresh"
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example Release Request**
|
||||
|
||||
.. sourcecode:: http
|
||||
@@ -305,6 +699,10 @@ Issue a SD command
|
||||
"command": "release"
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
:json string command: The command to issue, either ``init``, ``refresh`` or ``release``.
|
||||
:statuscode 204: No error
|
||||
:statuscode 409: If a ``refresh`` or ``release`` command is issued but the SD card has not been initialized (e.g.
|
||||
@@ -324,14 +722,15 @@ Retrieve the current SD state
|
||||
Returns a :http:statuscode:`200` with an :ref:`SD State Response <sec-api-printer-datamodel-sdstate>` in the body
|
||||
upon success.
|
||||
|
||||
**Example Request**
|
||||
**Example**
|
||||
|
||||
Read the current state of the SD card.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/printer/sd HTTP/1.1
|
||||
Host: example.com
|
||||
|
||||
**Example Response**
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
@@ -345,15 +744,123 @@ Retrieve the current SD state
|
||||
:statuscode 200: No error
|
||||
:statuscode 404: If SD support has been disabled in OctoPrint's config.
|
||||
|
||||
.. _sec-api-printer-arbcommand:
|
||||
|
||||
Send an arbitrary command to the printer
|
||||
========================================
|
||||
|
||||
.. http:post:: /api/printer/command
|
||||
|
||||
Sends any command to the printer via the serial interface. Should be used with some care as some commands can interfere with
|
||||
or even stop a running print job.
|
||||
|
||||
Expects a :ref:`Arbitrary Command Request <sec-api-printer-datamodel-arbcommand>` as the request's body.
|
||||
|
||||
If successful returns a :http:statuscode:`204` and an empty body.
|
||||
|
||||
**Example for sending a single command**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/command HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "M106"
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example for sending multiple commands**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/command HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"commands": [
|
||||
"M18",
|
||||
"M106 S0"
|
||||
]
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
:json string command: Single command to send to the printer, mutually exclusive with ``commands``.
|
||||
:json string commands: List of commands to send to the printer, mutually exclusive with ``command``.
|
||||
:statuscode 204: No error
|
||||
|
||||
.. _sec-api-printer-datamodel:
|
||||
|
||||
Datamodel
|
||||
=========
|
||||
|
||||
.. _sec-api-printer-datamodel-fullstate:
|
||||
|
||||
Full State Response
|
||||
-------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``temperature``
|
||||
- 0..1
|
||||
- :ref:`Temperature State <sec-api-printer-datamodel-temps>`
|
||||
- The printer's temperature state data
|
||||
* - ``sd``
|
||||
- 0..1
|
||||
- :ref:`SD State <sec-api-printer-datamodel-sdstate>`
|
||||
- The printer's sd state data
|
||||
* - ``state``
|
||||
- 0..1
|
||||
- :ref:`Printer State <sec-api-datamodel-printer-state>`
|
||||
- The printer's general state
|
||||
|
||||
.. _sec-api-printer-datamodel-temps:
|
||||
|
||||
Temperature State
|
||||
-----------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``tool{n}``
|
||||
- 0..*
|
||||
- :ref:`Temperature Data <sec-api-datamodel-printer-tempdata>`
|
||||
- Current temperature stats for tool *n*. Enumeration starts at 0 for the first tool. Not included if querying
|
||||
only bed state.
|
||||
* - ``bed``
|
||||
- 0..1
|
||||
- :ref:`Temperature Data <sec-api-datamodel-printer-tempdata>`
|
||||
- Current temperature stats for the printer's heated bed. Not included if querying only tool state.
|
||||
* - ``history``
|
||||
- 0..1
|
||||
- List of :ref:`Historic Temperature Datapoint <sec-api-datamodel-printer-temphistory>`
|
||||
- Temperature history
|
||||
|
||||
.. _sec-api-printer-datamodel-sdstate:
|
||||
|
||||
SD State Response
|
||||
-----------------
|
||||
SD State
|
||||
--------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
@@ -366,4 +873,38 @@ SD State Response
|
||||
* - ``ready``
|
||||
- 1
|
||||
- Boolean
|
||||
- Whether the SD card has been initialized (``true``) or not (``false``).
|
||||
- Whether the SD card has been initialized (``true``) or not (``false``).
|
||||
|
||||
.. _sec-api-printer-datamodel-arbcommand:
|
||||
|
||||
Arbitrary Command Request
|
||||
-------------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``command``
|
||||
- 0..1
|
||||
- String
|
||||
- Single command to send to the printer, mutually exclusive with ``commands`` and ``script``.
|
||||
* - ``commands``
|
||||
- 0..*
|
||||
- Array of String
|
||||
- Multiple commands to send to the printer (in the given order), mutually exclusive with ``command`` and ``script``.
|
||||
* - ``script``
|
||||
- 0..*
|
||||
- String
|
||||
- Name of the GCODE script template to send to the printer, mutually exclusive with ``command`` and ``commands``.
|
||||
* - ``parameters``
|
||||
- 0..1
|
||||
- Map of key value pairs
|
||||
- Key value pairs of parameters to replace in sent commands/provide to the script renderer
|
||||
* - ``context``
|
||||
- 0..1
|
||||
- Map of key value pairs
|
||||
- (only if ``script`` is set) additional template variables to provide to the script renderer
|
||||
@@ -12,6 +12,12 @@
|
||||
# serve to show the default.
|
||||
|
||||
import sys, os
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
sys.path.insert(0, os.path.abspath('../src/'))
|
||||
|
||||
import octoprint._version
|
||||
from datetime import date
|
||||
|
||||
|
||||
@@ -27,6 +27,26 @@ def package_data_dirs(source, sub_folders):
|
||||
return dirs
|
||||
|
||||
|
||||
def _recursively_handle_files(directory, file_matcher, folder_handler=None, file_handler=None):
|
||||
applied_handler = False
|
||||
|
||||
for filename in os.listdir(directory):
|
||||
path = os.path.join(directory, filename)
|
||||
|
||||
if file_handler is not None and file_matcher(filename):
|
||||
file_handler(path)
|
||||
applied_handler = True
|
||||
|
||||
elif os.path.isdir(path):
|
||||
sub_applied_handler = _recursively_handle_files(path, file_matcher, folder_handler=folder_handler, file_handler=file_handler)
|
||||
if sub_applied_handler:
|
||||
applied_handler = True
|
||||
|
||||
if folder_handler is not None:
|
||||
folder_handler(path, sub_applied_handler)
|
||||
|
||||
return applied_handler
|
||||
|
||||
class CleanCommand(Command):
|
||||
description = "clean build artifacts"
|
||||
user_options = []
|
||||
@@ -39,14 +59,37 @@ class CleanCommand(Command):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
# build folder
|
||||
if os.path.exists('build'):
|
||||
print "Deleting build directory"
|
||||
shutil.rmtree('build')
|
||||
|
||||
# eggs
|
||||
eggs = glob.glob('OctoPrint*.egg-info')
|
||||
for egg in eggs:
|
||||
print "Deleting %s directory" % egg
|
||||
shutil.rmtree(egg)
|
||||
|
||||
# pyc files
|
||||
def delete_folder_if_empty(path, applied_handler):
|
||||
if not applied_handler:
|
||||
return
|
||||
if len(os.listdir(path)) == 0:
|
||||
shutil.rmtree(path)
|
||||
print "Deleted %s since it was empty" % path
|
||||
|
||||
def delete_file(path):
|
||||
os.remove(path)
|
||||
print "Deleted %s" % path
|
||||
|
||||
import fnmatch
|
||||
_recursively_handle_files(
|
||||
os.path.abspath("src"),
|
||||
lambda name: fnmatch.fnmatch(name.lower(), "*.pyc"),
|
||||
folder_handler=delete_folder_if_empty,
|
||||
file_handler=delete_file
|
||||
)
|
||||
|
||||
|
||||
def get_cmdclass():
|
||||
cmdclass = versioneer.get_cmdclass()
|
||||
|
||||
@@ -214,7 +214,7 @@ def versions_from_parentdir(parentdir_prefix, root, verbose=False):
|
||||
print("guessing rootdir is '%s', but '%s' doesn't start with prefix '%s'" %
|
||||
(root, dirname, parentdir_prefix))
|
||||
return None
|
||||
return {"version": dirname[len(parentdir_prefix):], "full": ""}
|
||||
return {"version": dirname[len(parentdir_prefix):], "full": "", "branch": ""}
|
||||
|
||||
tag_prefix = ""
|
||||
parentdir_prefix = ""
|
||||
@@ -249,7 +249,7 @@ def parse_lookup_file(root, lookup_path=None):
|
||||
break
|
||||
return lookup
|
||||
|
||||
def get_versions(default={"version": "unknown", "full": ""}, lookup_path=None, verbose=False):
|
||||
def get_versions(default={"version": "unknown", "full": "", "branch": "unknown"}, lookup_path=None, verbose=False):
|
||||
# I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
|
||||
# __file__, we can work backwards from there to the root. Some
|
||||
# py2exe/bbfreeze/non-CPython implementations don't do __file__, in which
|
||||
|
||||
@@ -293,7 +293,7 @@ class CommandTrigger(GenericEventListener):
|
||||
def _executeGcodeCommand(self, command):
|
||||
commands = [command]
|
||||
if isinstance(command, (list, tuple, set)):
|
||||
self.logger.debug("Executing GCode commands: %r" % command)
|
||||
self._logger.debug("Executing GCode commands: %r" % command)
|
||||
commands = list(command)
|
||||
else:
|
||||
self._logger.debug("Executing GCode command: %s" % command)
|
||||
|
||||
@@ -388,6 +388,17 @@ class Printer():
|
||||
}
|
||||
else:
|
||||
self._selectedFile = None
|
||||
self._stateMonitor.setJobData({
|
||||
"file": {
|
||||
"name": None,
|
||||
"origin": None,
|
||||
"size": None,
|
||||
"date": None
|
||||
},
|
||||
"estimatedPrintTime": None,
|
||||
"filament": None,
|
||||
})
|
||||
return
|
||||
|
||||
estimatedPrintTime = None
|
||||
date = None
|
||||
@@ -617,12 +628,13 @@ class Printer():
|
||||
bedTempOffset = None
|
||||
|
||||
result = {}
|
||||
for tool in self._temp.keys():
|
||||
result["tool%d" % tool] = {
|
||||
"actual": self._temp[tool][0],
|
||||
"target": self._temp[tool][1],
|
||||
"offset": tempOffset[tool] if tool in tempOffset.keys() and tempOffset[tool] is not None else 0
|
||||
}
|
||||
if self._temp is not None:
|
||||
for tool in self._temp.keys():
|
||||
result["tool%d" % tool] = {
|
||||
"actual": self._temp[tool][0],
|
||||
"target": self._temp[tool][1],
|
||||
"offset": tempOffset[tool] if tool in tempOffset.keys() and tempOffset[tool] is not None else 0
|
||||
}
|
||||
if self._bedTemp is not None:
|
||||
result["bed"] = {
|
||||
"actual": self._bedTemp[0],
|
||||
|
||||
@@ -155,7 +155,15 @@ class Server():
|
||||
|
||||
app.wsgi_app = ReverseProxied(app.wsgi_app)
|
||||
|
||||
app.secret_key = "k3PuVYgtxNm8DXKKTw2nWmFQQun9qceV"
|
||||
secret_key = settings().get(["server", "secretKey"])
|
||||
if not secret_key:
|
||||
import string
|
||||
from random import choice
|
||||
chars = string.ascii_lowercase + string.ascii_uppercase + string.digits
|
||||
secret_key = "".join(choice(chars) for _ in xrange(32))
|
||||
settings().set(["server", "secretKey"], secret_key)
|
||||
settings().save()
|
||||
app.secret_key = secret_key
|
||||
loginManager = LoginManager()
|
||||
loginManager.session_protection = "strong"
|
||||
loginManager.user_callback = load_user
|
||||
@@ -193,7 +201,7 @@ class Server():
|
||||
|
||||
self._tornado_app = Application(self._router.urls + [
|
||||
(r"/downloads/timelapse/([^/]*\.mpg)", LargeResponseHandler, {"path": settings().getBaseFolder("timelapse"), "as_attachment": True}),
|
||||
(r"/downloads/files/local/([^/]*\.(gco|gcode))", LargeResponseHandler, {"path": settings().getBaseFolder("uploads"), "as_attachment": True}),
|
||||
(r"/downloads/files/local/([^/]*\.(gco|gcode|g))", LargeResponseHandler, {"path": settings().getBaseFolder("uploads"), "as_attachment": True}),
|
||||
(r"/downloads/logs/([^/]*)", LargeResponseHandler, {"path": settings().getBaseFolder("logs"), "as_attachment": True, "access_validation": admin_access_validation}),
|
||||
(r".*", FallbackHandler, {"fallback": WSGIContainer(app.wsgi_app)})
|
||||
])
|
||||
|
||||
@@ -120,7 +120,7 @@ def login():
|
||||
|
||||
user = octoprint.server.userManager.findUser(username)
|
||||
if user is not None:
|
||||
if user.check_password(octoprint.users.UserManager.createPasswordHash(password)):
|
||||
if octoprint.server.userManager.checkPassword(username, password):
|
||||
login_user(user, remember=remember)
|
||||
identity_changed.send(current_app._get_current_object(), identity=Identity(user.get_id()))
|
||||
return jsonify(user.asDict())
|
||||
|
||||
@@ -17,8 +17,27 @@ def printerState():
|
||||
if not printer.isOperational():
|
||||
return make_response("Printer is not operational", 409)
|
||||
|
||||
# process excludes
|
||||
excludes = []
|
||||
if "exclude" in request.values:
|
||||
excludeStr = request.values["exclude"]
|
||||
if len(excludeStr.strip()) > 0:
|
||||
excludes = filter(lambda x: x in ["temperature", "sd", "state"], map(lambda x: x.strip(), excludeStr.split(",")))
|
||||
|
||||
result = {}
|
||||
result.update(_getTemperatureData(lambda x: x))
|
||||
|
||||
# add temperature information
|
||||
if not "temperature" in excludes:
|
||||
result.update({"temperature": _getTemperatureData(lambda x: x)})
|
||||
|
||||
# add sd information
|
||||
if not "sd" in excludes and settings().getBoolean(["feature", "sdSupport"]):
|
||||
result.update({"sd": {"ready": printer.isSdReady()}})
|
||||
|
||||
# add state information
|
||||
if not "state" in excludes:
|
||||
state = printer.getCurrentData()["state"]
|
||||
result.update({"state": state})
|
||||
|
||||
return jsonify(result)
|
||||
|
||||
@@ -145,7 +164,7 @@ def printerBedCommand():
|
||||
|
||||
##~~ temperature offset
|
||||
elif command == "offset":
|
||||
offset = data["offsets"]
|
||||
offset = data["offset"]
|
||||
|
||||
# make sure the offset is valid
|
||||
if not isinstance(offset, (int, long, float)):
|
||||
|
||||
@@ -373,6 +373,14 @@ class ReverseProxied(object):
|
||||
|
||||
if scheme:
|
||||
environ['wsgi.url_scheme'] = scheme
|
||||
|
||||
host = environ.get('HTTP_X_FORWARDED_HOST', '')
|
||||
if not host:
|
||||
host = settings().get(["server", "forwardedHost"])
|
||||
|
||||
if host:
|
||||
environ['HTTP_HOST'] = host
|
||||
|
||||
return self.app(environ, start_response)
|
||||
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ default_settings = {
|
||||
"log": False,
|
||||
"timeout": {
|
||||
"detection": 0.5,
|
||||
"connection": 2,
|
||||
"communication": 5,
|
||||
"connection": 10,
|
||||
"communication": 30,
|
||||
"temperature": 5,
|
||||
"sdStatus": 1
|
||||
},
|
||||
@@ -41,8 +41,10 @@ default_settings = {
|
||||
"host": "0.0.0.0",
|
||||
"port": 5000,
|
||||
"firstRun": True,
|
||||
"secretKey": None,
|
||||
"baseUrl": "",
|
||||
"scheme": ""
|
||||
"scheme": "",
|
||||
"forwardedHost": ""
|
||||
},
|
||||
"webcam": {
|
||||
"stream": None,
|
||||
@@ -63,6 +65,9 @@ default_settings = {
|
||||
"mobileSizeThreshold": 2 * 1024 * 1024, # 2MB
|
||||
"sizeThreshold": 20 * 1024 * 1024, # 20MB
|
||||
},
|
||||
"gcodeAnalysis": {
|
||||
"maxExtruders": 10
|
||||
},
|
||||
"feature": {
|
||||
"temperatureGraph": True,
|
||||
"waitForStartOnConnect": False,
|
||||
@@ -113,6 +118,7 @@ default_settings = {
|
||||
},
|
||||
"accessControl": {
|
||||
"enabled": True,
|
||||
"salt": None,
|
||||
"userManager": "octoprint.users.FilebasedUserManager",
|
||||
"userfile": None,
|
||||
"autologinLocal": False,
|
||||
@@ -125,12 +131,12 @@ default_settings = {
|
||||
"config": "/default/path/to/your/cura/config.ini"
|
||||
},
|
||||
"events": {
|
||||
"enabled": False,
|
||||
"enabled": True,
|
||||
"subscriptions": []
|
||||
},
|
||||
"api": {
|
||||
"enabled": False,
|
||||
"key": ''.join('%02X' % ord(z) for z in uuid.uuid4().bytes)
|
||||
"enabled": True,
|
||||
"key": None
|
||||
},
|
||||
"terminalFilters": [
|
||||
{ "name": "Suppress M105 requests/responses", "regex": "(Send: M105)|(Recv: ok T\d*:)" },
|
||||
@@ -171,12 +177,19 @@ class Settings(object):
|
||||
self._configfile = os.path.join(self.settings_dir, "config.yaml")
|
||||
self.load(migrate=True)
|
||||
|
||||
if self.get(["api", "key"]) is None:
|
||||
self.set(["api", "key"], ''.join('%02X' % ord(z) for z in uuid.uuid4().bytes))
|
||||
self.save(force=True)
|
||||
|
||||
def _init_settings_dir(self, basedir):
|
||||
if basedir is not None:
|
||||
self.settings_dir = basedir
|
||||
else:
|
||||
self.settings_dir = _resolveSettingsDir(APPNAME)
|
||||
|
||||
if not os.path.isdir(self.settings_dir):
|
||||
os.makedirs(self.settings_dir)
|
||||
|
||||
def _getDefaultFolder(self, type):
|
||||
folder = default_settings["folder"][type]
|
||||
if folder is None:
|
||||
|
||||
@@ -514,6 +514,16 @@ GCODE.renderer = (function(){
|
||||
}
|
||||
zoomFactor = Math.min((canvas.width - 10) / bedWidth, (canvas.height - 10) / bedHeight);
|
||||
|
||||
var translationX, translationY;
|
||||
if (renderOptions["bed"]["circular"]) {
|
||||
translationX = canvas.width / 2;
|
||||
translationY = canvas.height / 2;
|
||||
} else {
|
||||
translationX = (canvas.width - bedWidth * zoomFactor) / 2;
|
||||
translationY = bedHeight * zoomFactor + (canvas.height - bedHeight * zoomFactor) / 2;
|
||||
}
|
||||
ctx.translate(translationX, translationY);
|
||||
|
||||
offsetModelX = 0;
|
||||
offsetModelY = 0;
|
||||
offsetBedX = 0;
|
||||
|
||||
@@ -201,7 +201,9 @@ function GcodeFilesViewModel(printerStateViewModel, loginStateViewModel) {
|
||||
} else {
|
||||
var i = 0;
|
||||
do {
|
||||
output += "<strong>Filament (Tool " + i + "):</strong> " + formatFilament(data["gcodeAnalysis"]["filament"]["tool" + i]) + "<br>";
|
||||
if (filament["tool" + i].hasOwnProperty("length") && filament["tool" + i]["length"] > 0) {
|
||||
output += "<strong>Filament (Tool " + i + "):</strong> " + formatFilament(filament["tool" + i]) + "<br>";
|
||||
}
|
||||
i++;
|
||||
} while (filament.hasOwnProperty("tool" + i));
|
||||
}
|
||||
|
||||
@@ -129,10 +129,12 @@ function PrinterStateViewModel(loginStateViewModel) {
|
||||
var i = 0;
|
||||
do {
|
||||
var key = "tool" + i;
|
||||
result[i] = {
|
||||
name: ko.observable("Tool " + i),
|
||||
data: ko.observable(data.filament[key])
|
||||
};
|
||||
if (data.filament.hasOwnProperty(key) && data.filament[key].hasOwnProperty("length") && data.filament[key].length > 0) {
|
||||
result.push({
|
||||
name: ko.observable("Tool " + i),
|
||||
data: ko.observable(data.filament[key])
|
||||
});
|
||||
}
|
||||
i++;
|
||||
} while (data.filament.hasOwnProperty("tool" + i));
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
var CONFIG_GCODE_SIZE_THRESHOLD = {{ gcodeThreshold }};
|
||||
var CONFIG_GCODE_MOBILE_SIZE_THRESHOLD = {{ gcodeMobileThreshold }};
|
||||
|
||||
var SOCKJS_URI = window.location.protocol.slice(0, -1) + "://" + (window.document ? window.document.domain : window.location.hostname) + ":" + window.location.port + "/sockjs";
|
||||
var SOCKJS_URI = "{{ url_for('index') }}" + "sockjs";
|
||||
var SOCKJS_DEBUG = {% if debug -%} true; {% else %} false; {%- endif %}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
@@ -226,8 +226,12 @@ class Timelapse(object):
|
||||
self._logger.warn("Cannot capture image, capture directory is unset")
|
||||
return
|
||||
|
||||
if self._imageNumber is None:
|
||||
self._logger.warn("Cannot capture image, image number is unset")
|
||||
return
|
||||
|
||||
with self._captureMutex:
|
||||
filename = os.path.join(self._captureDir, "tmp_%05d.jpg" % (self._imageNumber))
|
||||
filename = os.path.join(self._captureDir, "tmp_%05d.jpg" % self._imageNumber)
|
||||
self._imageNumber += 1
|
||||
self._logger.debug("Capturing image to %s" % filename)
|
||||
captureThread = threading.Thread(target=self._captureWorker, kwargs={"filename": filename})
|
||||
@@ -236,10 +240,16 @@ class Timelapse(object):
|
||||
return filename
|
||||
|
||||
def _captureWorker(self, filename):
|
||||
eventManager().fire(Events.CAPTURE_START, {"file": filename});
|
||||
urllib.urlretrieve(self._snapshotUrl, filename)
|
||||
self._logger.debug("Image %s captured from %s" % (filename, self._snapshotUrl))
|
||||
eventManager().fire(Events.CAPTURE_DONE, {"file": filename});
|
||||
eventManager().fire(Events.CAPTURE_START, {"file": filename})
|
||||
try:
|
||||
urllib.urlretrieve(self._snapshotUrl, filename)
|
||||
self._logger.debug("Image %s captured from %s" % (filename, self._snapshotUrl))
|
||||
except:
|
||||
self._logger.exception("Could not capture image %s from %s, decreasing image counter again" % (filename, self._snapshotUrl))
|
||||
with self._captureMutex:
|
||||
if self._imageNumber is not None and self._imageNumber > 0:
|
||||
self._imageNumber -= 1
|
||||
eventManager().fire(Events.CAPTURE_DONE, {"file": filename})
|
||||
|
||||
def _createMovie(self, success=True):
|
||||
ffmpeg = settings().get(["webcam", "ffmpeg"])
|
||||
|
||||
+39
-3
@@ -1,6 +1,9 @@
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import
|
||||
|
||||
__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 flask.ext.login import UserMixin
|
||||
from flask.ext.principal import Identity
|
||||
@@ -15,8 +18,38 @@ class UserManager(object):
|
||||
valid_roles = ["user", "admin"]
|
||||
|
||||
@staticmethod
|
||||
def createPasswordHash(password):
|
||||
return hashlib.sha512(password + "mvBUTvwzBzD3yPwvnJ4E4tXNf3CGJvvW").hexdigest()
|
||||
def createPasswordHash(password, salt=None):
|
||||
if not salt:
|
||||
salt = settings().get(["accessControl", "salt"])
|
||||
if salt is None:
|
||||
import string
|
||||
from random import choice
|
||||
chars = string.ascii_lowercase + string.ascii_uppercase + string.digits
|
||||
salt = "".join(choice(chars) for _ in xrange(32))
|
||||
settings().set(["accessControl", "salt"], salt)
|
||||
settings().save()
|
||||
|
||||
return hashlib.sha512(password + salt).hexdigest()
|
||||
|
||||
def checkPassword(self, username, password):
|
||||
user = self.findUser(username)
|
||||
if not user:
|
||||
return False
|
||||
|
||||
hash = UserManager.createPasswordHash(password)
|
||||
if user.check_password(hash):
|
||||
# new hash matches, correct password
|
||||
return True
|
||||
else:
|
||||
# new hash doesn't match, but maybe the old one does, so check that!
|
||||
oldHash = UserManager.createPasswordHash(password, salt="mvBUTvwzBzD3yPwvnJ4E4tXNf3CGJvvW")
|
||||
if user.check_password(oldHash):
|
||||
# old hash matches, we migrate the stored password hash to the new one and return True since it's the correct password
|
||||
self.changeUserPassword(username, password)
|
||||
return True
|
||||
else:
|
||||
# old hash doesn't match either, wrong password
|
||||
return False
|
||||
|
||||
def addUser(self, username, password, active, roles):
|
||||
pass
|
||||
@@ -97,7 +130,10 @@ class FilebasedUserManager(UserManager):
|
||||
self._dirty = False
|
||||
self._load()
|
||||
|
||||
def addUser(self, username, password, active=False, roles=["user"], apikey=None):
|
||||
def addUser(self, username, password, active=False, roles=None, apikey=None):
|
||||
if not roles:
|
||||
roles = ["user"]
|
||||
|
||||
if username in self._users.keys():
|
||||
raise UserAlreadyExists(username)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import
|
||||
__author__ = "Gina Häußge <osd@foosel.net> based on work by David Braam"
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
|
||||
@@ -250,18 +250,13 @@ class MachineCom(object):
|
||||
if self._state == self.STATE_CLOSED:
|
||||
return "Closed"
|
||||
if self._state == self.STATE_ERROR:
|
||||
return "Error: %s" % (self.getShortErrorString())
|
||||
return "Error: %s" % (self.getErrorString())
|
||||
if self._state == self.STATE_CLOSED_WITH_ERROR:
|
||||
return "Error: %s" % (self.getShortErrorString())
|
||||
return "Error: %s" % (self.getErrorString())
|
||||
if self._state == self.STATE_TRANSFERING_FILE:
|
||||
return "Transfering file to SD"
|
||||
return "?%d?" % (self._state)
|
||||
|
||||
def getShortErrorString(self):
|
||||
if len(self._errorValue) < 20:
|
||||
return self._errorValue
|
||||
return self._errorValue[:20] + "..."
|
||||
|
||||
def getErrorString(self):
|
||||
return self._errorValue
|
||||
|
||||
@@ -395,9 +390,8 @@ class MachineCom(object):
|
||||
})
|
||||
|
||||
if self.isSdFileSelected():
|
||||
if wasPaused:
|
||||
self.sendCommand("M26 S0")
|
||||
self._currentFile.setFilepos(0)
|
||||
self.sendCommand("M26 S0")
|
||||
self._currentFile.setFilepos(0)
|
||||
self.sendCommand("M24")
|
||||
else:
|
||||
self._sendNext()
|
||||
@@ -897,7 +891,7 @@ class MachineCom(object):
|
||||
if self._resendDelta is not None:
|
||||
self._resendNextCommand()
|
||||
elif not self._commandQueue.empty() and not self.isStreaming():
|
||||
self._sendCommand(self._commandQueue.get())
|
||||
self._sendCommand(self._commandQueue.get(), True)
|
||||
else:
|
||||
self._sendNext()
|
||||
elif line.lower().startswith("resend") or line.lower().startswith("rs"):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import
|
||||
__author__ = "Gina Häußge <osd@foosel.net> based on work by David Braam"
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
__copyright__ = "Copyright (C) 2013 David Braam, Gina Häußge - Released under terms of the AGPLv3 License"
|
||||
@@ -73,7 +73,14 @@ class gcode(object):
|
||||
if ';' in line:
|
||||
comment = line[line.find(';')+1:].strip()
|
||||
if comment.startswith("filament_diameter"):
|
||||
self._filamentDiameter = float(comment.split("=", 1)[1].strip())
|
||||
filamentValue = comment.split("=", 1)[1].strip()
|
||||
try:
|
||||
self._filamentDiameter = float(filamentValue)
|
||||
except ValueError:
|
||||
try:
|
||||
self._filamentDiameter = float(filamentValue.split(",")[0].strip())
|
||||
except ValueError:
|
||||
self._filamentDiameter = 0.0
|
||||
elif comment.startswith("CURA_PROFILE_STRING"):
|
||||
curaOptions = self._parseCuraProfileString(comment)
|
||||
if "filament_diameter" in curaOptions:
|
||||
@@ -85,23 +92,26 @@ class gcode(object):
|
||||
|
||||
T = getCodeInt(line, 'T')
|
||||
if T is not None:
|
||||
posOffset[0] -= offsets[currentExtruder]["x"] if currentExtruder < len(offsets) else 0
|
||||
posOffset[1] -= offsets[currentExtruder]["y"] if currentExtruder < len(offsets) else 0
|
||||
|
||||
currentExtruder = T
|
||||
|
||||
posOffset[0] += offsets[currentExtruder]["x"] if currentExtruder < len(offsets) else 0
|
||||
posOffset[1] += offsets[currentExtruder]["y"] if currentExtruder < len(offsets) else 0
|
||||
|
||||
if len(currentE) <= currentExtruder:
|
||||
for i in range(len(currentE), currentExtruder + 1):
|
||||
currentE.append(0.0)
|
||||
if len(maxExtrusion) <= currentExtruder:
|
||||
for i in range(len(maxExtrusion), currentExtruder + 1):
|
||||
maxExtrusion.append(0.0)
|
||||
if len(totalExtrusion) <= currentExtruder:
|
||||
for i in range(len(totalExtrusion), currentExtruder + 1):
|
||||
totalExtrusion.append(0.0)
|
||||
if T > settings().getInt(["gcodeAnalysis", "maxExtruders"]):
|
||||
self._logger.warn("GCODE tried to select tool %d, that looks wrong, ignoring for GCODE analysis" % T)
|
||||
else:
|
||||
posOffset[0] -= offsets[currentExtruder]["x"] if currentExtruder < len(offsets) else 0
|
||||
posOffset[1] -= offsets[currentExtruder]["y"] if currentExtruder < len(offsets) else 0
|
||||
|
||||
currentExtruder = T
|
||||
|
||||
posOffset[0] += offsets[currentExtruder]["x"] if currentExtruder < len(offsets) else 0
|
||||
posOffset[1] += offsets[currentExtruder]["y"] if currentExtruder < len(offsets) else 0
|
||||
|
||||
if len(currentE) <= currentExtruder:
|
||||
for i in range(len(currentE), currentExtruder + 1):
|
||||
currentE.append(0.0)
|
||||
if len(maxExtrusion) <= currentExtruder:
|
||||
for i in range(len(maxExtrusion), currentExtruder + 1):
|
||||
maxExtrusion.append(0.0)
|
||||
if len(totalExtrusion) <= currentExtruder:
|
||||
for i in range(len(totalExtrusion), currentExtruder + 1):
|
||||
totalExtrusion.append(0.0)
|
||||
|
||||
G = getCodeInt(line, 'G')
|
||||
if G is not None:
|
||||
@@ -239,13 +249,16 @@ def getCodeInt(line, code):
|
||||
|
||||
|
||||
def getCodeFloat(line, code):
|
||||
import math
|
||||
n = line.find(code) + 1
|
||||
if n < 1:
|
||||
return None
|
||||
m = line.find(' ', n)
|
||||
try:
|
||||
if m < 0:
|
||||
return float(line[n:])
|
||||
return float(line[n:m])
|
||||
val = float(line[n:])
|
||||
else:
|
||||
val = float(line[n:m])
|
||||
return val if not (math.isnan(val) or math.isinf(val)) else None
|
||||
except:
|
||||
return None
|
||||
@@ -1,5 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
|
||||
|
||||
+12
-10
@@ -473,7 +473,7 @@ def versions_from_parentdir(parentdir_prefix, root, verbose=False):
|
||||
print("guessing rootdir is '%%s', but '%%s' doesn't start with prefix '%%s'" %%
|
||||
(root, dirname, parentdir_prefix))
|
||||
return None
|
||||
return {"version": dirname[len(parentdir_prefix):], "full": ""}
|
||||
return {"version": dirname[len(parentdir_prefix):], "full": "", "branch": ""}
|
||||
|
||||
tag_prefix = "%(TAG_PREFIX)s"
|
||||
parentdir_prefix = "%(PARENTDIR_PREFIX)s"
|
||||
@@ -508,7 +508,7 @@ def parse_lookup_file(root, lookup_path=None):
|
||||
break
|
||||
return lookup
|
||||
|
||||
def get_versions(default={"version": "unknown", "full": ""}, lookup_path=None, verbose=False):
|
||||
def get_versions(default={"version": "unknown", "full": "", "branch": "unknown"}, lookup_path=None, verbose=False):
|
||||
# I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
|
||||
# __file__, we can work backwards from there to the root. Some
|
||||
# py2exe/bbfreeze/non-CPython implementations don't do __file__, in which
|
||||
@@ -649,7 +649,8 @@ def versions_from_expanded_variables(variables, tag_prefix, verbose=False):
|
||||
if verbose:
|
||||
print("no suitable tags, using full revision id")
|
||||
return { "version": variables["full"].strip(),
|
||||
"full": variables["full"].strip() }
|
||||
"full": variables["full"].strip(),
|
||||
"branch": ""}
|
||||
|
||||
|
||||
def versions_from_lookup(lookup, root, verbose=False):
|
||||
@@ -741,7 +742,7 @@ def versions_from_parentdir(parentdir_prefix, root, verbose=False):
|
||||
print("guessing rootdir is '%s', but '%s' doesn't start with prefix '%s'" %
|
||||
(root, dirname, parentdir_prefix))
|
||||
return None
|
||||
return {"version": dirname[len(parentdir_prefix):], "full": ""}
|
||||
return {"version": dirname[len(parentdir_prefix):], "full": "", "branch": ""}
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
@@ -801,15 +802,13 @@ SHORT_VERSION_PY = """
|
||||
|
||||
version_version = '%(version)s'
|
||||
version_full = '%(full)s'
|
||||
version_branch = %(branch)r
|
||||
version_branch = '%(branch)s'
|
||||
def get_versions(default={}, verbose=False):
|
||||
if version_branch:
|
||||
return {'version': version_version, 'full': version_full, 'branch': version_branch}
|
||||
return {'version': version_version, 'full': version_full}
|
||||
return {'version': version_version, 'full': version_full, 'branch': version_branch}
|
||||
|
||||
"""
|
||||
|
||||
DEFAULT = {"version": "unknown", "full": "unknown"}
|
||||
DEFAULT = {"version": "unknown", "full": "unknown", "branch": "unknown"}
|
||||
|
||||
def versions_from_file(filename):
|
||||
versions = {}
|
||||
@@ -824,6 +823,9 @@ def versions_from_file(filename):
|
||||
mo = re.match("version_full = '([^']+)'", line)
|
||||
if mo:
|
||||
versions["full"] = mo.group(1)
|
||||
mo = re.match("version_branch = '([^']+)'", line)
|
||||
if mo:
|
||||
versions["branch"] = mo.group(1)
|
||||
f.close()
|
||||
return versions
|
||||
|
||||
@@ -866,7 +868,7 @@ def parse_lookup_file(root, lookup_path=None):
|
||||
return lookup
|
||||
|
||||
def get_versions(default=DEFAULT, verbose=False):
|
||||
# returns dict with two keys: 'version' and 'full'
|
||||
# returns dict with three keys: 'version', 'full' and 'branch'
|
||||
assert versionfile_source is not None, "please set versioneer.versionfile_source"
|
||||
assert tag_prefix is not None, "please set versioneer.tag_prefix"
|
||||
assert parentdir_prefix is not None, "please set versioneer.parentdir_prefix"
|
||||
|
||||
Reference in new issue
Block a user