From c59c161d96770d26e4cb9f39fb2fee90755047ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 18 Jul 2023 13:24:58 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=94=96=20staging/bugfix=20is=20now=20?= =?UTF-8?q?1.9.3.dev?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .versioneer-lookup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.versioneer-lookup b/.versioneer-lookup index b1c48e689..7657e4e87 100644 --- a/.versioneer-lookup +++ b/.versioneer-lookup @@ -26,8 +26,8 @@ improve/.* 1.9.0 fa2c4680cca0d1d6b46e6c1ed68ceea4d9b79afb pep440-dev # staging/bugfix is the branch for preparation of the 1.9.x bugfix releases # so are any bug/... branches -staging/bugfix 1.9.2 1d519a21702ea180c026929da2a6e17079470b9a pep440-dev -bug/.* 1.9.2 1d519a21702ea180c026929da2a6e17079470b9a pep440-dev +staging/bugfix 1.9.3 f027aaa7300f70b046525a49245b33c43dd198c1 pep440-dev +bug/.* 1.9.3 f027aaa7300f70b046525a49245b33c43dd198c1 pep440-dev # staging/maintenance is currently the branch for preparation of 1.9.0rc6 # so is regressionfix/... From fc53dab0b7024346ee9dd4d3a6f7417c4b7a1bbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 18 Jul 2023 14:48:00 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Use=20file=20instead?= =?UTF-8?q?=20of=20config=20for=20incomplete=20startup=20flag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Makes it easier in CI situations to reconfigure the server. --- docs/configuration/config_yaml.rst | 4 ---- src/octoprint/__init__.py | 2 +- src/octoprint/schema/config/server.py | 3 --- src/octoprint/server/__init__.py | 19 +++++++++++++++---- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/docs/configuration/config_yaml.rst b/docs/configuration/config_yaml.rst index 71bf107cc..a0fcc0c5a 100644 --- a/docs/configuration/config_yaml.rst +++ b/docs/configuration/config_yaml.rst @@ -871,10 +871,6 @@ Use the following settings to configure the server: # reset the setting to false startOnceInSafeMode: false - # Signals to OctoPrint that the last startup was incomplete. OctoPrint will then startup - # in safe mode - incompleteStartup: false - # Set this to true to make OctoPrint ignore incomplete startups. Helpful for development. ignoreIncompleteStartup: false diff --git a/src/octoprint/__init__.py b/src/octoprint/__init__.py index 3f102e758..c0517a2ab 100644 --- a/src/octoprint/__init__.py +++ b/src/octoprint/__init__.py @@ -124,7 +124,7 @@ def init_platform( ) settings_incomplete_startup_safemode = ( "incomplete_startup" - if settings.getBoolean(["server", "incompleteStartup"]) + if os.path.exists(os.path.join(settings._basedir, ".incomplete_startup")) and not settings.getBoolean(["server", "ignoreIncompleteStartup"]) else None ) diff --git a/src/octoprint/schema/config/server.py b/src/octoprint/schema/config/server.py index ddc71b272..da28bdd9e 100644 --- a/src/octoprint/schema/config/server.py +++ b/src/octoprint/schema/config/server.py @@ -165,9 +165,6 @@ class ServerConfig(BaseModel): ignoreIncompleteStartup: bool = False """Set this to true to make OctoPrint ignore incomplete startups. Helpful for development.""" - incompleteStartup: bool = False - """Signals to OctoPrint that the last startup was incomplete. OctoPrint will then startup in safe mode.""" - seenWizards: Dict[str, str] = {} secretKey: Optional[str] = None diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index e09714a50..79b3eac0c 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -9,6 +9,7 @@ import logging import logging.config import mimetypes import os +import pathlib import re import signal import sys @@ -300,9 +301,14 @@ class Server: if self._settings is None: self._settings = settings() + incomplete_startup_flag = ( + pathlib.Path(self._settings._basedir) / ".incomplete_startup" + ) if not self._settings.getBoolean(["server", "ignoreIncompleteStartup"]): - self._settings.setBoolean(["server", "incompleteStartup"], True) - self._settings.save() + try: + incomplete_startup_flag.touch() + except Exception: + self._logger.exception("Could not create startup triggered safemode flag") if self._plugin_manager is None: self._plugin_manager = octoprint.plugin.plugin_manager() @@ -1294,8 +1300,13 @@ class Server: # if there was a rogue plugin we wouldn't even have made it here, so remove startup triggered safe mode # flag again... - self._settings.setBoolean(["server", "incompleteStartup"], False) - self._settings.save() + try: + if incomplete_startup_flag.exists(): + incomplete_startup_flag.unlink() + except Exception: + self._logger.exception( + "Could not clear startup triggered safe mode flag" + ) # make a backup of the current config self._settings.backup(ext="backup")