Merge branch 'maintenance' into devel

This commit is contained in:
Gina Häußge committed 2017-03-13 17:48:49 +01:00
commit 3d10fff7de
33 files changed
+1558 -1045

No files matched your search

+24 -13
View File
@@ -15,10 +15,17 @@ for contributing" linked above, read it!), NOT here.
Mark requests with a "[Request]" prefix in the title please. Fully fill
out the bug reporting template for bug reports (if you don't know where
to find some information - it's all described in the contribution
guidelines linked up there in the big yellow box). Do not delete any
lines from the template but those enclosed in [ and ] - and those please
DO delete, they are only provided for your information and removing them
makes your ticket more readable :)
guidelines linked up there in the big yellow box).
When reporting a bug do NOT delete any lines from the template but
those enclosed in [ and ] - and those please DO delete, they are
only provided for your information and removing them makes your
ticket more readable :)
Make sure any bug you want to repor tis still present with the CURRENT
OctoPrint version and that it does not vanish when you start OctoPrint
in safe mode - how to do that is also explained in the contribution
guidelines linked up there in the big yellow box.
Thank you!
@@ -30,28 +37,31 @@ by heart ;))
#### What were you doing?
[Please be as specific as possible here. The maintainers will need to
reproduce your issue in order to fix it and that is not possible if they
don't know what you did to get it to happen in the first place.
[Please describe the steps to reproduce your issue. Be as specific as
possible here. The maintainers will need to reproduce your issue in
order to fix it and that is not possible if they don't know what you
did to get it to happen in the first place.
If you encountered a problem with specific files of any sorts, make sure
to also include a link to a file with which to reproduce the problem.]
#### What did you expect to happen?
#### What happened instead?
#### What did you expect to happen and what happened instead?
#### Branch & Commit or Version of OctoPrint
[Can be found in the lower left corner of the web interface. ALWAYS INCLUDE.]
#### Operating System running OctoPrint
[OctoPi, Linux, Windows, MacOS, something else? With version please.]
#### Printer model & used firmware incl. version
[If applicable, always include if unsure.]
#### Browser and Version of Browser, Operating System running Browser
[If applicable, always include if unsure.]
[If applicable, always include if unsure or reporting UI issues.]
#### Link to octoprint.log
@@ -60,7 +70,8 @@ to also include a link to a file with which to reproduce the problem.]
#### Link to contents of terminal tab or serial.log
[On gist.github.com or pastebin.com. If applicable, always include if unsure or
reporting communication issues. Never truncate.
reporting any kind of communication issues between OctoPrint and your printer.
Never truncate.
serial.log is usually not written due to performance reasons and must be
enabled explicitly. Provide at the very least the FULL contents of your
@@ -72,7 +83,7 @@ a serial.log.]
[On gist.github.com or pastebin.com or alternatively a screenshot. If applicable -
always include if unsure or reporting UI issues.]
#### Screenshot(s) showing the problem:
#### Screenshot(s) or video(s) showing the problem:
[If applicable. Always include if unsure or reporting UI issues.]
+4 -3
View File
@@ -14,14 +14,15 @@ checklist:
made sure your changes don't interfere with current development by
talking it through with the maintainers, e.g. through a
Brainstorming ticket
* [ ] Your PR targets OctoPrint's devel branch (not master,
maintenance or anything else)
* [ ] Your PR targets OctoPrint's devel branch, or maintenance if it's
a bug fix for an issue present in the current stable version (no PRs
against master or anything else)
* [ ] Your PR was opened from a custom branch on your repository
(no PRs from your version of master, maintenance or devel please),
e.g. dev/my_new_feature
* [ ] Your PR only contains relevant changes: no unrelated files,
no dead code, ideally only one commit - rebase your PR if necessary!
* [ ] Your changes follow the coding style
* [ ] Your changes follow the existing coding style
* [ ] If your changes include style sheets: You have modified the
.less source files, not the .css files (those are generated with
lessc)
+46
View File
@@ -1,5 +1,50 @@
# OctoPrint Changelog
## 1.3.2rc1 (2017-03-10)
### Improvements
- [#732](https://github.com/foosel/OctoPrint/pull/732) - Have OctoPrint's `python setup.py clean` build on stock
`python setup.py clean` for better compatibility with packaging systems
- [#1506](https://github.com/foosel/OctoPrint/issues/1506) - Better handle really long "dwell"/`G4` commands on Repetier firmware (as for example apparently recommended to use with Wanhao D6 and similar printers for nozzle cooling) by actively stalling communication from OctoPrint's side as well. That way we no longer run into a communication timeout produced by a 5min dwell immediately happily acknowledged by the printer with an `ok`.
- [#1542](https://github.com/foosel/OctoPrint/issues/1542) - Support for multi-extruder setups with a shared single nozzle and heater (e.g. E3D Cyclops, Diamond hotend, etc).
- [#1712](https://github.com/foosel/OctoPrint/issues/1712) - Display current folder name in file list if in sub folder.
- [#1723](https://github.com/foosel/OctoPrint/issues/1723) - Ignore leading `v` or `V` on plugin version numbers for version checks in plugin manager and software updater (see also [#1724](https://github.com/foosel/OctoPrint/pull/1724))
- [#1770](https://github.com/foosel/OctoPrint/issues/1770) - Better resilience against null bytes received from the printer for whatever reason.
- [#1770](https://github.com/foosel/OctoPrint/issues/1770) - Detect printer as connected even when only receiving a `wait` instead of `ok`. Should solve issues with initial connect where printer sends garbage over the line that eats/covers the `ok` if printer also sends regular `wait` messages when idle.
- [#1780](https://github.com/foosel/OctoPrint/issues/1780) - Work around for Safari re-opening one copy of the webcam stream after the other and eating up bandwidth unnecessarily (see also [#1786](https://github.com/foosel/OctoPrint/issues/1786))
- [#1790](https://github.com/foosel/OctoPrint/issues/1790) - Removed unused "color" property from printer profile editor.
- [#1805](https://github.com/foosel/OctoPrint/issues/1805) - Better error resilience against invalid print history data from plugins that replace the printer communication.
- Better error resilience in Plugin Manager against wonky version data in repository file.
- Added a "Restart in safe mode" system menu entry that will always be available if the restart command is configured
- CLI: Only offer `daemon` sub command on Linux (since that it's the only OS it works on)
- Less throttling of analysis of GCODE files from the analysis backlog. Should still leave Pi and friends air to breathe but allow a slightly faster processing of the backlog.
- Added an explanation of safe mode to the docs.
### Bug fixes
- [#733](https://github.com/foosel/OctoPrint/issues/733) - Fixed multiple event handler commands running concurrently. Now they run one after the other, as expected.
- [#1317](https://github.com/foosel/OctoPrint/issues/1317) - Fixed a color distortion issue when rendering timelapses from higher resolution source snapshots that also need to be rotated by adjusting `ffmpeg` parameters to avoid an unexpected behaviour when a pixel format and a filter chain are required for processing.
- [#1631](https://github.com/foosel/OctoPrint/issues/1631) - Disable "Slice" button in slice dialog if a print is ongoing and a slicer is selected that runs on the same device as OctoPrint. The server would already deny such requests (simply due to performance reasons), but the UI didn't properly reflect that yet.
- [#1671](https://github.com/foosel/OctoPrint/issues/1671) - Removed "Hide empty folders" option from file list. Didn't really add value and caused usability issues.
- [#1771](https://github.com/foosel/OctoPrint/issues/1771) - Fixed `_config_version` in plugin settings not being properly updated.
- [#1732](https://github.com/foosel/OctoPrint/issues/1732) - Fixed a bug in the documentation for the printer profile API
- [#1760](https://github.com/foosel/OctoPrint/issues/1760) - Fixed missing reselect of selected file when updating via the watched folder, causing wrong progress percentages to be reported.
- [#1765](https://github.com/foosel/OctoPrint/issues/1765) - Fixed watched folder not waiting with file move until file stopped growing, causing wrong progress percentages to be reported.
- [#1777](https://github.com/foosel/OctoPrint/issues/1777) - Fixed z-change based timelapses with Slic3r generated z-hops not properly triggering snapshots.
- [#1792](https://github.com/foosel/OctoPrint/issues/1792) - Don't tell Safari we are "web-app-capable" because that means it will throw away all cookies and the user will have to constantly log in again when using a desktop shortcut for the OctoPrint instance.
- [#1812](https://github.com/foosel/OctoPrint/issues/1812) - Don't scroll up navigation in settings when switching between settings screens, very annoying on smaller resolutions (see also [#1814](https://github.com/foosel/OctoPrint/pull/1814))
- Fix settings helper not allowing to delete values for keys that are present in the local config but not in the defaults.
- Various fixes in the Software Update Plugin:
- Don't remove manual software update configurations on settings migration.
- Properly delete old restart/reboot commands that are now defined globally since config version 4. An issue with the settings helper prevented us from properly deleting them during migration to version 4.
- Fixed `python_checker` version check method and `python_updater` update method.
- Fixed update configs without a restart of any kind causing an issue due to an undefined variable.
- Fixed broken doctests.
- Upgrade LESS.min.js from 2.7.1 to 2.7.2 to fix the broken contrast function
([Commits](https://github.com/foosel/OctoPrint/compare/1.3.1...1.3.2rc1))
## 1.3.1 (2017-01-25)
### Note for upgraders
@@ -23,6 +68,7 @@
- New "Suppress wait responses" filter: `Recv: wait`
### Bug fixes
- [#1344](https://github.com/foosel/OctoPrint/issues/1344) - Fix ProgressBarPlugins to not correctly be triggered for 0% (second try, this time hopefully for good).
- [#1637](https://github.com/foosel/OctoPrint/issues/1637) - Fix issue preventing a folder to be deleted that has a name which is a common prefix of the file currently being printed.
- [#1641](https://github.com/foosel/OctoPrint/issues/1641) - Fix issue with `octoprint --daemon` not working.
+10 -4
View File
@@ -93,11 +93,15 @@ following section *completely* and also follow the instructions in the
2. Please make sure to **test out the current version** of OctoPrint to see
whether the problem you are encountering still exists, and **test without
any non-bundled plugins enabled** to make sure it's not a misbehaving
plugin causing the issue at hand.
any third-party plugins enabled** to make sure it's not a misbehaving
plugin causing the issue at hand. For that please restart OctoPrint in
**safe mode**, either by selecting "Restart OctoPrint in safe mode" from
the "System" menu, or by starting OctoPrint from the command line with
`octoprint serve --safe`. Then try to reproduce your issue. Find out
more about safe mode in the [docs](http://docs.octoprint.org/en/master/features/safemode.html).
If you are feeling up to it you might also want to try the current development
version of OctoPrint (if you aren't already). Refer to the [FAQ](https://github.com/foosel/OctoPrint/wiki/FAQ)
You might also want to try the current development version of OctoPrint
(if you aren't already). Refer to the [FAQ](https://github.com/foosel/OctoPrint/wiki/FAQ)
for information on how to do this.
3. The problem still exists? Then please **look through the
@@ -399,6 +403,8 @@ the local version identifier to allow for an exact determination of the active c
experiences
* 2017-01-25: Fixed a typo
* 2017-03-09: Allow PRs against `maintenance` branch for bugs in stable.
* 2017-03-10: Reproduce bugs in safe mode to make sure they are really caused
by OctoPrint itself and not a misbehaving plugin.
## Footnotes
* [1] - If you are wondering why, the problem is that anything that you add
+10 -3
View File
@@ -1,6 +1,8 @@
# OctoPrint
OctoPrint provides a snappy web interface for controlling a 3D printer (RepRap, Ultimaker, ...). It is Free Software
[![GitHub version](https://badge.fury.io/gh/foosel%2FOctoPrint.svg)](https://badge.fury.io/gh/foosel%2FOctoPrint)
OctoPrint provides a snappy web interface for controlling consumer 3D printers. It is Free Software
and released under the [GNU Affero General Public License V3](http://www.gnu.org/licenses/agpl.html).
Its website can be found at [octoprint.org](http://octoprint.org).
@@ -33,7 +35,7 @@ If you think something is bad about OctoPrint or its documentation the way it is
in any way to make it better instead of just complaining about it -- this is an Open Source Project
after all :)
For information about how to go about making contributions of any kind, please see the project's
For information about how to go about submitting bug reports or pull requests, please see the project's
[Contribution Guidelines](https://github.com/foosel/OctoPrint/blob/master/CONTRIBUTING.md).
## Installation
@@ -108,7 +110,12 @@ e.g.:
octoprint serve --config /path/to/another/config.yaml --basedir /path/to/my/basedir
See `octoprint --help` for further information.
To start OctoPrint in safe mode - which disables all third party plugins that do not come bundled with OctoPrint - use
the ``--safe`` flag:
octoprint serve --safe
See `octoprint --help` for more information on the available command line parameters.
OctoPrint also ships with a `run` script in its source directory. You can invoke it to start the server. It
takes the same command line arguments as the `octoprint` script.
+4 -6
View File
@@ -10,14 +10,12 @@ thanks to everyone who contributed!
* Aleph Objects, Inc.
* Andrew Moorby
* Arnljot Arntsen
* Aurelio Bernal
* Boris Hussein
* Brad Jackson
* Brent Fiegle
* Brian E. Tyler
* Christopher Day
* Christian Petropolis
* COLLE+McVOY
* CreativeTools
* D Brian Kimmel
* DeltaMaker 3D Printers
@@ -29,10 +27,10 @@ thanks to everyone who contributed!
* Gary Deen
* Gary N McKinney
* George Robles
* J. Eckert
* James Seigel
* Jamie van Dyke
* Jeff Moe
* Josh Daniels
* Joshua David Gregory
* Kaile Riser
* Kale Stedman
* Kazuhiro Ogura
@@ -44,6 +42,7 @@ thanks to everyone who contributed!
* Masayoshi Mitsui
* Michael Aumock
* Miles Flavel
* Mohammed khorakiwala
* Noe Ruiz
* Patrick McGinnis
* Peter Grace
@@ -58,11 +57,10 @@ thanks to everyone who contributed!
* Simon Hallam
* Stefan Krister
* Stephane Schittly
* Steven Pearson
* Sven Mueller
* Terrance Shaw
* Thomas Hatley
* Timeshell.ca
* Trent Shumay
and 1016 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
and 1041 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
+20
View File
@@ -68,6 +68,23 @@ Save settings
// ...
}
.. _sec-api-settings-generateapikey:
Regenerate the system wide API key
==================================
.. http:post:: /api/settings/apikey
Generates a new system wide API key.
Does not expect a body. Will return the generated API key as ``apikey``
property in the JSON object contained in the response body.
Requires admin rights.
:status 200: No error
:status 403: No admin rights
.. _sec-api-settings-datamodel:
Data model
@@ -87,6 +104,9 @@ mapped from the same fields in ``config.yaml`` unless otherwise noted:
-
* - ``api.key``
- Only maps to ``api.key`` in ``config.yaml`` if request is sent with admin rights, set to ``n/a`` otherwise.
Starting with OctoPrint 1.3.3 setting this field via :ref:`the API <sec-api-settings-save>` is not possible,
only :ref:`regenerting it <sec-api-settings-generateapikey>` is supported. Setting a custom value is only
possible through `config.yaml`.
* - ``api.allowCrossOrigin``
-
* - ``appearance.name``
+6 -2
View File
@@ -829,10 +829,14 @@ Use the following settings to configure the server:
# Use this option to define the port to which to bind the server, defaults to 5000
port: 5000
# If this option is true, OctoPrint will show the First Run dialog and set it to false after that
# completes
# If this option is true, OctoPrint will show the First Run wizard and set the setting to
# false after that completes
firstRun: false
# If this option is true, OctoPrint will enable safe mode on the next server start and
# reset the setting to false
startOnceInSafeMode: false
# Secret key for encrypting cookies and such, randomly generated on first run
secretKey: someSecretKey
+1
View File
@@ -16,3 +16,4 @@ Features
gcode_scripts.rst
action_commands.rst
plugins.rst
safemode.rst
+10
View File
@@ -11,6 +11,16 @@ Right now plugins can be used to extend OctoPrint's web interface, to execute sp
shutdown, to provide custom (API) endpoints or whole user interfaces with special functionality, to react to system
events or progress reports or to add support for additional slicers. More plugin types are planned for the future.
.. note::
Since a plugin might not function properly and cause issues that are hard to diagnose or outright disrupt server
functionality, you might want to be able to start OctoPrint without any third party plugins enabled. This is also
very important when reporting bugs in OctoPrint, to ensure that what you are observing is actually a bug in
OctoPrint and not in any of your installed third party plugins.
To do that, OctoPrint has a built-in safe mode that disables all plugins not shipped as part of OctoPrint. You can
read more on how to enable that :ref:`here <sec-features-safemode>`.
.. _sec-features-plugins-available:
Finding Plugins
+64
View File
@@ -0,0 +1,64 @@
.. _sec-features-safemode:
*********
Safe mode
*********
With the advent of support for plugins in OctoPrint, it quickly became apparent that some of the bugs
reported on OctoPrint's bug tracker were actually bugs with installed third party plugins instead of
OctoPrint itself.
To allow an easier identification of these cases, OctoPrint 1.3.0 introduced safe mode. Starting
OctoPrint in safe mode disables all plugins that are not bundled with OctoPrint, allowing to easier
identify most cases where a third party plugin is the culprit of an observed issue.
Additionally, OctoPrint allows uninstalling plugins in this mode, allowing recovery from cases where
a third party plugin causes the server to not start up or the web interface to not render or function
correctly anymore.
.. _sec-features-safemode-how:
How to start OctoPrint in safe mode
===================================
There exist three ways to start OctoPrint in safe mode:
* since OctoPrint 1.3.2: by selecting "Restart OctoPrint in safe mode" from the "System" menu,
if the "Restart OctoPrint" server command has been correctly configured (see :numref:`fig-features-safemode-systemmenu`).
* by starting OctoPrint with the command line parameter ``--safe``, e.g. ``octoprint serve --safe``
* by setting the option ``server.startOnceInSafeMode`` in :ref:`config.yaml <sec-configuration-config_yaml>`
to ``true`` and restarting
The last two options will have OctoPrint enable safe mode only for the next server start - once you
restart OctoPrint again, safe mode will be disabled again.
.. _fig-features-safemode-systemmenu:
.. figure:: ../images/features-safemode-systemmenu.png
:align: center
:alt: "Restart OctoPrint in safe mode" in the "System" menu
"Restart OctoPrint in safe mode" in the "System" menu
.. _sec-features-safemode-differences:
Differences of safe mode vs normal operation mode
=================================================
When OctoPrint is running in safe mode the following changes to its normal operation mode apply:
* OctoPrint will not enable any of the installed third party plugins. OctoPrint considers all plugins third
party plugins that do not ship with OctoPrint's sources, so any plugins installed either via `pip` or
into OctoPrint's plugin folder at ``~/.octoprint/plugins`` (Linux), ``%APPDATA%/OctoPrint`` (Windows) and
``~/Library/Application Support/OctoPrint`` (MacOS).
* OctoPrint will still allow to uninstall third party plugins through the built-in Plugin Manager.
* OctoPrint will still allow to disable (bundled) plugins that are still enabled.
* OctoPrint will not allow to enable third party plugins.
* OctoPrint's web interface will display a persistent notification to remind you that it is running in
safe mode.
.. _fig-features-safemode-notification:
.. figure:: ../images/features-safemode-notification.png
:align: center
:alt: Persistent safe mode notification
Persistent safe mode notification
Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

+7
View File
@@ -35,6 +35,13 @@
:param object opts: Additional options for the request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
.. js:function:: OctoPrintClient.settings.generateApiKey(opts)
Generate a new system wide API key.
:param object opts: Additional options for the request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
.. seealso::
:ref:`Settings API <sec-api-settings>`
@@ -705,7 +705,10 @@ $(function() {
}
};
self._forcedStdoutLine = /You are using pip version .*?, however version .*? is available\.|You should consider upgrading via the '.*?' command\./;
self._forcedStdoutPatterns = ["You are using pip version .*?, however version .*? is available\.",
"You should consider upgrading via the '.*?' command\.",
"'.*?' does not exist -- can't clean it"];
self._forcedStdoutLine = new RegExp(self._forcedStdoutPatterns.join("|"));
self._preprocessLine = function(line) {
if (line.stream == "stderr" && line.line.match(self._forcedStdoutLine)) {
line.stream = "stdout";
+19 -3
View File
@@ -15,7 +15,7 @@ from octoprint.events import eventManager, Events
from octoprint.settings import settings, valid_boolean_trues
from octoprint.server import admin_permission, printer
from octoprint.server.api import api
from octoprint.server.api import api, NO_CONTENT
from octoprint.server.util.flask import restricted_access, with_revalidation_checking
import octoprint.plugin
@@ -83,7 +83,7 @@ def getSettings():
data = {
"api": {
"enabled": s.getBoolean(["api", "enabled"]),
"key": s.get(["api", "key"]) if admin_permission.can() else "n/a",
"key": s.get(["api", "key"]) if admin_permission.can() else None,
"allowCrossOrigin": s.get(["api", "allowCrossOrigin"])
},
"appearance": {
@@ -261,6 +261,23 @@ def setSettings():
_saveSettings(data)
return getSettings()
@api.route("/settings/apikey", methods=["POST"])
@restricted_access
@admin_permission.require(403)
def generateApiKey():
apikey = settings().generateApiKey()
return jsonify(apikey=apikey)
@api.route("/settings/apikey", methods=["DELETE"])
@restricted_access
@admin_permission.require(403)
def deleteApiKey():
settings().deleteApiKey()
return NO_CONTENT
def _saveSettings(data):
logger = logging.getLogger(__name__)
@@ -271,7 +288,6 @@ def _saveSettings(data):
if "api" in data.keys():
if "enabled" in data["api"].keys(): s.setBoolean(["api", "enabled"], data["api"]["enabled"])
if "key" in data["api"].keys(): s.set(["api", "key"], data["api"]["key"], True)
if "allowCrossOrigin" in data["api"].keys(): s.setBoolean(["api", "allowCrossOrigin"], data["api"]["allowCrossOrigin"])
if "appearance" in data.keys():
+12 -2
View File
@@ -557,8 +557,7 @@ class Settings(object):
self.load(migrate=True)
if self.get(["api", "key"]) is None:
self.set(["api", "key"], ''.join('%02X' % z for z in bytes(uuid.uuid4().bytes)))
self.save(force=True)
self.generateApiKey()
self._script_env = self._init_script_templating()
@@ -1497,6 +1496,17 @@ class Settings(object):
with atomic_write(filename, "wb", max_permissions=0o666) as f:
f.write(script)
def generateApiKey(self):
apikey = ''.join('%02X' % z for z in bytes(uuid.uuid4().bytes))
self.set(["api", "key"], apikey)
self.save(force=True)
return apikey
def deleteApiKey(self):
self.set(["api", "key"], None)
self.save(force=True)
def _default_basedir(applicationName):
# taken from http://stackoverflow.com/questions/1084697/how-do-i-store-desktop-application-data-in-a-cross-platform-way-for-python
if sys.platform == "darwin":
+1 -1
View File
@@ -1 +1 @@
.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn.active,.btn:active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:focus,.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class*=" icon-"],.btn-large [class^=icon-]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class*=" icon-"],.btn-small [class^=icon-]{margin-top:0}.btn-mini [class*=" icon-"],.btn-mini [class^=icon-]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type=submit].btn-block,input[type=reset].btn-block,input[type=button].btn-block{width:100%}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary.active,.btn-primary:active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning.active,.btn-warning:active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#da4f49;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-repeaLine truncated
.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn.active,.btn:active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:focus,.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class*=" icon-"],.btn-large [class^=icon-]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class*=" icon-"],.btn-small [class^=icon-]{margin-top:0}.btn-mini [class*=" icon-"],.btn-mini [class^=icon-]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type=submit].btn-block,input[type=reset].btn-block,input[type=button].btn-block{width:100%}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary.active,.btn-primary:active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning.active,.btn-warning:active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#da4f49;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-repeaLine truncated
@@ -6,6 +6,7 @@
}
})(this, function(OctoPrintClient, $) {
var url = "api/settings";
var apiKeyUrl = url + "/apikey";
var OctoPrintSettingsClient = function(base) {
this.base = base;
@@ -40,6 +41,10 @@
return this.save(data, opts);
};
OctoPrintSettingsClient.prototype.generateApiKey = function (opts) {
return this.base.postJson(apiKeyUrl, opts);
};
OctoPrintClient.registerComponent("settings", OctoPrintSettingsClient);
return OctoPrintSettingsClient;
});
@@ -309,10 +309,6 @@ $(function() {
});
};
self.onSettingsShown = function() {
self.requestData();
};
self.onSettingsHidden = function() {
self.webcam_ffmpegPathReset();
};
@@ -419,6 +415,19 @@ $(function() {
self.settingsDialog.modal("hide");
};
self.generateApiKey = function() {
if (!CONFIG_ACCESS_CONTROL) return;
showConfirmationDialog(gettext("This will generate a new API Key. The old API Key will cease to function immediately."),
function() {
OctoPrint.settings.generateApiKey()
.done(function(response) {
self.api_key(response.apikey);
self.requestData();
});
});
};
self.showTranslationManager = function() {
self.translationManagerDialog.modal();
return false;
@@ -833,6 +842,16 @@ $(function() {
// better refresh them now
self.requestData();
};
self.onUserLoggedIn = function() {
// we might have other user rights now, refresh
self.requestData();
};
self.onUserLoggedOut = function() {
// we might have other user rights now, refresh
self.requestData();
}
}
OCTOPRINT_VIEWMODELS.push([
@@ -71,16 +71,32 @@ $(function() {
self.generateApikey = function() {
if (!CONFIG_ACCESS_CONTROL) return;
self.users.generateApikey(self.currentUser().name, function(response) {
self.access_apikey(response.apikey);
});
var generate = function() {
self.users.generateApikey(self.currentUser().name)
.done(function(response) {
self.access_apikey(response.apikey);
});
};
if (self.access_apikey()) {
showConfirmationDialog(gettext("This will generate a new API Key. The old API Key will cease to function immediately."),
generate);
} else {
generate();
}
};
self.deleteApikey = function() {
if (!CONFIG_ACCESS_CONTROL) return;
self.users.deleteApikey(self.currentUser().name, function() {
self.access_apikey(undefined);
});
if (!self.access_apikey()) return;
showConfirmationDialog(gettext("This will delete the API Key. It will cease to to function immediately."), function() {
self.users.deleteApikey(self.currentUser().name)
.done(function() {
self.access_apikey(undefined);
});
})
};
self.updateSettings = function(username, settings) {
+2 -2
View File
@@ -94,11 +94,11 @@ body {
}
.nav {
li.dropdown.open>.dropdown-toggle, li.dropdown.active>.dropdown-toggle, li.dropdown.open.active>.dropdown-toggle {
>li.dropdown.open>.dropdown-toggle, >li.dropdown.active>.dropdown-toggle, >li.dropdown.open.active>.dropdown-toggle {
// invert for dropdown
.navbar-background-color(fade(@bottom, @gradientalpha), fade(@top, @gradientalpha), @image);
}
li>a:hover {
>li>a:hover {
// darken for hover
@darkenedTop: darken(@top, 5%);
@darkenedBottom: darken(@bottom, 5%);
@@ -16,10 +16,14 @@
<div class="control-group">
<label class="control-label" for="settings-apiKey">{{ _('API Key') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: api_key, valueUpdate: 'afterkeydown'" id="settings-apikey">
<div class="input-append">
<input type="text" class="input-block-level" disabled="disabled" id="settings-apikey" data-bind="value: api_key, attr: {placeholder: '{{ _('N/A') }}'}">
<button class="btn" title="Generate new API Key" data-bind="click: generateApiKey, enable: api_key"><i class="icon-refresh"></i></button>
</div>
<span class="help-block">{{ _('Please note that changes to the API key are applied immediately, without having to "Save" first.') }}</span>
</div>
</div>
<div class="control-group">
<div class="control-group" data-bind="visible: api_key">
<label class="control-label">{{ _('QR Code') }}</label>
<div class="controls">
<div data-bind="qrcode: {text: api_key, size: 180}"></div>
@@ -24,14 +24,14 @@
<label class="control-label" for="userSettings-access_apikey">{{ _('Current API Key') }}</label>
<div class="controls">
<div class="input-append">
<input type="text" class="input-block-level uneditable-input" id="userSettings-access_apikey" data-bind="value: access_apikey, valueUpdate: 'input', attr: {placeholder: '{{ _('N/A') }}'}">
<a class="btn" title="Generate new Apikey" data-bind="click: generateApikey"><i class="icon-refresh"></i></a>
<a class="btn btn-danger" title="Delete Apikey" data-bind="click: deleteApikey"><i class="icon-trash"></i></a>
<input type="text" class="input-block-level" disabled="disabled" id="userSettings-access_apikey" data-bind="value: access_apikey, attr: {placeholder: '{{ _('N/A') }}'}">
<button class="btn" title="Generate new API Key" data-bind="click: generateApikey"><i class="icon-refresh"></i></button>
<button class="btn btn-danger" title="Delete API Key" data-bind="click: deleteApikey, enable: access_apikey"><i class="icon-trash"></i></button>
</div>
<span class="help-block">{{ _('Please note that changes to the API key are applied immediately, without having to "Confirm" first.') }}</span>
</div>
</div>
<div class="control-group">
<div class="control-group" data-bind="visible: access_apikey">
<label class="control-label">{{ _('QR Code') }}</label>
<div class="controls">
<div data-bind="qrcode: {text: access_apikey, size: 150}"></div>
File diff suppressed because it is too large. Load diff
+134 -125
View File
@@ -393,7 +393,7 @@ class MachineCom(object):
self._currentFile = None
# multithreading locks
self._sendNextLock = threading.Lock()
self._jobLock = threading.RLock()
self._sendingLock = threading.RLock()
# monitoring thread
@@ -749,41 +749,42 @@ class MachineCom(object):
self._pauseWaitTimeLost = 0.0
try:
self._currentFile.start()
with self._jobLock:
self._currentFile.start()
self._changeState(self.STATE_PRINTING)
self._changeState(self.STATE_PRINTING)
self.resetLineNumbers()
self.resetLineNumbers()
self._callback.on_comm_print_job_started()
self._callback.on_comm_print_job_started()
if self.isSdFileSelected():
#self.sendCommand("M26 S0") # setting the sd pos apparently sometimes doesn't work, so we re-select
# the file instead
if self.isSdFileSelected():
#self.sendCommand("M26 S0") # setting the sd pos apparently sometimes doesn't work, so we re-select
# the file instead
# make sure to ignore the "file selected" later on, otherwise we'll reset our progress data
self._ignore_select = True
self.sendCommand("M23 {filename}".format(filename=self._currentFile.getFilename()))
if pos is not None and isinstance(pos, int) and pos > 0:
self._currentFile.setFilepos(pos)
self.sendCommand("M26 S{}".format(pos))
# make sure to ignore the "file selected" later on, otherwise we'll reset our progress data
self._ignore_select = True
self.sendCommand("M23 {filename}".format(filename=self._currentFile.getFilename()))
if pos is not None and isinstance(pos, int) and pos > 0:
self._currentFile.setFilepos(pos)
self.sendCommand("M26 S{}".format(pos))
else:
self._currentFile.setFilepos(0)
self.sendCommand("M24")
self._sd_status_timer = RepeatedTimer(self._timeout_intervals.get("sdStatus", 1.0), self._poll_sd_status, run_first=True)
self._sd_status_timer.start()
else:
self._currentFile.setFilepos(0)
if pos is not None and isinstance(pos, int) and pos > 0:
self._currentFile.seek(pos)
self.sendCommand("M24")
line = self._getNext()
if line is not None:
self.sendCommand(line)
self._sd_status_timer = RepeatedTimer(self._timeout_intervals.get("sdStatus", 1.0), self._poll_sd_status, run_first=True)
self._sd_status_timer.start()
else:
if pos is not None and isinstance(pos, int) and pos > 0:
self._currentFile.seek(pos)
line = self._getNext()
if line is not None:
self.sendCommand(line)
# now make sure we actually do something, up until now we only filled up the queue
self._sendFromQueue()
# now make sure we actually do something, up until now we only filled up the queue
self._sendFromQueue()
except:
self._logger.exception("Error while trying to start printing")
self._errorValue = get_exception_string()
@@ -792,17 +793,18 @@ class MachineCom(object):
def startFileTransfer(self, filename, localFilename, remoteFilename):
if not self.isOperational() or self.isBusy():
logging.info("Printer is not operation or busy")
logging.info("Printer is not operational or busy")
return
self.resetLineNumbers()
with self._jobLock:
self.resetLineNumbers()
self._currentFile = StreamingGcodeFileInformation(filename, localFilename, remoteFilename)
self._currentFile.start()
self._currentFile = StreamingGcodeFileInformation(filename, localFilename, remoteFilename)
self._currentFile.start()
self.sendCommand("M28 %s" % remoteFilename)
eventManager().fire(Events.TRANSFER_STARTED, {"local": localFilename, "remote": remoteFilename})
self._callback.on_comm_file_transfer_started(remoteFilename, self._currentFile.getFilesize())
self.sendCommand("M28 %s" % remoteFilename)
eventManager().fire(Events.TRANSFER_STARTED, {"local": localFilename, "remote": remoteFilename})
self._callback.on_comm_file_transfer_started(remoteFilename, self._currentFile.getFilesize())
def selectFile(self, filename, sd):
if self.isBusy():
@@ -841,18 +843,6 @@ class MachineCom(object):
# we aren't even printing, nothing to cancel...
return
self._changeState(self.STATE_OPERATIONAL)
if self.isSdFileSelected():
self.sendCommand("M25") # pause print
self.sendCommand("M27") # get current byte position in file
self.sendCommand("M26 S0") # reset position in file to byte 0
if self._sd_status_timer is not None:
try:
self._sd_status_timer.cancel()
except:
pass
def _on_M400_sent():
# we don't call on_print_job_cancelled on our callback here
# because we do this only after our M114 has been answered
@@ -860,7 +850,20 @@ class MachineCom(object):
self._record_cancel_position = True
self.sendCommand("M114")
self.sendCommand("M400", on_sent=_on_M400_sent)
with self._jobLock:
self._changeState(self.STATE_OPERATIONAL)
if self.isSdFileSelected():
self.sendCommand("M25") # pause print
self.sendCommand("M27") # get current byte position in file
self.sendCommand("M26 S0") # reset position in file to byte 0
if self._sd_status_timer is not None:
try:
self._sd_status_timer.cancel()
except:
pass
self.sendCommand("M400", on_sent=_on_M400_sent)
def _pause_preparation_done(self):
self._callback.on_comm_print_job_paused()
@@ -872,41 +875,42 @@ class MachineCom(object):
if not self._currentFile:
return
if not pause and self.isPaused():
if self._pauseWaitStartTime:
self._pauseWaitTimeLost = self._pauseWaitTimeLost + (time.time() - self._pauseWaitStartTime)
self._pauseWaitStartTime = None
with self._jobLock:
if not pause and self.isPaused():
if self._pauseWaitStartTime:
self._pauseWaitTimeLost = self._pauseWaitTimeLost + (time.time() - self._pauseWaitStartTime)
self._pauseWaitStartTime = None
self._changeState(self.STATE_PRINTING)
self._callback.on_comm_print_job_resumed()
self._changeState(self.STATE_PRINTING)
self._callback.on_comm_print_job_resumed()
if self.isSdFileSelected():
self.sendCommand("M24")
self.sendCommand("M27")
else:
line = self._getNext()
if line is not None:
self.sendCommand(line)
if self.isSdFileSelected():
self.sendCommand("M24")
self.sendCommand("M27")
else:
line = self._getNext()
if line is not None:
self.sendCommand(line)
# now make sure we actually do something, up until now we only filled up the queue
self._sendFromQueue()
# now make sure we actually do something, up until now we only filled up the queue
self._sendFromQueue()
elif pause and self.isPrinting():
if not self._pauseWaitStartTime:
self._pauseWaitStartTime = time.time()
elif pause and self.isPrinting():
if not self._pauseWaitStartTime:
self._pauseWaitStartTime = time.time()
self._changeState(self.STATE_PAUSED)
if self.isSdFileSelected():
self.sendCommand("M25") # pause print
self._changeState(self.STATE_PAUSED)
if self.isSdFileSelected():
self.sendCommand("M25") # pause print
def _on_M400_sent():
# we don't call on_print_job_paused on our callback here
# because we do this only after our M114 has been answered
# by the firmware
self._record_pause_position = True
self.sendCommand("M114")
def _on_M400_sent():
# we don't call on_print_job_paused on our callback here
# because we do this only after our M114 has been answered
# by the firmware
self._record_pause_position = True
self.sendCommand("M114")
self.sendCommand("M400", on_sent=_on_M400_sent)
self.sendCommand("M400", on_sent=_on_M400_sent)
def getSdFiles(self):
return self._sdFiles
@@ -1844,7 +1848,7 @@ class MachineCom(object):
return line
def _sendNext(self):
with self._sendNextLock:
with self._jobLock:
while self._active:
# we loop until we've actually enqueued a line for sending
if self._state != self.STATE_PRINTING:
@@ -2608,6 +2612,7 @@ class PrintingGcodeFileInformation(PrintingFileInformation):
PrintingFileInformation.__init__(self, filename)
self._handle = None
self._handle_mutex = threading.RLock()
self._offsets_callback = offsets_callback
self._current_tool_callback = current_tool_callback
@@ -2619,76 +2624,80 @@ class PrintingGcodeFileInformation(PrintingFileInformation):
self._read_lines = 0
def seek(self, offset):
if self._handle is None:
return
with self._handle_mutex:
if self._handle is None:
return
self._handle.seek(offset)
self._pos = self._handle.tell()
self._read_lines = 0
self._handle.seek(offset)
self._pos = self._handle.tell()
self._read_lines = 0
def start(self):
"""
Opens the file for reading and determines the file size.
"""
PrintingFileInformation.start(self)
self._handle = bom_aware_open(self._filename, encoding="utf-8", errors="replace")
self._pos = self._handle.tell()
if self._handle.encoding.endswith("-sig"):
# Apparently we found an utf-8 bom in the file.
# We need to add its length to our pos because it will
# be stripped transparently and we'll have no chance
# catching that.
import codecs
self._pos += len(codecs.BOM_UTF8)
self._read_lines = 0
with self._handle_mutex:
self._handle = bom_aware_open(self._filename, encoding="utf-8", errors="replace")
self._pos = self._handle.tell()
if self._handle.encoding.endswith("-sig"):
# Apparently we found an utf-8 bom in the file.
# We need to add its length to our pos because it will
# be stripped transparently and we'll have no chance
# catching that.
import codecs
self._pos += len(codecs.BOM_UTF8)
self._read_lines = 0
def close(self):
"""
Closes the file if it's still open.
"""
PrintingFileInformation.close(self)
if self._handle is not None:
try:
self._handle.close()
except:
pass
self._handle = None
with self._handle_mutex:
if self._handle is not None:
try:
self._handle.close()
except:
pass
self._handle = None
def getNext(self):
"""
Retrieves the next line for printing.
"""
if self._handle is None:
raise ValueError("File %s is not open for reading" % self._filename)
with self._handle_mutex:
if self._handle is None:
raise ValueError("File %s is not open for reading" % self._filename)
try:
offsets = self._offsets_callback() if self._offsets_callback is not None else None
current_tool = self._current_tool_callback() if self._current_tool_callback is not None else None
try:
offsets = self._offsets_callback() if self._offsets_callback is not None else None
current_tool = self._current_tool_callback() if self._current_tool_callback is not None else None
processed = None
while processed is None:
if self._handle is None:
# file got closed just now
self._pos = self._size
self._report_stats()
return None
processed = None
while processed is None:
if self._handle is None:
# file got closed just now
self._pos = self._size
self._report_stats()
return None
# we need to manually keep track of our pos here since
# codecs' readline will make our handle's tell not
# return the actual number of bytes read, but also the
# already buffered bytes (for detecting the newlines)
line = self._handle.readline()
self._pos += len(line.encode("utf-8"))
# we need to manually keep track of our pos here since
# codecs' readline will make our handle's tell not
# return the actual number of bytes read, but also the
# already buffered bytes (for detecting the newlines)
line = self._handle.readline()
self._pos += len(line.encode("utf-8"))
if not line:
self.close()
processed = self._process(line, offsets, current_tool)
self._read_lines += 1
return processed
except Exception as e:
self.close()
self._logger.exception("Exception while processing line")
raise e
if not line:
self.close()
processed = self._process(line, offsets, current_tool)
self._read_lines += 1
return processed
except Exception as e:
self.close()
self._logger.exception("Exception while processing line")
raise e
def _process(self, line, offsets, current_tool):
return process_gcode_line(line, offsets=offsets, current_tool=current_tool)
-4
View File
@@ -370,10 +370,6 @@ class PipCaller(CommandlineCaller):
def _preprocess_lines(self, *lines):
return map(self._preprocess, lines)
@staticmethod
def _convert_lines(lines):
return map(PipCaller._convert_line, lines)
@staticmethod
def _preprocess(text):
"""
+2
View File
@@ -267,6 +267,7 @@ class RefreshTranslation(Command):
self.babel_update_messages.input_file = self.__class__.pot_file
self.babel_update_messages.output_dir = self.__class__.output_dir
self.babel_update_messages.locale = self.locale
self.babel_update_messages.finalize_options()
def run(self):
self.babel_extract_messages.run()
@@ -299,6 +300,7 @@ class CompileTranslation(Command):
def finalize_options(self):
self.babel_compile_messages.directory = self.__class__.output_dir
self.babel_compile_messages.finalize_options()
def run(self):
self.babel_compile_messages.run()
+86
View File
@@ -0,0 +1,86 @@
# coding=utf-8
from __future__ import print_function
"""
Place in ~/.octoprint/plugins & restart server to test:
* python_checker and python_updater mechanism
* demotion of pip and python setup.py clean output that
gets written to stderr but isn't as severe as that would
look
Plugin will always demand to update itself, multiple
consecutive runs are not a problem.
"""
import time
NAME = "Always Update"
OLD_VERSION = "1.0.0"
NEW_VERSION = "2.0.0"
class Foo(object):
def get_latest(self, target, check, full_data=None):
information = dict(local=dict(name=OLD_VERSION, value=OLD_VERSION),
remote=dict(name=NEW_VERSION, value=NEW_VERSION))
current = False
return information, current
def can_perform_update(self, target, check):
return True
def perform_update(self, target, check, target_version, log_cb=None):
if not callable(log_cb):
import sys
def log_cb(lines, prefix=None, stream=None, strip=True):
if stream == "stdout":
f = sys.stdout
elif stream == "stderr":
f = sys.stderr
else:
f = None
for line in lines:
print(line, file=f)
log_cb(["Updating Always Update..."])
time.sleep(1)
log_cb(["running clean",
"recursively removing *.pyc from 'src'"],
stream="stdout")
log_cb(["'build/lib' does not exist -- can't clean it",
"'build/bdist.win32' does not exist -- can't clean it",
"'build/scripts-2.7' does not exist -- can't clean it"],
stream="stderr")
log_cb(["removing 'Development\OctoPrint\OctoPrint\src\octoprint_setuptools\__init__.pyc'"],
stream="stdout")
time.sleep(1)
log_cb(["This should be red"],
stream="stderr")
log_cb(["You are using pip version 7.1.2, however version 9.0.1 is available.",
"You should consider upgrading via the 'python -m pip install --upgrade pip' command."],
stream="stderr")
time.sleep(3)
log_cb(["Done!"])
def get_update_information():
foo = Foo()
return dict(
always_update=dict(
displayName=NAME,
displayVersion=OLD_VERSION,
type="python_checker",
python_checker=foo,
python_updater=foo
)
)
__plugin_name__ = NAME
__plugin_hooks__ = {
"octoprint.plugin.softwareupdate.check_config": get_update_information,
}
Binary file not shown.
File diff suppressed because it is too large. Load diff
+343 -285
View File
File diff suppressed because it is too large. Load diff