Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9a9a405cd | ||
|
|
fa564c6029 | ||
|
|
36d1522f01 | ||
|
|
536e17eac4 | ||
|
|
887ec45b6b | ||
|
|
deb38f8455 | ||
|
|
293611287e | ||
|
|
7ebbf5911c | ||
|
|
d7e37cf658 | ||
|
|
e068012cfb | ||
|
|
d7f2075b1d | ||
|
|
e5ac94a16f | ||
|
|
f09d44d8a0 | ||
|
|
89cae22b91 | ||
|
|
0747336c0f | ||
|
|
bba625a68f | ||
|
|
b282a18f6b | ||
|
|
0fd9b3354a | ||
|
|
765b941472 | ||
|
|
64084bb628 | ||
|
|
df269eb4f7 | ||
|
|
722b03dca8 | ||
|
|
3ddfc93c1b | ||
|
|
5eb70fa57d |
No files matched your search
@@ -0,0 +1,13 @@
|
||||
Bug Reports
|
||||
-----------
|
||||
|
||||
**READ [How to file a bug report](https://github.com/foosel/OctoPrint/wiki/How-to-file-a-bug-report)!**.
|
||||
|
||||
Pull Requests
|
||||
-------------
|
||||
|
||||
1. Please create all pull requests against the `devel` branch.
|
||||
2. Create **one pull request per feature/bug fix**.
|
||||
3. Create a custom branch for your feature/bug fix and use that as base for your pull request. Pull requests directly against your version of `devel` will be closed.
|
||||
4. In your pull request's description, state what your pull request is doing, as in, what feature does it implement, what bug does it fix.
|
||||
|
||||
-177
@@ -1,177 +0,0 @@
|
||||
# Makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
PAPER =
|
||||
BUILDDIR = _build
|
||||
|
||||
# User-friendly check for sphinx-build
|
||||
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
|
||||
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
|
||||
endif
|
||||
|
||||
# Internal variables.
|
||||
PAPEROPT_a4 = -D latex_paper_size=a4
|
||||
PAPEROPT_letter = -D latex_paper_size=letter
|
||||
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
||||
# the i18n builder cannot share the environment and doctrees with the others
|
||||
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
||||
|
||||
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
|
||||
|
||||
help:
|
||||
@echo "Please use \`make <target>' where <target> is one of"
|
||||
@echo " html to make standalone HTML files"
|
||||
@echo " dirhtml to make HTML files named index.html in directories"
|
||||
@echo " singlehtml to make a single large HTML file"
|
||||
@echo " pickle to make pickle files"
|
||||
@echo " json to make JSON files"
|
||||
@echo " htmlhelp to make HTML files and a HTML help project"
|
||||
@echo " qthelp to make HTML files and a qthelp project"
|
||||
@echo " devhelp to make HTML files and a Devhelp project"
|
||||
@echo " epub to make an epub"
|
||||
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
|
||||
@echo " latexpdf to make LaTeX files and run them through pdflatex"
|
||||
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
|
||||
@echo " text to make text files"
|
||||
@echo " man to make manual pages"
|
||||
@echo " texinfo to make Texinfo files"
|
||||
@echo " info to make Texinfo files and run them through makeinfo"
|
||||
@echo " gettext to make PO message catalogs"
|
||||
@echo " changes to make an overview of all changed/added/deprecated items"
|
||||
@echo " xml to make Docutils-native XML files"
|
||||
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
|
||||
@echo " linkcheck to check all external links for integrity"
|
||||
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILDDIR)/*
|
||||
|
||||
html:
|
||||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
||||
|
||||
dirhtml:
|
||||
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
|
||||
|
||||
singlehtml:
|
||||
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
|
||||
|
||||
pickle:
|
||||
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
|
||||
@echo
|
||||
@echo "Build finished; now you can process the pickle files."
|
||||
|
||||
json:
|
||||
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
|
||||
@echo
|
||||
@echo "Build finished; now you can process the JSON files."
|
||||
|
||||
htmlhelp:
|
||||
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run HTML Help Workshop with the" \
|
||||
".hhp project file in $(BUILDDIR)/htmlhelp."
|
||||
|
||||
qthelp:
|
||||
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
||||
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
||||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/OctoPrint.qhcp"
|
||||
@echo "To view the help file:"
|
||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/OctoPrint.qhc"
|
||||
|
||||
devhelp:
|
||||
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
||||
@echo
|
||||
@echo "Build finished."
|
||||
@echo "To view the help file:"
|
||||
@echo "# mkdir -p $$HOME/.local/share/devhelp/OctoPrint"
|
||||
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/OctoPrint"
|
||||
@echo "# devhelp"
|
||||
|
||||
epub:
|
||||
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
|
||||
@echo
|
||||
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
|
||||
|
||||
latex:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo
|
||||
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
|
||||
@echo "Run \`make' in that directory to run these through (pdf)latex" \
|
||||
"(use \`make latexpdf' here to do that automatically)."
|
||||
|
||||
latexpdf:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo "Running LaTeX files through pdflatex..."
|
||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf
|
||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||
|
||||
latexpdfja:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo "Running LaTeX files through platex and dvipdfmx..."
|
||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
|
||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||
|
||||
text:
|
||||
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
|
||||
@echo
|
||||
@echo "Build finished. The text files are in $(BUILDDIR)/text."
|
||||
|
||||
man:
|
||||
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
|
||||
@echo
|
||||
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
|
||||
|
||||
texinfo:
|
||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||
@echo
|
||||
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
|
||||
@echo "Run \`make' in that directory to run these through makeinfo" \
|
||||
"(use \`make info' here to do that automatically)."
|
||||
|
||||
info:
|
||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||
@echo "Running Texinfo files through makeinfo..."
|
||||
make -C $(BUILDDIR)/texinfo info
|
||||
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
|
||||
|
||||
gettext:
|
||||
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
|
||||
@echo
|
||||
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
|
||||
|
||||
changes:
|
||||
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
|
||||
@echo
|
||||
@echo "The overview file is in $(BUILDDIR)/changes."
|
||||
|
||||
linkcheck:
|
||||
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
|
||||
@echo
|
||||
@echo "Link check complete; look for any errors in the above output " \
|
||||
"or in $(BUILDDIR)/linkcheck/output.txt."
|
||||
|
||||
doctest:
|
||||
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
|
||||
@echo "Testing of doctests in the sources finished, look at the " \
|
||||
"results in $(BUILDDIR)/doctest/output.txt."
|
||||
|
||||
xml:
|
||||
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
|
||||
@echo
|
||||
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
|
||||
|
||||
pseudoxml:
|
||||
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
|
||||
@echo
|
||||
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
|
||||
-248
@@ -1,248 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# OctoPrint documentation build configuration file, created by
|
||||
# sphinx-quickstart on Mon Dec 02 17:08:50 2013.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its containing dir.
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
#
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys, os
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# -- General configuration -----------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = ['sphinx.ext.todo']
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'OctoPrint'
|
||||
copyright = u'2013, Gina Häußge'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = open("../VERSION").read().strip()
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = version
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#language = None
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
#today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ['_build']
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
#default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
#modindex_common_prefix = []
|
||||
|
||||
# If true, keep warnings as "system message" paragraphs in the built documents.
|
||||
#keep_warnings = False
|
||||
|
||||
|
||||
# -- Options for HTML output ---------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
html_theme = 'default'
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'OctoPrintdoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'OctoPrint.tex', u'OctoPrint Documentation',
|
||||
u'Gina Häußge', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output --------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('index', 'octoprint', u'OctoPrint Documentation',
|
||||
[u'Gina Häußge'], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output ------------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'OctoPrint', u'OctoPrint Documentation',
|
||||
u'Gina Häußge', 'OctoPrint', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#texinfo_show_urls = 'footnote'
|
||||
|
||||
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
||||
#texinfo_no_detailmenu = False
|
||||
@@ -1,22 +0,0 @@
|
||||
.. OctoPrint documentation master file, created by
|
||||
sphinx-quickstart on Mon Dec 02 17:08:50 2013.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
Welcome to OctoPrint's documentation!
|
||||
=====================================
|
||||
|
||||
Contents:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
|
||||
-242
@@ -1,242 +0,0 @@
|
||||
@ECHO OFF
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set BUILDDIR=_build
|
||||
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
|
||||
set I18NSPHINXOPTS=%SPHINXOPTS% .
|
||||
if NOT "%PAPER%" == "" (
|
||||
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
|
||||
set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
|
||||
)
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
if "%1" == "help" (
|
||||
:help
|
||||
echo.Please use `make ^<target^>` where ^<target^> is one of
|
||||
echo. html to make standalone HTML files
|
||||
echo. dirhtml to make HTML files named index.html in directories
|
||||
echo. singlehtml to make a single large HTML file
|
||||
echo. pickle to make pickle files
|
||||
echo. json to make JSON files
|
||||
echo. htmlhelp to make HTML files and a HTML help project
|
||||
echo. qthelp to make HTML files and a qthelp project
|
||||
echo. devhelp to make HTML files and a Devhelp project
|
||||
echo. epub to make an epub
|
||||
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
|
||||
echo. text to make text files
|
||||
echo. man to make manual pages
|
||||
echo. texinfo to make Texinfo files
|
||||
echo. gettext to make PO message catalogs
|
||||
echo. changes to make an overview over all changed/added/deprecated items
|
||||
echo. xml to make Docutils-native XML files
|
||||
echo. pseudoxml to make pseudoxml-XML files for display purposes
|
||||
echo. linkcheck to check all external links for integrity
|
||||
echo. doctest to run all doctests embedded in the documentation if enabled
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "clean" (
|
||||
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
|
||||
del /q /s %BUILDDIR%\*
|
||||
goto end
|
||||
)
|
||||
|
||||
|
||||
%SPHINXBUILD% 2> nul
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.http://sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if "%1" == "html" (
|
||||
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "dirhtml" (
|
||||
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "singlehtml" (
|
||||
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "pickle" (
|
||||
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; now you can process the pickle files.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "json" (
|
||||
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; now you can process the JSON files.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "htmlhelp" (
|
||||
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; now you can run HTML Help Workshop with the ^
|
||||
.hhp project file in %BUILDDIR%/htmlhelp.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "qthelp" (
|
||||
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; now you can run "qcollectiongenerator" with the ^
|
||||
.qhcp project file in %BUILDDIR%/qthelp, like this:
|
||||
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\OctoPrint.qhcp
|
||||
echo.To view the help file:
|
||||
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\OctoPrint.ghc
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "devhelp" (
|
||||
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "epub" (
|
||||
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The epub file is in %BUILDDIR%/epub.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "latex" (
|
||||
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "latexpdf" (
|
||||
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
||||
cd %BUILDDIR%/latex
|
||||
make all-pdf
|
||||
cd %BUILDDIR%/..
|
||||
echo.
|
||||
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "latexpdfja" (
|
||||
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
||||
cd %BUILDDIR%/latex
|
||||
make all-pdf-ja
|
||||
cd %BUILDDIR%/..
|
||||
echo.
|
||||
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "text" (
|
||||
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The text files are in %BUILDDIR%/text.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "man" (
|
||||
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The manual pages are in %BUILDDIR%/man.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "texinfo" (
|
||||
%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "gettext" (
|
||||
%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "changes" (
|
||||
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.The overview file is in %BUILDDIR%/changes.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "linkcheck" (
|
||||
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Link check complete; look for any errors in the above output ^
|
||||
or in %BUILDDIR%/linkcheck/output.txt.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "doctest" (
|
||||
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Testing of doctests in the sources finished, look at the ^
|
||||
results in %BUILDDIR%/doctest/output.txt.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "xml" (
|
||||
%SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The XML files are in %BUILDDIR%/xml.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "pseudoxml" (
|
||||
%SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
|
||||
goto end
|
||||
)
|
||||
|
||||
:end
|
||||
@@ -1,13 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
print """
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!!! You are using an old startup method for OctoPrint. !!!
|
||||
!!! Please perform 'sudo python setup.py install' and !!!
|
||||
!!! use the 'octoprint' executable instead. !!!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
@@ -24,7 +16,7 @@ I don't know anything about).
|
||||
"""
|
||||
os.rename(old, os.path.join(basedir, "octoprint.backup"))
|
||||
|
||||
sys.path.append(os.path.join(basedir, "src"))
|
||||
sys.path.insert(0, os.path.join(basedir, "src"))
|
||||
|
||||
import octoprint
|
||||
octoprint.main()
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
VERSION = open("VERSION").read().strip()
|
||||
VERSION = "1.0.0"
|
||||
|
||||
def params():
|
||||
name = "OctoPrint"
|
||||
|
||||
@@ -3,8 +3,9 @@ import sys
|
||||
from octoprint.daemon import Daemon
|
||||
from octoprint.server import Server
|
||||
|
||||
|
||||
class Main(Daemon):
|
||||
def __init__(self, pidfile, configfile, basedir, host, port, debug):
|
||||
def __init__(self, pidfile, configfile, basedir, host, port, debug, allowRoot):
|
||||
Daemon.__init__(self, pidfile)
|
||||
|
||||
self._configfile = configfile
|
||||
@@ -12,9 +13,10 @@ class Main(Daemon):
|
||||
self._host = host
|
||||
self._port = port
|
||||
self._debug = debug
|
||||
self._allowRoot = allowRoot
|
||||
|
||||
def run(self):
|
||||
octoprint = Server(self._configfile, self._basedir, self._host, self._port, self._debug)
|
||||
octoprint = Server(self._configfile, self._basedir, self._host, self._port, self._debug, self._allowRoot)
|
||||
octoprint.run()
|
||||
|
||||
def main():
|
||||
@@ -50,7 +52,7 @@ def main():
|
||||
print >> sys.stderr, "Sorry, daemon mode is only supported under Linux right now"
|
||||
sys.exit(2)
|
||||
|
||||
daemon = Main(args.pidfile, args.config, args.basedir, args.host, args.port, args.debug)
|
||||
daemon = Main(args.pidfile, args.config, args.basedir, args.host, args.port, args.debug, args.allowRoot)
|
||||
if "start" == args.daemon:
|
||||
daemon.start()
|
||||
elif "stop" == args.daemon:
|
||||
|
||||
@@ -14,6 +14,7 @@ import octoprint.util.gcodeInterpreter as gcodeInterpreter
|
||||
|
||||
from octoprint.settings import settings
|
||||
from octoprint.events import eventManager
|
||||
from octoprint.filemanager.destinations import FileDestinations
|
||||
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
@@ -195,6 +196,7 @@ class GcodeManager:
|
||||
self.processStl(absolutePath, destination, uploadCallback)
|
||||
return filename, False
|
||||
|
||||
|
||||
def getFutureFileName(self, file):
|
||||
if not file:
|
||||
return None
|
||||
@@ -205,6 +207,7 @@ class GcodeManager:
|
||||
|
||||
return self._getBasicFilename(absolutePath)
|
||||
|
||||
|
||||
def processStl(self, absolutePath, destination, uploadCallback=None):
|
||||
from octoprint.slicers.cura import CuraFactory
|
||||
|
||||
@@ -227,6 +230,7 @@ class GcodeManager:
|
||||
eventManager().fire("SlicingStarted", {"stl": self._getBasicFilename(absolutePath), "gcode": self._getBasicFilename(gcodePath)})
|
||||
cura.process_file(config, gcodePath, absolutePath, stlProcessed, [absolutePath, gcodePath])
|
||||
|
||||
|
||||
def processGcode(self, absolutePath, destination, uploadCallback=None):
|
||||
if absolutePath is None:
|
||||
return None
|
||||
@@ -243,7 +247,7 @@ class GcodeManager:
|
||||
|
||||
if uploadCallback is not None:
|
||||
uploadCallback(filename, absolutePath, destination)
|
||||
return filename
|
||||
return filename
|
||||
|
||||
def getFutureFilename(self, file):
|
||||
if not file:
|
||||
@@ -482,8 +486,6 @@ class MetadataAnalyzer:
|
||||
def _work(self):
|
||||
aborted = None
|
||||
while True:
|
||||
self._active.wait()
|
||||
|
||||
if aborted is not None:
|
||||
filename = aborted
|
||||
aborted = None
|
||||
@@ -492,6 +494,8 @@ class MetadataAnalyzer:
|
||||
(priority, filename) = self._queue.get()
|
||||
self._logger.debug("Processing file %s from queue (priority %d)" % (filename, priority))
|
||||
|
||||
self._active.wait()
|
||||
|
||||
try:
|
||||
self._analyzeGcode(filename)
|
||||
self._queue.task_done()
|
||||
|
||||
@@ -9,6 +9,8 @@ import copy
|
||||
import os
|
||||
import logging
|
||||
|
||||
#import logging, logging.config
|
||||
|
||||
import octoprint.util.comm as comm
|
||||
import octoprint.util as util
|
||||
|
||||
@@ -457,7 +459,7 @@ class Printer():
|
||||
self._setProgressData(0.0, 0, 0, None)
|
||||
self._stateMonitor.setState({"state": self._state, "stateString": self.getStateString(), "flags": self._getStateFlags()})
|
||||
|
||||
def mcFileTransferDone(self, filename):
|
||||
def mcFileTransferDone(self):
|
||||
self._sdStreaming = False
|
||||
|
||||
if self._streamingFinishedCallback is not None:
|
||||
@@ -558,13 +560,6 @@ class Printer():
|
||||
}
|
||||
}
|
||||
|
||||
def getCurrentConnection(self):
|
||||
if self._comm is None:
|
||||
return "Closed", None, None
|
||||
|
||||
port, baudrate = self._comm.getConnection()
|
||||
return self._comm.getStateString(), port, baudrate
|
||||
|
||||
def isClosedOrError(self):
|
||||
return self._comm is None or self._comm.isClosedOrError()
|
||||
|
||||
|
||||
@@ -2,255 +2,148 @@
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
|
||||
from flask import request, jsonify, make_response
|
||||
from flask import request, jsonify
|
||||
|
||||
from octoprint.settings import settings, valid_boolean_trues
|
||||
from octoprint.settings import settings
|
||||
from octoprint.printer import getConnectionOptions
|
||||
from octoprint.server import printer, restricted_access, SUCCESS
|
||||
from octoprint.server.ajax import ajax
|
||||
import octoprint.util as util
|
||||
|
||||
|
||||
#~~ Printer control
|
||||
|
||||
|
||||
@ajax.route("/control/connection", methods=["GET"])
|
||||
@ajax.route("/control/connection/options", methods=["GET"])
|
||||
def connectionOptions():
|
||||
state, port, baudrate = printer.getCurrentConnection()
|
||||
current = {
|
||||
"state": state,
|
||||
"port": port,
|
||||
"baudrate": baudrate
|
||||
}
|
||||
return jsonify({"current": current, "options": getConnectionOptions()})
|
||||
return jsonify(getConnectionOptions())
|
||||
|
||||
|
||||
@ajax.route("/control/connection", methods=["POST"])
|
||||
@restricted_access
|
||||
def connectionCommand():
|
||||
valid_commands = {
|
||||
"connect": ["autoconnect"],
|
||||
"disconnect": []
|
||||
}
|
||||
|
||||
command, data, response = util.getJsonCommandFromRequest(request, valid_commands)
|
||||
if response is not None:
|
||||
return response
|
||||
|
||||
if command == "connect":
|
||||
options = getConnectionOptions()
|
||||
|
||||
def connect():
|
||||
if "command" in request.values.keys() and request.values["command"] == "connect":
|
||||
port = None
|
||||
baudrate = None
|
||||
if "port" in data.keys():
|
||||
port = data["port"]
|
||||
if port not in options["ports"]:
|
||||
return make_response("Invalid port: %s" % port, 400)
|
||||
if "baudrate" in data.keys():
|
||||
baudrate = data["baudrate"]
|
||||
if baudrate not in options["baudrates"]:
|
||||
return make_response("Invalid baudrate: %d" % baudrate, 400)
|
||||
if "save" in data.keys() and data["save"]:
|
||||
if "port" in request.values.keys():
|
||||
port = request.values["port"]
|
||||
if "baudrate" in request.values.keys():
|
||||
baudrate = request.values["baudrate"]
|
||||
if "save" in request.values.keys():
|
||||
settings().set(["serial", "port"], port)
|
||||
settings().setInt(["serial", "baudrate"], baudrate)
|
||||
settings().setBoolean(["serial", "autoconnect"], data["autoconnect"])
|
||||
settings().save()
|
||||
settings().save()
|
||||
if "autoconnect" in request.values.keys():
|
||||
settings().setBoolean(["serial", "autoconnect"], True)
|
||||
settings().save()
|
||||
printer.connect(port=port, baudrate=baudrate)
|
||||
elif command == "disconnect":
|
||||
elif "command" in request.values.keys() and request.values["command"] == "disconnect":
|
||||
printer.disconnect()
|
||||
|
||||
return jsonify(SUCCESS)
|
||||
|
||||
|
||||
@ajax.route("/control/printer/command", methods=["POST"])
|
||||
@ajax.route("/control/command", methods=["POST"])
|
||||
@restricted_access
|
||||
def printerCommand():
|
||||
if not printer.isOperational():
|
||||
return make_response("Printer is not operational", 403)
|
||||
if "application/json" in request.headers["Content-Type"]:
|
||||
data = request.json
|
||||
|
||||
if not "application/json" in request.headers["Content-Type"]:
|
||||
return make_response("Expected content type JSON", 400)
|
||||
parameters = {}
|
||||
if "parameters" in data.keys(): parameters = data["parameters"]
|
||||
|
||||
data = request.json
|
||||
commands = []
|
||||
if "command" in data.keys(): commands = [data["command"]]
|
||||
elif "commands" in data.keys(): commands = data["commands"]
|
||||
|
||||
parameters = {}
|
||||
if "parameters" in data.keys(): parameters = data["parameters"]
|
||||
commandsToSend = []
|
||||
for command in commands:
|
||||
commandToSend = command
|
||||
if len(parameters) > 0:
|
||||
commandToSend = command % parameters
|
||||
commandsToSend.append(commandToSend)
|
||||
|
||||
commands = []
|
||||
if "command" in data.keys(): commands = [data["command"]]
|
||||
elif "commands" in data.keys(): commands = data["commands"]
|
||||
|
||||
commandsToSend = []
|
||||
for command in commands:
|
||||
commandToSend = command
|
||||
if len(parameters) > 0:
|
||||
commandToSend = command % parameters
|
||||
commandsToSend.append(commandToSend)
|
||||
|
||||
printer.commands(commandsToSend)
|
||||
printer.commands(commandsToSend)
|
||||
|
||||
return jsonify(SUCCESS)
|
||||
|
||||
|
||||
@ajax.route("/control/job", methods=["POST"])
|
||||
@restricted_access
|
||||
def controlJob():
|
||||
if not printer.isOperational():
|
||||
return make_response("Printer is not operational", 403)
|
||||
|
||||
valid_commands = {
|
||||
"start": [],
|
||||
"pause": [],
|
||||
"cancel": []
|
||||
}
|
||||
|
||||
command, data, response = util.getJsonCommandFromRequest(request, valid_commands)
|
||||
if response is not None:
|
||||
return response
|
||||
|
||||
if command == "start":
|
||||
printer.startPrint()
|
||||
elif command == "pause":
|
||||
printer.togglePausePrint()
|
||||
elif command == "cancel":
|
||||
printer.cancelPrint()
|
||||
def printJobControl():
|
||||
if "command" in request.values.keys():
|
||||
if request.values["command"] == "start":
|
||||
printer.startPrint()
|
||||
elif request.values["command"] == "pause":
|
||||
printer.togglePausePrint()
|
||||
elif request.values["command"] == "cancel":
|
||||
printer.cancelPrint()
|
||||
return jsonify(SUCCESS)
|
||||
|
||||
|
||||
@ajax.route("/control/printer/hotend", methods=["POST"])
|
||||
@ajax.route("/control/temperature", methods=["POST"])
|
||||
@restricted_access
|
||||
def controlPrinterHotend():
|
||||
if not printer.isOperational():
|
||||
return make_response("Printer is not operational", 403)
|
||||
def setTargetTemperature():
|
||||
if "temp" in request.values.keys():
|
||||
# set target temperature
|
||||
temp = request.values["temp"]
|
||||
printer.command("M104 S" + temp)
|
||||
|
||||
valid_commands = {
|
||||
"temp": ["temps"],
|
||||
"offset": ["offsets"]
|
||||
}
|
||||
command, data, response = util.getJsonCommandFromRequest(request, valid_commands)
|
||||
if response is not None:
|
||||
return response
|
||||
if "bedTemp" in request.values.keys():
|
||||
# set target bed temperature
|
||||
bedTemp = request.values["bedTemp"]
|
||||
printer.command("M140 S" + bedTemp)
|
||||
|
||||
valid_targets = ["hotend", "bed"]
|
||||
if "tempOffset" in request.values.keys():
|
||||
# set target temperature offset
|
||||
try:
|
||||
tempOffset = float(request.values["tempOffset"])
|
||||
if tempOffset >= -50 and tempOffset <= 50:
|
||||
printer.setTemperatureOffset(tempOffset, None)
|
||||
except:
|
||||
pass
|
||||
|
||||
##~~ temperature
|
||||
if command == "temp":
|
||||
temps = data["temps"]
|
||||
|
||||
# make sure the targets are valid and the values are numbers
|
||||
validated_values = {}
|
||||
for type, value in temps.iteritems():
|
||||
if not type in valid_targets:
|
||||
return make_response("Invalid target for setting temperature: %s" % type, 400)
|
||||
if not isinstance(value, (int, long, float)):
|
||||
return make_response("Not a number for %s: %r" % (type, value), 400)
|
||||
validated_values[type] = value
|
||||
|
||||
# perform the actual temperature commands
|
||||
# TODO make this a generic method call (printer.setTemperature(type, value)) to get rid of gcode here
|
||||
if "hotend" in validated_values:
|
||||
printer.command("M104 S%f" % validated_values["hotend"])
|
||||
if "bed" in validated_values:
|
||||
printer.command("M140 S%f" % validated_values["bed"])
|
||||
|
||||
##~~ temperature offset
|
||||
elif command == "offset":
|
||||
offsets = data["offsets"]
|
||||
|
||||
# make sure the targets are valid, the values are numbers and in the range [-50, 50]
|
||||
validated_values = {}
|
||||
for type, value in offsets.iteritems():
|
||||
if not type in valid_targets:
|
||||
return make_response("Invalid target for setting temperature: %s" % type, 400)
|
||||
if not isinstance(value, (int, long, float)):
|
||||
return make_response("Not a number for %s: %r" % (type, value), 400)
|
||||
if not -50 <= value <= 50:
|
||||
return make_response("Offset %s not in range [-50, 50]: %f" % (type, value), 400)
|
||||
validated_values[type] = value
|
||||
|
||||
# set the offsets
|
||||
if "hotend" in validated_values and "bed" in validated_values:
|
||||
printer.setTemperatureOffset(validated_values["hotend"], validated_values["bed"])
|
||||
elif "hotend" in validated_values:
|
||||
printer.setTemperatureOffset(validated_values["hotend"], None)
|
||||
elif "bed" in validated_values:
|
||||
printer.setTemperatureOffset(None, validated_values["bed"])
|
||||
if "bedTempOffset" in request.values.keys():
|
||||
# set target bed temperature offset
|
||||
try:
|
||||
bedTempOffset = float(request.values["bedTempOffset"])
|
||||
if bedTempOffset >= -50 and bedTempOffset <= 50:
|
||||
printer.setTemperatureOffset(None, bedTempOffset)
|
||||
except:
|
||||
pass
|
||||
|
||||
return jsonify(SUCCESS)
|
||||
|
||||
|
||||
@ajax.route("/control/printer/printhead", methods=["POST"])
|
||||
@ajax.route("/control/jog", methods=["POST"])
|
||||
@restricted_access
|
||||
def controlPrinterPrinthead():
|
||||
def jog():
|
||||
if not printer.isOperational() or printer.isPrinting():
|
||||
# do not jog when a print job is running or we don't have a connection
|
||||
return make_response("Printer is not operational or currently printing", 403)
|
||||
return jsonify(SUCCESS)
|
||||
|
||||
valid_commands = {
|
||||
"jog": [],
|
||||
"home": ["axes"]
|
||||
}
|
||||
command, data, response = util.getJsonCommandFromRequest(request, valid_commands)
|
||||
if response is not None:
|
||||
return response
|
||||
|
||||
movementSpeed = settings().get(["printerParameters", "movementSpeed", ["x", "y", "z"]], asdict=True)
|
||||
|
||||
valid_axes = ["x", "y", "z"]
|
||||
##~~ jog command
|
||||
if command == "jog":
|
||||
# validate all jog instructions, make sure that the values are numbers
|
||||
validated_values = {}
|
||||
for axis in valid_axes:
|
||||
if axis in data:
|
||||
value = data[axis]
|
||||
if not isinstance(value, (int, long, float)):
|
||||
return make_response("Not a number for axis %s: %r" % (axis, value), 400)
|
||||
validated_values[axis] = value
|
||||
|
||||
# execute the jog commands
|
||||
for axis, value in validated_values.iteritems():
|
||||
# TODO make this a generic method call (printer.jog(axis, value)) to get rid of gcode here
|
||||
printer.commands(["G91", "G1 %s%.4f F%d" % (axis.upper(), value, movementSpeed[axis]), "G90"])
|
||||
|
||||
##~~ home command
|
||||
elif command == "home":
|
||||
validated_values = []
|
||||
axes = data["axes"]
|
||||
for axis in axes:
|
||||
if not axis in valid_axes:
|
||||
return make_response("Invalid axis: %s" % axis, 400)
|
||||
validated_values.append(axis)
|
||||
|
||||
# execute the home command
|
||||
# TODO make this a generic method call (printer.home(axis, ...)) to get rid of gcode here
|
||||
printer.commands(["G91", "G28 %s" % " ".join(map(lambda x: "%s0" % x.upper(), validated_values)), "G90"])
|
||||
|
||||
return jsonify(SUCCESS)
|
||||
|
||||
|
||||
@ajax.route("/control/printer/feeder", methods=["POST"])
|
||||
@restricted_access
|
||||
def controlPrinterFeeder():
|
||||
if not printer.isOperational() or printer.isPrinting():
|
||||
# do not jog when a print job is running or we don't have a connection
|
||||
return make_response("Printer is not operational or currently printing", 403)
|
||||
|
||||
valid_commands = {
|
||||
"extrude": ["amount"]
|
||||
}
|
||||
command, data, response = util.getJsonCommandFromRequest(request, valid_commands)
|
||||
if response is not None:
|
||||
return response
|
||||
|
||||
extrusionSpeed = settings().get(["printerParameters", "movementSpeed", "e"])
|
||||
|
||||
if command == "extrude":
|
||||
amount = data["amount"]
|
||||
if not isinstance(amount, (int, long, float)):
|
||||
return make_response("Not a number for extrusion amount: %r" % amount, 400)
|
||||
|
||||
# TODO make this a generic method call (printer.extruder([hotend,] amount)) to get rid of gcode here
|
||||
printer.commands(["G91", "G1 E%s F%d" % (data["amount"], extrusionSpeed), "G90"])
|
||||
(movementSpeedX, movementSpeedY, movementSpeedZ, movementSpeedE) = settings().get(["printerParameters", "movementSpeed", ["x", "y", "z", "e"]])
|
||||
if "x" in request.values.keys():
|
||||
# jog x
|
||||
x = request.values["x"]
|
||||
printer.commands(["G91", "G1 X%s F%d" % (x, movementSpeedX), "G90"])
|
||||
if "y" in request.values.keys():
|
||||
# jog y
|
||||
y = request.values["y"]
|
||||
printer.commands(["G91", "G1 Y%s F%d" % (y, movementSpeedY), "G90"])
|
||||
if "z" in request.values.keys():
|
||||
# jog z
|
||||
z = request.values["z"]
|
||||
printer.commands(["G91", "G1 Z%s F%d" % (z, movementSpeedZ), "G90"])
|
||||
if "homeXY" in request.values.keys():
|
||||
# home x/y
|
||||
printer.command("G28 X0 Y0")
|
||||
if "homeZ" in request.values.keys():
|
||||
# home z
|
||||
printer.command("G28 Z0")
|
||||
if "extrude" in request.values.keys():
|
||||
# extrude/retract
|
||||
length = request.values["extrude"]
|
||||
printer.commands(["G91", "G1 E%s F%d" % (length, movementSpeedE), "G90"])
|
||||
|
||||
return jsonify(SUCCESS)
|
||||
|
||||
@@ -265,23 +158,16 @@ def getCustomControls():
|
||||
@restricted_access
|
||||
def sdCommand():
|
||||
if not settings().getBoolean(["feature", "sdSupport"]) or not printer.isOperational() or printer.isPrinting():
|
||||
return make_response("SD support is disabled", 403)
|
||||
return jsonify(SUCCESS)
|
||||
|
||||
valid_commands = {
|
||||
"init": [],
|
||||
"refresh": [],
|
||||
"release": []
|
||||
}
|
||||
command, data, response = util.getJsonCommandFromRequest(request, valid_commands)
|
||||
if response is not None:
|
||||
return response
|
||||
|
||||
if command == "init":
|
||||
printer.initSdCard()
|
||||
elif command == "refresh":
|
||||
printer.refreshSdFiles()
|
||||
elif command == "release":
|
||||
printer.releaseSdCard()
|
||||
if "command" in request.values.keys():
|
||||
command = request.values["command"]
|
||||
if command == "init":
|
||||
printer.initSdCard()
|
||||
elif command == "refresh":
|
||||
printer.refreshSdFiles()
|
||||
elif command == "release":
|
||||
printer.releaseSdCard()
|
||||
|
||||
return jsonify(SUCCESS)
|
||||
|
||||
|
||||
@@ -18,38 +18,21 @@ from octoprint.server.ajax import ajax
|
||||
|
||||
@ajax.route("/gcodefiles", methods=["GET"])
|
||||
def readGcodeFiles():
|
||||
files = _getFileList(FileDestinations.LOCAL)
|
||||
files.extend(_getFileList(FileDestinations.SDCARD))
|
||||
files = gcodeManager.getAllFileData()
|
||||
|
||||
sdFileList = printer.getSdFiles()
|
||||
if sdFileList is not None:
|
||||
for sdFile in sdFileList:
|
||||
files.append({
|
||||
"name": sdFile,
|
||||
"size": "n/a",
|
||||
"bytes": 0,
|
||||
"date": "n/a",
|
||||
"origin": "sd"
|
||||
})
|
||||
return jsonify(files=files, free=util.getFormattedSize(util.getFreeBytes(settings().getBaseFolder("uploads"))))
|
||||
|
||||
|
||||
@ajax.route("/gcodefiles/<string:target>", methods=["GET"])
|
||||
def readGcodeFilesForTarget(target):
|
||||
if target not in [FileDestinations.LOCAL, FileDestinations.SDCARD]:
|
||||
return make_response("Invalid target: %s" % target, 400)
|
||||
|
||||
return jsonify(files=_getFileList(target), free=util.getFormattedSize(util.getFreeBytes(settings().getBaseFolder("uploads"))))
|
||||
|
||||
|
||||
def _getFileList(target):
|
||||
if target == FileDestinations.SDCARD:
|
||||
sdFileList = printer.getSdFiles()
|
||||
|
||||
files = []
|
||||
if sdFileList is not None:
|
||||
for sdFile in sdFileList:
|
||||
files.append({
|
||||
"name": sdFile,
|
||||
"size": "n/a",
|
||||
"bytes": 0,
|
||||
"date": "n/a",
|
||||
"origin": FileDestinations.SDCARD
|
||||
})
|
||||
else:
|
||||
files = gcodeManager.getAllFileData()
|
||||
return files
|
||||
|
||||
|
||||
@ajax.route("/gcodefiles/<string:target>", methods=["POST"])
|
||||
@restricted_access
|
||||
def uploadGcodeFile(target):
|
||||
@@ -118,78 +101,52 @@ def uploadGcodeFile(target):
|
||||
return make_response("No gcode_file included", 400)
|
||||
|
||||
|
||||
@ajax.route("/gcodefiles/local/<path:filename>", methods=["GET"])
|
||||
def readGcodeFile(filename):
|
||||
return redirectToTornado(request, url_for("index") + "downloads/gcode/" + filename)
|
||||
|
||||
|
||||
@ajax.route("/gcodefiles/<string:target>/<path:filename>", methods=["POST"])
|
||||
@ajax.route("/gcodefiles/load", methods=["POST"])
|
||||
@restricted_access
|
||||
def gcodeFileCommand(filename, target):
|
||||
if not target in [FileDestinations.LOCAL, FileDestinations.SDCARD]:
|
||||
return make_response("Invalid target: %s" % target, 400)
|
||||
|
||||
# valid file commands, dict mapping command name to mandatory parameters
|
||||
valid_commands = {
|
||||
"load": []
|
||||
}
|
||||
|
||||
command, data, response = util.getJsonCommandFromRequest(request, valid_commands)
|
||||
if response is not None:
|
||||
return response
|
||||
|
||||
if command == "load":
|
||||
# selects/loads a file
|
||||
def loadGcodeFile():
|
||||
if "filename" in request.values.keys():
|
||||
printAfterLoading = False
|
||||
if "print" in data.keys() and data["print"]:
|
||||
if "print" in request.values.keys() and request.values["print"] in valid_boolean_trues:
|
||||
printAfterLoading = True
|
||||
|
||||
sd = False
|
||||
if target == FileDestinations.SDCARD:
|
||||
filenameToSelect = filename
|
||||
if "target" in request.values.keys() and request.values["target"] == "sd":
|
||||
filename = request.values["filename"]
|
||||
sd = True
|
||||
else:
|
||||
filenameToSelect = gcodeManager.getAbsolutePath(filename)
|
||||
printer.selectFile(filenameToSelect, sd, printAfterLoading)
|
||||
return jsonify(SUCCESS)
|
||||
|
||||
return make_response("Command %s is currently not implemented" % command, 400)
|
||||
filename = gcodeManager.getAbsolutePath(request.values["filename"])
|
||||
printer.selectFile(filename, sd, printAfterLoading)
|
||||
return jsonify(SUCCESS)
|
||||
|
||||
|
||||
@ajax.route("/gcodefiles/<string:target>/<path:filename>", methods=["DELETE"])
|
||||
@ajax.route("/gcodefiles/delete", methods=["POST"])
|
||||
@restricted_access
|
||||
def deleteGcodeFile(filename, target):
|
||||
if not target in [FileDestinations.LOCAL, FileDestinations.SDCARD]:
|
||||
return make_response("Invalid target: %s" % target, 400)
|
||||
def deleteGcodeFile():
|
||||
if "filename" in request.values.keys():
|
||||
filename = request.values["filename"]
|
||||
sd = "target" in request.values.keys() and request.values["target"] == "sd"
|
||||
|
||||
sd = target == FileDestinations.SDCARD
|
||||
currentJob = printer.getCurrentJob()
|
||||
currentFilename = None
|
||||
currentSd = None
|
||||
if currentJob is not None and "filename" in currentJob.keys() and "sd" in currentJob.keys():
|
||||
currentFilename = currentJob["filename"]
|
||||
currentSd = currentJob["sd"]
|
||||
|
||||
currentJob = printer.getCurrentJob()
|
||||
currentFilename = None
|
||||
currentSd = None
|
||||
if currentJob is not None and "filename" in currentJob.keys() and "sd" in currentJob.keys():
|
||||
currentFilename = currentJob["filename"]
|
||||
currentSd = currentJob["sd"]
|
||||
if currentFilename is not None and filename == currentFilename and not (printer.isPrinting() or printer.isPaused()):
|
||||
printer.unselectFile()
|
||||
|
||||
if currentFilename is not None and filename == currentFilename and not (printer.isPrinting() or printer.isPaused()):
|
||||
printer.unselectFile()
|
||||
|
||||
if not (currentFilename == filename and currentSd == sd and (printer.isPrinting() or printer.isPaused())):
|
||||
if sd:
|
||||
printer.deleteSdFile(filename)
|
||||
else:
|
||||
gcodeManager.removeFile(filename)
|
||||
if not (currentFilename == filename and currentSd == sd and (printer.isPrinting() or printer.isPaused())):
|
||||
if sd:
|
||||
printer.deleteSdFile(filename)
|
||||
else:
|
||||
gcodeManager.removeFile(filename)
|
||||
return readGcodeFiles()
|
||||
|
||||
|
||||
@ajax.route("/gcodefiles/<string:target>/refresh", methods=["POST"])
|
||||
@ajax.route("/gcodefiles/refresh", methods=["POST"])
|
||||
@restricted_access
|
||||
def refreshFiles(target):
|
||||
if not target in [FileDestinations.LOCAL, FileDestinations.SDCARD]:
|
||||
return make_response("Invalid target: %s" % target, 400)
|
||||
|
||||
if target == FileDestinations.SDCARD:
|
||||
printer.updateSdFiles()
|
||||
|
||||
def refreshFiles():
|
||||
printer.updateSdFiles()
|
||||
return jsonify(SUCCESS)
|
||||
|
||||
@@ -56,6 +56,7 @@ def getSettings():
|
||||
"waitForStart": s.getBoolean(["feature", "waitForStartOnConnect"]),
|
||||
"alwaysSendChecksum": s.getBoolean(["feature", "alwaysSendChecksum"]),
|
||||
"sdSupport": s.getBoolean(["feature", "sdSupport"]),
|
||||
"sdAlwaysAvailable": s.getBoolean(["feature", "sdAlwaysAvailable"]),
|
||||
"swallowOkAfterResend": s.getBoolean(["feature", "swallowOkAfterResend"])
|
||||
},
|
||||
"serial": {
|
||||
@@ -129,6 +130,7 @@ def setSettings():
|
||||
if "waitForStart" in data["feature"].keys(): s.setBoolean(["feature", "waitForStartOnConnect"], data["feature"]["waitForStart"])
|
||||
if "alwaysSendChecksum" in data["feature"].keys(): s.setBoolean(["feature", "alwaysSendChecksum"], data["feature"]["alwaysSendChecksum"])
|
||||
if "sdSupport" in data["feature"].keys(): s.setBoolean(["feature", "sdSupport"], data["feature"]["sdSupport"])
|
||||
if "sdAlwaysAvailable" in data["feature"].keys(): s.setBoolean(["feature", "sdAlwaysAvailable"], data["feature"]["sdAlwaysAvailable"])
|
||||
if "swallowOkAfterResend" in data["feature"].keys(): s.setBoolean(["feature", "swallowOkAfterResend"], data["feature"]["swallowOkAfterResend"])
|
||||
|
||||
if "serial" in data.keys():
|
||||
|
||||
@@ -123,34 +123,3 @@ def changePasswordForUser(username):
|
||||
else:
|
||||
return make_response(("Forbidden", 403, []))
|
||||
|
||||
|
||||
@ajax.route("/users/<username>/apikey", methods=["DELETE"])
|
||||
@restricted_access
|
||||
def deleteApikeyForUser(username):
|
||||
if userManager is None:
|
||||
return jsonify(SUCCESS)
|
||||
|
||||
if current_user is not None and not current_user.is_anonymous() and (current_user.get_name() == username or current_user.is_admin()):
|
||||
try:
|
||||
userManager.deleteApikey(username)
|
||||
except users.UnknownUser:
|
||||
return make_response(("Unknown user: %s" % username, 404, []))
|
||||
return jsonify(SUCCESS)
|
||||
else:
|
||||
return make_response(("Forbidden", 403, []))
|
||||
|
||||
|
||||
@ajax.route("/users/<username>/apikey", methods=["POST"])
|
||||
@restricted_access
|
||||
def generateApikeyForUser(username):
|
||||
if userManager is None:
|
||||
return jsonify(SUCCESS)
|
||||
|
||||
if current_user is not None and not current_user.is_anonymous() and (current_user.get_name() == username or current_user.is_admin()):
|
||||
try:
|
||||
apikey = userManager.generateApiKey(username)
|
||||
except users.UnknownUser:
|
||||
return make_response(("Unknown user: %s" % username, 404, []))
|
||||
return jsonify({"apikey": apikey})
|
||||
else:
|
||||
return make_response(("Forbidden", 403, []))
|
||||
+24
-10
@@ -7,30 +7,36 @@ import logging
|
||||
from flask import Blueprint, request, jsonify, abort
|
||||
|
||||
from octoprint.server import printer, gcodeManager, SUCCESS
|
||||
from octoprint.server.util import api_access
|
||||
from octoprint.settings import valid_boolean_trues
|
||||
from octoprint.settings import settings, valid_boolean_trues
|
||||
from octoprint.filemanager.destinations import FileDestinations
|
||||
import octoprint.gcodefiles as gcodefiles
|
||||
|
||||
api = Blueprint("api", __name__)
|
||||
|
||||
|
||||
|
||||
#-- very simple api routines
|
||||
@api.route("/load", methods=["POST"])
|
||||
@api_access
|
||||
def apiLoad():
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if not settings().get(["api", "enabled"]):
|
||||
abort(401)
|
||||
|
||||
if not "apikey" in request.values.keys():
|
||||
abort(401)
|
||||
|
||||
if request.values["apikey"] != settings().get(["api", "key"]):
|
||||
abort(403)
|
||||
|
||||
if not "file" in request.files.keys():
|
||||
abort(400)
|
||||
|
||||
# Perform an upload
|
||||
f = request.files["file"]
|
||||
if not gcodefiles.isGcodeFileName(f.filename):
|
||||
file = request.files["file"]
|
||||
if not gcodefiles.isGcodeFileName(file.filename):
|
||||
abort(400)
|
||||
|
||||
destination = FileDestinations.LOCAL
|
||||
filename, done = gcodeManager.addFile(f, destination)
|
||||
filename, done = gcodeManager.addFile(file, destination)
|
||||
if filename is None:
|
||||
logger.warn("Upload via API failed")
|
||||
abort(500)
|
||||
@@ -45,11 +51,19 @@ def apiLoad():
|
||||
return jsonify(SUCCESS)
|
||||
|
||||
@api.route("/state", methods=["GET"])
|
||||
@api_access
|
||||
def apiPrinterState():
|
||||
if not settings().get(["api", "enabled"]):
|
||||
abort(401)
|
||||
|
||||
if not "apikey" in request.values.keys():
|
||||
abort(401)
|
||||
|
||||
if request.values["apikey"] != settings().get(["api", "key"]):
|
||||
abort(403)
|
||||
|
||||
currentData = printer.getCurrentData()
|
||||
currentData.update({
|
||||
"temperatures": printer.getCurrentTemperatures()
|
||||
"temperatures": printer.getCurrentTemperatures()
|
||||
})
|
||||
return jsonify(currentData)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from flask.ext.principal import identity_changed, Identity
|
||||
|
||||
from tornado.web import StaticFileHandler, HTTPError
|
||||
from flask import url_for, make_response, request, current_app
|
||||
from flask.ext.login import login_required, login_user
|
||||
from flask import url_for, make_response
|
||||
from flask.ext.login import login_required
|
||||
from werkzeug.utils import redirect
|
||||
from sockjs.tornado import SockJSConnection
|
||||
|
||||
@@ -15,70 +15,32 @@ import threading
|
||||
import logging
|
||||
from functools import wraps
|
||||
|
||||
from octoprint.server import userManager
|
||||
from octoprint.settings import settings
|
||||
import octoprint.timelapse
|
||||
import octoprint.server
|
||||
from octoprint.users import ApiUser
|
||||
|
||||
def restricted_access(func, apiEnabled=True):
|
||||
|
||||
def restricted_access(func):
|
||||
"""
|
||||
If you decorate a view with this, it will ensure that first setup has been
|
||||
done for OctoPrint's Access Control plus that any conditions of the
|
||||
login_required decorator are met. It also allows to login using the masterkey or any
|
||||
of the user's apikeys if API access is enabled globally and for the decorated view.
|
||||
login_required decorator are met.
|
||||
|
||||
If OctoPrint's Access Control has not been setup yet (indicated by the "firstRun"
|
||||
flag from the settings being set to True and the userManager not indicating
|
||||
that it's user database has been customized from default), the decorator
|
||||
will cause a HTTP 403 status code to be returned by the decorated resource.
|
||||
|
||||
If an API key is provided and it matches a known key, the user will be logged in and
|
||||
the view will be called directly. If the provided key doesn't match any known key,
|
||||
a HTTP 403 status code will be returned by the decorated resource.
|
||||
|
||||
Otherwise the result of calling login_required will be returned.
|
||||
"""
|
||||
@wraps(func)
|
||||
def decorated_view(*args, **kwargs):
|
||||
# if OctoPrint hasn't been set up yet, abort
|
||||
if settings().getBoolean(["server", "firstRun"]) and (octoprint.server.userManager is None or not octoprint.server.userManager.hasBeenCustomized()):
|
||||
if settings().getBoolean(["server", "firstRun"]) and (userManager is None or not userManager.hasBeenCustomized()):
|
||||
return make_response("OctoPrint isn't setup yet", 403)
|
||||
|
||||
# if API is globally enabled, enabled for this request and an api key is provided, try to use that
|
||||
if settings().get(["api", "enabled"]) and apiEnabled and "apikey" in request.values.keys():
|
||||
apikey = request.values["apikey"]
|
||||
user = None
|
||||
|
||||
if apikey == settings().get(["api", "key"]):
|
||||
# master key was used
|
||||
user = ApiUser()
|
||||
else:
|
||||
# user key might have been used
|
||||
user = octoprint.server.userManager.findUser(apikey=apikey)
|
||||
|
||||
if user is None:
|
||||
make_response("Invalid API key", 403)
|
||||
if login_user(user, remember=False):
|
||||
identity_changed.send(current_app._get_current_object(), identity=Identity(user.get_id()))
|
||||
return func(*args, **kwargs)
|
||||
|
||||
# call regular login_required decorator
|
||||
return login_required(func)(*args, **kwargs)
|
||||
return decorated_view
|
||||
|
||||
|
||||
def api_access(func):
|
||||
@wraps(func)
|
||||
def decorated_view(*args, **kwargs):
|
||||
if not settings().get(["api", "enabled"]):
|
||||
make_response("API disabled", 401)
|
||||
if not "apikey" in request.values.keys():
|
||||
make_response("No API key provided", 401)
|
||||
if request.values["apikey"] != settings().get(["api", "key"]):
|
||||
make_response("Invalid API key", 403)
|
||||
return func(args, kwargs)
|
||||
return decorated_view
|
||||
|
||||
#~~ Printer state
|
||||
|
||||
|
||||
@@ -324,7 +286,7 @@ class ReverseProxied(object):
|
||||
|
||||
def redirectToTornado(request, target):
|
||||
requestUrl = request.url
|
||||
appBaseUrl = requestUrl[:requestUrl.find(url_for("index") + "/ajax")]
|
||||
appBaseUrl = requestUrl[:requestUrl.find(url_for("ajax.base"))]
|
||||
|
||||
redirectUrl = appBaseUrl + target
|
||||
if "?" in requestUrl:
|
||||
|
||||
@@ -61,6 +61,7 @@ default_settings = {
|
||||
"waitForStartOnConnect": False,
|
||||
"alwaysSendChecksum": False,
|
||||
"sdSupport": True,
|
||||
"sdAlwaysAvailable": False,
|
||||
"swallowOkAfterResend": True
|
||||
},
|
||||
"folder": {
|
||||
@@ -187,7 +188,7 @@ class Settings(object):
|
||||
|
||||
#~~ getter
|
||||
|
||||
def get(self, path, asdict=False):
|
||||
def get(self, path):
|
||||
if len(path) == 0:
|
||||
return None
|
||||
|
||||
@@ -211,28 +212,17 @@ class Settings(object):
|
||||
else:
|
||||
keys = k
|
||||
|
||||
if asdict:
|
||||
results = {}
|
||||
else:
|
||||
results = []
|
||||
results = []
|
||||
for key in keys:
|
||||
if key in config.keys():
|
||||
value = config[key]
|
||||
results.append(config[key])
|
||||
elif key in defaults:
|
||||
value = defaults[key]
|
||||
results.append(defaults[key])
|
||||
else:
|
||||
value = None
|
||||
|
||||
if asdict:
|
||||
results[key] = value
|
||||
else:
|
||||
results.append(value)
|
||||
results.append(None)
|
||||
|
||||
if not isinstance(k, (list, tuple)):
|
||||
if asdict:
|
||||
return results.values().pop()
|
||||
else:
|
||||
return results.pop()
|
||||
return results.pop()
|
||||
else:
|
||||
return results
|
||||
|
||||
|
||||
@@ -19,10 +19,6 @@ function ItemListHelper(listType, supportedSorting, supportedFilters, defaultSor
|
||||
|
||||
//~~ item handling
|
||||
|
||||
self.refresh = function() {
|
||||
self._updateItems();
|
||||
}
|
||||
|
||||
self.updateItems = function(items) {
|
||||
self.allItems = items;
|
||||
self._updateItems();
|
||||
|
||||
@@ -9,7 +9,6 @@ function ConnectionViewModel(loginStateViewModel, settingsViewModel) {
|
||||
self.selectedPort = ko.observable(undefined);
|
||||
self.selectedBaudrate = ko.observable(undefined);
|
||||
self.saveSettings = ko.observable(undefined);
|
||||
self.autoconnect = ko.observable(undefined);
|
||||
|
||||
self.isErrorOrClosed = ko.observable(undefined);
|
||||
self.isOperational = ko.observable(undefined);
|
||||
@@ -30,7 +29,7 @@ function ConnectionViewModel(loginStateViewModel, settingsViewModel) {
|
||||
|
||||
self.requestData = function() {
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "control/connection",
|
||||
url: AJAX_BASEURL + "control/connection/options",
|
||||
method: "GET",
|
||||
dataType: "json",
|
||||
success: function(response) {
|
||||
@@ -40,18 +39,13 @@ function ConnectionViewModel(loginStateViewModel, settingsViewModel) {
|
||||
}
|
||||
|
||||
self.fromResponse = function(response) {
|
||||
var ports = response.options.ports;
|
||||
var baudrates = response.options.baudrates;
|
||||
var portPreference = response.options.portPreference;
|
||||
var baudratePreference = response.options.baudratePreference;
|
||||
self.portOptions(response.ports);
|
||||
self.baudrateOptions(response.baudrates);
|
||||
|
||||
self.portOptions(ports);
|
||||
self.baudrateOptions(baudrates);
|
||||
|
||||
if (!self.selectedPort() && ports && ports.indexOf(portPreference) >= 0)
|
||||
self.selectedPort(portPreference);
|
||||
if (!self.selectedBaudrate() && baudrates && baudrates.indexOf(baudratePreference) >= 0)
|
||||
self.selectedBaudrate(baudratePreference);
|
||||
if (!self.selectedPort() && response.ports && response.ports.indexOf(response.portPreference) >= 0)
|
||||
self.selectedPort(response.portPreference);
|
||||
if (!self.selectedBaudrate() && response.baudrates && response.baudrates.indexOf(response.baudratePreference) >= 0)
|
||||
self.selectedBaudrate(response.baudratePreference);
|
||||
|
||||
self.saveSettings(false);
|
||||
}
|
||||
@@ -92,8 +86,7 @@ function ConnectionViewModel(loginStateViewModel, settingsViewModel) {
|
||||
var data = {
|
||||
"command": "connect",
|
||||
"port": self.selectedPort(),
|
||||
"baudrate": self.selectedBaudrate(),
|
||||
"autoconnect": self.settings.serial_autoconnect()
|
||||
"baudrate": self.selectedBaudrate()
|
||||
};
|
||||
|
||||
if (self.saveSettings())
|
||||
@@ -103,20 +96,19 @@ function ConnectionViewModel(loginStateViewModel, settingsViewModel) {
|
||||
url: AJAX_BASEURL + "control/connection",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
data: JSON.stringify(data),
|
||||
success: function(response) {
|
||||
self.settings.requestData()
|
||||
}
|
||||
});
|
||||
data: data
|
||||
})
|
||||
|
||||
self.settings.serial_port(self.selectedPort())
|
||||
self.settings.serial_baudrate(self.selectedBaudrate())
|
||||
self.settings.saveData();
|
||||
} else {
|
||||
self.requestData();
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "control/connection",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
data: JSON.stringify({"command": "disconnect"})
|
||||
data: {"command": "disconnect"}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,37 +80,26 @@ function ControlViewModel(loginStateViewModel, settingsViewModel) {
|
||||
self.sendJogCommand = function(axis, multiplier, distance) {
|
||||
if (typeof distance === "undefined")
|
||||
distance = $('#jog_distance button.active').data('distance');
|
||||
|
||||
if (self.settings.getPrinterInvertAxis(axis)) {
|
||||
multiplier *= -1;
|
||||
}
|
||||
|
||||
var data = {
|
||||
"command": "jog"
|
||||
}
|
||||
data[axis] = distance * multiplier;
|
||||
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "control/printer/printhead",
|
||||
url: AJAX_BASEURL + "control/jog",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
data: JSON.stringify(data)
|
||||
});
|
||||
data: axis + "=" + ( distance * multiplier )
|
||||
})
|
||||
}
|
||||
|
||||
self.sendHomeCommand = function(axis) {
|
||||
var data = {
|
||||
"command": "home",
|
||||
"axes": axis
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "control/printer/printhead",
|
||||
url: AJAX_BASEURL + "control/jog",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
data: JSON.stringify(data)
|
||||
});
|
||||
data: "home" + axis
|
||||
})
|
||||
}
|
||||
|
||||
self.sendExtrudeCommand = function() {
|
||||
@@ -125,14 +114,12 @@ function ControlViewModel(loginStateViewModel, settingsViewModel) {
|
||||
var length = self.extrusionAmount();
|
||||
if (!length)
|
||||
length = 5;
|
||||
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "control/printer/feeder",
|
||||
url: AJAX_BASEURL + "control/jog",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
data: JSON.stringify({command: "extrude", amount: (dir * length)})
|
||||
});
|
||||
data: "extrude=" + (dir * length)
|
||||
})
|
||||
}
|
||||
|
||||
self.sendCustomCommand = function(command) {
|
||||
@@ -156,11 +143,11 @@ function ControlViewModel(loginStateViewModel, settingsViewModel) {
|
||||
}
|
||||
}
|
||||
|
||||
if (data === undefined)
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "control/printer/command",
|
||||
url: AJAX_BASEURL + "control/command",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
|
||||
@@ -43,10 +43,10 @@ function GcodeFilesViewModel(printerStateViewModel, loginStateViewModel) {
|
||||
return !(file["prints"] && file["prints"]["success"] && file["prints"]["success"] > 0);
|
||||
},
|
||||
"sd": function(file) {
|
||||
return file["origin"] && file["origin"] == "sdcard";
|
||||
return file["origin"] && file["origin"] == "sd";
|
||||
},
|
||||
"local": function(file) {
|
||||
return !(file["origin"] && file["origin"] == "sdcard");
|
||||
return !(file["origin"] && file["origin"] == "sd");
|
||||
}
|
||||
},
|
||||
"name",
|
||||
@@ -127,19 +127,11 @@ function GcodeFilesViewModel(printerStateViewModel, loginStateViewModel) {
|
||||
var file = self.listHelper.getItem(function(item) {return item.name == filename});
|
||||
if (!file) return;
|
||||
|
||||
var origin;
|
||||
if (file.origin === undefined) {
|
||||
origin = "local";
|
||||
} else {
|
||||
origin = file.origin;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "gcodefiles/" + origin + "/" + filename,
|
||||
url: AJAX_BASEURL + "gcodefiles/load",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
data: JSON.stringify({command: "load", print: printAfterLoad})
|
||||
data: {filename: filename, print: printAfterLoad, target: file.origin}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -147,16 +139,11 @@ function GcodeFilesViewModel(printerStateViewModel, loginStateViewModel) {
|
||||
var file = self.listHelper.getItem(function(item) {return item.name == filename});
|
||||
if (!file) return;
|
||||
|
||||
var origin;
|
||||
if (file.origin === undefined) {
|
||||
origin = "local";
|
||||
} else {
|
||||
origin = file.origin;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "gcodefiles/" + origin + "/" + filename,
|
||||
type: "DELETE",
|
||||
url: AJAX_BASEURL + "gcodefiles/delete",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: {filename: filename, target: file.origin},
|
||||
success: self.fromResponse
|
||||
})
|
||||
}
|
||||
|
||||
@@ -147,8 +147,7 @@ function PrinterStateViewModel(loginStateViewModel) {
|
||||
url: AJAX_BASEURL + "control/job",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
data: JSON.stringify({command: command})
|
||||
data: {command: command}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ function SettingsViewModel(loginStateViewModel, usersViewModel) {
|
||||
self.feature_waitForStart = ko.observable(undefined);
|
||||
self.feature_alwaysSendChecksum = ko.observable(undefined);
|
||||
self.feature_sdSupport = ko.observable(undefined);
|
||||
self.feature_sdAlwaysAvailable = ko.observable(undefined);
|
||||
self.feature_swallowOkAfterResend = ko.observable(undefined);
|
||||
|
||||
self.serial_port = ko.observable();
|
||||
@@ -135,6 +136,7 @@ function SettingsViewModel(loginStateViewModel, usersViewModel) {
|
||||
self.feature_waitForStart(response.feature.waitForStart);
|
||||
self.feature_alwaysSendChecksum(response.feature.alwaysSendChecksum);
|
||||
self.feature_sdSupport(response.feature.sdSupport);
|
||||
self.feature_sdAlwaysAvailable(response.feature.sdAlwaysAvailable);
|
||||
self.feature_swallowOkAfterResend(response.feature.swallowOkAfterResend);
|
||||
|
||||
self.serial_port(response.serial.port);
|
||||
@@ -195,6 +197,7 @@ function SettingsViewModel(loginStateViewModel, usersViewModel) {
|
||||
"waitForStart": self.feature_waitForStart(),
|
||||
"alwaysSendChecksum": self.feature_alwaysSendChecksum(),
|
||||
"sdSupport": self.feature_sdSupport(),
|
||||
"sdAlwaysAvailable": self.feature_sdAlwaysAvailable(),
|
||||
"swallowOkAfterResend": self.feature_swallowOkAfterResend()
|
||||
},
|
||||
"serial": {
|
||||
|
||||
@@ -167,64 +167,47 @@ function TemperatureViewModel(loginStateViewModel, settingsViewModel) {
|
||||
self.setTempFromProfile = function(profile) {
|
||||
if (!profile)
|
||||
return;
|
||||
self._sendHotendCommand("temp", "hotend", profile.extruder);
|
||||
self._updateTemperature(profile.extruder, "temp");
|
||||
}
|
||||
|
||||
self.setTemp = function() {
|
||||
self._sendHotendCommand("temp", "hotend", self.newTemp(), function() {self.targetTemp(self.newTemp()); self.newTemp("");});
|
||||
self._updateTemperature(self.newTemp(), "temp", function(){self.targetTemp(self.newTemp()); self.newTemp("");});
|
||||
};
|
||||
|
||||
self.setTempToZero = function() {
|
||||
self._sendHotendCommand("temp", "hotend", 0, function() {self.targetTemp(0); self.newTemp("");});
|
||||
self._updateTemperature(0, "temp", function(){self.targetTemp(0); self.newTemp("");});
|
||||
}
|
||||
|
||||
self.setTempOffset = function() {
|
||||
self._sendHotendCommand("offset", "hotend", self.newTempOffset(), function() {self.tempOffset(self.newTempOffset()); self.newTempOffset("");});
|
||||
self._updateTemperature(self.newTempOffset(), "tempOffset", function() {self.tempOffset(self.newTempOffset()); self.newTempOffset("");});
|
||||
}
|
||||
|
||||
self.setBedTempFromProfile = function(profile) {
|
||||
if (!profile)
|
||||
return;
|
||||
self._sendHotendCommand("temp", "bed", profile.bed);
|
||||
self._updateTemperature(profile.bed, "bedTemp");
|
||||
}
|
||||
|
||||
self.setBedTemp = function() {
|
||||
self._sendHotendCommand("temp", "bed", self.newBedTemp(), function() {self.bedTargetTemp(self.newBedTemp()); self.newBedTemp("");});
|
||||
self._updateTemperature(self.newBedTemp(), "bedTemp", function() {self.bedTargetTemp(self.newBedTemp()); self.newBedTemp("");});
|
||||
};
|
||||
|
||||
self.setBedTempToZero = function() {
|
||||
self._sendHotendCommand("temp", "bed", 0, function() {self.bedTargetTemp(0); self.newBedTemp("");});
|
||||
self._updateTemperature(0, "bedTemp", function() {self.bedTargetTemp(0); self.newBedTemp("");});
|
||||
}
|
||||
|
||||
self.setBedTempOffset = function() {
|
||||
self._sendHotendCommand("offset", "bed", self.newBedTempOffset(), function() {self.bedTempOffset(self.newBedTempOffset()); self.newBedTempOffset("");});
|
||||
self._updateTemperature(self.newBedTempOffset(), "bedTempOffset", function() {self.bedTempOffset(self.newBedTempOffset()); self.newBedTempOffset("");});
|
||||
}
|
||||
|
||||
self._sendHotendCommand = function(command, type, temp, callback) {
|
||||
var group;
|
||||
if ("temp" == command) {
|
||||
group = "temps";
|
||||
} else if ("offset" == command) {
|
||||
group = "offsets";
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
var data = {
|
||||
"command": command
|
||||
};
|
||||
data[group] = {};
|
||||
data[group][type] = parseInt(temp);
|
||||
self._updateTemperature = function(temp, type, callback) {
|
||||
var data = {};
|
||||
data[type] = temp;
|
||||
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "control/printer/hotend",
|
||||
url: AJAX_BASEURL + "control/temperature",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
data: JSON.stringify(data),
|
||||
data: data,
|
||||
success: function() { if (callback !== undefined) callback(); }
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
self.handleEnter = function(event, type) {
|
||||
|
||||
@@ -89,17 +89,18 @@ function TerminalViewModel(loginStateViewModel, settingsViewModel) {
|
||||
}
|
||||
|
||||
self.sendCommand = function() {
|
||||
/*
|
||||
var re = /^([gm][0-9]+)(\s.*)?/;
|
||||
var commandMatch = command.match(re);
|
||||
if (commandMatch != null) {
|
||||
command = commandMatch[1].toUpperCase() + ((commandMatch[2] !== undefined) ? commandMatch[2] : "");
|
||||
}
|
||||
*/
|
||||
|
||||
var command = self.command();
|
||||
|
||||
var re = /^([gm][0-9]+)(\s.*)?/;
|
||||
var commandMatch = command.match(re);
|
||||
if (commandMatch != null) {
|
||||
command = commandMatch[1].toUpperCase() + ((commandMatch[2] !== undefined) ? commandMatch[2] : "");
|
||||
}
|
||||
|
||||
if (command) {
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "control/printer/command",
|
||||
url: AJAX_BASEURL + "control/command",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
|
||||
@@ -28,7 +28,6 @@ function UsersViewModel(loginStateViewModel) {
|
||||
self.editorUsername = ko.observable(undefined);
|
||||
self.editorPassword = ko.observable(undefined);
|
||||
self.editorRepeatedPassword = ko.observable(undefined);
|
||||
self.editorApikey = ko.observable(undefined);
|
||||
self.editorAdmin = ko.observable(undefined);
|
||||
self.editorActive = ko.observable(undefined);
|
||||
|
||||
@@ -37,12 +36,10 @@ function UsersViewModel(loginStateViewModel) {
|
||||
self.editorUsername(undefined);
|
||||
self.editorAdmin(undefined);
|
||||
self.editorActive(undefined);
|
||||
self.editorApikey(undefined);
|
||||
} else {
|
||||
self.editorUsername(newValue.name);
|
||||
self.editorAdmin(newValue.admin);
|
||||
self.editorActive(newValue.active);
|
||||
self.editorApikey(newValue.apikey);
|
||||
}
|
||||
self.editorPassword(undefined);
|
||||
self.editorRepeatedPassword(undefined);
|
||||
@@ -125,27 +122,6 @@ function UsersViewModel(loginStateViewModel) {
|
||||
});
|
||||
}
|
||||
|
||||
self.confirmGenerateApikey = function() {
|
||||
if (!CONFIG_ACCESS_CONTROL) return;
|
||||
|
||||
self.generateApikey(self.currentUser().name, function(response) {
|
||||
self._updateApikey(response.apikey);
|
||||
})
|
||||
}
|
||||
|
||||
self.confirmDeleteApikey = function() {
|
||||
if (!CONFIG_ACCESS_CONTROL) return;
|
||||
|
||||
self.deleteApikey(self.currentUser().name, function() {
|
||||
self._updateApikey(undefined);
|
||||
})
|
||||
}
|
||||
|
||||
self._updateApikey = function(apikey) {
|
||||
self.editorApikey(apikey);
|
||||
self.requestData();
|
||||
}
|
||||
|
||||
//~~ AJAX calls
|
||||
|
||||
self.addUser = function(user, callback) {
|
||||
@@ -211,24 +187,4 @@ function UsersViewModel(loginStateViewModel) {
|
||||
success: callback
|
||||
});
|
||||
}
|
||||
|
||||
self.generateApikey = function(username, callback) {
|
||||
if (!CONFIG_ACCESS_CONTROL) return;
|
||||
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "users/" + username + "/apikey",
|
||||
type: "POST",
|
||||
success: callback
|
||||
});
|
||||
}
|
||||
|
||||
self.deleteApikey = function(username, callback) {
|
||||
if (!CONFIG_ACCESS_CONTROL) return;
|
||||
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "users/" + username + "/apikey",
|
||||
type: "DELETE",
|
||||
success: callback
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -210,18 +210,18 @@
|
||||
<span class="btn btn-primary fileinput-button span6" data-bind="css: {disabled: !$root.loginState.isUser()}" style="margin-bottom: 10px">
|
||||
<i class="icon-upload-alt icon-white"></i>
|
||||
<span>Upload</span>
|
||||
<input id="gcode_upload" type="file" name="gcode_file" class="fileinput-button" data-bind="enable: loginState.isUser()">
|
||||
<input id="gcode_upload" type="file" name="gcode_file" class="fileinput-button" data-url="/ajax/gcodefiles/upload" data-bind="enable: loginState.isUser()">
|
||||
</span>
|
||||
<span class="btn btn-primary fileinput-button span6" data-bind="css: {disabled: !$root.loginState.isUser() || !$root.isSdReady()}" style="margin-bottom: 10px">
|
||||
<i class="icon-upload-alt icon-white"></i>
|
||||
<span>Upload to SD</span>
|
||||
<input id="gcode_upload_sd" type="file" name="gcode_file" class="fileinput-button" data-bind="enable: loginState.isUser() && isSdReady()">
|
||||
<input id="gcode_upload_sd" type="file" name="gcode_file" class="fileinput-button" data-url="/ajax/gcodefiles/upload" data-bind="enable: loginState.isUser() && isSdReady()">
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="btn btn-primary fileinput-button span12" data-bind="css: {disabled: !$root.loginState.isUser()}" style="margin-bottom: 10px">
|
||||
<i class="icon-upload-alt icon-white"></i>
|
||||
<span>Upload</span>
|
||||
<input id="gcode_upload" type="file" name="gcode_file" class="fileinput-button" data-bind="enable: loginState.isUser()">
|
||||
<input id="gcode_upload" type="file" name="gcode_file" class="fileinput-button" data-url="/ajax/gcodefiles/upload" data-bind="enable: loginState.isUser()">
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
@@ -352,7 +352,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn box pull-left" data-bind="enable: isOperational() && !isPrinting() && loginState.isUser(), click: function() { $root.sendJogCommand('x',-1) }"><i class="icon-arrow-left"></i></button>
|
||||
<button class="btn box pull-left" data-bind="enable: isOperational() && !isPrinting() && loginState.isUser(), click: function() { $root.sendHomeCommand(['x', 'y']) }"><i class="icon-home"></i></button>
|
||||
<button class="btn box pull-left" data-bind="enable: isOperational() && !isPrinting() && loginState.isUser(), click: function() { $root.sendHomeCommand('XY') }"><i class="icon-home"></i></button>
|
||||
<button class="btn box pull-left" data-bind="enable: isOperational() && !isPrinting() && loginState.isUser(), click: function() { $root.sendJogCommand('x',1) }"><i class="icon-arrow-right"></i></button>
|
||||
</div>
|
||||
<div>
|
||||
@@ -366,7 +366,7 @@
|
||||
<button class="btn box" data-bind="enable: isOperational() && !isPrinting() && loginState.isUser(), click: function() { $root.sendJogCommand('z',1) }"><i class="icon-arrow-up"></i></button>
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn box" data-bind="enable: isOperational() && !isPrinting() && loginState.isUser(), click: function() { $root.sendHomeCommand(['z']) }"><i class="icon-home"></i></button>
|
||||
<button class="btn box" data-bind="enable: isOperational() && !isPrinting() && loginState.isUser(), click: function() { $root.sendHomeCommand('Z') }"><i class="icon-home"></i></button>
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn box" data-bind="enable: isOperational() && !isPrinting() && loginState.isUser(), click: function() { $root.sendJogCommand('z',-1) }"><i class="icon-arrow-down"></i></button>
|
||||
|
||||
@@ -204,6 +204,13 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: feature_sdAlwaysAvailable" id="settings-featureSdAlwaysAvailable"> Always assume SD card is present <span class="label">Repetier</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
@@ -382,7 +389,7 @@
|
||||
</thead>
|
||||
<tbody data-bind="foreach: users.listHelper.paginatedItems">
|
||||
<tr>
|
||||
<td class="settings_users_name"><span data-bind="text: name"></span><span class="muted" data-bind="visible: $root.api_enabled() && apikey"><br /><small>Apikey: <span data-bind="text: apikey"></span></small></span></td>
|
||||
<td class="settings_users_name" data-bind="text: name"></td>
|
||||
<td class="settings_users_active"><i data-bind="css: { 'icon-check': active, 'icon-check-empty': !active }"></i></td>
|
||||
<td class="settings_users_admin"><i data-bind="css: { 'icon-check': admin, 'icon-check-empty': !admin }"></i></td>
|
||||
<td class="settings_users_actions" class="system_users_action">
|
||||
@@ -504,20 +511,6 @@
|
||||
<span class="help-inline" data-bind="visible: $root.users.editorPasswordMismatch()">Passwords do not match</span>
|
||||
</div>
|
||||
</div>
|
||||
<fieldset data-bind="visible: api_enabled">
|
||||
<legend>Apikey</legend>
|
||||
<div class="control-group">
|
||||
<label class="control-label">Current Apikey</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="text" class="input-block-level uneditable-input" data-bind="value: $root.users.editorApikey, attr: {placeholder: 'N/A'}">
|
||||
<a class="btn" title="Generate new Apikey" data-bind="click: function() { $root.users.confirmGenerateApikey(); }"><i class="icon-refresh"></i></a>
|
||||
<a class="btn btn-danger" title="Delete Apikey" data-bind="click: function() { $root.users.confirmDeleteApikey(); }"><i class="icon-trash"></i></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
@@ -525,7 +518,6 @@
|
||||
<button class="btn btn-primary" data-bind="click: function() { $root.users.confirmChangePassword(); }, enable: !$root.users.editorPasswordMismatch()">Confirm</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
+12
-51
@@ -7,7 +7,6 @@ from flask.ext.principal import Identity
|
||||
import hashlib
|
||||
import os
|
||||
import yaml
|
||||
import uuid
|
||||
|
||||
from octoprint.settings import settings
|
||||
|
||||
@@ -71,10 +70,7 @@ class FilebasedUserManager(UserManager):
|
||||
data = yaml.safe_load(f)
|
||||
for name in data.keys():
|
||||
attributes = data[name]
|
||||
apikey = None
|
||||
if "apikey" in attributes:
|
||||
apikey = attributes["apikey"]
|
||||
self._users[name] = User(name, attributes["password"], attributes["active"], attributes["roles"], apikey)
|
||||
self._users[name] = User(name, attributes["password"], attributes["active"], attributes["roles"])
|
||||
else:
|
||||
self._customized = False
|
||||
|
||||
@@ -88,8 +84,7 @@ class FilebasedUserManager(UserManager):
|
||||
data[name] = {
|
||||
"password": user._passwordHash,
|
||||
"active": user._active,
|
||||
"roles": user._roles,
|
||||
"apikey": user._apikey
|
||||
"roles": user._roles
|
||||
}
|
||||
|
||||
with open(self._userfile, "wb") as f:
|
||||
@@ -97,11 +92,11 @@ class FilebasedUserManager(UserManager):
|
||||
self._dirty = False
|
||||
self._load()
|
||||
|
||||
def addUser(self, username, password, active=False, roles=["user"], apikey=None):
|
||||
def addUser(self, username, password, active=False, roles=["user"]):
|
||||
if username in self._users.keys():
|
||||
raise UserAlreadyExists(username)
|
||||
|
||||
self._users[username] = User(username, UserManager.createPasswordHash(password), active, roles, apikey)
|
||||
self._users[username] = User(username, UserManager.createPasswordHash(password), active, roles)
|
||||
self._dirty = True
|
||||
self._save()
|
||||
|
||||
@@ -159,25 +154,6 @@ class FilebasedUserManager(UserManager):
|
||||
self._dirty = True
|
||||
self._save()
|
||||
|
||||
def generateApiKey(self, username):
|
||||
if not username in self._users.keys():
|
||||
raise UnknownUser(username)
|
||||
|
||||
user = self._users[username]
|
||||
user._apikey = ''.join('%02X' % ord(z) for z in uuid.uuid4().bytes)
|
||||
self._dirty = True
|
||||
self._save()
|
||||
return user._apikey
|
||||
|
||||
def deleteApikey(self, username):
|
||||
if not username in self._users.keys():
|
||||
raise UnknownUser(username)
|
||||
|
||||
user = self._users[username]
|
||||
user._apikey = None
|
||||
self._dirty = True
|
||||
self._save()
|
||||
|
||||
def removeUser(self, username):
|
||||
if not username in self._users.keys():
|
||||
raise UnknownUser(username)
|
||||
@@ -186,20 +162,15 @@ class FilebasedUserManager(UserManager):
|
||||
self._dirty = True
|
||||
self._save()
|
||||
|
||||
def findUser(self, username=None, apikey=None):
|
||||
if username is not None:
|
||||
if username not in self._users.keys():
|
||||
return None
|
||||
def findUser(self, username=None):
|
||||
if username is None:
|
||||
return None
|
||||
|
||||
return self._users[username]
|
||||
elif apikey is not None:
|
||||
for user in self._users.values():
|
||||
if apikey == user._apikey:
|
||||
return user
|
||||
return None
|
||||
else:
|
||||
if username not in self._users.keys():
|
||||
return None
|
||||
|
||||
return self._users[username]
|
||||
|
||||
def getAllUsers(self):
|
||||
return map(lambda x: x.asDict(), self._users.values())
|
||||
|
||||
@@ -223,20 +194,18 @@ class UnknownRole(Exception):
|
||||
##~~ User object
|
||||
|
||||
class User(UserMixin):
|
||||
def __init__(self, username, passwordHash, active, roles, apikey=None):
|
||||
def __init__(self, username, passwordHash, active, roles):
|
||||
self._username = username
|
||||
self._passwordHash = passwordHash
|
||||
self._active = active
|
||||
self._roles = roles
|
||||
self._apikey = apikey
|
||||
|
||||
def asDict(self):
|
||||
return {
|
||||
"name": self._username,
|
||||
"active": self.is_active(),
|
||||
"admin": self.is_admin(),
|
||||
"user": self.is_user(),
|
||||
"apikey": self._apikey
|
||||
"user": self.is_user()
|
||||
}
|
||||
|
||||
def check_password(self, passwordHash):
|
||||
@@ -272,11 +241,3 @@ class DummyIdentity(Identity):
|
||||
|
||||
def dummy_identity_loader():
|
||||
return DummyIdentity()
|
||||
|
||||
|
||||
##~~ Apiuser object to use when api key is used to access the API
|
||||
|
||||
|
||||
class ApiUser(User):
|
||||
def __init__(self):
|
||||
User.__init__(self, "api", "", True, UserManager.valid_roles)
|
||||
@@ -191,6 +191,24 @@ def silentRemove(file):
|
||||
pass
|
||||
|
||||
|
||||
def sanitizeAscii(line):
|
||||
return unicode(line, 'ascii', 'replace').encode('ascii', 'replace').rstrip()
|
||||
|
||||
|
||||
def filterNonAscii(line):
|
||||
"""
|
||||
Returns True if the line contains non-ascii characters, false otherwise
|
||||
|
||||
@param line the line to test
|
||||
"""
|
||||
|
||||
try:
|
||||
unicode(line, 'ascii').encode('ascii')
|
||||
return False
|
||||
except ValueError:
|
||||
return True
|
||||
|
||||
|
||||
def getJsonCommandFromRequest(request, valid_commands):
|
||||
if not "application/json" in request.headers["Content-Type"]:
|
||||
return None, None, make_response("Expected content-type JSON", 400)
|
||||
|
||||
+58
-33
@@ -20,7 +20,7 @@ from octoprint.util.avr_isp import ispBase
|
||||
from octoprint.settings import settings
|
||||
from octoprint.events import eventManager
|
||||
from octoprint.gcodefiles import isGcodeFileName
|
||||
from octoprint.util import getExceptionString, getNewTimeout
|
||||
from octoprint.util import getExceptionString, getNewTimeout, sanitizeAscii, filterNonAscii
|
||||
from octoprint.util.virtual import VirtualPrinter
|
||||
|
||||
try:
|
||||
@@ -150,6 +150,18 @@ class MachineCom(object):
|
||||
# print job
|
||||
self._currentFile = None
|
||||
|
||||
# regexes
|
||||
floatPattern = "[-+]?[0-9]*\.?[0-9]+"
|
||||
intPattern = "[0-9]+"
|
||||
self._regex_command = re.compile("^\s*([GM]\d+)")
|
||||
self._regex_float = re.compile(floatPattern)
|
||||
self._regex_paramZFloat = re.compile("Z(%s)" % floatPattern)
|
||||
self._regex_paramSInt = re.compile("S(%s)" % intPattern)
|
||||
self._regex_paramNInt = re.compile("N(%s)" % intPattern)
|
||||
self._regex_minMaxError = re.compile("Error:[0-9]\n")
|
||||
self._regex_sdPrintingByte = re.compile("([0-9]*)/([0-9]*)")
|
||||
self._regex_sdFileOpened = re.compile("File opened:\s*(.*?)\s+Size:\s*([0-9]*)")
|
||||
|
||||
def __del__(self):
|
||||
self.close()
|
||||
|
||||
@@ -291,9 +303,6 @@ class MachineCom(object):
|
||||
def getOffsets(self):
|
||||
return (self._tempOffset, self._bedTempOffset)
|
||||
|
||||
def getConnection(self):
|
||||
return self._port, self._baudrate
|
||||
|
||||
##~~ external interface
|
||||
|
||||
def close(self, isError = False):
|
||||
@@ -333,14 +342,14 @@ class MachineCom(object):
|
||||
|
||||
if self._currentFile is None:
|
||||
raise ValueError("No file selected for printing")
|
||||
|
||||
wasPaused = self.isPaused()
|
||||
self._printSection = "CUSTOM"
|
||||
self._changeState(self.STATE_PRINTING)
|
||||
eventManager().fire("PrintStarted", self._currentFile.getFilename())
|
||||
|
||||
try:
|
||||
self._currentFile.start()
|
||||
|
||||
self._changeState(self.STATE_PRINTING)
|
||||
eventManager().fire("PrintStarted", self._currentFile.getFilename())
|
||||
|
||||
if self.isSdFileSelected():
|
||||
if wasPaused:
|
||||
self.sendCommand("M26 S0")
|
||||
@@ -454,6 +463,10 @@ class MachineCom(object):
|
||||
if not self.isOperational():
|
||||
return
|
||||
self.sendCommand("M21")
|
||||
if settings().getBoolean(["feature", "sdAlwaysAvailable"]):
|
||||
self._sdAvailable = True
|
||||
self.refreshSdFiles()
|
||||
self._callback.mcSdStateChange(self._sdAvailable)
|
||||
|
||||
def releaseSdCard(self):
|
||||
if not self.isOperational() or (self.isBusy() and self.isSdFileSelected()):
|
||||
@@ -504,15 +517,19 @@ class MachineCom(object):
|
||||
##~~ SD file list
|
||||
# if we are currently receiving an sd file list, each line is just a filename, so just read it and abort processing
|
||||
if self._sdFileList and isGcodeFileName(line.strip().lower()) and not 'End file list' in line:
|
||||
self._sdFiles.append(line.strip().lower())
|
||||
filename = line.strip().lower()
|
||||
if filterNonAscii(filename):
|
||||
self._logger.warn("Got a file from printer's SD that has a non-ascii filename (%s), that shouldn't happen according to the protocol" % filename)
|
||||
else:
|
||||
self._sdFiles.append(filename)
|
||||
continue
|
||||
|
||||
##~~ Temperature processing
|
||||
if ' T:' in line or line.startswith('T:'):
|
||||
try:
|
||||
self._temp = float(re.search("-?[0-9\.]*", line.split('T:')[1]).group(0))
|
||||
self._temp = float(self._regex_float.search(line.split('T:')[1]).group(0))
|
||||
if ' B:' in line:
|
||||
self._bedTemp = float(re.search("-?[0-9\.]*", line.split(' B:')[1]).group(0))
|
||||
self._bedTemp = float(self._regex_float.search(line.split(' B:')[1]).group(0))
|
||||
|
||||
self._callback.mcTempUpdate(self._temp, self._bedTemp, self._targetTemp, self._bedTargetTemp)
|
||||
except ValueError:
|
||||
@@ -537,7 +554,7 @@ class MachineCom(object):
|
||||
# something went wrong, printer is reporting that we actually are not printing right now...
|
||||
self._sdFilePos = 0
|
||||
self._changeState(self.STATE_OPERATIONAL)
|
||||
elif 'SD card ok' in line:
|
||||
elif 'SD card ok' in line and not self._sdAvailable:
|
||||
self._sdAvailable = True
|
||||
self.refreshSdFiles()
|
||||
self._callback.mcSdStateChange(self._sdAvailable)
|
||||
@@ -549,12 +566,12 @@ class MachineCom(object):
|
||||
self._callback.mcSdFiles(self._sdFiles)
|
||||
elif 'SD printing byte' in line:
|
||||
# answer to M27, at least on Marlin, Repetier and Sprinter: "SD printing byte %d/%d"
|
||||
match = re.search("([0-9]*)/([0-9]*)", line)
|
||||
match = self._regex_sdPrintingByte.search(line)
|
||||
self._currentFile.setFilepos(int(match.group(1)))
|
||||
self._callback.mcProgress()
|
||||
elif 'File opened' in line:
|
||||
# answer to M23, at least on Marlin, Repetier and Sprinter: "File opened:%s Size:%d"
|
||||
match = re.search("File opened:\s*(.*?)\s+Size:\s*([0-9]*)", line)
|
||||
match = self._regex_sdFileOpened.search(line)
|
||||
self._currentFile = PrintingSdFileInformation(match.group(1), int(match.group(2)))
|
||||
elif 'File selected' in line:
|
||||
# final answer to M23, at least on Marlin, Repetier and Sprinter: "File selected"
|
||||
@@ -563,7 +580,6 @@ class MachineCom(object):
|
||||
eventManager().fire("FileSelected", self._currentFile.getFilename())
|
||||
elif 'Writing to file' in line:
|
||||
# anwer to M28, at least on Marlin, Repetier and Sprinter: "Writing to file: %s"
|
||||
self._printSection = "CUSTOM"
|
||||
self._changeState(self.STATE_PRINTING)
|
||||
line = "ok"
|
||||
elif 'Done printing file' in line:
|
||||
@@ -657,6 +673,8 @@ class MachineCom(object):
|
||||
self._changeState(self.STATE_OPERATIONAL)
|
||||
if self._sdAvailable:
|
||||
self.refreshSdFiles()
|
||||
else:
|
||||
self.initSdCard()
|
||||
eventManager().fire("Connected", "%s at %s baud" % (self._port, self._baudrate))
|
||||
else:
|
||||
self._testingBaudrate = False
|
||||
@@ -669,7 +687,9 @@ class MachineCom(object):
|
||||
startSeen = True
|
||||
elif "ok" in line and startSeen:
|
||||
self._changeState(self.STATE_OPERATIONAL)
|
||||
if not self._sdAvailable:
|
||||
if self._sdAvailable:
|
||||
self.refreshSdFiles()
|
||||
else:
|
||||
self.initSdCard()
|
||||
eventManager().fire("Connected", "%s at %s baud" % (self._port, self._baudrate))
|
||||
elif time.time() > timeout:
|
||||
@@ -788,7 +808,7 @@ class MachineCom(object):
|
||||
# Marlin reports an MIN/MAX temp error as "Error:x\n: Extruder switched off. MAXTEMP triggered !\n"
|
||||
# But a bed temp error is reported as "Error: Temperature heated bed switched off. MAXTEMP triggered !!"
|
||||
# So we can have an extra newline in the most common case. Awesome work people.
|
||||
if re.match('Error:[0-9]\n', line):
|
||||
if self._regex_minMaxError.match(line):
|
||||
line = line.rstrip() + self._readline()
|
||||
#Skip the communication errors, as those get corrected.
|
||||
if 'checksum mismatch' in line \
|
||||
@@ -818,7 +838,7 @@ class MachineCom(object):
|
||||
if ret == '':
|
||||
#self._log("Recv: TIMEOUT")
|
||||
return ''
|
||||
self._log("Recv: %s" % (unicode(ret, 'ascii', 'replace').encode('ascii', 'replace').rstrip()))
|
||||
self._log("Recv: %s" % sanitizeAscii(ret))
|
||||
return ret
|
||||
|
||||
def _sendNext(self):
|
||||
@@ -829,8 +849,8 @@ class MachineCom(object):
|
||||
self._sendCommand("M29")
|
||||
filename = self._currentFile.getFilename()
|
||||
self._currentFile = None
|
||||
self._callback.mcFileTransferDone()
|
||||
self._changeState(self.STATE_OPERATIONAL)
|
||||
self._callback.mcFileTransferDone(filename)
|
||||
eventManager().fire("TransferDone", filename)
|
||||
self.refreshSdFiles()
|
||||
else:
|
||||
@@ -885,7 +905,7 @@ class MachineCom(object):
|
||||
return
|
||||
|
||||
if not self.isStreaming():
|
||||
gcode = re.search("^\s*([GM]\d+)", cmd)
|
||||
gcode = self._regex_command.search(cmd)
|
||||
if gcode:
|
||||
gcode = gcode.group(1)
|
||||
|
||||
@@ -935,13 +955,15 @@ class MachineCom(object):
|
||||
|
||||
def _gcode_G0(self, cmd):
|
||||
if 'Z' in cmd:
|
||||
try:
|
||||
z = float(re.search('Z([0-9\.]*)', cmd).group(1))
|
||||
if self._currentZ != z:
|
||||
self._currentZ = z
|
||||
self._callback.mcZChange(z)
|
||||
except ValueError:
|
||||
pass
|
||||
match = self._regex_paramZFloat.search(cmd)
|
||||
if match:
|
||||
try:
|
||||
z = float(match.group(1))
|
||||
if self._currentZ != z:
|
||||
self._currentZ = z
|
||||
self._callback.mcZChange(z)
|
||||
except ValueError:
|
||||
pass
|
||||
return cmd
|
||||
_gcode_G1 = _gcode_G0
|
||||
|
||||
@@ -951,7 +973,7 @@ class MachineCom(object):
|
||||
_gcode_M1 = _gcode_M0
|
||||
|
||||
def _gcode_M104(self, cmd):
|
||||
match = re.search('S([0-9]+)', cmd)
|
||||
match = self._regex_paramSInt.search(cmd)
|
||||
if match:
|
||||
try:
|
||||
self._targetTemp = float(match.group(1))
|
||||
@@ -960,7 +982,7 @@ class MachineCom(object):
|
||||
return cmd
|
||||
|
||||
def _gcode_M140(self, cmd):
|
||||
match = re.search('S([0-9]+)', cmd)
|
||||
match = self._regex_paramSInt.search(cmd)
|
||||
if match:
|
||||
try:
|
||||
self._bedTargetTemp = float(match.group(1))
|
||||
@@ -978,7 +1000,7 @@ class MachineCom(object):
|
||||
|
||||
def _gcode_M110(self, cmd):
|
||||
newLineNumber = None
|
||||
match = re.search("N([0-9]+)", cmd)
|
||||
match = self._regex_paramNInt.search(cmd)
|
||||
if match:
|
||||
try:
|
||||
newLineNumber = int(match.group(1))
|
||||
@@ -996,6 +1018,9 @@ class MachineCom(object):
|
||||
self._resendDelta = None
|
||||
|
||||
return None
|
||||
def _gcode_M112(self, cmd): # It's an emergency what todo? Canceling the print should be the minimum
|
||||
self.cancelPrint()
|
||||
return cmd
|
||||
|
||||
### MachineCom callback ################################################################################################
|
||||
|
||||
@@ -1113,7 +1138,7 @@ class PrintingGcodeFileInformation(PrintingFileInformation):
|
||||
self._firstLine = None
|
||||
|
||||
self._offsetCallback = offsetCallback
|
||||
self._tempCommandPattern = re.compile("^\s*M(104|109|140|190)\s+S([0-9\.]+)")
|
||||
self._regex_tempCommand = re.compile("^\s*M(104|109|140|190)\s+S([0-9\.]+)")
|
||||
|
||||
if not os.path.exists(self._filename) or not os.path.isfile(self._filename):
|
||||
raise IOError("File %s does not exist" % self._filename)
|
||||
@@ -1170,7 +1195,7 @@ class PrintingGcodeFileInformation(PrintingFileInformation):
|
||||
if self._offsetCallback is not None:
|
||||
(tempOffset, bedTempOffset) = self._offsetCallback()
|
||||
if tempOffset != 0 or bedTempOffset != 0:
|
||||
tempMatch = self._tempCommandPattern.match(line)
|
||||
tempMatch = self._regex_tempCommand.match(line)
|
||||
if tempMatch is not None:
|
||||
if tempMatch.group(1) == "104" or tempMatch.group(1) == "109":
|
||||
offset = tempOffset
|
||||
@@ -1192,4 +1217,4 @@ class PrintingGcodeFileInformation(PrintingFileInformation):
|
||||
|
||||
class StreamingGcodeFileInformation(PrintingGcodeFileInformation):
|
||||
def __init__(self, filename):
|
||||
PrintingGcodeFileInformation.__init__(self, filename, None)
|
||||
PrintingGcodeFileInformation.__init__(self, filename, None)
|
||||
Reference in new issue
Block a user