Skip to content

Commit

Permalink
Finish 0.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
malnvenshorn committed Nov 14, 2017
2 parents 6ac3234 + 62ab52d commit 2347d38
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 99 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This OctoPrint plugin helps to manage your filament spools. The project is still under heavy development. So don't rely on it and use it at your own risk. I'm grateful for all reports that help me to track down bugs.

If you have questions or encounter issues please take a look at the [Frequently Asked Questions](https://github.com/malnvenshorn/OctoPrint-FilamentManager/wiki#faq) first. There might be already an answer. In case you haven't found what you are looking for, feel free to open a [ticket](https://github.com/malnvenshorn/OctoPrint-FilamentManager/issues/new) and I'll try to help.

## Additional features

* Replacing filament volume with weight in sidebar
Expand Down
14 changes: 8 additions & 6 deletions octoprint_filamentmanager/manager.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# coding=utf-8
import sqlite3
import csv
import os
from multiprocessing import Lock

__author__ = "Sven Lohrmann <[email protected]>"
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
__copyright__ = "Copyright (C) 2017 Sven Lohrmann - Released under terms of the AGPLv3 License"

import sqlite3
import io
import os
from backports import csv
from multiprocessing import Lock


class FilamentManager(object):

Expand Down Expand Up @@ -204,7 +206,7 @@ def import_data(self, dirpath):

def _import_from_csv(self, dirpath, tablename):
filepath = os.path.join(dirpath, tablename + ".csv")
with open(filepath, "r") as csv_file:
with io.open(filepath, mode="r", encoding="utf-8") as csv_file:
csv_reader = csv.reader(csv_file)
header = next(csv_reader)
columns = ",".join(header)
Expand All @@ -219,7 +221,7 @@ def _export_to_csv(self, dirpath, tablename):
with self._db_lock, self._db as db:
cursor = db.execute("SELECT * FROM " + tablename)
filepath = os.path.join(dirpath, tablename + ".csv")
with open(filepath, "w") as csv_file:
with io.open(filepath, mode="w", encoding="utf-8") as csv_file:
csv_writer = csv.writer(csv_file)
csv_writer.writerow([i[0] for i in cursor.description])
csv_writer.writerows(cursor)
Expand Down
3 changes: 1 addition & 2 deletions octoprint_filamentmanager/odometer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# coding=utf-8
import re

__author__ = "Sven Lohrmann <[email protected]>"
__author__ = "Sven Lohrmann <[email protected]> based on work by Gina Häußge <[email protected]>"
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
__copyright__ = "Copyright (C) 2017 Sven Lohrmann - Released under terms of the AGPLv3 License"

Expand Down Expand Up @@ -29,7 +29,6 @@ def reset_extruded_length(self):
self.totalExtrusion = [0.0] * tools

def parse(self, gcode, cmd):
# taken from gcodeInterpreter.py
if gcode == "G1" or gcode == "G0": # move
e = self._get_float(cmd, self.regexE)
if e is not None:
Expand Down
20 changes: 15 additions & 5 deletions octoprint_filamentmanager/static/js/filamentmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,14 @@ $(function() {
});
};

var text = gettext("You are about to delete the filament profile \"%s (%s)\". " +
"Please notice that it is not possible to delete profiles with associated spools.");
showConfirmationDialog(_.sprintf(text, data.material, data.vendor), perform);
showConfirmationDialog({
title: gettext("Delete profile?"),
message: _.sprintf(gettext("You are about to delete the filament profile <strong>%s (%s)</strong>. " +
"Please note that it is not possible to delete profiles with associated spools."),
data.material, data.vendor),
proceed: gettext("Delete"),
onproceed: perform
});
};

// spools
Expand Down Expand Up @@ -633,8 +638,13 @@ $(function() {
});
};

var text = gettext("You are about to delete the filament spool \"%s - %s (%s)\".");
showConfirmationDialog(_.sprintf(text, data.name, data.profile.material, data.profile.vendor), perform);
showConfirmationDialog({
title: gettext("Delete spool?"),
message: _.sprintf(gettext("You are about to delete the filament spool <strong>%s - %s (%s)</strong>."),
data.name, data.profile.material, data.profile.vendor),
proceed: gettext("Delete"),
onproceed: perform
});
};

