From 656c47d5d6c00d674c556fd170d102af0ed9ba65 Mon Sep 17 00:00:00 2001 From: Vitor Henrique Date: Sat, 12 Sep 2015 00:40:13 -0500 Subject: [PATCH] initial commit --- .editorconfig | 17 ++++ .gitignore | 9 ++ MANIFEST.in | 1 + README.md | 17 ++++ babel.cfg | 6 ++ extras/README.txt | 8 ++ extras/enclosure.md | 55 +++++++++++ octoprint_enclosure/__init__.py | 65 +++++++++++++ octoprint_enclosure/static/css/README.txt | 1 + octoprint_enclosure/static/js/README.txt | 1 + octoprint_enclosure/static/less/README.txt | 1 + octoprint_enclosure/templates/README.txt | 1 + .../templates/enclosure_settings.jinja2 | 59 ++++++++++++ .../templates/enclosure_tab.jinja2 | 7 ++ requirements.txt | 9 ++ setup.py | 94 +++++++++++++++++++ translations/README.txt | 28 ++++++ 17 files changed, 379 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 MANIFEST.in create mode 100644 README.md create mode 100644 babel.cfg create mode 100644 extras/README.txt create mode 100644 extras/enclosure.md create mode 100644 octoprint_enclosure/__init__.py create mode 100644 octoprint_enclosure/static/css/README.txt create mode 100644 octoprint_enclosure/static/js/README.txt create mode 100644 octoprint_enclosure/static/less/README.txt create mode 100644 octoprint_enclosure/templates/README.txt create mode 100644 octoprint_enclosure/templates/enclosure_settings.jinja2 create mode 100644 octoprint_enclosure/templates/enclosure_tab.jinja2 create mode 100644 requirements.txt create mode 100644 setup.py create mode 100644 translations/README.txt diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..82c8e05 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +# 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 = tab + +[**.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..bb3ec5f --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..ec2f986 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# OctoPrint-Enclosure + +**TODO:** Describe what your plugin does. + +## Setup + +Install via the bundled [Plugin Manager](https://github.com/foosel/OctoPrint/wiki/Plugin:-Plugin-Manager) +or manually using this URL: + + https://github.com/vitormhenirque/OctoPrint-Enclosure/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..b6f5945 --- /dev/null +++ b/babel.cfg @@ -0,0 +1,6 @@ +[python: */**.py] +[jinja2: */**.jinja2] +extensions=jinja2.ext.autoescape, jinja2.ext.with_ + +[javascript: */**.js] +extract_messages = gettext, ngettext diff --git a/extras/README.txt b/extras/README.txt new file mode 100644 index 0000000..b30c31f --- /dev/null +++ b/extras/README.txt @@ -0,0 +1,8 @@ +Currently Cookiecutter generates the following helpful extras to this folder: + +enclosure.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/extras/enclosure.md b/extras/enclosure.md new file mode 100644 index 0000000..7708360 --- /dev/null +++ b/extras/enclosure.md @@ -0,0 +1,55 @@ +--- +layout: plugin + +id: enclosure +title: OctoPrint-Enclosure +description: TODO +author: Vitor Henrique +license: AGPLv3 + +# TODO +date: today's date in format YYYY-MM-DD, e.g. 2015-04-21 + +homepage: https://github.com/vitormhenirque/OctoPrint-Enclosure +source: https://github.com/vitormhenirque/OctoPrint-Enclosure +archive: https://github.com/vitormhenirque/OctoPrint-Enclosure/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 + alt: alt-text of a screenshot + caption: caption of a screenshot +- url: url of another screenshot + alt: alt-text of another screenshot + caption: caption of another screenshot +- ... + +# TODO +featuredimage: url of a featured image for your plugin + +compatibility: + # list of compatible versions, for example 1.2.0. If left empty no specific version requirement will be assumed + octoprint: + - 1.2.0 + + # list of compatible operating systems, valid values are linux, windows, macos, leaving empty defaults to all + os: + - linux + - windows + - macos +--- + +**TODO**: Longer description of your plugin, configuration examples etc. This part will be visible on the page at +http://plugins.octoprint.org/plugin/enclosure/ diff --git a/octoprint_enclosure/__init__.py b/octoprint_enclosure/__init__.py new file mode 100644 index 0000000..f0d9d44 --- /dev/null +++ b/octoprint_enclosure/__init__.py @@ -0,0 +1,65 @@ +# 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. +# +# Take a look at the documentation on what other plugin mixins are available. + +import octoprint.plugin +from octoprint.util import RepeatedTimer + +class EnclosurePlugin(octoprint.plugin.StartupPlugin, + octoprint.plugin.TemplatePlugin, + octoprint.plugin.SettingsPlugin): + + def on_after_startup(self): + self._logger.info("Starting Timer") + self.startTimer(5) + + def startTimer(self, interval): + self._checkTempTimer = RepeatedTimer(interval, self.checkEnclosureTemp, None, None, True) + self._checkTempTimer.start() + + def checkEnclosureTemp(self): + self._logger.info("Checking eclosure temp...") + import random + def randrange_float(start, stop, step): + return random.randint(0, int((stop - start) / step)) * step + start + p = randrange_float(5, 60, 0.1) + self._logger.info("temp:: %s" % p) + self._plugin_manager.send_plugin_message(self._identifier, dict(enclosureTemp=p)) + + ##~~ SettingsPlugin + def get_settings_defaults(self): + return dict(heaterPin=17, + heaterFrequency=5, + heaterEnable=False, + fanEnable=False, + fanPin=18, + lightEnable=True, + lightPin=20 + ) + + def get_template_configs(self): + return [ + dict(type="settings", custom_bindings=False) + ] + + +# 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__ = "Enclosure Plugin" + +def __plugin_load__(): + global __plugin_implementation__ + __plugin_implementation__ = EnclosurePlugin() + + # global __plugin_hooks__ + # __plugin_hooks__ = { + # "some.octoprint.hook": __plugin_implementation__.some_hook_handler + # } + diff --git a/octoprint_enclosure/static/css/README.txt b/octoprint_enclosure/static/css/README.txt new file mode 100644 index 0000000..1803f70 --- /dev/null +++ b/octoprint_enclosure/static/css/README.txt @@ -0,0 +1 @@ +Have your plugin's CSS files generated to here. \ No newline at end of file diff --git a/octoprint_enclosure/static/js/README.txt b/octoprint_enclosure/static/js/README.txt new file mode 100644 index 0000000..6705398 --- /dev/null +++ b/octoprint_enclosure/static/js/README.txt @@ -0,0 +1 @@ +Put your plugin's javascript files here. \ No newline at end of file diff --git a/octoprint_enclosure/static/less/README.txt b/octoprint_enclosure/static/less/README.txt new file mode 100644 index 0000000..023008f --- /dev/null +++ b/octoprint_enclosure/static/less/README.txt @@ -0,0 +1 @@ +Put your plugin's LESS files here, have them generated to ../css. \ No newline at end of file diff --git a/octoprint_enclosure/templates/README.txt b/octoprint_enclosure/templates/README.txt new file mode 100644 index 0000000..eb9629f --- /dev/null +++ b/octoprint_enclosure/templates/README.txt @@ -0,0 +1 @@ +Put your plugin's Jinja2 templates here. \ No newline at end of file diff --git a/octoprint_enclosure/templates/enclosure_settings.jinja2 b/octoprint_enclosure/templates/enclosure_settings.jinja2 new file mode 100644 index 0000000..4e50561 --- /dev/null +++ b/octoprint_enclosure/templates/enclosure_settings.jinja2 @@ -0,0 +1,59 @@ +

