Skip to content

Commit 02e6231

Browse files
committed
New Version 1.6.0
- E release-channles - E stale-bot via github-actions - E #79, #87, #99, #119, #157, #176, #202, weight calculation during editing PR #206, thx al lot @TiziG - E #106 switching from travis to github-actions - E #107, #215 database-settings in the log will only be shown, if sql-logging is enabled - E #170 inform user about switching a spool already selected - E #213 sort/filter options in spool selection dialog - E Extrusion-Debugging: Show current extrusion during printing - B #188 touchUI conflict - B #193, #196 sorting/showing of remaining weight - B #205 changed to "browser-native" date/time picker - B #210 loadCatalogColors when color name is blank - B #211 button text changed - B #212 import CSV only if printer in idle-mode - B #216 FilamentManager and SpoolManager used same viewmodel - B #217 when print is paused the extruded filament is assigned to the spool and the counter is reseted
1 parent 45bdb52 commit 02e6231

29 files changed

+4305
-526
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
###
2+
### Simple script to build a zip file of the whole repository
3+
###
4+
## Major - Tasks:
5+
# - ZIP
6+
# - Build draft release
7+
# - Attach Zip
8+
# - Download Zip
9+
10+
name: Build Plugin Release - Action
11+
on: [push]
12+
jobs:
13+
Build-Release-ZIP-Action:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check out repository code
17+
uses: actions/checkout@v2
18+
19+
- run: echo "Read current plugin version..."
20+
- run: export PLUGIN_VERSION=$(cat setup.py | grep 'plugin_version = "*"' | cut -d '"' -f2)
21+
- run: echo "Plugin Version $PLUGIN_VERSION ${PLUGIN_VERSION}"
22+
23+
- run: echo "Build ZIP"
24+
- run: zip -r master.zip * -i '\octoprint_*' 'translations' 'README.md' 'requirements.txt' 'setup.py'
25+
- name: List files in the repository
26+
run: |
27+
ls ${{ github.workspace }}
28+
29+
- name: version
30+
run: echo "::set-output name=version::$(cat setup.py | grep 'plugin_version = "*"' | cut -d '"' -f2)"
31+
id: version
32+
33+
- name: Repository and Branch name
34+
id: branch
35+
run: |
36+
export branch_name=${GITHUB_REF##*/}
37+
echo "::set-output name=branch_name::$branch_name"
38+
echo running on branch $branch_name
39+
export repo_name=${GITHUB_REPOSITORY#*/}
40+
echo "::set-output name=repo_name::$repo_name"
41+
42+
43+
- name: release
44+
uses: actions/create-release@latest
45+
id: create_release
46+
env:
47+
GITHUB_TOKEN: ${{ github.token }}
48+
with:
49+
draft: true
50+
commitish: ${{ steps.branch.outputs.branch_name }}
51+
prerelease: false
52+
release_name: V${{ steps.version.outputs.version }}-draft
53+
tag_name: ${{ steps.version.outputs.version }}-draft
54+
body: |
55+
## [BugFix]
56+
- #xxx
57+
58+
## [Enhancement]
59+
- #xxx
60+
61+
## Counter
62+
![downloaded](https://img.shields.io/github/downloads/OllisGit/${{ steps.branch.outputs.repo_name }}/${{ steps.version.outputs.version }}/total)
63+
# body_path: RELEASE_TEMPLATE.md
64+
65+
- name: upload master.zip to release
66+
uses: actions/upload-release-asset@v1
67+
env:
68+
GITHUB_TOKEN: ${{ github.token }}
69+
with:
70+
upload_url: ${{ steps.create_release.outputs.upload_url }}
71+
asset_path: master.zip
72+
asset_name: master.zip
73+
asset_content_type: application/gzip
74+
75+
- name: download master.zip
76+
run: curl -O -J -L -v https://github.com/OllisGit/${{ steps.branch.outputs.repo_name }}/releases/download/${{ steps.version.outputs.version }}/master.zip
77+
78+
- run: echo "🍏 This job's status is ${{ job.status }}."
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## Documentation could be found here
2+
## https://github.com/actions/stale
3+
##
4+
name: 'Stale and close issues'
5+
on:
6+
schedule:
7+
# Each day at 1:30am run the action
8+
- cron: '30 1 * * *'
9+
10+
jobs:
11+
stale:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/stale@v4
15+
with:
16+
exempt-issue-labels: 'status: analysing,status: inNextRelease,status: inProgress,status: wontfix'
17+
18+
days-before-issue-stale: 30
19+
stale-issue-message: 'This issue has been automatically marked for closing, because it has not had activity in 30 days. It will be closed if no further activity occurs in 10 days.'
20+
stale-issue-label: 'status: markedForAutoClose'
21+
22+
days-before-issue-close: 10
23+
close-issue-message: 'This issue was closed, because it has been already marked for 10 days with no activity.'
24+
close-issue-label: 'status: closedByBot'
File renamed without changes.

README.md

+17-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ If you like it, I would be thankful about a cup of coffee :)
1414
[![More coffee, more code](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6SW5R6ZUKLB5E&source=url)
1515

1616
## Tested with:
17-
- OctoPrint 1.5.2: with Python 3.6.8 and Python 2.7.9
17+
- OctoPrint 1.7.2: with Python 3.7.3
1818

1919
## Included features
2020

@@ -54,18 +54,32 @@ If you like it, I would be thankful about a cup of coffee :)
5454
-->
5555
![listSpools-tab](screenshots/listSpools-tab.png "ListSpools-Tab")
5656
![selectSpools-sidebar](screenshots/selectSpool-sidebar.png "SelectSpool-Sidebar")
57+
![selectSpools-dialog](screenshots/selectSpool-dialog.png "SelectSpool-Dialog")
5758
![editSpool-dialog](screenshots/editSpool-dialog.png "EditSpool-Dialog")
5859

5960
![scanSpool-dialog](screenshots/scanSpool-dialog.png "ScanSpool-Dialog")
6061

61-
6262
## Setup
63-
6463
Install via the bundled [Plugin Manager](http://docs.octoprint.org/en/master/bundledplugins/pluginmanager.html)
6564
or manually using this URL:
6665

6766
https://github.com/OllisGit/OctoPrint-SpoolManager/releases/latest/download/master.zip
6867

68+
After installation, you can listen on three release channels (since 1.6.0).
69+
What does this mean: Each channel has its own release-version and each release has a different kind of functionality and stability.
70+
71+
- **"Only Release"**: Only stable and tested versions will be shown in the software-update section of OctoPrint
72+
- **"Release & Candidate"**: Beside the stable release, you can also see the "release-candidates", like '''1.7.0rc3'''.
73+
The rc's includde new functionalty/bugfixes and are already tested by the community.. so by YOU ;-)
74+
- **"Release & Candidate & under Development"**: Beside stable and rc, you will be informed about development versions.
75+
A development version like '''1.8.0.dev5``` could include a new (experimental) feature/bugfixs, but it is not fully tested by the community
76+
77+
Changing between each release is done via the "Software Update section" in the settings.
78+
![release-channels](screenshots/release-channels.png "Release channels")
79+
80+
Hint: "Easy-switching" is possible with OctoPrint-Version 1.8.0 (see https://github.com/OctoPrint/OctoPrint/issues/4238).
81+
At the meantime you need to uninstall and install the version you like from the selected channel...or stay in one channel ;-)
82+
6983

7084
## Versions
7185

octoprint_SpoolManager/DatabaseManager.py

+94-10
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
FORCE_CREATE_TABLES = False
2424

25-
CURRENT_DATABASE_SCHEME_VERSION = 6
25+
CURRENT_DATABASE_SCHEME_VERSION = 7
2626

2727
# List all Models
2828
MODELS = [PluginMetaDataModel, SpoolModel]
@@ -166,14 +166,88 @@ def _createOrUpgradeSchemeIfNecessary(self):
166166

167167
def _upgradeDatabase(self,currentDatabaseSchemeVersion, targetDatabaseSchemeVersion):
168168

169-
migrationFunctions = [self._upgradeFrom1To2, self._upgradeFrom2To3, self._upgradeFrom3To4, self._upgradeFrom4To5, self._upgradeFrom5To6]
169+
migrationFunctions = [self._upgradeFrom1To2,
170+
self._upgradeFrom2To3,
171+
self._upgradeFrom3To4,
172+
self._upgradeFrom4To5,
173+
self._upgradeFrom5To6,
174+
self._upgradeFrom6To7,
175+
self._upgradeFrom7To8,
176+
self._upgradeFrom8To9,
177+
self._upgradeFrom9To10
178+
]
170179

171180
for migrationMethodIndex in range(currentDatabaseSchemeVersion -1, targetDatabaseSchemeVersion -1):
172181
self._logger.info("Database migration from '" + str(migrationMethodIndex + 1) + "' to '" + str(migrationMethodIndex + 2) + "'")
173182
migrationFunctions[migrationMethodIndex]()
174183
pass
175184
pass
176185

186+
def _upgradeFrom9To10(self):
187+
self._logger.info(" Starting 9 -> 10")
188+
# What is changed:
189+
# -
190+
self._passMessageToClient("error", "DatabaseManager",
191+
"Could not upgrade database scheme V1 to V2. See OctoPrint.log for details!")
192+
self._logger.info(" Successfully 9 -> 10")
193+
194+
def _upgradeFrom8To9(self):
195+
self._logger.info(" Starting 8 -> 9")
196+
# What is changed:
197+
# -
198+
self._passMessageToClient("error", "DatabaseManager",
199+
"Could not upgrade database scheme V1 to V2. See OctoPrint.log for details!")
200+
self._logger.info(" Successfully 8 -> 9")
201+
202+
def _upgradeFrom7To8(self):
203+
self._logger.info(" Starting 7 -> 8")
204+
# What is changed:
205+
# -
206+
self._passMessageToClient("error", "DatabaseManager",
207+
"Could not upgrade database scheme V1 to V2. See OctoPrint.log for details!")
208+
self._logger.info(" Successfully 7 -> 8")
209+
210+
def _upgradeFrom6To7(self):
211+
self._logger.info(" Starting 6 -> 7")
212+
# What is changed:
213+
# - Recalculate remaining weight
214+
215+
self._logger.info(" try to calculate remaining weight.")
216+
217+
# Calculate the remaining weight for all current spools
218+
with self._database.atomic() as transaction: # Opens new transaction.
219+
220+
try:
221+
allSpoolModels = self.loadAllSpoolsByQuery(None)
222+
if (allSpoolModels != None):
223+
for spoolModel in allSpoolModels:
224+
totalWeight = spoolModel.totalWeight
225+
usedWeight = spoolModel.usedWeight
226+
remainingWeight = Transformer.calculateRemainingWeight(usedWeight, totalWeight)
227+
if (remainingWeight != None):
228+
spoolModel.remainingWeight = remainingWeight
229+
spoolModel.save()
230+
231+
localSchemeVersionFromDatabaseModel = PluginMetaDataModel.get(
232+
PluginMetaDataModel.key == PluginMetaDataModel.KEY_DATABASE_SCHEME_VERSION)
233+
localSchemeVersionFromDatabaseModel.value = "7"
234+
localSchemeVersionFromDatabaseModel.save()
235+
236+
# do expicit commit
237+
transaction.commit()
238+
except:
239+
# Because this block of code is wrapped with "atomic", a
240+
# new transaction will begin automatically after the call
241+
# to rollback().
242+
transaction.rollback()
243+
self._logger.exception("Could not calculate remainingWeight during scheme update from 6 To 7:" )
244+
245+
return
246+
pass
247+
self._logger.info(" Successfully 6 -> 7")
248+
249+
250+
177251
def _upgradeFrom5To6(self):
178252
self._logger.info(" Starting 5 -> 6")
179253
# What is changed:
@@ -588,16 +662,18 @@ def connectoToDatabase(self, withMetaCheck=False, sendErrorPopUp=True) :
588662

589663
# build connection
590664
try:
591-
self._logger.info("Databaseconnection with...")
592-
self._logger.info(self._databaseSettings)
665+
if (self.sqlLoggingEnabled):
666+
self._logger.info("Databaseconnection with...")
667+
self._logger.info(self._databaseSettings)
593668
self._database = self._buildDatabaseConnection()
594669

595670
# connect to Database
596671
DatabaseManager.db = self._database
597672
self._database.bind(MODELS)
598673

599674
self._database.connect()
600-
self._logger.info("Database connection succesful. Checking Scheme versions")
675+
if (self.sqlLoggingEnabled):
676+
self._logger.info("Database connection succesful. Checking Scheme versions")
601677
# TODO do I realy need to check the meta-infos in the connect function
602678
# schemeVersionFromPlugin = str(CURRENT_DATABASE_SCHEME_VERSION)
603679
# schemeVersionFromDatabaseModel = str(PluginMetaDataModel.get(PluginMetaDataModel.key == PluginMetaDataModel.KEY_DATABASE_SCHEME_VERSION).value)
@@ -889,9 +965,9 @@ def databaseCallMethode():
889965

890966
if ("displayName" == sortColumn):
891967
if ("desc" == sortOrder):
892-
myQuery = myQuery.order_by(SpoolModel.displayName.desc())
968+
myQuery = myQuery.order_by(fn.Lower(SpoolModel.displayName).desc())
893969
else:
894-
myQuery = myQuery.order_by(SpoolModel.displayName.asc())
970+
myQuery = myQuery.order_by(fn.Lower(SpoolModel.displayName).asc())
895971
if ("lastUse" == sortColumn):
896972
if ("desc" == sortOrder):
897973
myQuery = myQuery.order_by(SpoolModel.lastUse.desc())
@@ -977,6 +1053,15 @@ def databaseCallMethode():
9771053

9781054
return databaseId
9791055

1056+
# always recalculate the remaing weight (total - used)
1057+
totalWeight = spoolModel.totalWeight
1058+
usedWeight = spoolModel.usedWeight
1059+
if (totalWeight != None):
1060+
if (usedWeight == None):
1061+
usedWeight = 0.0
1062+
remainingWeight = Transformer.calculateRemainingWeight(usedWeight, totalWeight)
1063+
spoolModel.remainingWeight = remainingWeight
1064+
9801065
return self._handleReusableConnection(databaseCallMethode, withReusedConnection, "saveSpool")
9811066

9821067
def countSpoolsByQuery(self, withReusedConnection=False):
@@ -1030,15 +1115,14 @@ def databaseCallMethode():
10301115
result = []
10311116
myQuery = SpoolModel.select(SpoolModel.color, SpoolModel.colorName).distinct()
10321117
for spool in myQuery:
1033-
value = spool.color
1034-
if (value != None):
1118+
if (spool.color != None and spool.colorName):
10351119
colorInfo = {
10361120
"colorId": spool.color + ";" + spool.colorName,
10371121
"color": spool.color,
10381122
"colorName": spool.colorName
10391123
}
10401124
result.append(colorInfo)
1041-
return result;
1125+
return result
10421126

10431127
return self._handleReusableConnection(databaseCallMethode, withReusedConnection, "loadCatalogColors", set())
10441128

octoprint_SpoolManager/Usecases.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# coding=utf-8
2+
from __future__ import absolute_import
3+
4+
5+
##############
6+
# Class is responsible for the needed usecases. E.g. saveSpool, calculations,, transaction
7+
# No technical stuff should be implemented here. E.g. sql-query, ..
8+
######
9+
class Usecases(object):
10+
11+
def __init__(self, parentLogger, databaseManager):
12+
self._logger = logging.getLogger(parentLogger.name + "." + self.__class__.__name__)
13+
14+
15+
16+
def saveSpool(self, spoolModel):
17+
pass

0 commit comments

Comments
 (0)