diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..df59181 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +# This file is for unifying the coding style for different editors and IDEs +# editorconfig.org + +root = true + +[*] +end_of_line = lf +charset = utf-8 +insert_final_newline = true +trim_trailing_whitespace = true + +[**.py] +indent_style = space +indent_size = 4 + +[**.js] +indent_style = space +indent_size = 4 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ecfcd6f --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*.pyc +*.swp +.idea +*.iml +build +dist +*.egg* +.DS_Store +*.zip diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..b9aa424 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,4 @@ +include README.md +recursive-include octoprint_CalibrationTools/templates * +recursive-include octoprint_CalibrationTools/translations * +recursive-include octoprint_CalibrationTools/static * diff --git a/README.md b/README.md new file mode 100644 index 0000000..39bfa53 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# OctoPrint-CalibrationTools + +**TODO:** Describe what your plugin does. + +## Setup + +Install via the bundled [Plugin Manager](https://docs.octoprint.org/en/master/bundledplugins/pluginmanager.html) +or manually using this URL: + + https://github.com/SergiuToporjinschi/OctoPrint-CalibrationTools/archive/master.zip + +**TODO:** Describe how to install your plugin, if more needs to be done than just installing it via pip or through +the plugin manager. + +## Configuration + +**TODO:** Describe your plugin's configuration options (if any). diff --git a/babel.cfg b/babel.cfg new file mode 100644 index 0000000..aed0a1b --- /dev/null +++ b/babel.cfg @@ -0,0 +1,8 @@ +[python: */**.py] + +[jinja2: */**.jinja2] +silent=false +extensions=jinja2.ext.autoescape, jinja2.ext.with_, jinja2.ext.do, octoprint.util.jinja.trycatch + +[javascript: */**.js] +extract_messages = gettext, ngettext diff --git a/extras/CalibrationTools.md b/extras/CalibrationTools.md new file mode 100644 index 0000000..2924283 --- /dev/null +++ b/extras/CalibrationTools.md @@ -0,0 +1,102 @@ +--- +layout: plugin + +id: CalibrationTools +title: OctoPrint-CalibrationTools +description: Calibration tools +authors: +- Sergiu Toporjinschi +license: GNUv3 + +# TODO +date: today's date in format YYYY-MM-DD, e.g. 2015-04-21 + +homepage: https://github.com/SergiuToporjinschi/OctoPrint-CalibrationTools +source: https://github.com/SergiuToporjinschi/OctoPrint-CalibrationTools +archive: https://github.com/SergiuToporjinschi/OctoPrint-CalibrationTools/archive/master.zip + +# TODO +# Set this to true if your plugin uses the dependency_links setup parameter to include +# library versions not yet published on PyPi. SHOULD ONLY BE USED IF THERE IS NO OTHER OPTION! +#follow_dependency_links: false + +# TODO +tags: +- a list +- of tags +- that apply +- to your plugin +- (take a look at the existing plugins for what makes sense here) + +# TODO +screenshots: +- url: url of a screenshot, /assets/img/... + alt: alt-text of a screenshot + caption: caption of a screenshot +- url: url of another screenshot, /assets/img/... + alt: alt-text of another screenshot + caption: caption of another screenshot +- ... + +# TODO +featuredimage: url of a featured image for your plugin, /assets/img/... + +# TODO +# You only need the following if your plugin requires specific OctoPrint versions or +# specific operating systems to function - you can safely remove the whole +# "compatibility" block if this is not the case. + +compatibility: + + # List of compatible versions + # + # A single version number will be interpretated as a minimum version requirement, + # e.g. "1.3.1" will show the plugin as compatible to OctoPrint versions 1.3.1 and up. + # More sophisticated version requirements can be modelled too by using PEP440 + # compatible version specifiers. + # + # You can also remove the whole "octoprint" block. Removing it will default to all + # OctoPrint versions being supported. + + octoprint: + - 1.2.0 + + # List of compatible operating systems + # + # Valid values: + # + # - windows + # - linux + # - macos + # - freebsd + # + # There are also two OS groups defined that get expanded on usage: + # + # - posix: linux, macos and freebsd + # - nix: linux and freebsd + # + # You can also remove the whole "os" block. Removing it will default to all + # operating systems being supported. + + os: + - linux + - windows + - macos + - freebsd + + # Compatible Python version + # + # Plugins should aim for compatibility for Python 2 and 3 for now, in which case the value should be ">=2.7,<4". + # + # Plugins that only wish to support Python 3 should set it to ">=3,<4". + # + # If your plugin only supports Python 2 (worst case, not recommended for newly developed plugins since Python 2 + # is EOL), leave at ">=2.7,<3" - be aware that your plugin will not be allowed to register on the + # plugin repository if it only support Python 2. + + python: ">=2.7,<3" + +--- + +**TODO**: Longer description of your plugin, configuration examples etc. This part will be visible on the page at +http://plugins.octoprint.org/plugin/CalibrationTools/ diff --git a/extras/README.txt b/extras/README.txt new file mode 100644 index 0000000..f3eb322 --- /dev/null +++ b/extras/README.txt @@ -0,0 +1,8 @@ +Currently Cookiecutter generates the following helpful extras to this folder: + +CalibrationTools.md + Data file for plugins.octoprint.org. Fill in the missing TODOs once your + plugin is ready for release and file a PR as described at + http://plugins.octoprint.org/help/registering/ to get it published. + +This folder may be safely removed if you don't need it. diff --git a/octoprint_CalibrationTools/__init__.py b/octoprint_CalibrationTools/__init__.py new file mode 100644 index 0000000..f86a3e6 --- /dev/null +++ b/octoprint_CalibrationTools/__init__.py @@ -0,0 +1,142 @@ +# coding=utf-8 +from __future__ import absolute_import + +### (Don't forget to remove me) +# This is a basic skeleton for your plugin's __init__.py. You probably want to adjust the class name of your plugin +# as well as the plugin mixins it's subclassing from. This is really just a basic skeleton to get you started, +# defining your plugin as a template plugin, settings and asset plugin. Feel free to add or remove mixins +# as necessary. +# +# Take a look at the documentation on what other plugin mixins are available. + +import octoprint.plugin +import re +from octoprint_CalibrationTools import ( + api +) + +class CalibrationtoolsPlugin(octoprint.plugin.StartupPlugin, + octoprint.plugin.TemplatePlugin, + octoprint.plugin.SettingsPlugin, + octoprint.plugin.AssetPlugin, + octoprint.plugin.SimpleApiPlugin +): + collectCommand = False + m92Data = { + "X": 0, + "Y": 0, + "Z": 0, + "E": 0 + } + + def initialize(self): + self.collectCommand = False + self._api = api.API(self) + + def on_after_startup(self): + self._logger.info("----------------[CalibrationTools]----------------") + self.collectCommand = True + self._printer.commands("M92") + + # API handling + def get_api_commands(self): + self._logger.info("get_api_commands") + return self._api.get_api_commands() + + def on_api_command(self, command, data): + self._logger.info("on_api_command") + return self._api.on_api_command(command, data) + + def on_api_get(self, request): + self._logger.info("on_api_get") + return self._api.on_api_get(request) + + ##~~ AssetPlugin mixin + def get_assets(self): + # Define your plugin's asset files to automatically include in the + # core UI here. + return { + "js": ["js/CalibrationTools.js"], + "css": ["css/style.css"] + } + +# self._printer.commands(commands) +# extrude(amount, speed=None, tags=None, *args, **kwargs) +# set_temperature(heater, value, tags=None, *args, **kwargs) + ##~~ Softwareupdate hook + def comm_protocol_gcode_received(self, comm, line, *args, **kwargs): + if not self.collectCommand: return line + + reg = re.compile("echo:\s*(?P(?PM\d{1,3}) X(?P\d{1,3}.\d{1,3}) Y(?P\d{1,3}.\d{1,3}) Z(?P\d{1,3}.\d{1,3}) E(?P\d{1,3}.\d{1,3}))") + isM92command = reg.match(line) + if isM92command: + command = isM92command.group("command") + if isM92command.group("gCode") == "M92": + xValue = isM92command.group("xVal") + yValue = isM92command.group("yVal") + zValue = isM92command.group("zVal") + eValue = isM92command.group("eVal") + + self.m92Data["X"] = float(xValue) + self.m92Data["Y"] = float(yValue) + self.m92Data["Z"] = float(zValue) + self.m92Data["E"] = float(eValue) + + # Send the new data to the UI to be reloaded + self._logger.info(line) + self._logger.info("gCode: %s", command) + self._logger.info("X: %s", xValue) + self._logger.info("Y: %s", yValue) + self._logger.info("Z: %s", zValue) + self._logger.info("E: %s", eValue) + self._logger.info("Finished data collection, updating UI") + self.collectCommand = False + return line + + def comm_protocol_gcode_sending(self, comm, phase, cmd, cmd_type, gcode, subcode=None, tags=None, *args, **kwargs): + # https://docs.octoprint.org/en/master/plugins/hooks.html#protocol_gcodephase_hook + if cmd == "M92": + self._logger.info("{} detected, collecting data".format(cmd)) + self.collectCommand = True + + def get_update_information(self): + # Define the configuration for your plugin to use with the Software Update + # Plugin here. See https://docs.octoprint.org/en/master/bundledplugins/softwareupdate.html + # for details. + return { + "CalibrationTools": { + "displayName": "Calibration Tools", + "displayVersion": self._plugin_version, + + # version check: github repository + "type": "github_release", + "user": "SergiuToporjinschi", + "repo": "OctoPrint-CalibrationTools", + "current": self._plugin_version, + + # update method: pip + "pip": "https://github.com/SergiuToporjinschi/OctoPrint-CalibrationTools/archive/{target_version}.zip", + } + } + + +# If you want your plugin to be registered within OctoPrint under a different name than what you defined in setup.py +# ("OctoPrint-PluginSkeleton"), you may define that here. Same goes for the other metadata derived from setup.py that +# can be overwritten via __plugin_xyz__ control properties. See the documentation for that. +__plugin_name__ = "Calibration Tools" + +# Starting with OctoPrint 1.4.0 OctoPrint will also support to run under Python 3 in addition to the deprecated +# Python 2. New plugins should make sure to run under both versions for now. Uncomment one of the following +# compatibility flags according to what Python versions your plugin supports! +#__plugin_pythoncompat__ = ">=2.7,<3" # only python 2 +#__plugin_pythoncompat__ = ">=3,<4" # only python 3 +__plugin_pythoncompat__ = ">=2.7,<4" # python 2 and 3 + +def __plugin_load__(): + global __plugin_implementation__ + __plugin_implementation__ = CalibrationtoolsPlugin() + + global __plugin_hooks__ + __plugin_hooks__ = { + "octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information + } diff --git a/octoprint_CalibrationTools/api.py b/octoprint_CalibrationTools/api.py new file mode 100644 index 0000000..3045df5 --- /dev/null +++ b/octoprint_CalibrationTools/api.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +from __future__ import absolute_import, division, unicode_literals + +import flask +CMD_LOAD_STEPS_EEPROM = "loadSteps" + + +class API: + def __init__(self, plugin): + self._settings = plugin._settings # noqa + self._logger = plugin._logger # noqa + self._printer = plugin._printer # noqa + self.m92Data = plugin.m92Data # noqa + self._plugin = plugin + + @staticmethod + def get_api_commands(): + return { + CMD_LOAD_STEPS_EEPROM: [] + } + + def on_api_get(self, request): + self._logger.info("on api get") + return flask.jsonify( + { + "data": self.m92Data + } + ) + + def on_api_command(self, command, data): + if command == CMD_LOAD_STEPS_EEPROM: + self._logger.info("CMD_LOAD_STEPS_EEPROM") + self._printer.commands("M92") + return flask.jsonify({ + "data": self.m92Data + }) diff --git a/octoprint_CalibrationTools/static/css/style.css b/octoprint_CalibrationTools/static/css/style.css new file mode 100644 index 0000000..69b2a86 --- /dev/null +++ b/octoprint_CalibrationTools/static/css/style.css @@ -0,0 +1,82 @@ +#tab_plugin_CalibrationTools .main { + margin-bottom: 30px; +} +#tab_plugin_CalibrationTools .header { + margin-bottom: 13px; +} + +#tab_plugin_CalibrationTools .title { + text-align: center; + font-weight: bold; + padding: 2px; + border: 1px solid; + border-color: #ddd; + border-radius: 4px; +} + +#tab_plugin_CalibrationTools .tab-content { + border: none; +} + +#tab_plugin_CalibrationTools ul.nav li:first-child > a { + border-radius: 4px 4px 0 0; + border-top: 1px solid #ddd !important; +} +#tab_plugin_CalibrationTools ul.nav li:last-child > a { + border-radius: 0 0 4px 4px; +} + +#tab_plugin_CalibrationTools ul.nav li > a { + border: 1px solid #ddd; + border-top: 0; + background-clip: border-box; +} + +#tab_plugin_CalibrationTools .card { + box-shadow: 0 0.125rem 0.25rem rgb(0 0 0 / 8%) !important; + border: 1px solid rgba(0, 0, 0, 0.125); + border-radius: 0.25rem; + padding: 1.25rem 0.5rem; + margin-bottom: 10px; +} + +#tab_plugin_CalibrationTools .icon a, #tab_plugin_CalibrationTools .icon a i { + vertical-align: middle; + cursor: pointer; +} + +#tab_plugin_CalibrationTools input:disabled { + cursor: text; +} + + +/* + + +#tab_plugin_CalibrationTools .container { + display: flex; + flex-direction: column; +} + +#tab_plugin_CalibrationTools .container .row { + display: flex; + flex-direction: row; + margin-left: 0px; + flex-basis: 40px; + align-items: baseline; +} + +#tab_plugin_CalibrationTools .settings_icon { + float: right; +} +#tab_plugin_CalibrationTools .eSteps_container .title { + flex-basis: 30%; +} + +#tab_plugin_CalibrationTools .eSteps_container .val { + max-width: 60px; +} + +#tab_plugin_CalibrationTools .numberInputField { + width: 60px; +} */ diff --git a/octoprint_CalibrationTools/static/js/CalibrationTools.js b/octoprint_CalibrationTools/static/js/CalibrationTools.js new file mode 100644 index 0000000..12d171b --- /dev/null +++ b/octoprint_CalibrationTools/static/js/CalibrationTools.js @@ -0,0 +1,106 @@ +//Notification +// new PNotify({ +// title: "Success", +// text: _.sprintf(text, { +// command: _.escape(commandSpec.name) +// }), +// type: "success" +// }); + + + +$(function () { + function CalibrationToolsViewModel(parameters) { + var self = this; + self.loginStateViewModel = parameters[0]; + self.settingsViewModel = parameters[1]; + self.controlViewModel = parameters[2]; + self.terminalViewModel = parameters[3]; + self.access = parameters[4]; + + self.is_admin = ko.observable(false); + self.steps = ko.observable(); + self.steps["X"] = ko.observable(); + self.steps["Y"] = ko.observable(); + self.steps["Z"] = ko.observable(); + self.steps["E"] = ko.observable(); + self.results = {}; + + self.results["remainedLength"] = ko.observable(20); + self.results["markLength"] = ko.observable(120); + self.results["actualExtrusion"] = ko.computed(function () { + return (self.results.markLength() - self.results.remainedLength()).toFixed(3); + }); + + self.results["newSteps"] = ko.computed(function () { + return (self.steps.E() / self.results.actualExtrusion() * 100).toFixed(3); + }); + + self.onBeforeBinding = self.onUserLoggedIn = self.onUserLoggedOut = function () { + self.is_admin(self.loginStateViewModel.isAdmin()); + } + + /**open settings*/ + self.openCalibrationSettings = function () { + $('a#navbar_show_settings').click(); + $('li#settings_plugin_CalibrationTools_link a').click(); + $("#settings_plugin_CalibrationTools").click(); + } + + self.from_json = function (response) { + self.steps["X"](response.data.X); + self.steps["Y"](response.data.Y); + self.steps["Z"](response.data.Z); + self.steps["E"](response.data.E); + } + + self.calibrateESteps = function () { + // OctoPrint.simpleApiCommand("loadSteps") + // OctoPrint.control.sendGcodeWithParameters("M92").done(function (responseM92) { + // OctoPrint.simpleApiGet("CalibrationTools").done(function (response) { + // console.log("CalibrationTools"); + // self.from_json(response); + // }); + // }); + console.log("calibrateESteps"); + console.log(self.steps.E(), self.results.remainedLength(), self.results.newSteps()); + } + + self.loadStepsFromEPROM = function () { + OctoPrint.simpleApiCommand("CalibrationTools","loadSteps").done(function (response) { + self.from_json(response); + }) + // OctoPrint.simpleApiGet("CalibrationTools").done(function (response) { + // console.log("CalibrationTools"); + // self.from_json(response); + // }); + } + + self.tempRestart = function () { + OctoPrint.system.executeCommand("core", "restart"); + } + self.runCommand = function () { + OctoPrint.control.sendGcodeWithParameters("G90"); + } + + self.onAllBound = self.onEventConnected = function () { + OctoPrint.simpleApiGet("CalibrationTools").done(function (response) { + console.log("CalibrationTools"); + self.from_json(response); + }); + } + } + + // This is how our plugin registers itself with the application, by adding some configuration + // information to the global variable OCTOPRINT_VIEWMODELS + OCTOPRINT_VIEWMODELS.push({ + // This is the constructor to call for instantiating the plugin + construct: CalibrationToolsViewModel, + // This is a list of dependencies to inject into the plugin, the order which you request + // here is the order in which the dependencies will be injected into your view model upon + // instantiation via the parameters argument + dependencies: ["loginStateViewModel", "settingsViewModel", "controlViewModel", "terminalViewModel", "accessViewModel"], + // Finally, this is the list of selectors for all elements we want this view model to be bound to. + elements: ["#tab_plugin_CalibrationTools"] + }); +}); \ No newline at end of file diff --git a/octoprint_CalibrationTools/templates/CalibrationTools_settings.jinja2 b/octoprint_CalibrationTools/templates/CalibrationTools_settings.jinja2 new file mode 100644 index 0000000..5762b7c --- /dev/null +++ b/octoprint_CalibrationTools/templates/CalibrationTools_settings.jinja2 @@ -0,0 +1,7 @@ +
+

