From c6dfc2391297cb24a41fc60c55051c3d31e7c801 Mon Sep 17 00:00:00 2001 From: OllisGit Date: Mon, 25 Jan 2021 18:48:25 +0100 Subject: [PATCH] #108 download link --- octoprint_SpoolManager/DatabaseManager.py | 7 +++++-- octoprint_SpoolManager/__init__.py | 4 ++-- octoprint_SpoolManager/api/SpoolManagerAPI.py | 2 +- setup.py | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/octoprint_SpoolManager/DatabaseManager.py b/octoprint_SpoolManager/DatabaseManager.py index 55c47905..44981a3f 100644 --- a/octoprint_SpoolManager/DatabaseManager.py +++ b/octoprint_SpoolManager/DatabaseManager.py @@ -382,7 +382,7 @@ def _storeErrorMessage(self, type, title, message, sendErrorPopUp): ################################################################################################### public functions @staticmethod - def getDatabaseFileLocation(pluginDataBaseFolder): + def buildDefaultDatabaseFileLocation(pluginDataBaseFolder): databaseFileLocation = os.path.join(pluginDataBaseFolder, "spoolmanager.db") return databaseFileLocation @@ -393,7 +393,7 @@ def initDatabase(self, databaseSettings, sendMessageToClient): self._passMessageToClient = sendMessageToClient self._databaseSettings = databaseSettings - databaseFileLocation = DatabaseManager.getDatabaseFileLocation(databaseSettings.baseFolder) + databaseFileLocation = DatabaseManager.buildDefaultDatabaseFileLocation(databaseSettings.baseFolder) self._databaseSettings.fileLocation = databaseFileLocation existsDatabaseFile = str(os.path.exists(self._databaseSettings.fileLocation)) self._logger.info("Databasefile '" +self._databaseSettings.fileLocation+ "' exists: " + existsDatabaseFile) @@ -421,6 +421,9 @@ def initDatabase(self, databaseSettings, sendMessageToClient): def assignNewDatabaseSettings(self, databaseSettings): self._databaseSettings = databaseSettings + def getDatabaseSettings(self): + return self._databaseSettings + def testDatabaseConnection(self, databaseSettings = None): result = None backupCurrentDatabaseSettings = None diff --git a/octoprint_SpoolManager/__init__.py b/octoprint_SpoolManager/__init__.py index 284af931..ac71225c 100644 --- a/octoprint_SpoolManager/__init__.py +++ b/octoprint_SpoolManager/__init__.py @@ -213,7 +213,7 @@ def _buildDatabaseSettingsFromPluginSettings(self): databaseSettings.password = self._settings.get([SettingsKeys.SETTINGS_KEY_DATABASE_PASSWORD]) pluginDataBaseFolder = self.get_plugin_data_folder() databaseSettings.baseFolder = pluginDataBaseFolder - databaseSettings.fileLocation = self._databaseManager.getDatabaseFileLocation(databaseSettings.baseFolder) + databaseSettings.fileLocation = self._databaseManager.buildDefaultDatabaseFileLocation(databaseSettings.baseFolder) return databaseSettings @@ -513,7 +513,7 @@ def get_settings_defaults(self): ## Database ## nested settings are not working, because if only a few attributes are changed it only returns these few attribuets, instead the default values + adjusted values settings[SettingsKeys.SETTINGS_KEY_DATABASE_USE_EXTERNAL] = False - datbaseLocation = DatabaseManager.getDatabaseFileLocation(self.get_plugin_data_folder()) + datbaseLocation = DatabaseManager.buildDefaultDatabaseFileLocation(self.get_plugin_data_folder()) settings[SettingsKeys.SETTINGS_KEY_DATABASE_LOCAL_FILELOCATION] = datbaseLocation settings[SettingsKeys.SETTINGS_KEY_DATABASE_TYPE] = "sqlite" # settings[SettingsKeys.SETTINGS_KEY_DATABASE_TYPE] = "postgres" diff --git a/octoprint_SpoolManager/api/SpoolManagerAPI.py b/octoprint_SpoolManager/api/SpoolManagerAPI.py index 2cbc52b0..943ee71e 100644 --- a/octoprint_SpoolManager/api/SpoolManagerAPI.py +++ b/octoprint_SpoolManager/api/SpoolManagerAPI.py @@ -491,7 +491,7 @@ def _buildDatabaseSettingsFromJson(self, jsonData): ####################################################################################### DOWNLOAD DATABASE-FILE @octoprint.plugin.BlueprintPlugin.route("/downloadDatabase", methods=["GET"]) def downloadDatabase(self): - return send_file(self._databaseManager.getDatabaseFileLocation(), + return send_file(self._databaseManager.getDatabaseSettings().fileLocation, mimetype='application/octet-stream', attachment_filename='spoolmanager.db', as_attachment=True) diff --git a/setup.py b/setup.py index 764ff34e..4b7fb007 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module # -plugin_version = "1.3.2" +plugin_version = "1.3.3-dev" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module