From 0070ccd52ba30914659883597573f823cf9f01c6 Mon Sep 17 00:00:00 2001 From: Jarek Szczepanski Date: Fri, 13 Mar 2015 13:58:20 +0100 Subject: [PATCH] Init --- .gitignore | 54 ++++++++++++++++++++++++ README.md | 15 +++++++ octoprint_printhistory/__init__.py | 18 ++++++++ requirements.txt | 1 + setup.py | 67 ++++++++++++++++++++++++++++++ 5 files changed, 155 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 octoprint_printhistory/__init__.py create mode 100644 requirements.txt create mode 100644 setup.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..db4561e --- /dev/null +++ b/.gitignore @@ -0,0 +1,54 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..d91b78d --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# Plugin for OctoPrint - saves filename, print time and filament usage for each print + +## Setup + +Install the plugin like you would install any regular Python package from source: + + pip install https://github.com/imrahil/OctoPrint-PrintHistoryPlugin/archive/master.zip + +Make sure you use the same Python environment that you installed OctoPrint under, otherwise the plugin +won't be able to satisfy its dependencies. + +Restart OctoPrint. `octoprint.log` should show you that the plugin was successfully found and loaded: + + 2014-09-18 17:49:21,500 - octoprint.plugin.core - INFO - Loading plugins from ... and installed plugin packages... + 2014-09-18 17:49:21,611 - octoprint.plugin.core - INFO - Found 2 plugin(s): Print History Plugin (0.1), Discovery (0.1) \ No newline at end of file diff --git a/octoprint_printhistory/__init__.py b/octoprint_printhistory/__init__.py new file mode 100644 index 0000000..7d6dfe4 --- /dev/null +++ b/octoprint_printhistory/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +from __future__ import absolute_import + +__author__ = "Jarek Szczepanski " +__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" +__copyright__ = "Copyright (C) 2014 Jarek Szczepanski - Released under terms of the AGPLv3 License" + +import octoprint.plugin +import octoprint.events + +class PrintHistoryPlugin(octoprint.plugin.EventHandlerPlugin, + octoprint.plugin.SettingsPlugin, + octoprint.plugin.TemplatePlugin, + octoprint.plugin.AssetPlugin): + + +__plugin_name__ = "Print History Plugin" +__plugin_implementations__ = [PrintHistoryPlugin()] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..752b524 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +OctoPrint \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..b28edab --- /dev/null +++ b/setup.py @@ -0,0 +1,67 @@ +# coding=utf-8 +import setuptools + +######################################################################################################################## + +plugin_identifier = "printhistory" +plugin_package = "octoprint_%s" % plugin_identifier +plugin_name = "OctoPrint-PrintHistory" +plugin_version = "0.1" +plugin_description = "Saves filename, print time and filament usage for each print" +plugin_author = "Jarek Szczepanski" +plugin_author_email = "imrahil@imrahil.com" +plugin_url = "https://github.com/imrahil/OctoPrint-PrintHistory" +plugin_license = "AGPLv3" +plugin_additional_data = [] + +######################################################################################################################## + +def package_data_dirs(source, sub_folders): + import os + dirs = [] + + for d in sub_folders: + folder = os.path.join(source, d) + if not os.path.exists(folder): + continue + + for dirname, _, files in os.walk(folder): + dirname = os.path.relpath(dirname, source) + for f in files: + dirs.append(os.path.join(dirname, f)) + + return dirs + +def params(): + # Our metadata, as defined above + name = plugin_name + version = plugin_version + description = plugin_description + author = plugin_author + author_email = plugin_author_email + url = plugin_url + license = plugin_license + + # we only have our plugin package to install + packages = [plugin_package] + + # we might have additional data files in sub folders that need to be installed too + package_data = {plugin_package: package_data_dirs(plugin_package, ['static', 'templates', 'translations'] + plugin_additional_data)} + include_package_data = True + + # If you have any package data that needs to be accessible on the file system, such as templates or static assets + # this plugin is not zip_safe. + zip_safe = False + + # Read the requirements from our requirements.txt file + install_requires = open("requirements.txt").read().split("\n") + + # Hook the plugin into the "octoprint.plugin" entry point, mapping the plugin_identifier to the plugin_package. + # That way OctoPrint will be able to find the plugin and load it. + entry_points = { + "octoprint.plugin": ["%s = %s" % (plugin_identifier, plugin_package)] + } + + return locals() + +setuptools.setup(**params()) \ No newline at end of file