Something in settings

+
Actual extrusion:
+
New steps value:
+
Extrusion marking length:
+
Measured value:
+
\ No newline at end of file diff --git a/octoprint_CalibrationTools/templates/CalibrationTools_tab.jinja2 b/octoprint_CalibrationTools/templates/CalibrationTools_tab.jinja2 new file mode 100644 index 0000000..d9dd52f --- /dev/null +++ b/octoprint_CalibrationTools/templates/CalibrationTools_tab.jinja2 @@ -0,0 +1,38 @@ +
+
+
+

Calibration

+
+
+ +
+
+ + + +
+
+
+
+ +
+
+ {% include "tabs/tab-content.jinja2" %} +
+
+
\ No newline at end of file diff --git a/octoprint_CalibrationTools/templates/macros.jinja2 b/octoprint_CalibrationTools/templates/macros.jinja2 new file mode 100644 index 0000000..cc8b19a --- /dev/null +++ b/octoprint_CalibrationTools/templates/macros.jinja2 @@ -0,0 +1,34 @@ +{% macro subSection(title, spaceBefore) %} +{% if (spaceBefore) %}

{% endif %} +{{ _(title) }} +
+{% endmacro %} + + +{% macro card(content, class) %} +
+

{{ _(content) }}

+
+{% endmacro %} + +{% macro quote(content, class) %} +
+