self.duplicateSpool = function(data) {
Expand Down
32 changes: 20 additions & 12 deletions octoprint_filamentmanager/static/js/warning.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ $(function() {
self.settings = parameters[2];

self.filename = undefined;
self.previousData = undefined;

self.printerState.filamentWithWeight = ko.observableArray([]);

Expand Down Expand Up @@ -44,19 +43,35 @@ $(function() {
});
};

self.waitForFilamentData = false

self.onBeforeBinding = function() {
self.printerState.filament.subscribe(self._processData);
self.printerState.filament.subscribe(function() {
if (self.filename !== self.printerState.filename()) {
if (self.printerState.filename() != undefined && self.printerState.filament().length < 1) {
// file selected, but no filament data found, probably because it's still in analysis queue
self.waitForFilamentData = true;
} else {
self._processData();
}
}
else if (self.waitForFilamentData && self.printerState.filament().length > 0) {
self._processData();
}
});
self.filamentManager.selectedSpools.subscribe(self._processData);
}

self._processData = function() {
self.waitForFilamentData = false;

var filament = self.printerState.filament();
var spoolData = self.filamentManager.selectedSpools();
var fileHasChanged = (self.filename !== self.printerState.filename());
var warningIsShown = false;

var warningIsShown = false; // used to prevent a separate warning message for each tool

for (var i = 0; i < filament.length && i < spoolData.length; ++i) {
if (spoolData[i] === undefined) {
if (spoolData[i] == undefined) {
// skip tools with no selected spool
filament[i].data().weight = 0;
continue;
Expand All @@ -70,12 +85,6 @@ $(function() {

filament[i].data().weight = requiredFilament;

if (!fileHasChanged && self.previousData !== undefined
&& JSON.stringify(spoolData[i]) === JSON.stringify(self.previousData[i])) {
// skip check if file and data hasn't changed, this prevents warning message spamming
continue;
}

if (self.settings.settings.plugins.filamentmanager.enableWarning()) {
var remainingFilament = spoolData[i].weight - spoolData[i].used;

Expand All @@ -87,7 +96,6 @@ $(function() {
}

self.filename = self.printerState.filename();
self.previousData = spoolData;
self.printerState.filamentWithWeight(filament);;
};

Expand Down
Binary file modified octoprint_filamentmanager/translations/de/LC_MESSAGES/messages.mo
Binary file not shown.
62 changes: 37 additions & 25 deletions octoprint_filamentmanager/translations/de/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: OctoPrint-FilamentManager 0.1.0\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2017-11-12 00:49+0100\n"
"PO-Revision-Date: 2017-11-12 01:02+0100\n"
"POT-Creation-Date: 2017-11-14 20:39+0100\n"
"PO-Revision-Date: 2017-11-14 20:44+0100\n"
"Last-Translator: Sven Lohrmann <[email protected]>\n"
"Language: de\n"
"Language-Team: de <[email protected]>\n"
Expand Down Expand Up @@ -68,75 +68,91 @@ msgstr ""
msgid "Could not delete profile"
msgstr "Konnte Profil nicht löschen"

#: octoprint_filamentmanager/static/js/filamentmanager.js:537
#: octoprint_filamentmanager/static/js/filamentmanager.js:538
msgid "Delete profile?"
msgstr "Profil löschen?"

#: octoprint_filamentmanager/static/js/filamentmanager.js:539
#, python-format
msgid ""
"You are about to delete the filament profile \"%s (%s)\". Please notice that it "
"is not possible to delete profiles with associated spools."
"You are about to delete the filament profile <strong>%s (%s)</strong>. Please "
"note that it is not possible to delete profiles with associated spools."
msgstr ""
"Du bist im Begriff das Filamentprofil \"%s (%s)\" zu löschen. Bitte beachte, "
"dass es nicht möglich ist Profile zu löschen die Spulen zugewiesen wurden."
"Du bist im Begriff das Filament-Profil <strong>%s (%s)</strong> zu löschen. "
"Bitte beachte, dass es nicht möglich ist Profile zu löschen die Spulen "
"zugewiesen wurden."

#: octoprint_filamentmanager/static/js/filamentmanager.js:585
#: octoprint_filamentmanager/static/js/filamentmanager.js:542
#: octoprint_filamentmanager/static/js/filamentmanager.js:645
#: octoprint_filamentmanager/templates/settings_profiledialog.jinja2:15
msgid "Delete"
msgstr "Löschen"

#: octoprint_filamentmanager/static/js/filamentmanager.js:590
msgid ""
"There was an unexpected error while saving the filament spool, please consult "
"the logs."
msgstr ""
"Unerwarteter Fehler beim speichern der Filamentspule, bitte konsultiere das Log."

#: octoprint_filamentmanager/static/js/filamentmanager.js:587
#: octoprint_filamentmanager/static/js/filamentmanager.js:592
msgid "Could not add spool"
msgstr "Konnte Spule nicht hinzufügen"

#: octoprint_filamentmanager/static/js/filamentmanager.js:610
#: octoprint_filamentmanager/static/js/filamentmanager.js:615
msgid ""
"There was an unexpected error while updating the filament spool, please consult "
"the logs."
msgstr ""
"Unerwarteter Fehler beim Aktualisieren der Filamentspule, bitte konsultiere das "
"Log."

#: octoprint_filamentmanager/static/js/filamentmanager.js:612
#: octoprint_filamentmanager/static/js/filamentmanager.js:617
msgid "Could not update spool"
msgstr "Konnte Spule nicht aktualisieren"

#: octoprint_filamentmanager/static/js/filamentmanager.js:629
#: octoprint_filamentmanager/static/js/filamentmanager.js:634
msgid ""
"There was an unexpected error while removing the filament spool, please consult "
"the logs."
msgstr ""
"Unerwarteter Fehler beim Löschen der Filamentspule, bitte konsultiere das Log."

#: octoprint_filamentmanager/static/js/filamentmanager.js:631
#: octoprint_filamentmanager/static/js/filamentmanager.js:636
msgid "Could not delete spool"
msgstr "Konnte Spule nicht löschen"

#: octoprint_filamentmanager/static/js/filamentmanager.js:636
#: octoprint_filamentmanager/static/js/filamentmanager.js:642
msgid "Delete spool?"
msgstr "Spule löschen?"

#: octoprint_filamentmanager/static/js/filamentmanager.js:643
#, python-format
msgid "You are about to delete the filament spool \"%s - %s (%s)\"."
msgstr "Du bist im Begriff die Filamentspule \"%s - %s (%s)\" zu löschen."
msgid "You are about to delete the filament spool <strong>%s - %s (%s)</strong>."
msgstr ""
"Du bist im Begriff die Filament-Spule <strong>%s - %s (%s)</strong> zu löschen."

#: octoprint_filamentmanager/static/js/filamentmanager.js:681
#: octoprint_filamentmanager/static/js/filamentmanager.js:691
msgid "Data import successfull"
msgstr "Daten-Import erfolgreich"

#: octoprint_filamentmanager/static/js/filamentmanager.js:701
#: octoprint_filamentmanager/static/js/filamentmanager.js:711
msgid "Data import failed"
msgstr "Daten-Import fehlgeschlagen"

#: octoprint_filamentmanager/static/js/filamentmanager.js:702
#: octoprint_filamentmanager/static/js/filamentmanager.js:712
msgid "Something went wrong, please consult the logs."
msgstr "Etwas ist schief gelaufen, bitte konsultiere das Log."

#: octoprint_filamentmanager/static/js/warning.js:95
#: octoprint_filamentmanager/static/js/warning.js:103
msgid ""
"The current print job needs more material than what's remaining on the selected "
"spool."
msgstr ""
"Der aktuelle Druckauftrag benötigt mehr Material als auf der ausgewählten Spule "
"vorhanden ist."

#: octoprint_filamentmanager/static/js/warning.js:96
#: octoprint_filamentmanager/static/js/warning.js:104
msgid "Insufficient filament"
msgstr "Filament nicht ausreichend"

Expand Down Expand Up @@ -292,10 +308,6 @@ msgstr "--- Neues Profil ---"
msgid "New"
msgstr "Neu"

#: octoprint_filamentmanager/templates/settings_profiledialog.jinja2:15
msgid "Delete"
msgstr "Löschen"

#: octoprint_filamentmanager/templates/settings_profiledialog.jinja2:16
msgid "Save profile"
msgstr "Profil speichern"
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
plugin_identifier = "filamentmanager"
plugin_package = "octoprint_filamentmanager"
plugin_name = "OctoPrint-FilamentManager"
plugin_version = "0.4.0"
plugin_version = "0.4.1"
plugin_description = "Manage your spools and keep track of remaining filament on them"
plugin_author = "Sven Lohrmann"
plugin_author_email = "[email protected]"
plugin_url = "https://github.com/malnvenshorn/OctoPrint-FilamentManager"
plugin_license = "AGPLv3"
plugin_requires = []
plugin_requires = ["backports.csv>=1.0.5,<1.1"]
plugin_additional_data = []
plugin_additional_packages = []
plugin_ignored_packages = []
Expand Down
Binary file modified translations/de/LC_MESSAGES/messages.mo
Binary file not shown.
Loading

0 comments on commit 2347d38

Please sign in to comment.