Skip to content

Commit

Permalink
#108 download link
Browse files Browse the repository at this point in the history
  • Loading branch information
OllisGit committed Jan 25, 2021
1 parent c5c8a99 commit c6dfc23
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions octoprint_SpoolManager/DatabaseManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions octoprint_SpoolManager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion octoprint_SpoolManager/api/SpoolManagerAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c6dfc23

Please sign in to comment.