{{ _(content) }}

+
+{% endmacro %} + +{% macro field(label, number, binding, enable, unit) %} +
+
+ +
+
+
+ + {{ _(unit) }} +
+
+
+{% endmacro %} \ No newline at end of file diff --git a/octoprint_CalibrationTools/templates/tabs/tab-content.jinja2 b/octoprint_CalibrationTools/templates/tabs/tab-content.jinja2 new file mode 100644 index 0000000..245d6be --- /dev/null +++ b/octoprint_CalibrationTools/templates/tabs/tab-content.jinja2 @@ -0,0 +1,15 @@ + +
+
+ {% include "tabs/tab-doc.jinja2" %} +
+
+ {% include "tabs/tab-xyz.jinja2" %} +
+
+ {% include "tabs/tab-esteps.jinja2" %} +
+
+ {% include "tabs/tab-pind.jinja2" %} +
+
\ No newline at end of file diff --git a/octoprint_CalibrationTools/templates/tabs/tab-doc.jinja2 b/octoprint_CalibrationTools/templates/tabs/tab-doc.jinja2 new file mode 100644 index 0000000..c1cc65a --- /dev/null +++ b/octoprint_CalibrationTools/templates/tabs/tab-doc.jinja2 @@ -0,0 +1,3 @@ + + Something in documentation tab... + diff --git a/octoprint_CalibrationTools/templates/tabs/tab-esteps.jinja2 b/octoprint_CalibrationTools/templates/tabs/tab-esteps.jinja2 new file mode 100644 index 0000000..0250774 --- /dev/null +++ b/octoprint_CalibrationTools/templates/tabs/tab-esteps.jinja2 @@ -0,0 +1,38 @@ +{% import "macros.jinja2" as snipped %} + +{{ snipped.subSection("EEPROM values") }} + +{{ snipped.field("E steps", "number", "$root.steps.E", "false", "steps/mm") }} +
+
+
+ +
+
+ +{{ snipped.subSection("Compute", true) }} + +{{ snipped.field("Actual extrusion", "number", "$root.results.actualExtrusion", "false", "mm") }} +{{ snipped.field("New steps value", "number", "$root.results.newSteps", "false", "steps/mm") }} +{{ snipped.field("Extrusion marking length", "number", "$root.results.markLength", "true", "mm") }} +{{ snipped.field("Measured value", "number", "$root.results.remainedLength", "true", "mm") }} +
+
+
+ +
+
+ +{{ snipped.subSection("Process description", true) }} +{{ snipped.quote(" +First Read this

+This calibration is best done with the extruder detached from the hot end, so no restriction is present on the movement. If it is convenient, you can partially disassemble the printer so the output of the extruder is +open and the filament exits in free air. If this is inconvenient, the process below aims to minimise restrictions by extruding very slowly and with a slightly higher temperature. The results from this should still be +reliable. +", "text-warning" ) }} \ No newline at end of file diff --git a/octoprint_CalibrationTools/templates/tabs/tab-pind.jinja2 b/octoprint_CalibrationTools/templates/tabs/tab-pind.jinja2 new file mode 100644 index 0000000..9b490a1 --- /dev/null +++ b/octoprint_CalibrationTools/templates/tabs/tab-pind.jinja2 @@ -0,0 +1 @@ +Something in pid tab... \ No newline at end of file diff --git a/octoprint_CalibrationTools/templates/tabs/tab-xyz.jinja2 b/octoprint_CalibrationTools/templates/tabs/tab-xyz.jinja2 new file mode 100644 index 0000000..34c114e --- /dev/null +++ b/octoprint_CalibrationTools/templates/tabs/tab-xyz.jinja2 @@ -0,0 +1 @@ +Something in xyz tab... \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a1dc463 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,9 @@ +### +# This file is only here to make sure that something like +# +# pip install -e . +# +# works as expected. Requirements can be found in setup.py. +### + +. diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..2a9acf1 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal = 1 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..7663097 --- /dev/null +++ b/setup.py @@ -0,0 +1,100 @@ +# coding=utf-8 + +######################################################################################################################## +### Do not forget to adjust the following variables to your own plugin. + +# The plugin's identifier, has to be unique +plugin_identifier = "CalibrationTools" + +# The plugin's python package, should be "octoprint_", has to be unique +plugin_package = "octoprint_CalibrationTools" + +# The plugin's human readable name. Can be overwritten within OctoPrint's internal data via __plugin_name__ in the +# plugin module +plugin_name = "OctoPrint-CalibrationTools" + +# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module +plugin_version = "0.1.0" + +# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin +# module +plugin_description = """Calibration tools""" + +# The plugin's author. Can be overwritten within OctoPrint's internal data via __plugin_author__ in the plugin module +plugin_author = "Sergiu Toporjinschi" + +# The plugin's author's mail address. +plugin_author_email = "you@example.com" + +# The plugin's homepage URL. Can be overwritten within OctoPrint's internal data via __plugin_url__ in the plugin module +plugin_url = "https://github.com/SergiuToporjinschi/OctoPrint-CalibrationTools" + +# The plugin's license. Can be overwritten within OctoPrint's internal data via __plugin_license__ in the plugin module +plugin_license = "GNUv3" + +# Any additional requirements besides OctoPrint should be listed here +plugin_requires = [] + +### -------------------------------------------------------------------------------------------------------------------- +### More advanced options that you usually shouldn't have to touch follow after this point +### -------------------------------------------------------------------------------------------------------------------- + +# Additional package data to install for this plugin. The subfolders "templates", "static" and "translations" will +# already be installed automatically if they exist. Note that if you add something here you'll also need to update +# MANIFEST.in to match to ensure that python setup.py sdist produces a source distribution that contains all your +# files. This is sadly due to how python's setup.py works, see also http://stackoverflow.com/a/14159430/2028598 +plugin_additional_data = [] + +# Any additional python packages you need to install with your plugin that are not contained in .* +plugin_additional_packages = [] + +# Any python packages within .* you do NOT want to install with your plugin +plugin_ignored_packages = [] + +# Additional parameters for the call to setuptools.setup. If your plugin wants to register additional entry points, +# define dependency links or other things like that, this is the place to go. Will be merged recursively with the +# default setup parameters as provided by octoprint_setuptools.create_plugin_setup_parameters using +# octoprint.util.dict_merge. +# +# Example: +# plugin_requires = ["someDependency==dev"] +# additional_setup_parameters = {"dependency_links": ["https://github.com/someUser/someRepo/archive/master.zip#egg=someDependency-dev"]} +additional_setup_parameters = {} + +######################################################################################################################## + +from setuptools import setup + +try: + import octoprint_setuptools +except: + print( + "Could not import OctoPrint's setuptools, are you sure you are running that under " + "the same python installation that OctoPrint is installed under?" + ) + import sys + + sys.exit(-1) + +setup_parameters = octoprint_setuptools.create_plugin_setup_parameters( + identifier=plugin_identifier, + package=plugin_package, + name=plugin_name, + version=plugin_version, + description=plugin_description, + author=plugin_author, + mail=plugin_author_email, + url=plugin_url, + license=plugin_license, + requires=plugin_requires, + additional_packages=plugin_additional_packages, + ignored_packages=plugin_ignored_packages, + additional_data=plugin_additional_data, +) + +if len(additional_setup_parameters): + from octoprint.util import dict_merge + + setup_parameters = dict_merge(setup_parameters, additional_setup_parameters) + +setup(**setup_parameters) diff --git a/translations/README.txt b/translations/README.txt new file mode 100644 index 0000000..1426db0 --- /dev/null +++ b/translations/README.txt @@ -0,0 +1,28 @@ +Your plugin's translations will reside here. The provided setup.py supports a +couple of additional commands to make managing your translations easier: + +babel_extract + Extracts any translateable messages (marked with Jinja's `_("...")` or + JavaScript's `gettext("...")`) and creates the initial `messages.pot` file. +babel_refresh + Reruns extraction and updates the `messages.pot` file. +babel_new --locale= + Creates a new translation folder for locale ``. +babel_compile + Compiles the translations into `mo` files, ready to be used within + OctoPrint. +babel_pack --locale= [ --author= ] + Packs the translation for locale `` up as an installable + language pack that can be manually installed by your plugin's users. This is + interesting for languages you can not guarantee to keep up to date yourself + with each new release of your plugin and have to depend on contributors for. + +If you want to bundle translations with your plugin, create a new folder +`octoprint_CalibrationTools/translations`. When that folder exists, +an additional command becomes available: + +babel_bundle --locale= + Moves the translation for locale `` to octoprint_CalibrationTools/translations, + effectively bundling it with your plugin. This is interesting for languages + you can guarantee to keep up to date yourself with each new release of your + plugin.