diff --git a/.versioneer-lookup b/.versioneer-lookup index 64c127d0c..acbff62a1 100644 --- a/.versioneer-lookup +++ b/.versioneer-lookup @@ -18,16 +18,16 @@ prerelease HEAD \(detached.* -# maintenance is currently the branch for preparation of maintenance release 1.3.7 +# maintenance is currently the branch for preparation of maintenance release 1.3.9 # so are any fix/... and improve/... branches -maintenance 1.3.7 99e1c3ac007a0eee9d6f908e598c6b029f3ae40c pep440-dev -fix/.* 1.3.7 99e1c3ac007a0eee9d6f908e598c6b029f3ae40c pep440-dev -improve/.* 1.3.7 99e1c3ac007a0eee9d6f908e598c6b029f3ae40c pep440-dev +maintenance 1.3.9 da2c9632ea54fd1b3c8ae34f8f26bab29dbaf3c6 pep440-dev +fix/.* 1.3.9 da2c9632ea54fd1b3c8ae34f8f26bab29dbaf3c6 pep440-dev +improve/.* 1.3.9 da2c9632ea54fd1b3c8ae34f8f26bab29dbaf3c6 pep440-dev -# staging/maintenance is currently the branch for preparation of 1.3.7rc4 +# staging/maintenance is currently the branch for preparation of 1.3.7rc5 # so is regressionfix/... -staging/maintenance 1.3.7rc4 9c5d996ea2b66a085392981a5e6e0ee341013674 pep440-dev -regressionfix/.* 1.3.7rc4 9c5d996ea2b66a085392981a5e6e0ee341013674 pep440-dev +staging/maintenance 1.3.7rc5 e5caa3d0bf77ed23f04c1d96ab0fa997d19d2006 pep440-dev +regressionfix/.* 1.3.7rc5 e5caa3d0bf77ed23f04c1d96ab0fa997d19d2006 pep440-dev # every other branch is a development branch and thus gets resolved to 1.4.0-dev for now .* 1.4.0 7f5d03d0549bcbd26f40e7e4a3297ea5204fb1cc pep440-dev diff --git a/AUTHORS.md b/AUTHORS.md index 8b2b61f1a..bf2df0c9b 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -75,6 +75,7 @@ date of first contribution): * [Mathias Rangel Wulff](https://github.com/mathiasrw) * [Clemens Niemeyer](https://github.com/clemniem) * ["I-am-me"](https://github.com/I-am-me) + * [J-J Heinonen](https://github.com/jammi) * [Noah Martin](https://github.com/noahsmartin) * [Eyal Soha](https://github.com/eyal0) * [Greg Hulands](https://github.com/ghulands) @@ -87,6 +88,8 @@ date of first contribution): * [Josh Major](https://github.com/astateofblank) * ["alex-gh"](https://github.com/alex-gh) * [Bernd Zeimetz](https://github.com/bzed) + * [Daniele Forsi](https://github.com/dforsi) + * [Ganey](https://github.com/ganey) * [Zachary Nofzinger](https://github.com/ZachNo) OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by diff --git a/docs/api/datamodel.rst b/docs/api/datamodel.rst index 74d56dc57..a55554e9e 100644 --- a/docs/api/datamodel.rst +++ b/docs/api/datamodel.rst @@ -263,8 +263,11 @@ File information - Path to type of file in extension tree. E.g. ``["model", "stl"]`` for ``.stl`` files, or ``["machinecode", "gcode"]`` for ``.gcode`` files. ``["folder"]`` for folders. -Additional properties depend on ``type``. For a ``type`` value of ``folder``, see "Folders". For any other value -see "Files". +Additional properties depend on ``type``. +For a ``type`` value of ``folder``, see :ref:`Folders `. +For any other value see :ref:`Files `. + +.. _sec-api-datamodel-files-folders: Folders ''''''' @@ -280,13 +283,14 @@ Folders * - ``children`` - 0..* - Array of :ref:`File information items ` - - Contained children for entries of type ``folder``. Will only include children in subfolders in recursive - listings. Not present in non recursive listings, this might be revisited in the future. + - Contained children for entries of type ``folder``. On non recursive listings only present on first level + sub folders! * - ``size`` - 0..1 - Number - - The size of all files contained in the folder and its subfolders. Not present in non recursive listings, this might - be revisited in the future. + - The size of all files contained in the folder and its subfolders. Not present in non recursive listings! + +.. _sec-api-datamodel-files-files: Files ''''' @@ -385,14 +389,58 @@ GCODE analysis information - 0..1 - Object - The estimated usage of filament - * - ``filament.length`` + * - ``filament.tool{n}.length`` - 0..1 - Integer - The length of filament used, in mm - * - ``filament.volume`` + * - ``filament.tool{n}.volume`` - 0..1 - Float - The volume of filament used, in cm³ + * - ``dimensions`` + - 0..1 + - Object + - Information regarding the size of the printed model + * - ``dimensions.depth`` + - 0..1 + - Float + - The depth of the printed model, in mm + * - ``dimensions.height`` + - 0..1 + - Float + - The height of the printed model, in mm + * - ``dimensions.width`` + - 0..1 + - Float + - The width of the printed model, in mm + * - ``printingArea`` + - 0..1 + - Object + - Information regarding the size of the printing area + * - ``printingArea.maxX`` + - 0..1 + - Float + - The maximum X coordinate of the printed model, in mm + * - ``printingArea.maxY`` + - 0..1 + - Float + - The maximum Y coordinate of the printed model, in mm + * - ``printingArea.maxZ`` + - 0..1 + - Float + - The maximum Z coordinate of the printed model, in mm + * - ``printingArea.minX`` + - 0..1 + - Float + - The minimum X coordinate of the printed model, in mm + * - ``printingArea.minY`` + - 0..1 + - Float + - The minimum Y coordinate of the printed model, in mm + * - ``printingArea.minZ`` + - 0..1 + - Float + - The minimum Z coordinate of the printed model, in mm .. _sec-api-datamodel-files-ref: @@ -421,4 +469,3 @@ References - URL - The model from which this file was generated (e.g. an STL, currently not used). Never present for folders. - diff --git a/docs/api/files.rst b/docs/api/files.rst index 188731a40..23583d59c 100644 --- a/docs/api/files.rst +++ b/docs/api/files.rst @@ -82,8 +82,37 @@ Retrieve all files "path": "folderA", "type": "folder", "typePath": ["folder"], - "children": [], - "size": 1334 + "children": [ + { + "name": "whistle_v2_copy.gcode", + "path": "whistle_v2_copy.gcode", + "type": "machinecode", + "typePath": ["machinecode", "gcode"], + "hash": "...", + "size": 1468987, + "date": 1378847754, + "origin": "local", + "refs": { + "resource": "http://example.com/api/files/local/folderA/whistle_v2_copy.gcode", + "download": "http://example.com/downloads/files/local/folderA/whistle_v2_copy.gcode" + }, + "gcodeAnalysis": { + "estimatedPrintTime": 1188, + "filament": { + "length": 810, + "volume": 5.36 + } + }, + "print": { + "failure": 4, + "success": 23, + "last": { + "date": 1387144346, + "success": true + } + } + } + ] } ], "free": "3.2GB" @@ -443,7 +472,7 @@ Upload file or create folder :form select: Whether to select the file directly after upload (``true``) or not (``false``). Optional, defaults to ``false``. Ignored when creating a folder. :form print: Whether to start printing the file directly after upload (``true``) or not (``false``). If set, ``select`` - is implicitely ``true`` as well. Optional, defaults to ``false``. Ignored when creating a folder. + is implicitly ``true`` as well. Optional, defaults to ``false``. Ignored when creating a folder. :form userdata: [Optional] An optional string that if specified will be interpreted as JSON and then saved along with the file as metadata (metadata key ``userdata``). Ignored when creating a folder. :form foldername: The name of the folder to create. Ignored when uploading a file. diff --git a/docs/api/printer.rst b/docs/api/printer.rst index 1409bf300..5d7c8ebde 100644 --- a/docs/api/printer.rst +++ b/docs/api/printer.rst @@ -37,7 +37,7 @@ Besides that, OctoPrint also provides a :ref:`full state report of the printer < OctoPrint's internal webserver is single threaded and can only handle one request at a time. This is not a problem generally since asynchronous programming allows to just have one request which is waiting for data from a long running backend operation to sleep while handling other requests. The internal framework - used for providing the REST API though, Flask, is based on WSGI, which is synchrounous in nature. This means + used for providing the REST API though, Flask, is based on WSGI, which is synchronous in nature. This means that it is impossible to wait in a non blocking wait while handling a request on the REST API. So in order to return the response of a command sent to the printer, the single thread of the webserver would have to be blocked by the API while the response wasn't available yet. Which in turn would mean that the whole web server would diff --git a/docs/api/printerprofiles.rst b/docs/api/printerprofiles.rst index 835399d5c..8db1b51ae 100644 --- a/docs/api/printerprofiles.rst +++ b/docs/api/printerprofiles.rst @@ -581,7 +581,7 @@ Profile * - ``axes`` - 0..1 - Object - - Description of the printer's axes properties, one entry each for ``x``, ``y``, ``z`` and ``e`` holding maxium speed + - Description of the printer's axes properties, one entry each for ``x``, ``y``, ``z`` and ``e`` holding maximum speed and whether this axis is inverted or not. * - ``axes.{axis}.speed`` - 0..1 diff --git a/docs/api/settings.rst b/docs/api/settings.rst index b26b2d25d..c5947c4b5 100644 --- a/docs/api/settings.rst +++ b/docs/api/settings.rst @@ -106,7 +106,7 @@ 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 ` is not possible, - only :ref:`regenerting it ` is supported. Setting a custom value is only + only :ref:`regenerating it ` is supported. Setting a custom value is only possible through `config.yaml`. * - ``api.allowCrossOrigin`` - diff --git a/docs/configuration/config_yaml.rst b/docs/configuration/config_yaml.rst index 790702fd1..79795f021 100644 --- a/docs/configuration/config_yaml.rst +++ b/docs/configuration/config_yaml.rst @@ -151,7 +151,7 @@ appearance or to modify the order and presence of the various UI components: # order of settings, if settings plugins are registered gets extended internally by # section_plugins and all settings plugins - settings + settings: - section_printer - serial - printerprofiles @@ -454,7 +454,7 @@ the estimation of the left print time during an active job utilizes this section .. code-block:: yaml estimation: - # Parameters for the print time estmation during an ongoing print job + # Parameters for the print time estimation during an ongoing print job printTime: # Until which percentage to do a weighted mixture of statistical duration (analysis or # past prints) with the result from the calculated estimate if that's already available. @@ -893,7 +893,7 @@ Use the following settings to configure the serial connection to the printer: supportResendsWithoutOk: false # Whether to "manually" trigger an ok for M29 (a lot of versions of this command are buggy and - # the responds skips on the ok) + # the response skips on the ok) triggerOkForM29: true capabilities: @@ -934,7 +934,7 @@ Use the following settings to configure the server: # Settings if OctoPrint is running behind a reverse proxy (haproxy, nginx, apache, ...). # These are necessary in order to make OctoPrint generate correct external URLs so - # that AJAX requests and download URLs work. + # that AJAX requests and download URLs work, and so that client IPs are read correctly. reverseProxy: # The request header from which to determine the URL prefix under which OctoPrint @@ -968,6 +968,14 @@ Use the following settings to configure the server: # (X-Forwarded-Host by default, see above) with forwarded requests. hostFallback: + # List of trusted downstream servers for which to ignore the IP address when trying to determine + # the connecting client's IP address. If you have OctoPrint behind more than one reverse proxy + # you should add their IPs here so that they won't be interpreted as the client's IP. One reverse + # proxy will be handled correctly by default. + trustedDownstream: + - 192.168.1.254 + - 192.168.23.42 + # Settings for file uploads to OctoPrint, such as maximum allowed file size and # header suffixes to use for streaming uploads. OctoPrint does some nifty things internally in # order to allow streaming of large file uploads to the application rather than just storing @@ -1092,7 +1100,12 @@ System Use the following settings to add custom system commands to the "System" dropdown within OctoPrint's top bar. -Commands consist of a name, an action identifier, the commandline to execute and an optional confirmation message to +Commands consist of a ``name`` shown to the user, an ``action`` identifier used by the code and the actual +``command`` including any argument needed for its execution. +By default OctoPrint blocks until the command has returned so that the exit code can be used to show a success +or failure message; use the flag ``async: true`` for commands that don't return. + +Optionally you can add a confirmation message to display before actually executing the command (should be set to False if a confirmation dialog is not desired). The following example defines a command for shutting down the system under Linux. It assumes that the user under which diff --git a/docs/events/index.rst b/docs/events/index.rst index 193574247..a97e7e385 100644 --- a/docs/events/index.rst +++ b/docs/events/index.rst @@ -207,8 +207,8 @@ FolderAdded Payload: * ``storage``: the storage's identifier - * ``path``: the folders's path within its storage location - * ``name``: the folders's name + * ``path``: the folder's path within its storage location + * ``name``: the folder's name .. note:: @@ -220,8 +220,8 @@ FolderRemoved Payload: * ``storage``: the storage's identifier - * ``path``: the folders's path within its storage location - * ``name``: the folders's name + * ``path``: the folder's path within its storage location + * ``name``: the folder's name .. note:: diff --git a/docs/features/gcode_scripts.rst b/docs/features/gcode_scripts.rst index 65732e2fd..4fb891eb4 100644 --- a/docs/features/gcode_scripts.rst +++ b/docs/features/gcode_scripts.rst @@ -75,7 +75,7 @@ All GCODE scripts have access to the following template variables through the te * ``last_temperature``: Last actual and target temperature reported for all available tools and if available the heated bed. This is a dictionary of key-value pairs. The keys are the indices of the available tools (``0``, ``1``, ...) and ``b`` for the heated bed. The values are a dictionary consisting of ``actual`` and ``target`` keys mapped - to the corresponding temperature in degrees celsius. Note that not all tools your printer has must necessarily be + to the corresponding temperature in degrees Celsius. Note that not all tools your printer has must necessarily be present here, neither must the heated bed - it depends on whether OctoPrint has values for a tool or the bed. Also note that ``actual`` and ``target`` might be ``None``. * ``script``: An object wrapping the script's type (``gcode``) and name (e.g. ``afterPrintCancelled``) as ``script.type`` diff --git a/docs/jsclientlib/base.rst b/docs/jsclientlib/base.rst index 618299fd1..63833f0dc 100644 --- a/docs/jsclientlib/base.rst +++ b/docs/jsclientlib/base.rst @@ -417,7 +417,7 @@ Creates a custom exception class. ``name`` may be either a function in which case it will be used as constructor for the new exception class, or a string, in which case a constructor with proper - ``name``, ``message`` and ``stack`` attributes will be created. The class hierarchy will be propery + ``name``, ``message`` and ``stack`` attributes will be created. The class hierarchy will be properly setup to subclass ``Error``. **Example:** diff --git a/docs/jsclientlib/files.rst b/docs/jsclientlib/files.rst index 9c4d8233a..5ecf5ea38 100644 --- a/docs/jsclientlib/files.rst +++ b/docs/jsclientlib/files.rst @@ -189,7 +189,7 @@ A boolean value, specifies whether to immediately start printing the file after the upload completes (true) or not (false, default) userdata - An optional object or a serialized JSON string of additional user supplised data to associate with + An optional object or a serialized JSON string of additional user supplied data to associate with the uploaded file. See :ref:`Upload file or create folder ` for more details on the file upload API and diff --git a/docs/jsclientlib/socket.rst b/docs/jsclientlib/socket.rst index 844b845a5..6da88a1ee 100644 --- a/docs/jsclientlib/socket.rst +++ b/docs/jsclientlib/socket.rst @@ -85,7 +85,7 @@ .. js:function:: OctoPrintClient.socket.onRateTooHigh(measured, maximum) Called by the socket client when the last measured round trip time was higher than the - current upper procesisng limit, indicating that the messages are now processed slower than + current upper processing limit, indicating that the messages are now processed slower than the current rate requires and a slower rate might be necessary. Can be overwritten with custom handler methods. The default implementation will call diff --git a/docs/plugins/gettingstarted.rst b/docs/plugins/gettingstarted.rst index c26686a41..ac43e92ad 100644 --- a/docs/plugins/gettingstarted.rst +++ b/docs/plugins/gettingstarted.rst @@ -410,8 +410,8 @@ Now look at that! Settings Galore: How to make parts of your plugin user adjustable ----------------------------------------------------------------- -Remember that Wikipedia link we added to our little link in the navigation bar? It links to the english Wikipedia. But -what if we want to allow our users to adjust that according to their wishes, e.g. to link to the german language node +Remember that Wikipedia link we added to our little link in the navigation bar? It links to the English Wikipedia. But +what if we want to allow our users to adjust that according to their wishes, e.g. to link to the German language node about "Hello World" programs instead? To allow your users to customized the behaviour of your plugin you'll need to implement the :class:`~octoprint.plugin.SettingsPlugin` @@ -509,7 +509,7 @@ section doesn't yet exist in the file, create it): # [...] Restart OctoPrint. Not only should the URL displayed in the log file have changed, but also the link should now (after -a proper shift-reload) point to the german Wikipedia node about "Hello World" programs:: +a proper shift-reload) point to the German Wikipedia node about "Hello World" programs:: 2015-01-30 11:47:18,634 - octoprint.plugins.helloworld - INFO - Hello World! (more: https://de.wikipedia.org/wiki/Hallo-Welt-Programm) diff --git a/docs/plugins/hooks.rst b/docs/plugins/hooks.rst index 18d63f75f..7126bf60a 100644 --- a/docs/plugins/hooks.rst +++ b/docs/plugins/hooks.rst @@ -66,7 +66,7 @@ the general type of script for which to look for additions ("gcode") and the scr return a 2-tuple of prefix and postfix if has something for either of those, otherwise ``None``. OctoPrint will then take care to add prefix and suffix as necessary after a small round of preprocessing. -Plugins can easily add their own hooks too. For example, the `Software Update Plugin `_ +Plugins can easily add their own hooks too. For example, the `Software Update Plugin `_ declares a custom hook "octoprint.plugin.softwareupdate.check_config" which other plugins can add handlers for in order to register themselves with the Software Update Plugin by returning their own update check configuration. @@ -1151,3 +1151,35 @@ octoprint.users.factory :return: The ``userManager`` instance to use globally. :rtype: UserManager subclass or None + +.. _sec-plugins-hook-timelapse-capture-pre: + +octoprint.timelapse.capture.pre +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. py:function:: capture_pre_hook(filename) + + Perform specific actions prior to capturing a timelapse frame. + + ``filename`` will be the future path of the frame to be saved. + + :param str filename: The future path of the frame to be saved. + :return: None + :rtype: None + +.. _sec-plugins-hook-timelapse-capture-post: + +octoprint.timelapse.capture.post +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. py:function:: capture_post_hook(filename, success) + + Perform specific actions after capturing a timelapse frame. + + ``filename`` will be the path of the frame that should have been saved. + ``sucesss`` indicates whether the capture was successful or not. + + :param str filename: The path of the frame that should have been saved. + :param boolean success: Indicates whether the capture was successful or not. + :return: None + :rtype: None diff --git a/docs/plugins/viewmodels.rst b/docs/plugins/viewmodels.rst index b21d07e1f..051e71c6b 100644 --- a/docs/plugins/viewmodels.rst +++ b/docs/plugins/viewmodels.rst @@ -56,9 +56,9 @@ Example: // more of your view model's implementation } - // we don't explicitely declare a name property here + // we don't explicitly declare a name property here // our view model will be registered under "myCustomViewModel" (implicit - // name derived from contructor name) and "yourCustomViewModel" (explicitely + // name derived from constructor name) and "yourCustomViewModel" (explicitly // provided as additional name) OCTOPRINT_VIEWMODELS.push({ construct: MyCustomViewModel, diff --git a/setup.py b/setup.py index 765ed5bee..224a20696 100644 --- a/setup.py +++ b/setup.py @@ -14,35 +14,33 @@ import octoprint_setuptools # Requirements for our application INSTALL_REQUIRES = [ - "flask>=0.9,<0.11", + "flask>=0.12,<0.13", + "werkzeug>=0.11.1,<0.12", + "tornado>=5.0.1,<6", "Jinja2>=2.8,<2.9", # Jinja 2.9 has breaking changes WRT template scope - we can't # guarantee backwards compatibility for plugins and such with that # version, hence we need to pin to a lower version for now. See #1697 - "werkzeug>=0.8.3,<0.9", - "tornado==4.0.2", # pinned for now, we need to migrate to a newer tornado, but due - # to some voodoo needed to get large streamed uploads and downloads - # to work that is probably not completely straightforward and therefore - # something for post-1.3.0-stable release - "sockjs-tornado>=1.0.3,<1.1", - "PyYAML>=3.10,<3.11", - "Flask-Login>=0.2.2,<0.3", - "Flask-Principal>=0.3.5,<0.4", - "Flask-Babel>=0.9,<0.10", - "Flask-Assets>=0.10,<0.11", + #"sockjs-tornado>=1.0.3,<1.1", # current version is incompatible to tornado 5, we use a + # vendored one + "PyYAML>=3.12,<3.13", + "Flask-Login>=0.4,<0.5", + "Flask-Principal>=0.4,<0.5", + "Flask-Babel>=0.11,<0.12", + "Flask-Assets>=0.12,<0.13", "markdown>=2.6.4,<2.7", - "pyserial>=2.7,<3.5", + "pyserial>=3.4,<3.5", "netaddr>=0.7.17,<0.8", "watchdog>=0.8.3,<0.9", "sarge>=0.1.4,<0.2", "netifaces>=0.10,<0.11", "pylru>=1.0.9,<1.1", - "rsa>=3.2,<3.3", - "pkginfo>=1.2.1,<1.3", + "rsa>=3.4,<3.5", + "pkginfo>=1.4.1,<1.5", "requests>=2.18.4,<3", - "semantic_version>=2.4.2,<2.5", + "semantic_version>=2.6.0,<2.7", "psutil==5.4.3", # 5.4.4 introduced a breaking change concerning installing under non current # setuptools versions. Pinning to 5.4.3 for now to work around this. - "Click>=6.2,<6.3", + "Click>=6.7,<6.8", "awesome-slugify>=1.6.5,<1.7", "feedparser>=5.2.1,<5.3", "chainmap>=1.0.2,<1.1", @@ -81,7 +79,7 @@ EXTRA_REQUIRES = dict( # Dependencies for developing OctoPrint plugins plugins=[ - "cookiecutter>=1.4,<1.7" + "cookiecutter>=1.5,<1.7" ] ) diff --git a/src/octoprint/__init__.py b/src/octoprint/__init__.py index c67c05280..45a8328a1 100644 --- a/src/octoprint/__init__.py +++ b/src/octoprint/__init__.py @@ -198,7 +198,7 @@ def init_logging(settings, use_logging_file=True, logging_file=None, default_con }, "handlers": { "console": { - "class": "logging.StreamHandler", + "class": "octoprint.logging.handlers.OctoPrintStreamHandler", "level": "DEBUG", "formatter": "simple", "stream": "ext://sys.stdout" diff --git a/src/octoprint/filemanager/storage.py b/src/octoprint/filemanager/storage.py index dc4e9f16b..51d56a575 100644 --- a/src/octoprint/filemanager/storage.py +++ b/src/octoprint/filemanager/storage.py @@ -153,7 +153,8 @@ class StorageInterface(object): from root of base folder :param function filter: a filter that matches the files that are to be returned, may be left out in which case no filtering will take place - :param bool recursive: will also step into sub folders for building the complete list if set to True + :param bool recursive: will also step into sub folders for building the complete list if set to True, otherwise will only + do one step down into sub folders to be able to populate the ``children``. :return: a dictionary mapping entry names to entry data that represents the whole file list """ raise NotImplementedError() @@ -183,7 +184,7 @@ class StorageInterface(object): def copy_folder(self, source, destination): """ - Copys the folder ``source`` to ``destination`` + Copies the folder ``source`` to ``destination`` :param string source: path to the source folder :param string destination: path to destination @@ -232,7 +233,7 @@ class StorageInterface(object): def copy_file(self, source, destination): """ - Copys the file ``source`` to ``destination`` + Copies the file ``source`` to ``destination`` :param string source: path to the source file :param string destination: path to destination @@ -1277,7 +1278,7 @@ class LocalFileStorage(StorageInterface): if metadata_dirty: self._save_metadata(path, metadata) - def _list_folder(self, path, base="", entry_filter=None, recursive=True, **kwargs): + def _list_folder(self, path, base="", entry_filter=None, recursive=True, include_children=True, **kwargs): if entry_filter is None: entry_filter = kwargs.get("filter", None) @@ -1385,8 +1386,14 @@ class LocalFileStorage(StorageInterface): sub_result = self._list_folder(entry_path, base=path_in_location + "/", entry_filter=entry_filter, recursive=recursive) entry_data["children"] = sub_result + elif include_children: + sub_result = self._list_folder(entry_path, base=path_in_location + "/", entry_filter=entry_filter, + recursive=False, include_children=False) + entry_data["children"] = sub_result if not entry_filter or entry_filter(entry_name, entry_data): + # only add folders passing the optional filter + def get_size(): total_size = 0 for element in entry_data["children"].values(): @@ -1395,7 +1402,6 @@ class LocalFileStorage(StorageInterface): return total_size - # only add folders passing the optional filter extended_entry_data = dict() extended_entry_data.update(entry_data) if recursive: diff --git a/src/octoprint/logging/handlers.py b/src/octoprint/logging/handlers.py index 232216ee0..ade943c76 100644 --- a/src/octoprint/logging/handlers.py +++ b/src/octoprint/logging/handlers.py @@ -6,10 +6,30 @@ import os import re import time +# noinspection PyCompatibility +import concurrent.futures + + +class AsyncLogHandlerMixin(logging.Handler): + def __init__(self, *args, **kwargs): + self._executor = concurrent.futures.ThreadPoolExecutor(max_workers=1) + super(AsyncLogHandlerMixin, self).__init__(*args, **kwargs) + + def emit(self, record): + try: + self._executor.submit(self._emit, record) + except: + self.handleError(record) + + def _emit(self, record): + # noinspection PyUnresolvedReferences + super(AsyncLogHandlerMixin, self).emit(record) + + class CleaningTimedRotatingFileHandler(logging.handlers.TimedRotatingFileHandler): def __init__(self, *args, **kwargs): - logging.handlers.TimedRotatingFileHandler.__init__(self, *args, **kwargs) + super(CleaningTimedRotatingFileHandler, self).__init__(*args, **kwargs) # clean up old files on handler start if self.backupCount > 0: @@ -17,7 +37,7 @@ class CleaningTimedRotatingFileHandler(logging.handlers.TimedRotatingFileHandler os.remove(s) -class OctoPrintLogHandler(CleaningTimedRotatingFileHandler): +class OctoPrintLogHandler(AsyncLogHandlerMixin, CleaningTimedRotatingFileHandler): rollover_callbacks = [] @classmethod @@ -25,32 +45,33 @@ class OctoPrintLogHandler(CleaningTimedRotatingFileHandler): cls.rollover_callbacks.append((callback, args, kwargs)) def doRollover(self): - CleaningTimedRotatingFileHandler.doRollover(self) + super(OctoPrintLogHandler, self).doRollover() for rcb in self.rollover_callbacks: callback, args, kwargs = rcb callback(*args, **kwargs) -class SerialLogHandler(logging.handlers.RotatingFileHandler): +class OctoPrintStreamHandler(AsyncLogHandlerMixin, logging.StreamHandler): + pass - _do_rollover = False - _suffix_template = "%Y-%m-%d_%H-%M-%S" - _file_pattern = re.compile(r"^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}$") + +class SerialLogHandler(AsyncLogHandlerMixin, logging.handlers.RotatingFileHandler): + + do_rollover = False + suffix_template = "%Y-%m-%d_%H-%M-%S" + file_pattern = re.compile(r"^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}$") @classmethod def on_open_connection(cls): - cls._do_rollover = True + cls.do_rollover = True def __init__(self, *args, **kwargs): - logging.handlers.RotatingFileHandler.__init__(self, *args, **kwargs) + super(SerialLogHandler, self).__init__(*args, **kwargs) self.cleanupFiles() - def emit(self, record): - logging.handlers.RotatingFileHandler.emit(self, record) - def shouldRollover(self, record): - return self.__class__._do_rollover + return type(self).do_rollover def getFilesToDelete(self): """ @@ -64,7 +85,7 @@ class SerialLogHandler(logging.handlers.RotatingFileHandler): for fileName in fileNames: if fileName[:plen] == prefix: suffix = fileName[plen:] - if self.__class__._file_pattern.match(suffix): + if type(self).file_pattern.match(suffix): result.append(os.path.join(dirName, fileName)) result.sort() if len(result) < self.backupCount: @@ -88,7 +109,7 @@ class SerialLogHandler(logging.handlers.RotatingFileHandler): if os.path.exists(self.baseFilename): # figure out creation date/time to use for file suffix t = time.localtime(os.stat(self.baseFilename).st_mtime) - dfn = self.baseFilename + "." + time.strftime(self.__class__._suffix_template, t) + dfn = self.baseFilename + "." + time.strftime(type(self).suffix_template, t) if os.path.exists(dfn): os.remove(dfn) os.rename(self.baseFilename, dfn) @@ -98,8 +119,8 @@ class SerialLogHandler(logging.handlers.RotatingFileHandler): self.stream = self._open() class RecordingLogHandler(logging.Handler): - def __init__(self, target=None, level=logging.NOTSET): - logging.Handler.__init__(self, level=level) + def __init__(self, target=None, *args, **kwargs): + super(RecordingLogHandler, self).__init__(*args, **kwargs) self._buffer = [] self._target = target @@ -133,6 +154,7 @@ class RecordingLogHandler(logging.Handler): return len(self._buffer) +# noinspection PyAbstractClass class CombinedLogHandler(logging.Handler): def __init__(self, *handlers): logging.Handler.__init__(self) diff --git a/src/octoprint/plugin/types.py b/src/octoprint/plugin/types.py index 9b3fc46f2..21c4657af 100644 --- a/src/octoprint/plugin/types.py +++ b/src/octoprint/plugin/types.py @@ -1443,7 +1443,7 @@ class SettingsPlugin(OctoPrintPlugin): Make sure to protect sensitive information stored by your plugin that only logged in administrators (or users) should have access to via :meth:`~octoprint.plugin.SettingsPlugin.get_settings_restricted_paths`. OctoPrint will - return its settings on the REST API even to anonymous clients, but will filter out fields it know are restricted, + return its settings on the REST API even to anonymous clients, but will filter out fields it knows are restricted, therefore you **must** make sure that you specify sensitive information accordingly to limit access as required! """ @@ -1527,8 +1527,8 @@ class SettingsPlugin(OctoPrintPlugin): else: node[key] = None - conditions = dict(user=lambda: current_user is not None and not current_user.is_anonymous(), - admin=lambda: current_user is not None and not current_user.is_anonymous() and current_user.is_admin(), + conditions = dict(user=lambda: current_user is not None and not current_user.is_anonymous, + admin=lambda: current_user is not None and not current_user.is_anonymous and current_user.is_admin, never=lambda: False) for level, condition in conditions.items(): diff --git a/src/octoprint/plugins/corewizard/subwizards.py b/src/octoprint/plugins/corewizard/subwizards.py index d9eeb8578..550b701a2 100644 --- a/src/octoprint/plugins/corewizard/subwizards.py +++ b/src/octoprint/plugins/corewizard/subwizards.py @@ -74,9 +74,9 @@ class AclSubwizard(object): if not self._settings.global_get(["server", "firstRun"]) or self._user_manager.hasBeenCustomized(): abort(404) - data = request.values - if hasattr(request, "json") and request.json: - data = request.json + data = request.get_json() + if data is None: + data = request.values if "ac" in data and data["ac"] in valid_boolean_trues and \ "user" in data.keys() and "pass1" in data.keys() and \ diff --git a/src/octoprint/plugins/cura/templates/snippets/settings/cura/profileImporter.jinja2 b/src/octoprint/plugins/cura/templates/snippets/settings/cura/profileImporter.jinja2 index c2aee1663..ddf48eb2b 100644 --- a/src/octoprint/plugins/cura/templates/snippets/settings/cura/profileImporter.jinja2 +++ b/src/octoprint/plugins/cura/templates/snippets/settings/cura/profileImporter.jinja2 @@ -52,7 +52,7 @@ {% trans %} You can import your existing profile .ini files from Cura 15.04.x or older - here. Anything but those are not supported. That especiallymeans that .json + here. Anything but those are not supported. That especially means that .json profiles from Cura 15.06.x and .curaprofile profiles from Cura 2.x will not work, and neither will custom Cura profile formats that third party tools like e.g. Repetier create. {% endtrans %} diff --git a/src/octoprint/plugins/pluginmanager/__init__.py b/src/octoprint/plugins/pluginmanager/__init__.py index f219186ae..54ae3cb92 100644 --- a/src/octoprint/plugins/pluginmanager/__init__.py +++ b/src/octoprint/plugins/pluginmanager/__init__.py @@ -333,7 +333,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin, raise ValueError("Either URL or path must be provided") self._logger.info("Installing plugin from {}".format(source)) - pip_args = ["install", sarge.shell_quote(source)] + pip_args = ["install", sarge.shell_quote(source), '--no-cache-dir'] if dependency_links or self._settings.get_boolean(["dependency_links"]): pip_args.append("--process-dependency-links") diff --git a/src/octoprint/plugins/pluginmanager/static/css/pluginmanager.css b/src/octoprint/plugins/pluginmanager/static/css/pluginmanager.css index ed0017ddb..f34d4e990 100644 --- a/src/octoprint/plugins/pluginmanager/static/css/pluginmanager.css +++ b/src/octoprint/plugins/pluginmanager/static/css/pluginmanager.css @@ -1 +1 @@ -table td.settings_plugin_plugin_manager_plugins_name,table th.settings_plugin_plugin_manager_plugins_name{text-overflow:ellipsis;text-align:left}table td.settings_plugin_plugin_manager_plugins_actions,table th.settings_plugin_plugin_manager_plugins_actions{text-align:center;width:80px}table td.settings_plugin_plugin_manager_plugins_actions a,table th.settings_plugin_plugin_manager_plugins_actions a{text-decoration:none;color:#000}table td.settings_plugin_plugin_manager_plugins_actions a.disabled,table th.settings_plugin_plugin_manager_plugins_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_repositorydialog .slimScrollDiv{margin-bottom:20px;padding-right:12px}#settings_plugin_pluginmanager_repositorydialog h4{position:relative}#settings_plugin_pluginmanager_repositorydialog h4 a.dropdown-toggle{color:inherit;text-decoration:none;font-size:14px}#settings_plugin_pluginmanager_repositorydialog h4 ul.dropdown-menu{font-size:14px}#settings_plugin_pluginmanager_repositorydialog .form-search{text-align:center;margin-bottom:5px!important}#settings_plugin_pluginmanager_repositorydialog .form-inline{padding:5px 10px 5px 5px;margin-bottom:0}#settings_plugin_pluginmanager_repositorydialog .form-inline .help-block{margin-bottom:0;font-size:85%}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable{overflow:hidden;width:100%;height:300px;background-image:url(../img/repo_unavailable.png);text-align:center;display:table}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable div{display:table-cell;vertical-align:middle}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list{overflow:hidden;width:auto;height:300px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry{border-bottom:1px solid #ddd;padding:5px 10px 5px 5px}#settings_plugin_pluginmanager_workingdialog_output .message{font-weight:700}#settings_plugin_pluginmanager_workingdialog_output .error{font-weight:700;color:#900}#settings_plugin_pluginmanager_workingdialog_output .stdout{color:#333}#settings_plugin_pluginmanager_workingdialog_output .stderr{color:#900}#settings_plugin_pluginmanager_workingdialog_output .call{color:#009} \ No newline at end of file +table td.settings_plugin_plugin_manager_plugins_name,table th.settings_plugin_plugin_manager_plugins_name{text-overflow:ellipsis;text-align:left}table td.settings_plugin_plugin_manager_plugins_actions,table th.settings_plugin_plugin_manager_plugins_actions{text-align:center;width:80px}table td.settings_plugin_plugin_manager_plugins_actions a,table th.settings_plugin_plugin_manager_plugins_actions a{text-decoration:none;color:#000}table td.settings_plugin_plugin_manager_plugins_actions a.disabled,table th.settings_plugin_plugin_manager_plugins_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_repositorydialog h4{position:relative}#settings_plugin_pluginmanager_repositorydialog h4 a.dropdown-toggle{color:inherit;text-decoration:none;font-size:14px}#settings_plugin_pluginmanager_repositorydialog h4 ul.dropdown-menu{font-size:14px}#settings_plugin_pluginmanager_repositorydialog .form-search{text-align:center;margin-bottom:5px!important}#settings_plugin_pluginmanager_repositorydialog .form-inline{padding:5px 10px 5px 5px;margin-bottom:0}#settings_plugin_pluginmanager_repositorydialog .form-inline .help-block{margin-bottom:0;font-size:85%}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable{overflow:hidden;width:100%;height:300px;background-image:url(../img/repo_unavailable.png);text-align:center;display:table}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable div{display:table-cell;vertical-align:middle}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list{width:auto;height:300px;overflow-x:hidden;overflow-y:scroll;padding-right:2px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry{border-bottom:1px solid #ddd;padding:5px}#settings_plugin_pluginmanager_workingdialog_output .message{font-weight:700}#settings_plugin_pluginmanager_workingdialog_output .error{font-weight:700;color:#900}#settings_plugin_pluginmanager_workingdialog_output .stdout{color:#333}#settings_plugin_pluginmanager_workingdialog_output .stderr{color:#900}#settings_plugin_pluginmanager_workingdialog_output .call{color:#009} \ No newline at end of file diff --git a/src/octoprint/plugins/pluginmanager/static/less/pluginmanager.less b/src/octoprint/plugins/pluginmanager/static/less/pluginmanager.less index 4dc41f4e3..b828f87fa 100644 --- a/src/octoprint/plugins/pluginmanager/static/less/pluginmanager.less +++ b/src/octoprint/plugins/pluginmanager/static/less/pluginmanager.less @@ -23,13 +23,6 @@ table { } #settings_plugin_pluginmanager_repositorydialog { - .slimScrollDiv { - @scrollBar: 10px; - - margin-bottom: 20px; - padding-right: @scrollBar + 2px; - } - h4 { position: relative; @@ -75,14 +68,15 @@ table { } #settings_plugin_pluginmanager_repositorydialog_list { - overflow: hidden; width: auto; height: 300px; + overflow-x: hidden; + overflow-y: scroll; + padding-right: 2px; .entry { border-bottom: 1px solid #ddd; padding: 5px; - padding-right: 10px; } } } diff --git a/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 b/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 index 6541c2b58..95e9d9077 100644 --- a/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 +++ b/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 @@ -155,7 +155,7 @@
-
+
@@ -245,57 +245,64 @@

{% trans %}You should normally not have to change any of the following settings, they are purely provided for convenience here.{% endtrans %}

- {{ _('Plugin repository configuration') }} +
+ {{ _('Plugin repository configuration') }} -
- -
- -
-
-
- -
-
- - min +
+ +
+
-
- - {{ _('Notices configuration') }} - -
- -
- -
-
-
- -
-
- - min +
+ +
+
+ + min +
-
+
- {{ _('pip configuration') }} +
+ {{ _('Notices configuration') }} -
- -
- +
+ +
+ +
-
-
-
- +
+ +
+
+ + min +
+
-
+
+ +
+ {{ _('pip configuration') }} + +
+ +
+ +
+
+
+
+ +
+
+
+