diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index b74302e99..5bb769e20 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -1,6 +1,10 @@ name: Test install of branches and latest release twice per day on: + push: + branches: + - master + workflow_dispatch: schedule: - cron: '0 */12 * * *' diff --git a/.github/workflows/trigger_docker.yml b/.github/workflows/trigger_docker.yml new file mode 100644 index 000000000..1d842b60c --- /dev/null +++ b/.github/workflows/trigger_docker.yml @@ -0,0 +1,18 @@ +name: Trigger docker build +on: + release: + types: + - released + - prereleased + +jobs: + trigger: + runs-on: ubuntu-latest + steps: + - name: 🚀 Repository Dispatch + uses: peter-evans/repository-dispatch@v1 + with: + token: ${{ secrets.DOCKER_ACCESS_TOKEN }} + repository: OctoPrint/docker + event-type: octoprint-release + client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "event-name": "${{ github.event_name }}", "event-type": "${{ github.event.action }}"}' diff --git a/docs/development/environment.rst b/docs/development/environment.rst index 5283796f0..bb37dcdd8 100644 --- a/docs/development/environment.rst +++ b/docs/development/environment.rst @@ -21,9 +21,9 @@ below. * ``git clone https://github.com/OctoPrint/OctoPrint.git`` * Enter the checked out source folder: ``cd OctoPrint`` - * Create virtual environments in the checked out source folder for both Python 2.7 and Python 3.7 to use for - installing and running OctoPrint and its dependencies (this avoids potential versioning issues for the dependencies - with system wide installed instances): + * Create virtual environments in the checked out source folder for both Python 2 and Python 3 to use for + installing and running OctoPrint and its dependencies. Creating virtual environments avoids potential versioning + issues for the dependencies with system wide installed instances: * ``virtualenv --python=python3 venv`` @@ -49,33 +49,38 @@ below. When the virtual environment is activated you can then: * run the OctoPrint server via ``octoprint serve`` - * run the test suite from the checked out source folder via ``nosetests --with-doctest`` - * build the documentation from the ``docs`` sub folder of the checked out sources via ``sphinx-build -b html . _build`` + * run the test suite from the checked out source folder via ``pytest`` To switch the activated virtual environment, simply activate the new environment as described above. To deactivate the virtual environment and return to the system's default Python: ``deactivate``. +If you also want to be able to build the documentation that resides in the ``docs`` subfolder, you need to activate +the *Python 3* environment and install the docs dependencies as well: + + * ``source venv3/bin/activate`` (Linux, macOS) or ``source venv3/Scripts/activate`` (Git Bash under Windows, see below) + * ``pip install -e .[develop,plugins,docs]`` + +You can then build the documentation: + + * ``sphinx-build -b html . _build`` + .. _sec-development-environment-source-linux: Linux ..... -.. todo:: - - This guide is not yet adapted to the concurrent use of Python 2.7 and 3.7 environments during development. - This assumes you'll host your OctoPrint development checkout at ``~/devel/OctoPrint``. If you want to use a different location, please substitute accordingly. -First make sure you have python including its header files, pip, setuptools, virtualenv, git and some build requirements +First make sure you have python 2 and 3 including their header files, pip, setuptools, virtualenv, git and some build requirements installed: * On apt based distributions (e.g. Debian, Ubuntu, ...): .. code-block:: none - sudo apt-get install python3 python3-pip python3-dev python3-setuptools python3-virtualenv git libyaml-dev build-essential + sudo apt-get install python3 python3-pip python3-dev python3-setuptools python3-virtualenv python3 python3-virtualenv python3-dev git libyaml-dev build-essential .. todo:: @@ -88,25 +93,24 @@ Then: .. code-block:: none cd ~/devel - git clone -b devel https://github.com/OctoPrint/OctoPrint.git + git clone https://github.com/OctoPrint/OctoPrint.git cd OctoPrint - virtualenv venv - source ./venv/bin/activate + virtualenv --python=python2 venv2 + virtualenv --python=python3 venv3 + source ./venv2/bin/activate pip install --upgrade pip pip install -e .[develop,plugins] + source ./venv3/bin/activate + pip install --upgrade pip + pip install -e .[develop,plugins,docs] -You can then start OctoPrint via ``~/devel/OctoPrint/venv/bin/octoprint`` or just ``octoprint`` if you activated the virtual -environment. +You can then start OctoPrint via ``octoprint`` after activating one of the two virtual environments. .. _sec-development-environment-windows: Windows ....... -.. todo:: - - This guide is not yet adapted to the concurrent use of Python 2.7 and 3.7 environments during development. - This assumes you'll host your OctoPrint development checkout at ``C:\Devel\OctoPrint``. If you want to use a different location, please substitute accordingly. @@ -115,6 +119,8 @@ First download & install: * `The current Python 3.8 Windows x86 executable installer `_ * make sure to have the installer add Python to the ``PATH`` and have it install ``pip`` too + * it's recommended to install Python 2.7 into ``C:\Python27`` and Python 3 into ``C:\Python38`` - if you select + different install locations please substitute accordingly * `Build Tools for Visual Studio 2019 `_ * `Git for Windows `_ @@ -127,10 +133,14 @@ Open the Git Bash you just installed and in that: cd /c/Devel git clone https://github.com/OctoPrint/OctoPrint.git cd OctoPrint - virtualenv venv - source ./venv/Scripts/activate + virtualenv --python=C:\Python27\python.exe venv2 + virtualenv --python=C:\Python38\python.exe venv3 + source ./venv2/Scripts/activate pip install --upgrade pip pip install -e .[develop,plugins] + source ./venv3/Scripts/activate + pip install --upgrade pip + pip install -e .[develop,plugins,docs] .. _sec-development-environment-mac: @@ -144,7 +154,9 @@ Mac OS X .. todo:: - This guide is not yet adapted to the concurrent use of Python 2.7 and 3.7 environments during development. + This guide is not yet adapted to the concurrent use of Python 2 and 3 environments during development. Please send a + `Pull Request `_ to get the necessary + steps into this guide! This assumes you'll host your OctoPrint development checkout at ``~/devel/OctoPrint``. If you want to use a different location, please substitute accordingly. @@ -196,18 +208,23 @@ PyCharm ....... - "File" > "Open ...", select OctoPrint checkout folder (e.g. ``~/devel/OctoPrint`` or ``C:\Devel\OctoPrint``) - - **(Linux, Windows)** "File" > "Settings ..." > "Project: OctoPrint" > "Project Interpreter" > "Add local ...", select OctoPrint venv - folder (e.g. ``~/devel/OctoPrint/venv`` or ``C:\Devel\OctoPrint\venv``) - - **(macOS)** "PyCharm" > "Preferences ..." > "Project: OctoPrint" > "Project Interpreter" > "Add ..." > - "Virtualenv Environment > "Existing Environment", select OctoPrint venv folder (e.g. ``~/devel/OctoPrint/venv``) + - Register virtual environments: + + - **(Linux, Windows)** "File" > "Settings ..." > "Project: OctoPrint" > "Project Interpreter" > "Add local ...", + select OctoPrint ``venv2`` folder (e.g. ``~/devel/OctoPrint/venv2`` or ``C:\Devel\OctoPrint\venv2``). + - **(macOS)** "PyCharm" > "Preferences ..." > "Project: OctoPrint" > "Project Interpreter" > "Add ..." > + "Virtualenv Environment > "Existing Environment", select OctoPrint ``venv2`` folder (e.g. ``~/devel/OctoPrint/venv2``). + + Repeat for the ``venv3`` folder. + - Right click "src" in project tree, mark as source folder - Add Run/Debug Configuration, select "Python": * Name: OctoPrint server * Module name: ``octoprint`` - * Module parameters: ``serve --debug`` + * Parameters: ``serve --debug`` * Project: ``OctoPrint`` - * Python interpreter: the ``venv`` local virtual environment + * Python interpreter: Project Default * Working directory: the OctoPrint checkout folder (e.g. ``~/devel/OctoPrint`` or ``C:\Devel\OctoPrint``) * If you want build artifacts to be cleaned up on run (recommended): "Before Launch" > "+" > "Run external tool" > "+" @@ -223,29 +240,38 @@ PyCharm * Parameters: ``-m pip install -e .[develop,plugins]`` * Working directory: ``$ProjectFileDir$`` + Note that sadly that seems to cause some hiccups on current PyCharm versions due to ``$PyInterpreterDirectory$`` + being empty sometimes, so if this fails to run on your installation, you should update your dependencies manually + for now. + - Add Run/Debug Configuration, select "Python tests" and therein "pytest": - * Name: OctoPrint pytest + * Name: OctoPrint tests * Target: Custom * Project: ``OctoPrint`` - * Python interpreter: the ``venv`` local virtual environment + * Python interpreter: Project Default * Working directory: the OctoPrint checkout folder (e.g. ``~/devel/OctoPrint`` or ``C:\Devel\OctoPrint``) * Just like with the run configuration for the server you can also have the dependencies auto-update on run of the tests, see above on how to set this up. - - Add Run/Debug Configuration, select "Python docs" and therein "Sphinx task" + - Add Run/Debug Configuration, select "Python": * Name: OctoPrint docs - * Command: ``html`` - * Input: the ``docs`` folder in the OctoPrint checkout folder (e.g. ``~/devel/OctoPrint/docs`` or - ``C:\Devel\OctoPrint\docs``) - * Output: the ``docs/_build`` folder in the OctoPrint checkout folder (e.g. ``~/devel/OctoPrint/docs/_build`` or - ``C:\Devel\OctoPrint\docs\_build``) + * Module name: ``sphinx.cmd.build`` + * Parameters: ``-v -T -E ./docs ./docs/_build -b html`` * Project: ``OctoPrint`` - * Python interpreter: the ``venv`` local virtual environment + * Python interpreter: ``venv3`` environment (the docs build requires Python 3) + * Working directory: the OctoPrint checkout folder (e.g. ``~/devel/OctoPrint`` or ``C:\Devel\OctoPrint``) * Just like with the run configuration for the server you can also have the dependencies auto-update when building the documentation, see above on how to set this up. + Note that this requires you to also have installed the additional ``docs`` dependencies into the Python 3 venv as + described above via ``pip install -e .[develop,plugins,docs]``. + +To switch between Python 2 and 3, all you need to do now is change the Project Default Interpreter and restart +OctoPrint. On current PyCharm versions you can do that right from a small selection field in the footer of the IDE. +Otherwise go through Settings. + .. note:: Make sure you are running a PyCharm version of 2016.1 or later, or manually fix diff --git a/setup.py b/setup.py index 9cc5db62a..23fc7e3b8 100644 --- a/setup.py +++ b/setup.py @@ -64,6 +64,7 @@ INSTALL_REQUIRES = [ "frozendict>=1.2,<2", "sentry-sdk>=0.15.1,<1", "filetype>=1.0.7,<2", + "zeroconf>=0.24,<0.25", # vendor bundle dependencies "unidecode>=0.04.14,<0.05", # dependency of awesome-slugify diff --git a/src/octoprint/__init__.py b/src/octoprint/__init__.py index 18322aa29..0196952f7 100644 --- a/src/octoprint/__init__.py +++ b/src/octoprint/__init__.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera import io import sys import logging as log +import os #~~ version @@ -19,7 +20,9 @@ __revision__ = versions.get('full-revisionid', versions.get('full', None)) del versions del get_versions -#~~ try to ensure a sound SSL environment +# figure out current umask - sadly only doable by setting a new one and resetting it, no query method +UMASK = os.umask(0) +os.umask(UMASK) urllib3_ssl = True """Whether requests/urllib3 and urllib3 (if installed) should be able to establish diff --git a/src/octoprint/filemanager/util.py b/src/octoprint/filemanager/util.py index 7074d508a..682d18e53 100644 --- a/src/octoprint/filemanager/util.py +++ b/src/octoprint/filemanager/util.py @@ -6,7 +6,9 @@ __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agp __copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License" import io +import os +from octoprint import UMASK from octoprint.util import atomic_write class AbstractFileWrapper(object): @@ -17,15 +19,18 @@ class AbstractFileWrapper(object): filename (str): The file's name """ + DEFAULT_PERMISSIONS = 0o664 + def __init__(self, filename): self.filename = filename - def save(self, path): + def save(self, path, permissions=None): """ Saves the file's content to the given absolute path. Arguments: path (str): The absolute path to where to save the file + permissions (int): The permissions to set on the file """ raise NotImplementedError() @@ -55,7 +60,7 @@ class DiskFileWrapper(AbstractFileWrapper): self.path = path self.move = move - def save(self, path): + def save(self, path, permissions=None): import shutil if self.move: @@ -63,6 +68,10 @@ class DiskFileWrapper(AbstractFileWrapper): else: shutil.copy2(self.path, path) + if permissions is None: + permissions = self.DEFAULT_PERMISSIONS & ~UMASK + os.chmod(path, permissions) + def stream(self): return io.open(self.path, 'rb') @@ -80,7 +89,7 @@ class StreamWrapper(AbstractFileWrapper): AbstractFileWrapper.__init__(self, filename) self.streams = streams - def save(self, path): + def save(self, path, permissions=None): """ Will dump the contents of all streams provided during construction into the target file, in the order they were provided. @@ -90,6 +99,9 @@ class StreamWrapper(AbstractFileWrapper): with atomic_write(path, mode='wb') as dest: for source in self.streams: shutil.copyfileobj(source, dest) + if permissions is None: + permissions = self.DEFAULT_PERMISSIONS & ~UMASK + os.chmod(path, permissions) def stream(self): """ diff --git a/src/octoprint/plugins/discovery/__init__.py b/src/octoprint/plugins/discovery/__init__.py index 3a12687e9..db9e03504 100644 --- a/src/octoprint/plugins/discovery/__init__.py +++ b/src/octoprint/plugins/discovery/__init__.py @@ -9,7 +9,6 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms The SSDP/UPNP implementations has been largely inspired by https://gist.github.com/schlamar/2428250 """ -import logging import flask from flask_babel import gettext @@ -20,17 +19,18 @@ import octoprint.plugin import octoprint.util try: - # TODO: looks like pybonjour is py2 only - find alternatives or port? - import pybonjour -except ImportError: - pybonjour = False + # python 3 + import zeroconf +except ImportError: + # python 2: vendored version with some backported fixes + import octoprint.vendor.zeroconf as zeroconf + +import time +import collections +import socket def __plugin_load__(): - if not pybonjour: - # no pybonjour available, we can't use that - logging.getLogger("octoprint.plugins." + __name__).info("pybonjour is not installed, Zeroconf Discovery won't be available") - plugin = DiscoveryPlugin() global __plugin_implementation__ @@ -38,14 +38,11 @@ def __plugin_load__(): global __plugin_helpers__ __plugin_helpers__ = dict( - ssdp_browse=plugin.ssdp_browse + ssdp_browse=plugin.ssdp_browse, + zeroconf_browse = plugin.zeroconf_browse, + zeroconf_register = plugin.zeroconf_register, + zeroconf_unregister = plugin.zeroconf_unregister ) - if pybonjour: - __plugin_helpers__.update(dict( - zeroconf_browse=plugin.zeroconf_browse, - zeroconf_register=plugin.zeroconf_register, - zeroconf_unregister=plugin.zeroconf_unregister - )) class DiscoveryPlugin(octoprint.plugin.StartupPlugin, octoprint.plugin.ShutdownPlugin, @@ -62,8 +59,8 @@ class DiscoveryPlugin(octoprint.plugin.StartupPlugin, self.port = None # zeroconf - self._sd_refs = dict() - self._cnames = dict() + self._zeroconf = zeroconf.Zeroconf() + self._zeroconf_registrations = collections.defaultdict(list) # upnp/ssdp self._ssdp_monitor_active = False @@ -143,14 +140,12 @@ class DiscoveryPlugin(octoprint.plugin.StartupPlugin, # Zeroconf self.zeroconf_register("_http._tcp", self.get_instance_name(), txt_record=self._create_http_txt_record_dict()) self.zeroconf_register("_octoprint._tcp", self.get_instance_name(), txt_record=self._create_octoprint_txt_record_dict()) - for zeroconf in self._settings.get(["zeroConf"]): - if "service" in zeroconf: - self.zeroconf_register( - zeroconf["service"], - zeroconf["name"] if "name" in zeroconf else self.get_instance_name(), - port=zeroconf["port"] if "port" in zeroconf else None, - txt_record=zeroconf["txtRecord"] if "txtRecord" in zeroconf else None - ) + for zc in self._settings.get(["zeroConf"]): + if "service" in zc: + self.zeroconf_register(zc["service"], + zc.get("name", self.get_instance_name()), + port=zc.get("port"), + txt_record=zc.get("txtRecord")) # SSDP self._ssdp_register() @@ -158,7 +153,7 @@ class DiscoveryPlugin(octoprint.plugin.StartupPlugin, ##~~ ShutdownPlugin API -- used for unregistering OctoPrint's Zeroconf and SSDP service upon application shutdown def on_shutdown(self): - for key in self._sd_refs: + for key in self._zeroconf_registrations: reg_type, port = key self.zeroconf_unregister(reg_type, port) @@ -168,6 +163,27 @@ class DiscoveryPlugin(octoprint.plugin.StartupPlugin, # ZeroConf + def _format_zeroconf_service_type(self, service_type): + service_type = octoprint.util.to_native_str(service_type) + if not service_type.endswith(octoprint.util.to_native_str(".")): + service_type += octoprint.util.to_native_str(".") + if not service_type.endswith(octoprint.util.to_native_str("local.")): + service_type += octoprint.util.to_native_str("local.") + return service_type + + def _format_zeroconf_name(self, name, service_type): + service_type = self._format_zeroconf_service_type(service_type) + return octoprint.util.to_native_str(name) + octoprint.util.to_native_str(".") + service_type + + def _format_zeroconf_txt(self, record): + result = dict() + if not record: + return result + + for key, value in record.items(): + result[octoprint.util.to_bytes(key)] = octoprint.util.to_bytes(value) + return result + def zeroconf_register(self, reg_type, name=None, port=None, txt_record=None): """ Registers a new service with Zeroconf/Bonjour/Avahi. @@ -178,37 +194,29 @@ class DiscoveryPlugin(octoprint.plugin.StartupPlugin, :param txt_record: optional txt record to attach to the service, dictionary of key-value-pairs """ - if not pybonjour: - return - if not name: name = self.get_instance_name() if not port: port = self.port - params = dict( - name=name, - regtype=reg_type, - port=port - ) - if txt_record: - params["txtRecord"] = pybonjour.TXTRecord(txt_record) + reg_type = self._format_zeroconf_service_type(reg_type) + name = self._format_zeroconf_name(name, reg_type) + txt_record = self._format_zeroconf_txt(txt_record) key = (reg_type, port) + addresses = list(map(lambda x: socket.inet_aton(x), octoprint.util.net.interface_addresses())) - counter = 1 - while True: - try: - self._sd_refs[key] = pybonjour.DNSServiceRegister(**params) - self._logger.info("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"] = "{} ({})".format(name, counter) - else: - raise + try: + info = zeroconf.ServiceInfo(reg_type, name, + addresses=addresses, + port=port, + server="{}.local.".format(socket.gethostname()), + properties=txt_record) + self._zeroconf.register_service(info, allow_name_change=True) + self._zeroconf_registrations[key].append(info) + self._logger.info("Registered '{}' for {}".format(name, reg_type)) + except Exception: + self._logger.exception("Could not register {} for {} on port {}".format(name, reg_type, port)) def zeroconf_unregister(self, reg_type, port=None): """ @@ -219,22 +227,21 @@ class DiscoveryPlugin(octoprint.plugin.StartupPlugin, :return: """ - if not pybonjour: - return - if not port: port = self.port + reg_type = self._format_zeroconf_service_type(reg_type) key = (reg_type, port) - if not key in self._sd_refs: + if not key in self._zeroconf_registrations: return - sd_ref = self._sd_refs[key] + infos = self._zeroconf_registrations.pop(key) try: - sd_ref.close() - self._logger.debug("Unregistered {reg_type} on port {port}".format(reg_type=reg_type, port=port)) - except Exception: - self._logger.exception("Could not unregister {reg_type} on port {port}".format(reg_type=reg_type, port=port)) + for info in infos: + self._zeroconf.unregister_service(info) + self._logger.debug("Unregistered {} on port {}".format(reg_type, port)) + except: + self._logger.exception("Could not (fully) unregister {} on port {}".format(reg_type, port)) def zeroconf_browse(self, service_type, block=True, callback=None, browse_timeout=5, resolve_timeout=5): """ @@ -271,79 +278,46 @@ class DiscoveryPlugin(octoprint.plugin.StartupPlugin, supplied to the callback instead) """ - if not pybonjour: - return None - import threading - import select if not block and not callback: raise ValueError("Non-blocking mode but no callback given") + service_type = self._format_zeroconf_service_type(service_type) + result = [] result_available = threading.Event() result_available.clear() - resolved = [] + class ZeroconfListener(object): + def __init__(self, logger): + self._logger = logger - def resolve_callback(sd_ref, flags, interface_index, error_code, fullname, hosttarget, port, txt_record): - if error_code == pybonjour.kDNSServiceErr_NoError: - txt_record_dict = None - if txt_record: - record = pybonjour.TXTRecord.parse(txt_record) - txt_record_dict = dict() - for key, value in record: - txt_record_dict[key] = value + def add_service(self, zeroconf, type, name): + self._logger.debug("Got a browsing result for Zeroconf resolution of {}, resolving...".format(type)) + info = zeroconf.get_service_info(type, name, timeout=resolve_timeout * 1000) + if info: + def to_result(info, address): + n = info.name[:-(len(type) + 1)] + p = info.port - name = fullname[:fullname.find(service_type) - 1].replace("\\032", " ") - host = hosttarget[:-1] + self._logger.debug("Resolved a result for Zeroconf resolution of {}: {} @ {}:{}".format(type, + n, + address, + p)) - self._logger.debug("Resolved a result for Zeroconf resolution of {service_type}: {name} @ {host}".format(service_type=service_type, name=name, host=host)) - result.append(dict( - name=name, - host=host, - port=port, - txt_record=txt_record_dict - )) - resolved.append(True) + return dict(name=n, host=address, port=p, txt_record=info.properties) - def browse_callback(sd_ref, flags, interface_index, error_code, service_name, regtype, reply_domain): - if error_code != pybonjour.kDNSServiceErr_NoError: - return - - if not (flags & pybonjour.kDNSServiceFlagsAdd): - return - - self._logger.debug("Got a browsing result for Zeroconf resolution of {service_type}, resolving...".format(service_type=service_type)) - resolve_ref = pybonjour.DNSServiceResolve(0, interface_index, service_name, regtype, reply_domain, resolve_callback) - - try: - while not resolved: - ready = select.select([resolve_ref], [], [], resolve_timeout) - if resolve_ref not in ready[0]: - break - - pybonjour.DNSServiceProcessResult(resolve_ref) - else: - resolved.pop() - finally: - resolve_ref.close() + for address in map(lambda x: socket.inet_ntoa(x), info.addresses): + result.append(to_result(info, address)) self._logger.debug("Browsing Zeroconf for {service_type}".format(service_type=service_type)) def browse(): - sd_ref = pybonjour.DNSServiceBrowse(regtype=service_type, callBack=browse_callback) - try: - while True: - ready = select.select([sd_ref], [], [], browse_timeout) - - if not ready[0]: - break - - if sd_ref in ready[0]: - pybonjour.DNSServiceProcessResult(sd_ref) - finally: - sd_ref.close() + listener = ZeroconfListener(self._logger) + browser = zeroconf.ServiceBrowser(self._zeroconf, service_type, listener) + time.sleep(browse_timeout) + browser.cancel() if callback: callback(result) @@ -414,8 +388,6 @@ class DiscoveryPlugin(octoprint.plugin.StartupPlugin, result_available.clear() def browse(): - import socket - socket.setdefaulttimeout(timeout) search_message = "".join([ @@ -568,8 +540,6 @@ class DiscoveryPlugin(octoprint.plugin.StartupPlugin, :param alive: True to send an "ssdp:alive" message, False to send an "ssdp:byebye" message """ - import socket - if alive and self._ssdp_last_notify + self._ssdp_notify_timeout > octoprint.util.monotonic_time(): # we just sent an alive, no need to send another one now return @@ -627,7 +597,6 @@ class DiscoveryPlugin(octoprint.plugin.StartupPlugin, from BaseHTTPServer import BaseHTTPRequestHandler from io import BytesIO - import socket socket.setdefaulttimeout(timeout) @@ -703,7 +672,6 @@ class DiscoveryPlugin(octoprint.plugin.StartupPlugin, if name: return "OctoPrint instance \"{}\"".format(name) else: - import socket return "OctoPrint instance on {}".format(socket.gethostname()) diff --git a/src/octoprint/templates/dialogs/settings.jinja2 b/src/octoprint/templates/dialogs/settings.jinja2 index 1063b6809..87f37f0aa 100644 --- a/src/octoprint/templates/dialogs/settings.jinja2 +++ b/src/octoprint/templates/dialogs/settings.jinja2 @@ -1,6 +1,6 @@ -