diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 861215f4d..97299046d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -27,7 +27,7 @@ to **address problems in a timely manner** but also keep it possible for them
to **fix bugs, add new and improve on existing functionality** instead of doing
nothing but ticket management.
-
+
- **[Read the FAQ](https://faq.octoprint.org)**
- If you want to report a **bug**, [read "How to file a bug report" below](#how-to-file-a-bug-report)
@@ -39,11 +39,11 @@ nothing but ticket management.
[community forum at discourse.octoprint.org](https://discourse.octoprint.org) for
such support issues.
- If you are a **developer** that wants to brainstorm a pull request or possible
- changes to the plugin system, add [Brainstorming] to your issue's title (e.g.
- `[Brainstorming] New plugin hook for doing some cool stuff`).
+ changes to the plugin system, please get in touch on the
+ [community forum at discourse.octoprint.org](https://discourse.octoprint.org/c/development).
- If you need **support**, have a **question** or some **other reason** that
doesn't fit any of the above categories, the issue tracker is not the right place.
- Consult the [community forum at discourse.octoprint.org](https://discourse.octoprint.org) instead.
+ Consult the [community forum at discourse.octoprint.org](https://discourse.octoprint.org/c/support) instead.
No matter what kind of ticket you create, never mix two or more "ticket reasons"
into one ticket: One ticket per bug, request, brainstorming thread please.
@@ -53,7 +53,7 @@ into one ticket: One ticket per bug, request, brainstorming thread please.
> A bot is in place that monitors new tickets, automatically
> categorizes them and checks new bug reports for usage of the provided template.
> That bot will only bother you if you open a ticket that appears to be a bug (no
-> `[Request]` or `[Brainstorming]` in the title) without the complete template, and it
+> `[Request]` in the title) without the complete template, and it
> will do that only to ensure that all information needed to solve the issue is
> available for the maintainers to directly start tackling that problem.
@@ -301,7 +301,8 @@ the documentation.
the discussion going on how best to solve *this* in OctoPrint's plugin
system - maybe that's the actual PR you have been waiting for to contribute :)
2. If you plan to make **any large or otherwise disruptive changes to the
- code or appearance, please open a "Brainstorming" ticket first** so
+ code or appearance, please get in touch on the
+ [forums](https://discourse.octoprint.org/c/development)** first so
that we can determine if it's a good time for your specific pull
request. It might be that we're currently in the process of making
heavy changes to the code locations you'd target as well, or your
@@ -311,7 +312,8 @@ the documentation.
3. Create your pull request **from a custom branch** on your end (e.g.
`dev/myNewFeature`)[1].
4. Create your pull request **only against the `maintenance` or `devel` branch**:
- * if it's a bug fix for a bug in the current stable version: `maintenance` branch
+ * if it's a bug fix for a bug in the current stable version, an improvement of existing functionality or a
+ *small* new feature (e.g. a new hook, a new config flag, ...): `maintenance` branch
* otherwise: `devel` branch
5. Create **one pull request per feature/bug fix**.
6. Make sure there are **only relevant changes** included in your PR. No
@@ -472,7 +474,9 @@ the local version identifier to allow for an exact determination of the active c
* 2017-11-22: Added note on how to run the unit tests
* 2018-03-15: Link to new community forum and some clarifications re bug
reporting
- * 2018-03-29: "Where to find version numbers" is now located on the FAQ
+ * 2018-03-29: "Where to find version numbers" is now located on the FAQ
+ * 2018-10-18: Allow PRs against `maintenance` branch for improvements and small
+ new features, suggest getting in touch on the forum for larger changes
## Footnotes
* [1] - If you are wondering why, the problem is that anything that you add
diff --git a/docs/api/general.rst b/docs/api/general.rst
index cc1cd0a72..7600cc80c 100644
--- a/docs/api/general.rst
+++ b/docs/api/general.rst
@@ -120,3 +120,94 @@ If CORS is not enabled you will get errors like the following::
XMLHttpRequest cannot load http://localhost:8081/api/files. No 'Access-Control-Allow-Origin'
header is present on the requested resource.
+.. _sec-api-general-login:
+
+Login
+=====
+
+.. http:post:: /api/login
+
+ Creates a login session or retrieves information about the currently existing session ("passive login").
+
+ Can be used in one of two ways: to login a user via username and password and create a persistent session (usually
+ from a UI in the browser), or to retrieve information about the active user (from an existing session or an API key)
+ via the ``passive`` flag.
+
+ Will return a :http:statuscode:`200` with a :ref:`login response ` on successful
+ login, whether active or passive. The active (username/password) login may also return a :http:statuscode:`401` in
+ case of a username/password mismatch or unknown user and a :http:statuscode:`403` in case of a deactivated account.
+
+ :json passive: If present, performs a passive login only, returning information about the current user that's
+ active either through an existing session or the used API key
+ :json user: (active login only) Username
+ :json pass: (active login only) Password
+ :json remember: (active login only) Whether to set a "remember me" cookie on the session
+ :status 200: Successful login
+ :status 401: Username/password mismatch or unknown user
+ :status 403: Deactivated account
+
+.. _sec-api-general-logout:
+
+Logout
+======
+
+.. http:post:: /api/logout
+
+ Ends the current login session of the current user.
+
+ Only makes sense in the context of browser based workflows.
+
+ Will return a :http:statuscode:`204`.
+
+ :status 204: No error
+
+.. _sec-api-general-datamodel:
+
+Data model
+==========
+
+.. _sec-api-general-datamodel-login:
+
+Login response
+--------------
+
+.. list-table::
+ :widths: 15 5 10 30
+ :header-rows: 1
+
+ * - Name
+ - Multiplicity
+ - Type
+ - Description
+ * - ``name``
+ - 1
+ - string
+ - the user's name
+ * - ``active``
+ - 1
+ - boolean
+ - Whether the user's account is active or not
+ * - ``admin``
+ - 1
+ - boolean
+ - Whether the user has admin rights or not
+ * - ``user``
+ - 1
+ - boolean
+ - Whether the user has user rights or not (always ``true``)
+ * - ``apikey``
+ - 1
+ - string or None
+ - The user's API key, if set
+ * - ``settings``
+ - 1
+ - dict
+ - The user's settings, if any
+ * - ``session``
+ - 1
+ - string
+ - The session key, can be used to authenticate with the ``auth`` message on the :ref:`push API `.
+ * - ``_is_external_client``
+ - 1
+ - boolean
+ - Whether the client that made the request got detected as external from the local network or not.
diff --git a/docs/api/push.rst b/docs/api/push.rst
index 7d8813867..83fe2a486 100644
--- a/docs/api/push.rst
+++ b/docs/api/push.rst
@@ -47,23 +47,41 @@ Clients must ignore any unknown messages.
The data model of the attached payloads is described further below.
-OctoPrint's SockJS socket also accepts one command from the client to the server,
-the ``throttle`` command. Usually, OctoPrint will push the general state update
-in the ``current`` message twice per second. For some clients that might still
-be too fast, so they can signal a different factor to OctoPrint utilizing the
-``throttle`` message. OctoPrint expects a single integer here which represents
-the multiplier for the base rate limit of one message every 500ms. A value of
-1 hence will produce the default behaviour of getting every update. A value of
-2 will set the rate limit to maximally one message every 1s, 3 to maximally one
-message every 1.5s and so on.
+OctoPrint's SockJS socket also accepts two commands from the client to the server.
-Example for a ``throttle`` client-server-message:
+ * ``auth`` (since 1.3.10): With the ``auth`` message, clients may associate an
+ existing user session with the socket. That is of special importance to receive
+ any kind of messages if the bundled :ref:`Forcelogin Plugin ` is enabled
+ (as it is by default), since it will prevent any kind of status messages to be sent to connected unauthenticated
+ clients.
-.. sourcecode:: javascript
+ The ``auth`` message expects a session key to be obtained from the successful payload of a
+ :ref:`(passive or active) login via the API `.
- {
- "throttle": 2
- }
+ Example for a ``auth`` client-server-message:
+
+ .. sourcecode:: javascript
+
+ {
+ "auth": "LGZ0trf8By"
+ }
+
+ * ``throttle``: Usually, OctoPrint will push the general state update
+ in the ``current`` message twice per second. For some clients that might still
+ be too fast, so they can signal a different factor to OctoPrint utilizing the
+ ``throttle`` message. OctoPrint expects a single integer here which represents
+ the multiplier for the base rate limit of one message every 500ms. A value of
+ 1 hence will produce the default behaviour of getting every update. A value of
+ 2 will set the rate limit to maximally one message every 1s, 3 to maximally one
+ message every 1.5s and so on.
+
+ Example for a ``throttle`` client-server-message:
+
+ .. sourcecode:: javascript
+
+ {
+ "throttle": 2
+ }
.. _sec-api-push-datamodel:
diff --git a/docs/bundledplugins/announcements.rst b/docs/bundledplugins/announcements.rst
new file mode 100644
index 000000000..44dfe63e1
--- /dev/null
+++ b/docs/bundledplugins/announcements.rst
@@ -0,0 +1,67 @@
+.. _sec-bundledplugins-announcements:
+
+Announcement Plugin
+===================
+
+The OctoPrint Announcement Plugin comes bundled with OctoPrint (starting with 1.2.11).
+
+It displays announcements fetched from OctoPrint's websites, such as important updates, release announcements, new
+plugins and similar. Through some manual configuration via ``config.yaml`` it also allows adding additional channels
+via RSS or Atom feed URLs.
+
+.. _fig-bundledplugins-announcements-example1:
+.. figure:: ../images/bundledplugins-announcements-example1.png
+ :align: center
+ :alt: Example notification
+
+ An example notification from the Announcement Plugin.
+
+.. _fig-bundledplugins-announcements-example2:
+.. figure:: ../images/bundledplugins-announcements-example2.png
+ :align: center
+ :alt: Announcement reader
+
+ The Announcement Plugin's reader dialog.
+
+.. _fig-bundledplugins-announcements-settings:
+.. figure:: ../images/bundledplugins-announcements-settings.png
+ :align: center
+ :alt: Announcement settings
+
+ The Announcement Plugin's settings dialog.
+
+.. _sec-bundledplugins-announcements-configuration:
+
+Configuring the plugin
+----------------------
+
+The plugin allows enabling and disabling the preconfigured announcement channels via its settings dialog.
+
+On top of that it's possible to add additional announcement channels (as RSS or Atom feed URLs) or change the
+configuration of the existing channels through ``config.yaml``.
+
+The available configuration keys are:
+
+ * ``channels``: Configured announcement channels. A mapping from a unique identifier to a configuration structure
+ that follows this format:
+
+ * ``name``: Name of the channel, used e.g. in the title of the displayed notifications.
+ * ``description``: Description of the channel.
+ * ``priority``: ``1`` for high priority announcements (red notification), ``2`` for regular ones (yellow notification).
+ * ``type``: Currently unused.
+ * ``url``: URL for the feed acting as notification source, must be RSS or Atom format.
+
+ * ``enabled_channels``: List of identifiers of enabled channels.
+ * ``forced_channels``: List of identifiers of channels that cannot be disabled (currently only ``_important`` which is used sparingly).
+ * ``channel_order``: List of channel identifiers in the order they should appear in the UI.
+ * ``ttl``: Time to live of the channel cache in minutes (default: 6 hours).
+ * ``display_limit``: Limit of items to display per channel (default: 3).
+ * ``summary_limit``: Limit of characters to display from each channel entry (default: 300).
+
+.. _sec-bundledplugins-announcements-sourcecode:
+
+Source code
+-----------
+
+The source of the Announcement plugin is bundled with OctoPrint and can be found in
+its source repository under ``src/octoprint/plugins/announcements``.
diff --git a/docs/bundledplugins/backup.rst b/docs/bundledplugins/backup.rst
new file mode 100644
index 000000000..350d40508
--- /dev/null
+++ b/docs/bundledplugins/backup.rst
@@ -0,0 +1,70 @@
+.. _sec-bundledplugins-backup:
+
+Backup Plugin
+=============
+
+The OctoPrint Backup Plugin comes bundled with OctoPrint (starting with 1.3.10).
+
+It allows the creation and restoration of backups of OctoPrint's settings, data and installed plugins [#]_.
+
+This allows easy migration
+to newly setup instances as well as making regular backups to prevent data loss.
+
+.. _fig-bundledplugins-backup-settings:
+.. figure:: ../images/bundledplugins-backup-settings.png
+ :align: center
+ :alt: OctoPrint Backup Plugin
+
+ The plugin's settings panel with existing backups, the backup creation and restore sections.
+
+As long as plugins adhere to the standard of storing their data and settings in OctoPrint's plugin data folders, their
+data will be part of the backup. Note that the backups made by the Backup Plugin will *not* be part of any backups -
+you'll need to persist the resulting zip files yourself!
+
+.. _sec-bundledplugins-backup-cli:
+
+Command line usage
+------------------
+
+The Backup Plugin implements a command line interface that allows creation and restoration of backups.
+It adds two new commands, ``backup:backup`` and ``backup_restore``.
+
+.. code-block:: none
+
+ $ octoprint plugins backup:backup --help
+ Initializing settings & plugin subsystem...
+ Usage: octoprint plugins backup:backup [OPTIONS]
+
+ Creates a new backup.
+
+ Options:
+ --exclude TEXT Identifiers of data folders to exclude, e.g. 'uploads' to
+ exclude uploads or 'timelapse' to exclude timelapses.
+ --help Show this message and exit.
+
+ $ octoprint plugins backup:restore --help
+ Initializing settings & plugin subsystem...
+ Usage: octoprint plugins backup:restore [OPTIONS] PATH
+
+ Restores an existing backup from the backup zip provided as argument.
+
+ OctoPrint does not need to run for this to proceed.
+
+ Options:
+ --help Show this message and exit.
+
+.. note::
+
+ The ``backup:backup`` command can be useful in combination with a cronjob to create backups in regular intervals.
+
+.. _sec-bundledplugins-backup-sourcecode:
+
+Source code
+-----------
+
+The source of the Backup plugin is bundled with OctoPrint and can be found in
+its source repository under ``src/octoprint/plugins/backup``.
+
+.. [#] Note that only those plugins that are available on `OctoPrint's official plugin repository `_
+ can be automatically restored. If you have plugins installed that are not available on there you'll get their
+ names and - if available - homepage URL displayed after restore in order to be able to manually reinstall them.
diff --git a/docs/bundledplugins/forcelogin.rst b/docs/bundledplugins/forcelogin.rst
new file mode 100644
index 000000000..bb69c35c9
--- /dev/null
+++ b/docs/bundledplugins/forcelogin.rst
@@ -0,0 +1,35 @@
+.. _sec-bundledplugins-forcelogin:
+
+Forcelogin Plugin
+=================
+
+The Forcelogin Plugin comes bundled with OctoPrint (starting with version 1.3.10). It removes the anonymous
+read-only access that up until 1.3.10 was standard when accessing OctoPrint instances without being logged in and
+instead forces users to log in if they want to get any kind of information from OctoPrint.
+
+.. _fig-bundledplugins-forcelogin:
+.. figure:: ../images/bundledplugins-forcelogin-dialog.png
+ :align: center
+ :alt: Forced login dialog
+
+ OctoPrint's new forced login dialog.
+
+.. warning::
+
+ Keep in mind that **OctoPrint does not manage your webcam**, it merely embeds it. If you have a webcam,
+ it will still be accessible to users who are not logged in under its (guessable) URL. If you need to restrict
+ access to your webcam, you'll need to find a way to do so directly on the webcam server which - again -
+ is not OctoPrint itself.
+
+.. note::
+
+ If you want back the old behaviour of allowing anonymous read-only access to your OctoPrint instance, disable
+ the Forcelogin Plugin in OctoPrint's plugin manager.
+
+.. _sec-bundledplugins-forcelogin-sourcecode:
+
+Source code
+-----------
+
+The source of the Backup plugin is bundled with OctoPrint and can be found in
+its source repository under ``src/octoprint/plugins/forcelogin``.
diff --git a/docs/bundledplugins/index.rst b/docs/bundledplugins/index.rst
index 26a520699..a1683a800 100644
--- a/docs/bundledplugins/index.rst
+++ b/docs/bundledplugins/index.rst
@@ -8,8 +8,11 @@ Bundled Plugins
:maxdepth: 2
action_command_prompt.rst
+ announcements.rst
+ backup.rst
cura.rst
discovery.rst
+ forcelogin.rst
logging.rst
pluginmanager.rst
printer_safety_check.rst
diff --git a/docs/bundledplugins/printer_safety_check.rst b/docs/bundledplugins/printer_safety_check.rst
index 89974de48..6770056cb 100644
--- a/docs/bundledplugins/printer_safety_check.rst
+++ b/docs/bundledplugins/printer_safety_check.rst
@@ -16,17 +16,12 @@ such identification.
An example of a warning generated by the Printer Safety Check
-Currently the following firmwares produce this warning:
-
- * Anet A8 stock firmware
+Please refer to the `entry on the "unsafe firmware" warning in OctoPrint's FAQ `_
+for a list of currently identified printers.
If you know of further printers/printer firmwares that need to be added here, please
`get in touch on the forum and provide their response to an M115 `_.
-.. seealso::
-
- `Entry on the "unsafe firmware" warning in OctoPrint's FAQ `_
-
.. note::
Feel free to disable the plugin in OctoPrint's Plugin Manager if you feel like it is unnecessary. Be advised though
diff --git a/docs/images/bundledplugins-announcements-example1.png b/docs/images/bundledplugins-announcements-example1.png
new file mode 100644
index 000000000..153abeb29
Binary files /dev/null and b/docs/images/bundledplugins-announcements-example1.png differ
diff --git a/docs/images/bundledplugins-announcements-example2.png b/docs/images/bundledplugins-announcements-example2.png
new file mode 100644
index 000000000..6cdda8521
Binary files /dev/null and b/docs/images/bundledplugins-announcements-example2.png differ
diff --git a/docs/images/bundledplugins-announcements-settings.png b/docs/images/bundledplugins-announcements-settings.png
new file mode 100644
index 000000000..3e280c9de
Binary files /dev/null and b/docs/images/bundledplugins-announcements-settings.png differ
diff --git a/docs/images/bundledplugins-backup-settings.png b/docs/images/bundledplugins-backup-settings.png
new file mode 100644
index 000000000..1d21c69e8
Binary files /dev/null and b/docs/images/bundledplugins-backup-settings.png differ
diff --git a/docs/images/bundledplugins-forcelogin-dialog.png b/docs/images/bundledplugins-forcelogin-dialog.png
new file mode 100644
index 000000000..8508cb6d4
Binary files /dev/null and b/docs/images/bundledplugins-forcelogin-dialog.png differ
diff --git a/docs/plugins/hooks.rst b/docs/plugins/hooks.rst
index b97d8ff8f..4d20367da 100644
--- a/docs/plugins/hooks.rst
+++ b/docs/plugins/hooks.rst
@@ -1238,6 +1238,45 @@ octoprint.server.http.routes
:return: a list of 3-tuples with additional routes as defined above
:rtype: list
+.. _sec-plugins-hook-server-sockjs-register:
+
+octoprint.server.sockjs.register
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. py:function:: socket_registration_hook(socket, user, *args, **kwargs):
+
+ Allows plugins to prevent a new :ref:`push socket client ` to be registered to the system.
+
+ Handlers should return either ``True`` or ``False``. ``True`` signals to proceed with normal registration. ``False``
+ signals to not register the client.
+
+ See the bundled :ref:`Forcelogin Plugin ` for an example on how to utilize this.
+
+ :param object socket: the socket object which is about to be registered
+ :param object user: the user currently authenticated on the socket - might be None
+ :return: whether to proceed with registration (``True``) or not (``False``)
+ :rtype: boolean
+
+.. _sec-plugins-hook-server-sockjs-emit:
+
+octoprint.server.sockjs.emit
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. py:function:: socket_emit_hook(socket, user, message, payload, *args, **kwargs):
+
+ Allows plugins to prevent any messages to be emitted on an existing :ref:`push connection `.
+
+ Handlers should return either ``True`` to allow the message to be emitted, or ``False`` to prevent it.
+
+ See the bundled :ref:`Forcelogin Plugin ` for an example on how to utilize this.
+
+ :param object socket: the socket object on which a message is about to be emitted
+ :param object user: the user currently authenticated on the socket - might be None
+ :param string message: the message type about to be emitted
+ :param dict payload: the payload of the message about to be emitted (may be None)
+ :return: whether to proceed with sending the message (``True``) or not (``False``)
+ :rtype: boolean
+
.. _sec-plugins-hook-timelapse-extensions:
octoprint.timelapse.extensions
diff --git a/setup.py b/setup.py
index ba2412f48..0c48481af 100644
--- a/setup.py
+++ b/setup.py
@@ -12,6 +12,9 @@ import octoprint_setuptools
#-----------------------------------------------------------------------------------------------------------------------
+# Supported python versions
+PYTHON_REQUIRES = ">=2.7.3,<3" # TODO change to >=2.7.9,<3 in 1.3.11
+
# Requirements for our application
INSTALL_REQUIRES = [
"flask>=0.10.1,<0.11",
@@ -79,9 +82,6 @@ EXTRA_REQUIRES = dict(
]
)
-# Additional requirements for setup
-SETUP_REQUIRES = []
-
# Dependency links for any of the aforementioned dependencies
DEPENDENCY_LINKS = []
@@ -154,10 +154,10 @@ def params():
long_description = read_file_contents(os.path.join(here, "README.md"))
long_description_content_type = "text/markdown"
+ python_requires = PYTHON_REQUIRES
install_requires = INSTALL_REQUIRES
extras_require = EXTRA_REQUIRES
dependency_links = DEPENDENCY_LINKS
- setup_requires = SETUP_REQUIRES
classifiers = [
"Development Status :: 5 - Production/Stable",
diff --git a/src/octoprint/plugins/announcements/__init__.py b/src/octoprint/plugins/announcements/__init__.py
index bccea5198..8ff8e289a 100644
--- a/src/octoprint/plugins/announcements/__init__.py
+++ b/src/octoprint/plugins/announcements/__init__.py
@@ -372,15 +372,24 @@ class AnnouncementPlugin(octoprint.plugin.AssetPlugin,
result = []
if "entries" in feed:
for entry in feed["entries"]:
- internal_entry = self._to_internal_entry(entry, read_until=read_until)
- if internal_entry:
- result.append(internal_entry)
+ try:
+ internal_entry = self._to_internal_entry(entry, read_until=read_until)
+ if internal_entry:
+ result.append(internal_entry)
+ except:
+ self._logger.exception("Error while converting entry from feed, skipping it")
return result
def _to_internal_entry(self, entry, read_until=None):
"""Convert feed entries to internal data structure."""
- published = calendar.timegm(entry["published_parsed"])
+ timestamp = entry.get("published_parsed",
+ entry.get("updated_parsed",
+ None))
+ if timestamp is None:
+ return None
+
+ published = calendar.timegm(timestamp)
read = True
if read_until is not None:
diff --git a/src/octoprint/plugins/backup/__init__.py b/src/octoprint/plugins/backup/__init__.py
index e687b3b85..cf75a073a 100644
--- a/src/octoprint/plugins/backup/__init__.py
+++ b/src/octoprint/plugins/backup/__init__.py
@@ -301,8 +301,14 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin,
import click
@click.command("backup")
- @click.option("--exclude", multiple=True)
+ @click.option("--exclude", multiple=True,
+ help="Identifiers of data folders to exclude, e.g. 'uploads' to exclude uploads or "
+ "'timelapse' to exclude timelapses.")
def backup_command(exclude):
+ """
+ Creates a new backup.
+ """
+
backup_file = "backup-{}.zip".format(time.strftime("%Y%m%d-%H%M%S"))
settings = octoprint.plugin.plugin_settings_for_settings_plugin("backup", self, settings=cli_group.settings)
@@ -310,16 +316,22 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin,
if not os.path.isdir(datafolder):
os.makedirs(datafolder)
+ click.echo("Creating backup at {}, please wait...".format(backup_file))
self._create_backup(backup_file,
exclude=exclude,
settings=settings,
plugin_manager=cli_group.plugin_manager,
datafolder=datafolder)
- click.echo("Created {}".format(backup_file))
+ click.echo("Done.")
@click.command("restore")
@click.argument("path")
def restore_command(path):
+ """
+ Restores an existing backup from the backup zip provided as argument.
+
+ OctoPrint does not need to run for this to proceed.
+ """
settings = octoprint.plugin.plugin_settings_for_settings_plugin("backup", self, settings=cli_group.settings)
plugin_manager = cli_group.plugin_manager
diff --git a/src/octoprint/plugins/discovery/__init__.py b/src/octoprint/plugins/discovery/__init__.py
index 031ef7d48..d5fb2fb41 100644
--- a/src/octoprint/plugins/discovery/__init__.py
+++ b/src/octoprint/plugins/discovery/__init__.py
@@ -194,8 +194,20 @@ class DiscoveryPlugin(octoprint.plugin.StartupPlugin,
params["txtRecord"] = pybonjour.TXTRecord(txt_record)
key = (reg_type, port)
- self._sd_refs[key] = pybonjour.DNSServiceRegister(**params)
- self._logger.info(u"Registered {name} for {reg_type}".format(**locals()))
+
+ counter = 1
+ while True:
+ try:
+ self._sd_refs[key] = pybonjour.DNSServiceRegister(**params)
+ self._logger.info(u"Registered '{name}' for {regtype}".format(**params))
+ return True
+ except pybonjour.BonjourError as be:
+ if be.errorCode == pybonjour.kDNSServiceErr_NameConflict:
+ # Name already registered by different service, let's try a counter postfix. See #2852
+ counter += 1
+ params["name"] = u"{} ({})".format(name, counter)
+ else:
+ raise
def zeroconf_unregister(self, reg_type, port=None):
"""
diff --git a/src/octoprint/plugins/softwareupdate/__init__.py b/src/octoprint/plugins/softwareupdate/__init__.py
index bd13f2a3d..fd17d0897 100644
--- a/src/octoprint/plugins/softwareupdate/__init__.py
+++ b/src/octoprint/plugins/softwareupdate/__init__.py
@@ -27,9 +27,16 @@ from flask_babel import gettext
from octoprint.server.util.flask import restricted_access, with_revalidation_checking, check_etag
from octoprint.server import admin_permission, VERSION, REVISION, BRANCH
from octoprint.util import dict_merge, to_unicode
+from octoprint.util.version import get_comparable_version
+from octoprint.util.pip import LocalPipCaller
import octoprint.settings
+MINIMUM_PYTHON = "2.7.9"
+MINIMUM_SETUPTOOLS = "5.5.1"
+MINIMUM_PIP = "9.0.1"
+
+
##~~ Plugin
@@ -43,7 +50,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
COMMIT_TRACKING_TYPES = ("github_commit", "bitbucket_commit")
- DATA_FORMAT_VERSION = "v3"
+ DATA_FORMAT_VERSION = "v4"
# noinspection PyMissingConstructor
def __init__(self):
@@ -62,6 +69,10 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
self._version_cache_dirty = False
self._version_cache_timestamp = None
+ self._environment_supported = False
+ self._environment_versions = dict()
+ self._environment_ready = threading.Event()
+
self._console_logger = None
def initialize(self):
@@ -92,6 +103,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
# the server startup
def fetch_data():
self.get_current_versions()
+ self._check_environment()
thread = threading.Thread(target=fetch_data)
thread.daemon = True
@@ -165,6 +177,24 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
return self._configured_checks
+ def _check_environment(self):
+ from platform import python_version
+ import pkg_resources
+
+ local_pip = LocalPipCaller()
+
+ # check python and setuptools version
+ versions = dict(python=python_version(),
+ setuptools=pkg_resources.get_distribution("setuptools").version,
+ pip=local_pip.version_string)
+ supported = get_comparable_version(versions["python"]) >= get_comparable_version(MINIMUM_PYTHON) \
+ and get_comparable_version(versions["setuptools"]) >= get_comparable_version(MINIMUM_SETUPTOOLS) \
+ and get_comparable_version(versions["pip"]) >= get_comparable_version(MINIMUM_PIP)
+
+ self._environment_supported = supported
+ self._environment_versions = versions
+ self._environment_ready.set()
+
def _load_version_cache(self):
if not os.path.isfile(self._version_cache_path):
return
@@ -483,11 +513,17 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
force = flask.request.values.get("force", "false") in octoprint.settings.valid_boolean_trues
def view():
+ self._environment_ready.wait()
+
try:
information, update_available, update_possible = self.get_current_versions(check_targets=check_targets, force=force)
- return flask.jsonify(dict(status="inProgress" if self._update_in_progress else "updatePossible" if update_available and update_possible else "updateAvailable" if update_available else "current",
+ return flask.jsonify(dict(status="inProgress" if self._update_in_progress else "updatePossible" if update_available and update_possible and self._environment_supported else "updateAvailable" if update_available else "current",
information=information,
- timestamp=self._version_cache_timestamp))
+ timestamp=self._version_cache_timestamp,
+ environment=dict(supported=self._environment_supported,
+ versions=[dict(name=gettext("Python"), current=self._environment_versions.get("python", "unknown"), minimum=MINIMUM_PYTHON),
+ dict(name=gettext("pip"), current=self._environment_versions.get("pip", "unknown"), minimum=MINIMUM_PIP),
+ dict(name=gettext("setuptools"), current=self._environment_versions.get("setuptools", "unknown"), minimum=MINIMUM_SETUPTOOLS)])))
except exceptions.ConfigurationInvalid as e:
return flask.make_response("Update not properly configured, can't proceed: %s" % e.message, 500)
@@ -514,6 +550,8 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
hash.update(str(data.get("online", None)))
hash.update(",".join(targets))
+
+ hash.update(str(self._environment_supported))
hash.update(str(self._version_cache_timestamp))
hash.update(str(self._connectivity_checker.online))
hash.update(str(self._update_in_progress))
@@ -536,6 +574,9 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
# do not update while a print job is running
return flask.make_response("Printer is currently printing or paused", 409)
+ if not self._environment_supported:
+ return flask.make_response("Direct updates are not supported in this Python environment", 409)
+
if not "application/json" in flask.request.headers["Content-Type"]:
return flask.make_response("Expected content-type JSON", 400)
@@ -647,6 +688,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
continue
target_information, target_update_available, target_update_possible, target_online, target_error = future.result()
+ target_update_possible = target_update_possible and self._environment_supported
target_information = dict_merge(dict(local=dict(name="?", value="?"),
remote=dict(name="?", value="?",
@@ -780,6 +822,10 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
:param targets: an iterable defining the targets to update, if not supplied defaults to all targets
"""
+ if not self._environment_supported:
+ self._logger.error("Direct updates are unsupported in this environment")
+ return [], dict()
+
targets = kwargs.get("targets", kwargs.get("check_targets", None))
checks = self._get_configured_checks()
diff --git a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js
index fbe341dae..c3125ef82 100644
--- a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js
+++ b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js
@@ -31,6 +31,9 @@ $(function() {
&& !self.octoprintReleasedVersion();
});
+ self.environmentSupported = ko.observable(true);
+ self.environmentVersions = ko.observableArray([]);
+
self.cacheTimestamp = ko.observable();
self.cacheTimestampText = ko.pureComputed(function() {
return formatDate(self.cacheTimestamp());
@@ -47,6 +50,10 @@ $(function() {
&& (!self.config_checkoutFolder() || self.config_checkoutFolder().trim() === '');
});
+ self.enableUpdate = ko.pureComputed(function() {
+ return !self.updateInProgress && self.environmentSupported();
+ });
+
self.enable_configSave = ko.pureComputed(function() {
return self.config_checkType() === "github_release"
|| (self.config_checkType() === "git_commit" && !self.error_checkoutFolder());
@@ -215,6 +222,9 @@ $(function() {
var octoprint = data.information["octoprint"];
self.octoprintReleasedVersion(!octoprint || octoprint.released_version);
+ self.environmentSupported(data.environment.supported);
+ self.environmentVersions(data.environment.versions);
+
if (data.status === "inProgress") {
self._markWorking(gettext("Updating..."), gettext("Updating, please wait."));
return;
@@ -229,7 +239,7 @@ $(function() {
_.each(self.versions.items(), function(update_info) {
if (update_info.updateAvailable) {
text += "
+ This version of the Python environment is not supported for direct updates.
+
+
+ To reduce the likelihood of running into update problems in outdated environments, the following minimal
+ versions are required to use this updater to update OctoPrint or any installed plugins:
+
diff --git a/src/octoprint/plugins/softwareupdate/updaters/pip.py b/src/octoprint/plugins/softwareupdate/updaters/pip.py
index 08dfed097..fb970144f 100644
--- a/src/octoprint/plugins/softwareupdate/updaters/pip.py
+++ b/src/octoprint/plugins/softwareupdate/updaters/pip.py
@@ -10,6 +10,7 @@ import logging
import pkg_resources
from octoprint.util.pip import PipCaller, UnknownPip
+from octoprint.util.version import get_comparable_version
from .. import exceptions
logger = logging.getLogger("octoprint.plugins.softwareupdate.updaters.pip")
@@ -23,8 +24,13 @@ _pip_callers = dict()
_pip_version_dependency_links = pkg_resources.parse_version("1.5")
def can_perform_update(target, check, online=True):
+ from .. import MINIMUM_PIP
pip_caller = _get_pip_caller(command=check["pip_command"] if "pip_command" in check else None)
- return "pip" in check and pip_caller is not None and pip_caller.available and (online or check.get("offline", False))
+ return "pip" in check \
+ and pip_caller is not None \
+ and pip_caller.available \
+ and pip_caller.version >= get_comparable_version(MINIMUM_PIP) \
+ and (online or check.get("offline", False))
def _get_pip_caller(command=None):
key = command
diff --git a/src/octoprint/plugins/tracking/__init__.py b/src/octoprint/plugins/tracking/__init__.py
index 2dca12454..038008d05 100644
--- a/src/octoprint/plugins/tracking/__init__.py
+++ b/src/octoprint/plugins/tracking/__init__.py
@@ -6,7 +6,7 @@ __copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms
import octoprint.plugin
-from flask.ext.babel import gettext
+from flask_babel import gettext
import requests
import hashlib
diff --git a/src/octoprint/server/api/__init__.py b/src/octoprint/server/api/__init__.py
index bf9b7efbe..ed4cc7cee 100644
--- a/src/octoprint/server/api/__init__.py
+++ b/src/octoprint/server/api/__init__.py
@@ -215,9 +215,12 @@ def login():
login_user(user, remember=remember)
identity_changed.send(current_app._get_current_object(), identity=Identity(user.get_id()))
+ remote_addr = get_remote_address(request)
+ logging.getLogger(__name__).info("Actively logging in user {} from {}".format(user.get_id(), remote_addr))
+
response = user.asDict()
response["_is_external_client"] = s().getBoolean(["server", "ipCheck", "enabled"]) \
- and not util_net.is_lan_address(get_remote_address(request),
+ and not util_net.is_lan_address(remote_addr,
additional_private=s().get(["server", "ipCheck", "trustedSubnets"]))
return jsonify(response)
diff --git a/src/octoprint/server/util/flask.py b/src/octoprint/server/util/flask.py
index 66bd47d46..fc3b148f0 100644
--- a/src/octoprint/server/util/flask.py
+++ b/src/octoprint/server/util/flask.py
@@ -526,6 +526,8 @@ def passive_login():
flask.session["usersession.id"] = user.session
flask.g.user = user
+ logging.getLogger(__name__).info("Passively logging in user {} from {}".format(user.get_id(), remoteAddr))
+
response = user.asDict()
response["_is_external_client"] = ipCheckEnabled and not is_lan_address(remoteAddr,
additional_private=ipCheckTrusted)
@@ -551,6 +553,9 @@ def passive_login():
flask_principal.identity_changed.send(flask.current_app._get_current_object(),
identity=flask_principal.Identity(user.get_id()))
+ logging.getLogger(__name__).info("Passively logging in user {} from {} via autologin".format(user.get_id(),
+ remoteAddr))
+
response = user.asDict()
response["_is_external_client"] = ipCheckEnabled and not is_lan_address(remoteAddr,
additional_private=ipCheckTrusted)
@@ -1133,24 +1138,34 @@ def redirect_to_tornado(request, target, code=302):
def restricted_access(func):
+ """
+ This combines :py:func:`no_firstrun_access` and ``login_required``.
+ """
+ @functools.wraps(func)
+ def decorated_view(*args, **kwargs):
+ return no_firstrun_access(flask_login.login_required(func))(*args, **kwargs)
+ return decorated_view
+
+def no_firstrun_access(func):
"""
If you decorate a view with this, it will ensure that first setup has been
- done for OctoPrint's Access Control plus that any conditions of the
- login_required decorator are met (possibly through a session already created
- by octoprint.server.util.apiKeyRequestHandler earlier in the request processing).
+ done for OctoPrint's Access Control.
If OctoPrint's Access Control has not been setup yet (indicated by the "firstRun"
flag from the settings being set to True and the userManager not indicating
that it's user database has been customized from default), the decorator
will cause a HTTP 403 status code to be returned by the decorated resource.
"""
+
@functools.wraps(func)
def decorated_view(*args, **kwargs):
- return flask_login.login_required(no_firstrun_access(func))(*args, **kwargs)
+ # if OctoPrint hasn't been set up yet, abort
+ if settings().getBoolean(["server", "firstRun"]) and settings().getBoolean(["accessControl", "enabled"]) and (octoprint.server.userManager is None or not octoprint.server.userManager.hasBeenCustomized()):
+ return flask.make_response("OctoPrint isn't setup yet", 403)
+ return func(*args, **kwargs)
return decorated_view
-
def firstrun_only_access(func):
"""
If you decorate a view with this, it will ensure that first setup has _not_ been
@@ -1168,24 +1183,6 @@ def firstrun_only_access(func):
return decorated_view
-def no_firstrun_access(func):
- """
- If you decorate a view with this, it will ensure that first setup as been done for
- OctoPrint's Access Control. Otherwise it
- will cause a HTTP 403 status code to be returned by the decorated resource.
- """
-
- @functools.wraps(func)
- def decorated_view(*args, **kwargs):
- # if OctoPrint hasn't been set up yet, abort
- if settings().getBoolean(["server", "firstRun"]) and settings().getBoolean(["accessControl", "enabled"]) and \
- (octoprint.server.userManager is None or not octoprint.server.userManager.hasBeenCustomized()):
- return flask.make_response("OctoPrint isn't setup yet", 403)
- return func(*args, **kwargs)
-
- return decorated_view
-
-
class AppSessionManager(object):
VALIDITY_UNVERIFIED = 1 * 60 # 1 minute
diff --git a/src/octoprint/static/js/app/viewmodels/loginstate.js b/src/octoprint/static/js/app/viewmodels/loginstate.js
index c67273c2a..d00e7f804 100644
--- a/src/octoprint/static/js/app/viewmodels/loginstate.js
+++ b/src/octoprint/static/js/app/viewmodels/loginstate.js
@@ -20,6 +20,8 @@ $(function() {
self.elementPasswordInput = undefined;
self.elementLoginButton = undefined;
+ self.externalAddressNotification = undefined;
+
self.userMenuText = ko.pureComputed(function() {
if (self.loggedIn()) {
return self.username();
@@ -80,10 +82,15 @@ $(function() {
"everyone with an internet connection.
Please see " +
"this blog post for " +
"ways to safely access your OctoPrint instance from remote.
" +
- "
If you know what you are doing or you are sure this message is" +
+ "
If you know what you are doing or you are sure this message is " +
"mistaken since you are in an isolated LAN, feel free to ignore it.
");
text = _.sprintf(text, {url: "https://octoprint.org/blog/2018/09/03/safe-remote-access/"});
- new PNotify({
+
+ if (self.externalAddressNotification !== undefined) {
+ self.externalAddressNotification.remove();
+ }
+
+ self.externalAddressNotification = new PNotify({
title: gettext("Possible external access detected"),
text: text,
hide: false,
diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py
index bee3e0837..68ffbf039 100644
--- a/src/octoprint/util/comm.py
+++ b/src/octoprint/util/comm.py
@@ -126,7 +126,7 @@ Groups will be as follows:
* ``target``: new target temperature (float)
"""
-regex_position = re.compile("X:(?P{float})\s*Y:(?P{float})\s*Z:(?P{float})\s*((E:(?P{float}))|(?P(E\d+:{float}\s*)+))".format(float=regex_float_pattern))
+regex_position = re.compile("X:\s*(?P{float})\s*Y:\s*(?P{float})\s*Z:\s*(?P{float})\s*((E:\s*(?P{float}))|(?P(E\d+:\s*{float}\s*)+))".format(float=regex_float_pattern))
"""Regex for matching position reporting.
Groups will be as follows:
@@ -138,7 +138,7 @@ Groups will be as follows:
* ``es``: multiple E coordinates if present, to be parsed further with regex_e_positions
"""
-regex_e_positions = re.compile("E(?P\d+):(?P{float})".format(float=regex_float_pattern))
+regex_e_positions = re.compile("E(?P\d+):\s*(?P{float})".format(float=regex_float_pattern))
"""Regex for matching multiple E coordinates in a position report.
Groups will be as follows:
diff --git a/src/octoprint/util/net.py b/src/octoprint/util/net.py
index 05106ac74..2ca5cfea3 100644
--- a/src/octoprint/util/net.py
+++ b/src/octoprint/util/net.py
@@ -25,6 +25,10 @@ else:
HAS_V6 = False
def is_lan_address(address, additional_private=None):
+ if address.lower().startswith("::ffff:") and "." in address:
+ # ipv6 mapped ipv4 address, unmap
+ address = address[len("::ffff:"):]
+
ip = netaddr.IPAddress(address)
if ip.is_private() or ip.is_loopback():
return True
@@ -45,7 +49,12 @@ def is_lan_address(address, additional_private=None):
if "/" in prefix:
# v6 notation in netifaces output, e.g. "ffff:ffff:ffff:ffff::/64"
_, prefix = prefix.split("/")
- return netaddr.IPNetwork("{}/{}".format(address["addr"], prefix))
+
+ addr = address["addr"]
+ if "%" in addr:
+ # interface comment in netifaces output, e.g. "fe80::457f:bbee:d579:1063%wlan0"
+ addr = addr[:addr.find("%")]
+ return netaddr.IPNetwork("{}/{}".format(addr, prefix))
except:
pass
diff --git a/src/octoprint/vendor/sockjs/tornado/transports/rawwebsocket.py b/src/octoprint/vendor/sockjs/tornado/transports/rawwebsocket.py
index d5dd6efc7..00e494b6d 100644
--- a/src/octoprint/vendor/sockjs/tornado/transports/rawwebsocket.py
+++ b/src/octoprint/vendor/sockjs/tornado/transports/rawwebsocket.py
@@ -10,6 +10,7 @@ import socket
from octoprint.vendor.sockjs.tornado import websocket, session
from octoprint.vendor.sockjs.tornado.transports import base
+from tornado.ioloop import IOLoop
LOG = logging.getLogger("tornado.general")
@@ -74,11 +75,16 @@ class RawWebSocketTransport(websocket.SockJSWebSocketHandler, base.BaseTransport
session.close()
def send_pack(self, message, binary=False):
- # Send message
- try:
- self.write_message(message, binary)
- except IOError:
- self.server.io_loop.add_callback(self.on_close)
+ if IOLoop.current(False) == self.server.io_loop:
+ # Running in Main Thread
+ # Send message
+ try:
+ self.write_message(message, binary)
+ except IOError:
+ self.server.io_loop.add_callback(self.on_close)
+ else:
+ # Not running in Main Thread so use proper thread to send message
+ self.server.io_loop.add_callback(lambda: self.send_pack(message, binary))
def session_closed(self):
try:
diff --git a/src/octoprint/vendor/sockjs/tornado/transports/websocket.py b/src/octoprint/vendor/sockjs/tornado/transports/websocket.py
index 8df3a2901..644b14543 100644
--- a/src/octoprint/vendor/sockjs/tornado/transports/websocket.py
+++ b/src/octoprint/vendor/sockjs/tornado/transports/websocket.py
@@ -11,6 +11,7 @@ import socket
from octoprint.vendor.sockjs.tornado import proto, websocket
from octoprint.vendor.sockjs.tornado.transports import base
from octoprint.vendor.sockjs.tornado.util import bytes_to_str
+from tornado.ioloop import IOLoop
LOG = logging.getLogger("tornado.general")
@@ -81,11 +82,16 @@ class WebSocketTransport(websocket.SockJSWebSocketHandler, base.BaseTransportMix
session.close()
def send_pack(self, message, binary=False):
- # Send message
- try:
- self.write_message(message, binary)
- except IOError:
- self.server.io_loop.add_callback(self.on_close)
+ if IOLoop.current(False) == self.server.io_loop:
+ # Running in Main Thread
+ # Send message
+ try:
+ self.write_message(message, binary)
+ except IOError:
+ self.server.io_loop.add_callback(self.on_close)
+ else:
+ # Not running in Main Thread so use proper thread to send message
+ self.server.io_loop.add_callback(lambda: self.send_pack(message, binary))
def session_closed(self):
# If session was closed by the application, terminate websocket
diff --git a/src/octoprint_setuptools/__init__.py b/src/octoprint_setuptools/__init__.py
index 328be4558..158408a53 100644
--- a/src/octoprint_setuptools/__init__.py
+++ b/src/octoprint_setuptools/__init__.py
@@ -524,8 +524,7 @@ def create_plugin_setup_parameters(identifier="todo", name="TODO", version="0.1"
translation_dir = os.path.join(source_folder, "translations")
pot_file = os.path.join(translation_dir, "messages.pot")
bundled_dir = os.path.join(source_folder, package, "translations")
- if os.path.isdir(translation_dir) and os.path.isfile(pot_file):
- cmdclass.update(get_babel_commandclasses(pot_file=pot_file, output_dir=translation_dir, bundled_dir=bundled_dir, pack_name_prefix="{name}-i18n-".format(**locals()), pack_path_prefix="_plugins/{identifier}/".format(**locals())))
+ cmdclass.update(get_babel_commandclasses(pot_file=pot_file, output_dir=translation_dir, bundled_dir=bundled_dir, pack_name_prefix="{name}-i18n-".format(**locals()), pack_path_prefix="_plugins/{identifier}/".format(**locals())))
from setuptools import find_packages
packages = list(set([package] + filter(lambda x: x.startswith("{package}.".format(package=package)), find_packages(where=source_folder, exclude=ignored_packages)) + additional_packages))
diff --git a/tests/util/test_comm_helpers.py b/tests/util/test_comm_helpers.py
index 119ff406d..dc3adae14 100644
--- a/tests/util/test_comm_helpers.py
+++ b/tests/util/test_comm_helpers.py
@@ -267,11 +267,11 @@ class TestCommHelpers(unittest.TestCase):
("NAME. Malyan VER: 3.7 MODEL: M300 HW: HG01",
dict(NAME="Malyan", VER="3.7", MODEL="M300", HW="HG01")),
("FIRMWARE_NAME:Marlin 1.1.0 From Archive SOURCE_CODE_URL:http:// ... PROTOCOL_VERSION:1.0 MACHINE_TYPE:www.cxsw3d.com EXTRUDER_COUNT:1 UUID:00000000-0000-0000-0000-000000000000",
- dict(FIRMWARE_NAME="Marlin 1.1.0 From Archive",
- SOURCE_CODE_URL="http:// ...",
- PROTOCOL_VERSION="1.0",
- MACHINE_TYPE="www.cxsw3d.com",
- EXTRUDER_COUNT="1",
+ dict(FIRMWARE_NAME="Marlin 1.1.0 From Archive",
+ SOURCE_CODE_URL="http:// ...",
+ PROTOCOL_VERSION="1.0",
+ MACHINE_TYPE="www.cxsw3d.com",
+ EXTRUDER_COUNT="1",
UUID="00000000-0000-0000-0000-000000000000"))
)
@unpack
@@ -333,6 +333,12 @@ class TestCommHelpers(unittest.TestCase):
e4=0.0,
e5=0.0)),
+ # whitespace after the :, e.g. AlfaWise U20, see #2839
+ ("X:150.0 Y:150.0 Z: 0.7 E: 0.0", dict(x=150.0,
+ y=150.0,
+ z=0.7,
+ e=0.0)),
+
# invalid
("", None),
("X:62.417 Y:64.781 Z:0.2", None)
diff --git a/tests/util/test_net.py b/tests/util/test_net.py
index e773ddac4..a1a33cec0 100644
--- a/tests/util/test_net.py
+++ b/tests/util/test_net.py
@@ -38,6 +38,8 @@ class UtilNetTest(unittest.TestCase):
("10.1.2.3", [], True),
("fc00::1", [], True),
("::1", [], True),
+ ("::ffff:192.168.1.1", [], True),
+ ("::ffff:8.8.8.8", [], False),
("11.1.2.3", [], False),
("11.1.2.3", ["11/8"], True),
("12.1.1.123", [], True),