{{ _('Heater') }}

+ +
+
+
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +

{{ _('Fan') }}

+ +
+
+
+ +
+
+
+ +
+ +
+
+
+ +

{{ _('Light') }}

+ +
+
+
+ +
+
+
+ +
+ +
+
+
\ No newline at end of file diff --git a/octoprint_enclosure/templates/enclosure_tab.jinja2 b/octoprint_enclosure/templates/enclosure_tab.jinja2 new file mode 100644 index 0000000..23e4cf3 --- /dev/null +++ b/octoprint_enclosure/templates/enclosure_tab.jinja2 @@ -0,0 +1,7 @@ +
+

Enclosure Info

+
+ +

+
+
\ 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.py b/setup.py new file mode 100644 index 0000000..c28aa72 --- /dev/null +++ b/setup.py @@ -0,0 +1,94 @@ +# 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 = "enclosure" + +# The plugin's python package, should be "octoprint_", has to be unique +plugin_package = "octoprint_enclosure" + +# The plugin's human readable name. Can be overwritten within OctoPrint's internal data via __plugin_name__ in the +# plugin module +plugin_name = "OctoPrint-Enclosure" + +# 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 = """TODO""" + +# The plugin's author. Can be overwritten within OctoPrint's internal data via __plugin_author__ in the plugin module +plugin_author = "Vitor Henrique" + +# The plugin's author's mail address. +plugin_author_email = "vitormhenrique@gmail.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/vitormhenirque/OctoPrint-Enclosure" + +# The plugin's license. Can be overwritten within OctoPrint's internal data via __plugin_license__ in the plugin module +plugin_license = "AGPLv3" + +# 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. +plugin_additional_data = [] + +# Any additional python packages you need to install with your plugin that are not contains in .* +plugin_addtional_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_addtional_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..7edeefe --- /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_enclosure/translations`. When that folder exists, +an additional command becomes available: + +babel_bundle --locale= + Moves the translation for locale `` to octoprint_enclosure/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.