Merge branch 'maintenance' into pr/3856
This commit is contained in:
commit
211669db1c
65 files changed
+1707
-721
No files matched your search
@@ -0,0 +1,3 @@
|
||||
# someone from the docker-maintainers team will be requested for review
|
||||
# whenever the trigger_docker workflow is changed in a Pull Request
|
||||
.github/workflows/trigger_docker.yml @OctoPrint/docker-maintainers
|
||||
@@ -0,0 +1,62 @@
|
||||
approve_label: approved
|
||||
problem_label: incomplete
|
||||
ignored_labels:
|
||||
- approved
|
||||
- bug
|
||||
- request
|
||||
- improvement
|
||||
- brainstorming
|
||||
- task
|
||||
- rc feedback
|
||||
- awaiting information
|
||||
- not octoprint
|
||||
- done
|
||||
ignored_authors:
|
||||
- "@OctoPrint"
|
||||
- "sentry-io"
|
||||
- "FormerLurker"
|
||||
- "bzed"
|
||||
|
||||
validation_comment: >
|
||||
Hi @@@AUTHOR@@,
|
||||
|
||||
|
||||
it looks like there is some **information missing** from your bug report that will
|
||||
be needed in order to solve the problem. Read the [Contribution Guidelines](https://github.com/OctoPrint/OctoPrint/blob/master/CONTRIBUTING.md)
|
||||
which will provide you with a template to *fully fill out* here so that your bug report
|
||||
is ready to be investigated (I promise I'll go away then too!).
|
||||
|
||||
|
||||
If you did not intend to report a bug but wanted to **request a feature or brain
|
||||
storm** about some kind of development, please take special note of the title format
|
||||
to use as described in the [Contribution Guidelines](https://github.com/OctoPrint/OctoPrint/blob/master/CONTRIBUTING.md).
|
||||
|
||||
|
||||
**Please do not abuse the bug tracker as a support forum** - that can be found at
|
||||
[community.octoprint.org](https://community.octoprint.org). Go there for any kind
|
||||
of issues with network connectivity, webcam functionality, printer detection or
|
||||
any other kind of such support requests or general questions.
|
||||
|
||||
|
||||
Also **make sure you are at the right place** - this is the bug tracker of the official
|
||||
version of OctoPrint, not the Raspberry Pi image OctoPi nor any unbundled third
|
||||
party OctoPrint plugins or unofficial versions. Make sure too that you have **read
|
||||
through the [Frequently Asked Questions](http://faq.octoprint.org)** and searched
|
||||
the [**existing tickets**](https://github.com/OctoPrint/OctoPrint/issues)
|
||||
for your problem - try multiple search terms please.
|
||||
|
||||
|
||||
I'm marking this one now as needing some more information. Please understand that
|
||||
if you do not provide that information within the next two weeks
|
||||
I'll close this ticket so it doesn't clutter the bug tracker. This is nothing
|
||||
personal, it's needed to keep this project manageable. Please just be considerate
|
||||
and help the maintainers solve this problem
|
||||
quickly by following the guidelines linked above. Remember, the less time the devs
|
||||
have to spend running after information on tickets, the more time they have to actually
|
||||
solve problems and add awesome new features. Thank you!
|
||||
|
||||
|
||||
*I'm just a bot 🤖, not a human being, so don't expect any replies
|
||||
from me :) Your ticket is read by humans too, I'm just not one of them.*
|
||||
|
||||
keyphrase: I have read the FAQ
|
||||
@@ -0,0 +1,25 @@
|
||||
docs:
|
||||
- "docs/*"
|
||||
- "docs/**/*"
|
||||
- "README.md"
|
||||
|
||||
meta:
|
||||
- "CODE_OF_CONDUCT.md"
|
||||
- "CONTRIBUTING.md"
|
||||
- "SECURITY.md"
|
||||
- ".github/CODEOWNERS"
|
||||
- ".github/FUNDING.yml"
|
||||
- ".github/ISSUE_TEMPLATE/*"
|
||||
- ".github/PULL_REQUEST_TEMPLATE.md"
|
||||
|
||||
ci/cd:
|
||||
- ".github/fixtures/**/*"
|
||||
- ".github/workflows/*"
|
||||
- ".github/labeler.yml"
|
||||
|
||||
docker:
|
||||
- ".github/workflows/trigger_docker.yml"
|
||||
|
||||
tests:
|
||||
- "tests/*"
|
||||
- "tests/**/*"
|
||||
@@ -0,0 +1,14 @@
|
||||
approve_label: "approved"
|
||||
problem_label: "needs some work"
|
||||
|
||||
allowed_targets: ["maintenance", "devel", "staging/maintenance", "staging/devel"]
|
||||
forbidden_sources:
|
||||
["master", "maintenance", "devel", "staging/maintenance", "staging/devel"]
|
||||
|
||||
labels:
|
||||
docs:
|
||||
additional_allowed_targets: ["master"]
|
||||
meta:
|
||||
additional_allowed_targets: ["master"]
|
||||
ci/cd:
|
||||
additional_allowed_targets: ["master"]
|
||||
@@ -0,0 +1,37 @@
|
||||
name: "Cleanup issues & PRs"
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
lock:
|
||||
name: 🔒 Lock issues & PRs closed over a year
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: dessant/lock-threads@v2
|
||||
with:
|
||||
github-token: ${{ github.token }}
|
||||
issue-lock-comment: ""
|
||||
pr-lock-comment: ""
|
||||
|
||||
cleanup:
|
||||
name: 🧹 Close issues marked as incomplete & older than 14 days
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- id: date
|
||||
run: |
|
||||
echo "::set-output name=CUTOFF::`date --date='14 days ago' +'%Y-%m-%d'`"
|
||||
- uses: OctoPrint/actions/close-by-query@main
|
||||
with:
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
query: "is:issue is:open label:incomplete created:<${{ steps.date.outputs.CUTOFF }}"
|
||||
comment: >
|
||||
Since apparently some of the required information is still missing, this will be
|
||||
closed now, sorry. Feel free to request a reopen of this or create a new issue
|
||||
once you can provide **all**
|
||||
[required information](https://github.com/OctoPrint/OctoPrint/blob/master/CONTRIBUTING.md#how-to-file-a-bug-report).
|
||||
|
||||
|
||||
This is nothing personal. Thank you for your collaboration.
|
||||
@@ -1,10 +1,10 @@
|
||||
name: "Issue Labeler"
|
||||
name: "Issue Automation"
|
||||
on:
|
||||
issues:
|
||||
types: [opened, edited, closed, reopened]
|
||||
|
||||
jobs:
|
||||
label-opened-and-edited:
|
||||
issue-automation:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/github-script@v2
|
||||
@@ -62,3 +62,8 @@ jobs:
|
||||
labels: labels
|
||||
})
|
||||
}
|
||||
|
||||
- uses: OctoPrint/actions/issue-validation@main
|
||||
if: github.event_name == 'issues' && (github.event.action == 'opened' || github.event.action == 'edited')
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -1,16 +0,0 @@
|
||||
name: "Lock outdated issues & PRs"
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
|
||||
jobs:
|
||||
lock:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 🔒 Lock issues & PRs closed over a year
|
||||
uses: dessant/lock-threads@v2
|
||||
with:
|
||||
github-token: ${{ github.token }}
|
||||
issue-lock-comment: ""
|
||||
pr-lock-comment: ""
|
||||
@@ -0,0 +1,16 @@
|
||||
name: "Pull Request Automation"
|
||||
on:
|
||||
pull_request_target:
|
||||
types: ["opened", "synchronize", "reopened", "edited", "labeled", "unlabeled"]
|
||||
|
||||
jobs:
|
||||
pr-automation:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/labeler@v3
|
||||
with:
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
|
||||
- uses: OctoPrint/actions/pr-validation@main
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -4,16 +4,44 @@ on:
|
||||
types:
|
||||
- released
|
||||
- prereleased
|
||||
push:
|
||||
branches:
|
||||
- maintenance
|
||||
- devel
|
||||
|
||||
jobs:
|
||||
trigger:
|
||||
dispatch_releases:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == 'OctoPrint/OctoPrint'
|
||||
if: github.repository == 'OctoPrint/OctoPrint' && github.event_name != 'push'
|
||||
steps:
|
||||
- name: 🚀 Repository Dispatch
|
||||
uses: peter-evans/repository-dispatch@v1
|
||||
with:
|
||||
token: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
||||
repository: ${{ github.repository_owner }}/octoprint-docker
|
||||
event-type: "release"
|
||||
event-type: ${{ github.event.action }}
|
||||
client-payload: '{"tag_name": "${{ github.event.release.tag_name }}"}'
|
||||
|
||||
dispatch_canary:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == 'OctoPrint/OctoPrint' && github.event_name == 'push' && github.ref == 'refs/heads/maintenance'
|
||||
steps:
|
||||
- name: 🚀 Repository Dispatch
|
||||
uses: peter-evans/repository-dispatch@v1
|
||||
with:
|
||||
token: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
||||
repository: ${{ github.repository_owner }}/octoprint-docker
|
||||
event-type: "canary"
|
||||
client-payload: '{"tag_name": "maintenance"}'
|
||||
|
||||
dispatch_bleeding:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == 'OctoPrint/OctoPrint' && github.event_name == 'push' && github.ref == 'refs/heads/devel'
|
||||
steps:
|
||||
- name: 🚀 Repository Dispatch
|
||||
uses: peter-evans/repository-dispatch@v1
|
||||
with:
|
||||
token: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
||||
repository: ${{ github.repository_owner }}/octoprint-docker
|
||||
event-type: "bleeding"
|
||||
client-payload: '{"tag_name": "devel"}'
|
||||
+4
-2
@@ -24,8 +24,10 @@ maintenance 1.6.0 b7a45b79bf86339f0b28177ac1eaebb56d00ea37 pep440-dev
|
||||
fix/.* 1.6.0 b7a45b79bf86339f0b28177ac1eaebb56d00ea37 pep440-dev
|
||||
improve/.* 1.6.0 b7a45b79bf86339f0b28177ac1eaebb56d00ea37 pep440-dev
|
||||
|
||||
# staging/hotfix is the branch for preparation of the 1.5.1 hotfix release
|
||||
staging/hotfix 1.5.1 f67c15a9a47794a68be9aed4f2d5a12a87e70179 pep440-dev
|
||||
# staging/bugfix is the branch for preparation of the 1.5.3 hotfix release
|
||||
# so are any bug/... branches
|
||||
staging/bugfix 1.5.3 e46e8fa17a1553cd0c228a4fa4cfd93e2a9bce7b pep440-dev
|
||||
bug/.* 1.5.3 e46e8fa17a1553cd0c228a4fa4cfd93e2a9bce7b pep440-dev
|
||||
|
||||
# staging/maintenance is currently the branch for preparation of 1.5.0rc4
|
||||
# so is regressionfix/...
|
||||
|
||||
@@ -130,6 +130,11 @@ date of first contribution):
|
||||
* [Sophist](https://github.com/Sophist-UK)
|
||||
* [Manuel McLure](https://github.com/ManuelMcLure)
|
||||
* ["j7126"](https://github.com/j7126)
|
||||
* ["coliss86"](https://github.com/coliss86)
|
||||
* ["MichaIng"](https://github.com/MichaIng)
|
||||
* ["jasonbcox"](https://github.com/jasonbcox)
|
||||
* ["shadycuz"](https://github.com/shadycuz)
|
||||
* [David Rifkind](https://github.com/drifkind)
|
||||
* [Nils Hofmann](https://github.com/Master92)
|
||||
|
||||
OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by
|
||||
|
||||
+7
-4
@@ -6,18 +6,22 @@ thanks to everyone who contributed!
|
||||
|
||||
## Patrons & Sponsors
|
||||
|
||||
* 3DPrinterOS
|
||||
* Andrew Moorby
|
||||
* Arnljot Arntsen
|
||||
* Ash King
|
||||
* BigTreeTech
|
||||
* Boris Hussein
|
||||
* Brad Jackson
|
||||
* BRANDON ROBERTSON
|
||||
* BuildBee
|
||||
* Christian Petropolis
|
||||
* Christian Wolf
|
||||
* Creality3D
|
||||
* D Brian Kimmel
|
||||
* DeltaMaker 3D Printers
|
||||
* Dennis Breining
|
||||
* Diana C Rodriguez
|
||||
* Eric Betts
|
||||
* Ernesto Martinez
|
||||
* Franziska Kunsmann
|
||||
@@ -25,12 +29,10 @@ thanks to everyone who contributed!
|
||||
* Greg Holloway
|
||||
* Hog Duske
|
||||
* Hopewell Medical Acupuncture Center
|
||||
* Hugh Blemings
|
||||
* jean-claude migneault
|
||||
* Jefferson Hunt
|
||||
* Jeremy Cole
|
||||
* Joe Pasqua
|
||||
* John Gregory Robinson
|
||||
* Joshua Wills
|
||||
* Justin Kaufman
|
||||
* Kaile Riser
|
||||
@@ -51,13 +53,14 @@ thanks to everyone who contributed!
|
||||
* Mosaic Manufacturing
|
||||
* Neil R. Goldberg
|
||||
* Patrick Glyré
|
||||
* Patrick McGinnis
|
||||
* Pete Barnwell
|
||||
* Prof Yuh Wen Chen
|
||||
* Raise3D
|
||||
* Randy C. Will
|
||||
* Ranjib Dey
|
||||
* Richard McGuire
|
||||
* Richard Michaud
|
||||
* Richard Stocks
|
||||
* Rigid3D
|
||||
* Robert Gusek
|
||||
* Ronald Griehsler
|
||||
@@ -68,4 +71,4 @@ thanks to everyone who contributed!
|
||||
* Sven Mueller
|
||||
* Ulrich Kempken
|
||||
|
||||
and 2116 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [Github Sponsors](https://github.com/users/foosel/sponsorship)!
|
||||
and 2225 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [Github Sponsors](https://github.com/users/foosel/sponsorship)!
|
||||
+4
-2
@@ -205,8 +205,10 @@ Retrieve information about the current job
|
||||
},
|
||||
"estimatedPrintTime": 8811,
|
||||
"filament": {
|
||||
"length": 810,
|
||||
"volume": 5.36
|
||||
"tool0": {
|
||||
"length": 810,
|
||||
"volume": 5.36
|
||||
}
|
||||
}
|
||||
},
|
||||
"progress": {
|
||||
|
||||
@@ -10,7 +10,7 @@ The OctoPrint Action Command Notification Support Plugin comes bundled with Octo
|
||||
It allows firmware to trigger notifications users with the ``PLUGIN_ACTION_COMMAND_NOTIFICATION_SHOW`` permission
|
||||
using :ref:`action commands <sec-features-action_commands>` about relevant events. These notifications will be shown
|
||||
in the sidebar and if configured also as popup messages. The notifications in the sidebar panel can also be cleared
|
||||
by users with the ``PLUGIN_ACTION_COMMAND_NOTIFICATION_CLEAR` permission.
|
||||
by users with the ``PLUGIN_ACTION_COMMAND_NOTIFICATION_CLEAR`` permission.
|
||||
|
||||
.. _fig-bundledplugins-action_command_notification-example:
|
||||
.. figure:: ../images/bundledplugins-action_command_notification-example.png
|
||||
|
||||
@@ -177,6 +177,30 @@ octoprint.plugin.backup.additional_excludes
|
||||
:return: A list of paths to exclude, relative to your plugin's data folder
|
||||
:rtype: list
|
||||
|
||||
Helpers
|
||||
-------
|
||||
|
||||
.. _sec-bundledplugins-backup-helpers:
|
||||
|
||||
The Backup plugin exports two helpers that can be used by other plugins or internal methods
|
||||
from within OctoPrint, without going via the API.
|
||||
|
||||
.. _sec-bundledplugins-backup-helpers-create_backup:
|
||||
|
||||
create_backup
|
||||
+++++++++++++
|
||||
|
||||
.. autofunction:: octoprint.plugins.backup.BackupPlugin.create_backup_helper
|
||||
|
||||
|
||||
.. _sec-bundledplugins-backup-helpers-delete_backup:
|
||||
|
||||
delete_backup
|
||||
+++++++++++++
|
||||
|
||||
.. autofunction:: octoprint.plugins.backup.BackupPlugin.delete_backup_helper
|
||||
|
||||
|
||||
.. _sec-bundledplugins-backup-sourcecode:
|
||||
|
||||
Source code
|
||||
|
||||
@@ -30,7 +30,7 @@ Use the following settings to enable access control:
|
||||
userManager: octoprint.access.users.FilebasedUserManager
|
||||
|
||||
# The YAML user file to use. If left out defaults to users.yaml in the default configuration folder.
|
||||
userFile: /path/to/users.yaml
|
||||
userfile: /path/to/users.yaml
|
||||
|
||||
# If set to true, will automatically log on clients originating from any of the networks defined in
|
||||
# "localNetworks" as the user defined in "autologinAs". Defaults to false.
|
||||
|
||||
@@ -30,8 +30,8 @@ There are three main branches in OctoPrint:
|
||||
|
||||
There are couple more RC and staging branches that see regular use:
|
||||
|
||||
``staging/hotfix``
|
||||
Any preparation for potential hotfix releases takes place here.
|
||||
``staging/bugfix``
|
||||
Any preparation for potential bugfix releases takes place here.
|
||||
Version number follows the scheme ``<x>.<y>.<z+1>`` (e.g. ``1.5.1``) for a current release
|
||||
of ``<x>.<y>.<z>``.
|
||||
``rc/maintenance``
|
||||
@@ -56,8 +56,8 @@ There are couple more RC and staging branches that see regular use:
|
||||
Additionally, from time to time you might see other branches pop up in the repository.
|
||||
Those usually have one of the following prefixes:
|
||||
|
||||
``hotfix/...``
|
||||
Hotfixes under development that are to be merged into the ``staging/hotfix``
|
||||
``bug/...``
|
||||
Fixes under development that are to be merged into the ``staging/bugfix``
|
||||
and later the ``master`` branch.
|
||||
``fix/...``
|
||||
Fixes under development that are to be merged into the ``maintenance``
|
||||
|
||||
@@ -200,6 +200,31 @@ There many configuration options via ``config.yaml`` for the virtual printer tha
|
||||
|
||||
# Simulated ambient temperature in °C
|
||||
ambientTemperature: 21.3
|
||||
|
||||
# Response to M105 when there is a target
|
||||
# Placeholders:
|
||||
# - heater: The heater id (eg. T0, T1, B)
|
||||
# - actual: The actual temperature of the heater
|
||||
# - target: The target temperature of heater
|
||||
m105TargetFormatString: {heater}:{actual:.2f}/ {target:.2f}
|
||||
|
||||
# Response to M105 when there is no target
|
||||
# Placeholders:
|
||||
# - heater: The heater id (eg. T0, T1, B)
|
||||
# - actual: The actual temperature of the heater
|
||||
m105NoTargetFormatString: {heater}:{actual:.2f}
|
||||
|
||||
# Enable virtual EEPROM
|
||||
# If enabled, a file `eeprom.json` will be created in the plugin data folder
|
||||
# to enable settings persistence across connections. Enables M500/1/2/4 commmands
|
||||
# And a selection of other settings commands. Responses modeled on Marlin 2.0
|
||||
enable_eeprom: true
|
||||
|
||||
# Support M503
|
||||
support_m503: true
|
||||
|
||||
# Resend ratio to simulate noise on the line
|
||||
resend_ratio: 0
|
||||
|
||||
.. _sec-development-virtual-printer-log:
|
||||
|
||||
|
||||
@@ -539,6 +539,34 @@ PrintResumed
|
||||
|
||||
.. versionchanged:: 1.4.0
|
||||
|
||||
GcodeScript${ScriptName}Running
|
||||
A custom :ref:`GCODE script <sec-features-gcode_scripts>` has started running.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``name``: the file's name
|
||||
* ``path``: the file's path within its storage location
|
||||
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
|
||||
* ``size``: the file's size in bytes (if available)
|
||||
* ``owner``: the user who started the print job (if available)
|
||||
* ``time``: the time needed for the print, in seconds (float)
|
||||
|
||||
.. versionadded:: 1.6.0
|
||||
|
||||
GcodeScript${ScriptName}Finished
|
||||
A custom :ref:`GCODE script <sec-features-gcode_scripts>` has finished running.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``name``: the file's name
|
||||
* ``path``: the file's path within its storage location
|
||||
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
|
||||
* ``size``: the file's size in bytes (if available)
|
||||
* ``owner``: the user who started the print job (if available)
|
||||
* ``time``: the time needed for the print, in seconds (float)
|
||||
|
||||
.. versionadded:: 1.6.0
|
||||
|
||||
.. _sec-events-available_events-gcode_processing:
|
||||
|
||||
GCODE processing
|
||||
|
||||
+193
-53
@@ -3,7 +3,7 @@
|
||||
Access Control
|
||||
==============
|
||||
|
||||
.. versionchanged:: 1.4.0
|
||||
.. versionchanged:: 1.5.0
|
||||
|
||||
OctoPrint's bundled access control feature allows granular permission control
|
||||
over which users or user groups are allowed to access which parts of OctoPrint.
|
||||
@@ -17,8 +17,17 @@ users out of the box.
|
||||
thus also cannot limit access to it. If an anonymous user correctly guesses the
|
||||
webcam URL, they will thus be able to see it.
|
||||
|
||||
If read-only access for anonymous users is enabled, anonymous users will have
|
||||
read-only access to the following parts of the UI:
|
||||
Upon first start a configuration wizard is provided which allows configuration
|
||||
of the first administrator account to be used for OctoPrint. After initial setup,
|
||||
you can then create more users and groups under Settings > Access Control for
|
||||
customisation of the granular permission system.
|
||||
|
||||
The predefined "Guests" group can be used to configure default permissions of anonymous
|
||||
users, that is those who have not logged in. By default, no permissions are granted to
|
||||
these users.
|
||||
|
||||
A predefined "Read-only Access" group with no users is configured which by default grants
|
||||
read-only access to the following parts of the UI to any users assigned to this group:
|
||||
|
||||
* printer state
|
||||
* available gcode files and stats (upload is disabled)
|
||||
@@ -30,29 +39,195 @@ read-only access to the following parts of the UI:
|
||||
* any components provided through plugins which are enabled for anonymous
|
||||
users
|
||||
|
||||
Logged in users without admin flag will be allowed to access everything besides the
|
||||
Settings and System Commands, which are admin-only.
|
||||
Another predefined "Operator" group is the default group for newly created users and
|
||||
by default gives access to all aspects of OctoPrint that involve regular printer
|
||||
operation. It matches the old "user" role from OctoPrint prior to 1.4.0.
|
||||
|
||||
If Access Control is disabled, everything is directly accessible. **That also
|
||||
includes all administrative functionality as well as full control over the
|
||||
printer**, and without the need for an :ref:`API key <sec-api-general-authorization>`!
|
||||
|
||||
Upon first start a configuration wizard is provided which allows configuration
|
||||
of the first administrator account or alternatively disabling Access Control
|
||||
(which is **NOT** recommended for systems that are directly accessible via the
|
||||
internet or other untrusted networks!).
|
||||
Finally, the predefined "Admins" group gives full admin access to the platform. You should
|
||||
be careful of who you put into that. It matches the old "admin" role from OctoPrint prior
|
||||
to 1.4.0.
|
||||
|
||||
.. hint::
|
||||
|
||||
If you plan to have your OctoPrint instance accessible over the internet,
|
||||
**always enable Access Control** and ideally **don't make it accessible to
|
||||
**please use additional security measures** and ideally **don't make it accessible to
|
||||
everyone over the internet but instead use a VPN** or at the very least
|
||||
HTTP basic authentication on a layer above OctoPrint.
|
||||
HTTP basic authentication on a layer above OctoPrint. Unless you are using a VPN
|
||||
**please do not** enable any permissions for the Guest group or the auto-login feature
|
||||
described below.
|
||||
|
||||
A physical device that includes heaters and stepper motors really should not be
|
||||
publicly reachable by everyone with an internet connection, even with access
|
||||
control enabled.
|
||||
|
||||
.. _sec-features-access_control-autologin:
|
||||
|
||||
Autologin
|
||||
---------
|
||||
|
||||
While access control cannot be disabled as of OctoPrint 1.5+, the Autologin feature can
|
||||
be used to bypass authentication for hosts on the network(s) that you trust.
|
||||
|
||||
Starting with OctoPrint 1.5.0, OctoPrint makes enabled access control mandatory. This
|
||||
might be an inconvience for some who run OctoPrint in an isolated setup where a login is
|
||||
not required to ensure security, at a benefit for a huge number of users out there who
|
||||
continue to underestimate or simply ignore the risk of keeping their OctoPrint instance
|
||||
unsecured and then happily exposing it on the public internet.
|
||||
|
||||
That being said, even as far back as OctoPrint 1.0.0 (released in 2013) there has existed
|
||||
a way to have OctoPrint automatically log you in, if you connect from a trusted local
|
||||
network address. This functionality has not been exposed on the UI, and for now also won't
|
||||
be (to make it a bit harder to once again create an insecure setup for those who simply
|
||||
won't listen to common sense), but it's easy to set up with a bit of configuration
|
||||
editing.
|
||||
|
||||
When set up properly, it will make sure to automatically log you in as a configured user
|
||||
whenever you connect from a device on your local network. To get back pretty much the same
|
||||
behaviour as with disabled access control, you'll only need to create a single (admin)
|
||||
account and then set up autologin for it.
|
||||
|
||||
|
||||
.. warning::
|
||||
|
||||
**Do not do this if you cannot trust EVERYONE on your local network.** And that really
|
||||
means mean everyone. If you ignore this and then someone takes over your OctoPrint
|
||||
instance, installs malware on it and makes your printer print an endless stream of
|
||||
benchies, that's on you.
|
||||
|
||||
.. _sec-features-access_control-autologin-gather_config_info:
|
||||
|
||||
Gather configuration information
|
||||
................................
|
||||
|
||||
You can configure Autologin via a plugin (the easy way), or manually (the hard way), but
|
||||
in either case you will need to specify which user should be automatically logged in, and
|
||||
which hosts are permitted access this way.
|
||||
|
||||
**Improperly setting this subnet option can lead to the compromise of your system, or even
|
||||
your entire network. Proceed with extreme caution.**
|
||||
|
||||
The subnet to use is usually the IP address range of your LAN, which sounds scary but
|
||||
actually isn't. Just `figure out your PC's IP address and subnet mask <https://lifehacker.com/how-to-find-your-local-and-external-ip-address-5833108>`_
|
||||
and then combine both with a / in between.
|
||||
|
||||
On OctoPi (or another Linux distribution) you can use the follwing command:
|
||||
|
||||
.. code-block::
|
||||
|
||||
ip route | grep -P 'eth0|wlan0' | awk '{print $1}'
|
||||
|
||||
Or, for IPv6, use this:
|
||||
|
||||
.. code-block::
|
||||
|
||||
ip -6 route | grep -P 'eth0|wlan0' | awk '{print $1}'
|
||||
|
||||
This will be what you set as the subnet in the plugin, or where it says
|
||||
``<yourAddressRange>`` below on the manual configuration instructions.
|
||||
|
||||
Example: Your PC has an IP address of ``192.168.23.42`` and a subnet mask of
|
||||
``255.255.255.0``. Your address range is ``192.168.23.42/255.255.255.0``.
|
||||
|
||||
.. _sec-features-access_control-autologin-plugin:
|
||||
|
||||
The easy way: Using the OctoPrint-AutoLoginConfig plugin
|
||||
........................................................
|
||||
|
||||
The easist way to configure AutoLogin is to install the
|
||||
`OctoPrint-AutoLoginConfig plugin <https://plugins.octoprint.org/plugins/autologin_config/>`_
|
||||
via the plugin manager.
|
||||
|
||||
Open its settings and follow the instructions on the screen.
|
||||
|
||||
.. _sec-features-access_control-autologin-manual:
|
||||
|
||||
The hard way: Manual editing of config.yaml
|
||||
...........................................
|
||||
|
||||
Preparation
|
||||
***********
|
||||
|
||||
First of all, read :ref:`the YAML primer <sec-configuration-yaml>`. You
|
||||
will have to edit OctoPrint's main configuration file, and thus should make sure
|
||||
you understand at least roughly how things work and that you should keep your
|
||||
hands off the Tab key. If you don't, you might break your config file, and
|
||||
while the steps include making a backup, this still can be easily avoided by
|
||||
learning about the DOs and DONTs first.
|
||||
|
||||
Then, take a look at :ref:`the docs on config.yaml <sec-configuration-config_yaml>`
|
||||
on where to find that central configuration file of OctoPrint.
|
||||
|
||||
Configuration
|
||||
*************
|
||||
|
||||
Ready? Let's do some editing then. I'll outline what to do and where first, and then
|
||||
further down there's also a dedicated list of steps for OctoPi specifically.
|
||||
|
||||
1. Shutdown OctoPrint
|
||||
2. Make a backup of your config.yaml
|
||||
3. Open it in a text editor (e.g. nano). Right at the very top it'll say something like
|
||||
this:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
accessControl:
|
||||
salt: aabbccddee1234523452345
|
||||
|
||||
Edit this, adding lines so it looks like this (making absolutely sure not to touch the
|
||||
salt line):
|
||||
|
||||
.. code-block:: yaml
|
||||
accessControl:
|
||||
salt: aabbccddee1234523452345
|
||||
autologinLocal: true
|
||||
autologinAs: "<yourUsername>"
|
||||
localNetworks:
|
||||
- "127.0.0.0/8"
|
||||
- "<yourAddressRange>"
|
||||
|
||||
4. Restart OctoPrint, check that everything works.
|
||||
|
||||
This will automatically log you in as the user you specified whenver you connect to
|
||||
OctoPrint from an address in the address range (e.g. a device on your local network).
|
||||
|
||||
OctoPi specific steps
|
||||
*********************
|
||||
|
||||
If you are running OctoPi you will have to SSH into your Raspberry Pi. Then issue
|
||||
the following commands:
|
||||
|
||||
1. ``sudo service octoprint stop``
|
||||
2. ``cp ~/.octoprint/config.yaml ~/.octoprint/config.yaml.back``
|
||||
3. ``nano ~/.octoprint/config.yaml, make the edits as described above``
|
||||
4. ``sudo service octoprint start``
|
||||
|
||||
If something went wrong, you can restore the config backup with
|
||||
|
||||
.. code-block::
|
||||
|
||||
cp ~/.octoprint/config.yaml.back ~/.octoprint/config.yaml
|
||||
|
||||
|
||||
If you are using a VPN and your setup ABSOLUTELY REQUIRES disabling internal OctoPrint access controls
|
||||
......................................................................................................
|
||||
|
||||
.. warning::
|
||||
|
||||
You probably shouldn't do this, EVER. There are usually other options. Don't even
|
||||
THINK about it, unless you have a VPN layer for security. Only consider proceeding
|
||||
with this configuration after exhausting ALL other possibilities, and even then, you
|
||||
should think long and hard about whether this is a good idea. You almost certainly
|
||||
don't need or want to do this.
|
||||
|
||||
While access controls can no longer be disabled in OctoPrint 1.5+, this can be
|
||||
approximated by an Autologin configuration that automatically logs in all users, that is
|
||||
by using subnets that match all possible IP addresses. By specifying the ``0.0.0.0/0``
|
||||
subnet (for IPv4) and ``::/0`` for IPv6 in the AutoLogin configuration, you can achieve
|
||||
this. This configuration is permitted, but highly, highly discouraged.
|
||||
|
||||
Please don't do this. You will almost certainly regret it. You alone are responsible for
|
||||
your actions.
|
||||
|
||||
.. _sec-features-access_control-hooks:
|
||||
|
||||
Available Extension Hooks
|
||||
@@ -71,42 +246,7 @@ See :ref:`here <sec-plugins-hook-permissions>`.
|
||||
|
||||
.. _sec-features-access_control-hooks-loginui:
|
||||
|
||||
octoprint.plugin.loginui.theming
|
||||
................................
|
||||
octoprint.theming.login
|
||||
.......................
|
||||
|
||||
See :ref:`here <sec-bundledplugins-loginui-hooks-theming>`.
|
||||
|
||||
.. _sec-features-access_control-rerunning_wizard:
|
||||
|
||||
Rerunning the wizard
|
||||
--------------------
|
||||
|
||||
In case Access Control was disabled in the configuration wizard, it is
|
||||
possible to re-run it by editing ``config.yaml`` [#f1]_ and setting ``firstRun``
|
||||
in the ``server`` section and ``enabled`` in the ``accessControl`` section to
|
||||
``true``:
|
||||
|
||||
.. code-block-ext:: yaml
|
||||
|
||||
accessControl:
|
||||
enabled: true
|
||||
# ...
|
||||
server:
|
||||
firstRun: true
|
||||
|
||||
Then restart the server and connect to the web interface - the wizard should
|
||||
be shown again.
|
||||
|
||||
.. note::
|
||||
|
||||
If user accounts were created prior to disabling Access Control and those
|
||||
user accounts are not to be used any more, remove ``.octoprint/users.yaml``.
|
||||
If you don't remove this file, the above changes won't lead to the
|
||||
configuration being shown again, instead Access Control will just be
|
||||
enabled using the already existing login data. This is to prevent you from
|
||||
resetting access control by accident.
|
||||
|
||||
.. rubric:: Footnotes
|
||||
|
||||
.. [#f1] For Linux that will be ``~/.octoprint/config.yaml``, for Windows it will be ``%APPDATA%/OctoPrint/config.yaml`` and for
|
||||
Mac ``~/Library/Application Support/OctoPrint/config.yaml``
|
||||
See :ref:`here <sec-plugins-hook-theming-dialog>`.
|
||||
@@ -43,6 +43,15 @@ The following GCODE scripts are sent by OctoPrint automatically:
|
||||
|
||||
Plugins may extend these scripts through :ref:`a hook <sec-plugins-hook-comm-protocol-scripts>`.
|
||||
|
||||
.. _sec-features-gcode_scripts-events:
|
||||
|
||||
Events
|
||||
------
|
||||
|
||||
Every GCODE script that is executed will emit two events. The event name will start with 'GcodeScript' followed by the capitalized name
|
||||
of the script. When ``afterPrintDone`` has started the event will be ``GcodeScriptAfterPrintDoneRunning`` and once it has completed the last event
|
||||
will be ``GcodeScriptAfterPrintDoneFinished``. You can find more details in the :ref:`Events <sec-events-available_events-printing>` documentation.
|
||||
|
||||
.. _sec-features-gcode_scripts-snippets:
|
||||
|
||||
Snippets
|
||||
|
||||
@@ -60,3 +60,22 @@ that in the `Plugin Repository's help pages <http://plugins.octoprint.org/help/r
|
||||
If you used the `OctoPrint Plugin Cookiecutter Template <https://github.com/OctoPrint/cookiecutter-octoprint-plugin>`_
|
||||
when creating your plugin, you can find a prepared registration entry ``.md`` file in the ``extras`` folder of your
|
||||
plugin.
|
||||
|
||||
Version management after the official plugin repository release
|
||||
---------------------------------------------------------------
|
||||
|
||||
Once your plugin is available in the official plugin repository, you probably want to create and distribute new versions.
|
||||
For "beta" users you can use the manual file distribution method, or a more elegant release channels (see below).
|
||||
After you finalized a new plugin version, don't forget to actually update the version in the ``setup.py``,
|
||||
and `submit a new release on github <https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/managing-releases-in-a-repository#creating-a-release>`_.
|
||||
|
||||
After you published the new release, you can verify it on your installed octoprint,
|
||||
with force checking the updates under the advanced options (in the software updates menu in the settings).
|
||||
The new versions will appear to the plugin users in the next 24 hours (it depends on their cache refreshes).
|
||||
|
||||
The `Software Update Plugin <https://docs.octoprint.org/en/master/bundledplugins/softwareupdate.html#>`_ has options to define multiple release channels,
|
||||
and you can let the users decide if they want to test your pre-releases or not.
|
||||
This can be achieved with defining ``stable_branch`` and ``prerelease_branches`` in the ``get_update_information`` function,
|
||||
and creating github releases to the newly configured branches too.
|
||||
For more information you can check the `Software Update Plugin documentation <https://docs.octoprint.org/en/master/bundledplugins/softwareupdate.html#version-checks>`_
|
||||
or read a more step-by-step writeup `here <https://github.com/cp2004/OctoPrint-Knowledge/blob/main/release-channels.md>`_.
|
||||
@@ -1173,15 +1173,6 @@ octoprint.plugin.backup.additional_excludes
|
||||
|
||||
See :ref:`here <sec-bundledplugins-backup-hooks-excludes>`.
|
||||
|
||||
.. _sec-plugins-hook-plugin-loginui-theming:
|
||||
|
||||
octoprint.plugin.loginui.theming
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. versionadded:: 1.4.0
|
||||
|
||||
See :ref:`here <sec-bundledplugins-loginui-hooks-theming>`.
|
||||
|
||||
.. _sec-plugins-hook-plugin-pluginmanager-reconnect:
|
||||
|
||||
octoprint.plugin.pluginmanager.reconnect_hooks
|
||||
|
||||
@@ -259,6 +259,10 @@ onUserSettingsShown()
|
||||
onUserSettingsHidden()
|
||||
Called when the user settings dialog is hidden.
|
||||
|
||||
onUserSettingsBeforeSave()
|
||||
Called just before the user settings view model is sent to the server. This is useful, for example, if your plugin
|
||||
needs to compute persisted settings from a custom view model.
|
||||
|
||||
onWizardDetails(response)
|
||||
Called with the response from the wizard detail API call initiated before opening the wizard dialog. Will contain
|
||||
the data from all :class:`~octoprint.plugin.WizardPlugin` implementations returned by their :meth:`~octoprint.plugin.WizardPlugin.get_wizard_details`
|
||||
|
||||
@@ -6,7 +6,7 @@ Wants=network-online.target
|
||||
[Service]
|
||||
Environment="LC_ALL=C.UTF-8"
|
||||
Environment="LANG=C.UTF-8"
|
||||
Type=simple
|
||||
Type=exec
|
||||
User=pi
|
||||
ExecStart=/home/pi/OctoPrint/venv/bin/octoprint
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ INSTALL_REQUIRES = [
|
||||
"PyYAML>=5.3.1,<6",
|
||||
"pyserial>=3.4,<4",
|
||||
"netaddr>=0.7.19,<1",
|
||||
"watchdog>=0.10.2,<1",
|
||||
"watchdog==0.10.4", # watchdog dropped Py>3.6 on 0.10.5 point release...
|
||||
"sarge==0.1.5post0",
|
||||
"netifaces>=0.10.9,<1",
|
||||
"pylru>=1.2,<2",
|
||||
@@ -62,6 +62,7 @@ INSTALL_REQUIRES = [
|
||||
"frozendict>=1.2,<2",
|
||||
"sentry-sdk>=0.15.1,<1",
|
||||
"filetype>=1.0.7,<2",
|
||||
"zipstream-new>=1.1.8,<1.2",
|
||||
# vendor bundled dependencies
|
||||
"unidecode>=0.04.14,<0.05", # dependency of awesome-slugify
|
||||
"blinker>=1.4,<2", # dependency of flask_principal
|
||||
|
||||
@@ -40,7 +40,7 @@ def _set_helper(settings, path, value, data_type=None):
|
||||
if name is not None:
|
||||
method = getattr(settings, name)
|
||||
|
||||
method(path, value)
|
||||
method(path, value, force=True)
|
||||
settings.save()
|
||||
|
||||
|
||||
|
||||
@@ -792,7 +792,7 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
|
||||
list: A list of paths to additional files whose modification to track for (in)validating
|
||||
the cache. Ignored if ``None`` is returned.
|
||||
|
||||
..versionadded:: 1.3.0
|
||||
.. versionadded:: 1.3.0
|
||||
"""
|
||||
return None
|
||||
|
||||
@@ -807,7 +807,7 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
|
||||
list: A list of paths representing the only files whose modification to track for (in)validating
|
||||
the cache. Ignored if ``None`` is returned.
|
||||
|
||||
..versionadded:: 1.3.0
|
||||
.. versionadded:: 1.3.0
|
||||
"""
|
||||
return None
|
||||
|
||||
@@ -820,7 +820,7 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
|
||||
Returns:
|
||||
str: An alternatively calculated ETag value. Ignored if ``None`` is returned (default).
|
||||
|
||||
..versionadded:: 1.3.0
|
||||
.. versionadded:: 1.3.0
|
||||
"""
|
||||
return None
|
||||
|
||||
@@ -838,7 +838,7 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
|
||||
Returns:
|
||||
(list): A list of additional fields for the ETag generation, or None
|
||||
|
||||
..versionadded:: 1.3.0
|
||||
.. versionadded:: 1.3.0
|
||||
"""
|
||||
return default_additional
|
||||
|
||||
@@ -851,7 +851,7 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
|
||||
Returns:
|
||||
int: An alternatively calculated LastModified value. Ignored if ``None`` is returned (default).
|
||||
|
||||
..versionadded:: 1.3.0
|
||||
.. versionadded:: 1.3.0
|
||||
"""
|
||||
return None
|
||||
|
||||
@@ -877,7 +877,7 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
|
||||
Returns:
|
||||
dict: Additional data to persist in the preemptive cache configuration.
|
||||
|
||||
..versionadded:: 1.3.0
|
||||
.. versionadded:: 1.3.0
|
||||
"""
|
||||
return None
|
||||
|
||||
@@ -895,7 +895,7 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
|
||||
dict: Additional request data to persist in the preemptive cache configuration and to
|
||||
use for request environment construction.
|
||||
|
||||
..versionadded:: 1.3.0
|
||||
.. versionadded:: 1.3.0
|
||||
"""
|
||||
return None
|
||||
|
||||
@@ -911,7 +911,7 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
|
||||
Returns:
|
||||
bool: Whether to suppress a record (True) or not (False, default)
|
||||
|
||||
..versionadded:: 1.3.0
|
||||
.. versionadded:: 1.3.0
|
||||
"""
|
||||
return False
|
||||
|
||||
@@ -933,7 +933,7 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
|
||||
and returning ``True`` to keep it and ``False`` to filter it out. If ``None`` is returned, no
|
||||
filtering will take place.
|
||||
|
||||
..versionadded:: 1.3.0
|
||||
.. versionadded:: 1.3.0
|
||||
"""
|
||||
return default_template_filter
|
||||
|
||||
@@ -953,7 +953,7 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
|
||||
(list) A list of permissions which to check the current user session against.
|
||||
May be empty to indicate that no permission checks should be made by OctoPrint.
|
||||
|
||||
..versionadded: 1.5.0
|
||||
.. versionadded: 1.5.0
|
||||
"""
|
||||
from octoprint.access.permissions import Permissions
|
||||
|
||||
@@ -1381,7 +1381,7 @@ class BlueprintPlugin(OctoPrintPlugin, RestartNeedingPlugin):
|
||||
and `the documentation for flask.Flask.errorhandler <http://flask.pocoo.org/docs/0.10/api/#flask.Flask.errorhandler>`_ for more
|
||||
information.
|
||||
|
||||
..versionadded:: 1.3.0
|
||||
.. versionadded:: 1.3.0
|
||||
"""
|
||||
from collections import defaultdict
|
||||
|
||||
@@ -1580,7 +1580,7 @@ class SettingsPlugin(OctoPrintPlugin):
|
||||
|
||||
from flask_login import current_user
|
||||
|
||||
from octoprint.access.permissions import Permissions
|
||||
from octoprint.access.permissions import OctoPrintPermission, Permissions
|
||||
|
||||
data = copy.deepcopy(self._settings.get_all_data(merged=True))
|
||||
if self.config_version_key in data:
|
||||
@@ -1632,9 +1632,15 @@ class SettingsPlugin(OctoPrintPlugin):
|
||||
"never": lambda: False,
|
||||
}
|
||||
|
||||
for level, condition in conditions.items():
|
||||
paths_for_level = restricted_paths.get(level, [])
|
||||
for path in paths_for_level:
|
||||
for level, paths in restricted_paths.items():
|
||||
if isinstance(level, OctoPrintPermission):
|
||||
condition = lambda: (
|
||||
current_user is not None and current_user.has_permission(level)
|
||||
)
|
||||
else:
|
||||
condition = conditions.get(level, lambda: False)
|
||||
|
||||
for path in paths:
|
||||
restrict_path_unless(data, path, condition)
|
||||
|
||||
return data
|
||||
@@ -1708,12 +1714,15 @@ class SettingsPlugin(OctoPrintPlugin):
|
||||
Retrieves the list of paths in the plugin's settings which be restricted on the REST API.
|
||||
|
||||
Override this in your plugin's implementation to restrict whether a path should only be returned to users with
|
||||
the SETTINGS permission, any logged in users, or never on the REST API.
|
||||
certain permissions, or never on the REST API.
|
||||
|
||||
Return a ``dict`` with the keys ``admin``, ``user``, ``never`` mapping to a list of paths (as tuples or lists of
|
||||
the path elements) for which to restrict access via the REST API accordingly. Paths returned for the ``admin``
|
||||
key will only be available on the REST API when access with admin rights, ``user`` will only be available when accessed
|
||||
as a logged in user. ``never`` will never be returned on the API.
|
||||
Return a ``dict`` with one of the following keys, mapping to a list of paths (as tuples or lists of
|
||||
the path elements) for which to restrict access via the REST API accordingly.
|
||||
|
||||
* An :py:class:`~octoprint.access.permissions.OctoPrintPermission` instance: Paths will only be available on the REST API for users with the permission
|
||||
* ``admin``: Paths will only be available on the REST API for users with admin rights (any user with the SETTINGS permission)
|
||||
* ``user``: Paths will only be available on the REST API when accessed as a logged in user
|
||||
* ``never``: Paths will never be returned on the API
|
||||
|
||||
Example:
|
||||
|
||||
@@ -1724,12 +1733,15 @@ class SettingsPlugin(OctoPrintPlugin):
|
||||
user_only=dict(path="path", bar="bar")),
|
||||
another=dict(admin_only=dict(path="path"),
|
||||
field="field"),
|
||||
path=dict(to=dict(never=dict(return="return"))))
|
||||
path=dict(to=dict(never=dict(return="return"))),
|
||||
the=dict(webcam=dict(data="webcam")))
|
||||
|
||||
def get_settings_restricted_paths(self):
|
||||
return dict(admin=[["some", "admin_only", "path"], ["another", "admin_only", "path"],],
|
||||
user=[["some", "user_only", "path"],],
|
||||
never=[["path", "to", "never", "return"],])
|
||||
from octoprint.access.permissions import Permissions
|
||||
return {'admin':[["some", "admin_only", "path"], ["another", "admin_only", "path"],],
|
||||
'user':[["some", "user_only", "path"],],
|
||||
'never':[["path", "to", "never", "return"],],
|
||||
Permissions.WEBCAM:[["the", "webcam", "data"],]}
|
||||
|
||||
# this will make the plugin return settings on the REST API like this for an anonymous user
|
||||
#
|
||||
@@ -1737,15 +1749,26 @@ class SettingsPlugin(OctoPrintPlugin):
|
||||
# user_only=dict(path=None, bar="bar")),
|
||||
# another=dict(admin_only=dict(path=None),
|
||||
# field="field"),
|
||||
# path=dict(to=dict(never=dict(return=None))))
|
||||
# path=dict(to=dict(never=dict(return=None))),
|
||||
# the=dict(webcam=dict(data=None)))
|
||||
#
|
||||
# like this for a logged in user
|
||||
# like this for a logged in user without the webcam permission
|
||||
#
|
||||
# dict(some=dict(admin_only=dict(path=None, foo="foo"),
|
||||
# user_only=dict(path="path", bar="bar")),
|
||||
# another=dict(admin_only=dict(path=None),
|
||||
# field="field"),
|
||||
# path=dict(to=dict(never=dict(return=None))))
|
||||
# path=dict(to=dict(never=dict(return=None))),
|
||||
# the=dict(webcam=dict(data=None)))
|
||||
#
|
||||
# like this for a logged in user with the webcam permission
|
||||
#
|
||||
# dict(some=dict(admin_only=dict(path=None, foo="foo"),
|
||||
# user_only=dict(path="path", bar="bar")),
|
||||
# another=dict(admin_only=dict(path=None),
|
||||
# field="field"),
|
||||
# path=dict(to=dict(never=dict(return=None))),
|
||||
# the=dict(webcam=dict(data="webcam")))
|
||||
#
|
||||
# and like this for an admin user
|
||||
#
|
||||
@@ -1753,9 +1776,10 @@ class SettingsPlugin(OctoPrintPlugin):
|
||||
# user_only=dict(path="path", bar="bar")),
|
||||
# another=dict(admin_only=dict(path="path"),
|
||||
# field="field"),
|
||||
# path=dict(to=dict(never=dict(return=None))))
|
||||
# path=dict(to=dict(never=dict(return=None))),
|
||||
# the=dict(webcam=dict(data="webcam")))
|
||||
|
||||
..versionadded:: 1.2.17
|
||||
.. versionadded:: 1.2.17
|
||||
"""
|
||||
return {}
|
||||
|
||||
@@ -1793,7 +1817,7 @@ class SettingsPlugin(OctoPrintPlugin):
|
||||
|
||||
Returns:
|
||||
(dict, dict): A tuple consisting of two dictionaries, the first being the plugin's preprocessors for
|
||||
getters, the second the preprocessors for setters
|
||||
getters, the second the preprocessors for setters
|
||||
"""
|
||||
return {}, {}
|
||||
|
||||
@@ -1807,8 +1831,8 @@ class SettingsPlugin(OctoPrintPlugin):
|
||||
|
||||
Returns:
|
||||
int or None: an int signifying the current settings format, should be incremented by plugins whenever there
|
||||
are backwards incompatible changes. Returning None here disables the version tracking for the
|
||||
plugin's configuration.
|
||||
are backwards incompatible changes. Returning None here disables the version tracking for the
|
||||
plugin's configuration.
|
||||
"""
|
||||
return None
|
||||
|
||||
@@ -1844,7 +1868,7 @@ class SettingsPlugin(OctoPrintPlugin):
|
||||
the differences to the defaults (in case the current data was persisted with an older
|
||||
version of OctoPrint that still duplicated default data).
|
||||
|
||||
..versionadded:: 1.3.0
|
||||
.. versionadded:: 1.3.0
|
||||
"""
|
||||
import octoprint.util
|
||||
from octoprint.settings import NoSuchSettingsPath
|
||||
@@ -1987,7 +2011,7 @@ class SlicerPlugin(OctoPrintPlugin):
|
||||
|
||||
Returns: (dict) a dictionary containing a valid extension subtree.
|
||||
|
||||
..versionadded:: 1.3.11
|
||||
.. versionadded:: 1.3.11
|
||||
"""
|
||||
from octoprint.filemanager import ContentTypeMapping
|
||||
|
||||
@@ -2004,7 +2028,7 @@ class SlicerPlugin(OctoPrintPlugin):
|
||||
Arguments:
|
||||
profile_path (str): The base folder where OctoPrint stores this slicer plugin's profiles
|
||||
|
||||
..versionadded:: 1.3.7
|
||||
.. versionadded:: 1.3.7
|
||||
"""
|
||||
|
||||
try:
|
||||
@@ -2029,7 +2053,7 @@ class SlicerPlugin(OctoPrintPlugin):
|
||||
# noinspection PyMethodMayBeStatic
|
||||
def get_slicer_profiles_lastmodified(self, profile_path):
|
||||
"""
|
||||
..versionadded:: 1.3.0
|
||||
.. versionadded:: 1.3.0
|
||||
"""
|
||||
import os
|
||||
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
<a id="navbar_show_prompt" class="pull-right" style="display: none" href="javascript:void(0)" data-bind="click: function() { showPrompt(); }, visible: active() && !visible()" title="{{ _('Message from your printer')|edq }}">
|
||||
<i class="far fa-commenting-dots"></i>
|
||||
<i class="far fa-comment-dots"></i>
|
||||
</a>
|
||||
@@ -31,7 +31,7 @@ $(function () {
|
||||
5
|
||||
);
|
||||
|
||||
self.unread = ko.observable();
|
||||
self.unread = ko.observable(false);
|
||||
self.hiddenChannels = [];
|
||||
self.channelNotifications = {};
|
||||
|
||||
|
||||
@@ -168,65 +168,14 @@ class BackupPlugin(
|
||||
@no_firstrun_access
|
||||
@Permissions.PLUGIN_BACKUP_ACCESS.require(403)
|
||||
def create_backup(self):
|
||||
backup_file = self._build_backup_filename(settings=self._settings)
|
||||
|
||||
data = flask.request.json
|
||||
exclude = data.get("exclude", [])
|
||||
filename = self._build_backup_filename(settings=self._settings)
|
||||
|
||||
def on_backup_start(name, temporary_path, exclude):
|
||||
self._logger.info(
|
||||
"Creating backup zip at {} (excluded: {})...".format(
|
||||
temporary_path, ",".join(exclude) if len(exclude) else "-"
|
||||
)
|
||||
)
|
||||
self._start_backup(exclude, filename)
|
||||
|
||||
with self._in_progress_lock:
|
||||
self._in_progress.append(name)
|
||||
self._send_client_message("backup_started", payload={"name": name})
|
||||
|
||||
def on_backup_done(name, final_path, exclude):
|
||||
with self._in_progress_lock:
|
||||
self._in_progress.remove(name)
|
||||
self._send_client_message("backup_done", payload={"name": name})
|
||||
|
||||
self._logger.info("... done creating backup zip.")
|
||||
|
||||
self._event_bus.fire(
|
||||
Events.PLUGIN_BACKUP_BACKUP_CREATED,
|
||||
{"name": name, "path": final_path, "excludes": exclude},
|
||||
)
|
||||
|
||||
def on_backup_error(name, exc_info):
|
||||
with self._in_progress_lock:
|
||||
try:
|
||||
self._in_progress.remove(name)
|
||||
except ValueError:
|
||||
# we'll ignore that
|
||||
pass
|
||||
|
||||
self._send_client_message(
|
||||
"backup_error", payload={"name": name, "error": "{}".format(exc_info[1])}
|
||||
)
|
||||
self._logger.error("Error while creating backup zip", exc_info=exc_info)
|
||||
|
||||
thread = threading.Thread(
|
||||
target=self._create_backup,
|
||||
args=(backup_file,),
|
||||
kwargs={
|
||||
"exclude": exclude,
|
||||
"settings": self._settings,
|
||||
"plugin_manager": self._plugin_manager,
|
||||
"logger": self._logger,
|
||||
"datafolder": self.get_plugin_data_folder(),
|
||||
"on_backup_start": on_backup_start,
|
||||
"on_backup_done": on_backup_done,
|
||||
"on_backup_error": on_backup_error,
|
||||
},
|
||||
)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
response = flask.jsonify(started=True, name=backup_file)
|
||||
response = flask.jsonify(started=True, name=filename)
|
||||
response.status_code = 201
|
||||
return response
|
||||
|
||||
@@ -234,18 +183,8 @@ class BackupPlugin(
|
||||
@no_firstrun_access
|
||||
@Permissions.PLUGIN_BACKUP_ACCESS.require(403)
|
||||
def delete_backup(self, filename):
|
||||
backup_folder = self.get_plugin_data_folder()
|
||||
full_path = os.path.realpath(os.path.join(backup_folder, filename))
|
||||
if (
|
||||
full_path.startswith(backup_folder)
|
||||
and os.path.exists(full_path)
|
||||
and not is_hidden_path(full_path)
|
||||
):
|
||||
try:
|
||||
os.remove(full_path)
|
||||
except Exception:
|
||||
self._logger.exception("Could not delete {}".format(filename))
|
||||
raise
|
||||
self._delete_backup(filename)
|
||||
|
||||
return NO_CONTENT
|
||||
|
||||
@octoprint.plugin.BlueprintPlugin.route("/restore", methods=["POST"])
|
||||
@@ -454,6 +393,76 @@ class BackupPlugin(
|
||||
# max upload size of 1GB for the restore endpoint
|
||||
return [("POST", r"/restore", 1024 * 1024 * 1024)]
|
||||
|
||||
# Exported plugin helpers
|
||||
def create_backup_helper(self, exclude=None, filename=None):
|
||||
"""
|
||||
.. versionadded:: 1.6.0
|
||||
|
||||
Create a backup from a plugin or other internal call
|
||||
|
||||
This helper is exported as ``create_backup`` and can be used from the plugin
|
||||
manager's ``get_helpers`` method.
|
||||
|
||||
**Example**
|
||||
|
||||
The following code snippet can be used from within a plugin, and will create a backup
|
||||
excluding two folders (``timelapse`` and ``uploads``)
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
helpers = self._plugin_manager.get_helpers("backup", "create_backup")
|
||||
|
||||
if helpers and "create_backup" in helpers:
|
||||
helpers["create_backup"](exclude=["timelapse", "uploads"])
|
||||
|
||||
By using the ``if helpers [...]`` clause, plugins can fall back to other methods
|
||||
when they are running under versions where these helpers did not exist.
|
||||
|
||||
|
||||
:param list exclude: Names of data folders to exclude, defaults to None
|
||||
:param str filename: Name of backup to be created, if None (default) the backup
|
||||
name will be auto-generated. This should use a ``.zip`` extension.
|
||||
"""
|
||||
if exclude is None:
|
||||
exclude = []
|
||||
if not isinstance(exclude, list):
|
||||
exclude = list(exclude)
|
||||
|
||||
self._start_backup(exclude, filename=filename)
|
||||
|
||||
def delete_backup_helper(self, filename):
|
||||
"""
|
||||
.. versionadded:: 1.6.0
|
||||
|
||||
Delete the specified backup from a plugin or other internal call
|
||||
|
||||
This helper is exported as ``delete_backup`` and can be used through the plugin
|
||||
manager's ``get_helpers`` method.
|
||||
|
||||
**Example**
|
||||
The following code snippet can be used from within a plugin, and will attempt to
|
||||
delete the backup named ``ExampleBackup.zip``.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
helpers = self._plugin_manager.get_helpers("backup", "delete_backup")
|
||||
|
||||
if helpers and "delete_backup" in helpers:
|
||||
helpers["delete_backup"]("ExampleBackup.zip")
|
||||
|
||||
By using the ``if helpers [...]`` clause, plugins can fall back to other methods
|
||||
when they are running under versions where these helpers did not exist.
|
||||
|
||||
.. warning::
|
||||
|
||||
This method will fail silently if the backup does not exist, and so
|
||||
it is recommended that you make sure the name comes from a verified source,
|
||||
for example the name from the events or other helpers.
|
||||
|
||||
:param str filename: The name of the backup to delete
|
||||
"""
|
||||
self._delete_backup(filename)
|
||||
|
||||
##~~ CLI hook
|
||||
|
||||
def cli_commands_hook(self, cli_group, pass_octoprint_ctx, *args, **kwargs):
|
||||
@@ -482,26 +491,24 @@ class BackupPlugin(
|
||||
)
|
||||
|
||||
if path is not None:
|
||||
datafolder, backup_file = os.path.split(os.path.abspath(path))
|
||||
datafolder, filename = os.path.split(os.path.abspath(path))
|
||||
else:
|
||||
backup_file = self._build_backup_filename(settings=settings)
|
||||
filename = self._build_backup_filename(settings=settings)
|
||||
datafolder = os.path.join(settings.getBaseFolder("data"), "backup")
|
||||
|
||||
if not os.path.isdir(datafolder):
|
||||
os.makedirs(datafolder)
|
||||
|
||||
click.echo("Creating backup at {}, please wait...".format(backup_file))
|
||||
click.echo("Creating backup at {}, please wait...".format(filename))
|
||||
self._create_backup(
|
||||
backup_file,
|
||||
filename,
|
||||
exclude=exclude,
|
||||
settings=settings,
|
||||
plugin_manager=cli_group.plugin_manager,
|
||||
datafolder=datafolder,
|
||||
)
|
||||
click.echo("Done.")
|
||||
click.echo(
|
||||
"Backup located at {}".format(os.path.join(datafolder, backup_file))
|
||||
)
|
||||
click.echo("Backup located at {}".format(os.path.join(datafolder, filename)))
|
||||
|
||||
@click.command("restore")
|
||||
@click.argument("path")
|
||||
@@ -638,6 +645,82 @@ class BackupPlugin(
|
||||
|
||||
##~~ helpers
|
||||
|
||||
def _start_backup(self, exclude, filename=None):
|
||||
if filename is None:
|
||||
filename = self._build_backup_filename(settings=self._settings)
|
||||
|
||||
def on_backup_start(name, temporary_path, exclude):
|
||||
self._logger.info(
|
||||
"Creating backup zip at {} (excluded: {})...".format(
|
||||
temporary_path, ",".join(exclude) if len(exclude) else "-"
|
||||
)
|
||||
)
|
||||
|
||||
with self._in_progress_lock:
|
||||
self._in_progress.append(name)
|
||||
self._send_client_message("backup_started", payload={"name": name})
|
||||
|
||||
def on_backup_done(name, final_path, exclude):
|
||||
with self._in_progress_lock:
|
||||
self._in_progress.remove(name)
|
||||
self._send_client_message("backup_done", payload={"name": name})
|
||||
|
||||
self._logger.info("... done creating backup zip.")
|
||||
|
||||
self._event_bus.fire(
|
||||
Events.PLUGIN_BACKUP_BACKUP_CREATED,
|
||||
{"name": name, "path": final_path, "excludes": exclude},
|
||||
)
|
||||
|
||||
def on_backup_error(name, exc_info):
|
||||
with self._in_progress_lock:
|
||||
try:
|
||||
self._in_progress.remove(name)
|
||||
except ValueError:
|
||||
# we'll ignore that
|
||||
pass
|
||||
|
||||
self._send_client_message(
|
||||
"backup_error", payload={"name": name, "error": "{}".format(exc_info[1])}
|
||||
)
|
||||
self._logger.error("Error while creating backup zip", exc_info=exc_info)
|
||||
|
||||
thread = threading.Thread(
|
||||
target=self._create_backup,
|
||||
args=(filename,),
|
||||
kwargs={
|
||||
"exclude": exclude,
|
||||
"settings": self._settings,
|
||||
"plugin_manager": self._plugin_manager,
|
||||
"logger": self._logger,
|
||||
"datafolder": self.get_plugin_data_folder(),
|
||||
"on_backup_start": on_backup_start,
|
||||
"on_backup_done": on_backup_done,
|
||||
"on_backup_error": on_backup_error,
|
||||
},
|
||||
)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
def _delete_backup(self, filename):
|
||||
"""
|
||||
Delete the backup specified
|
||||
Args:
|
||||
filename (str): Name of backup to delete
|
||||
"""
|
||||
backup_folder = self.get_plugin_data_folder()
|
||||
full_path = os.path.realpath(os.path.join(backup_folder, filename))
|
||||
if (
|
||||
full_path.startswith(backup_folder)
|
||||
and os.path.exists(full_path)
|
||||
and not is_hidden_path(full_path)
|
||||
):
|
||||
try:
|
||||
os.remove(full_path)
|
||||
except Exception:
|
||||
self._logger.exception("Could not delete {}".format(filename))
|
||||
raise
|
||||
|
||||
def _get_backups(self):
|
||||
backups = []
|
||||
for entry in scandir(self.get_plugin_data_folder()):
|
||||
@@ -1331,3 +1414,7 @@ __plugin_hooks__ = {
|
||||
"octoprint.events.register_custom_events": _register_custom_events,
|
||||
"octoprint.server.sockjs.emit": __plugin_implementation__.socket_emit_hook,
|
||||
}
|
||||
__plugin_helpers__ = {
|
||||
"create_backup": __plugin_implementation__.create_backup_helper,
|
||||
"delete_backup": __plugin_implementation__.delete_backup_helper,
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
OctoPrint comes preconfigured to perform the connectivity check every 15 minutes. You may change the value here.
|
||||
{% endtrans %}</p>
|
||||
|
||||
<form class="form-horizontal" data-bind="with: settingsViewModel, enable: !setup(), css {disabled: setup()}" onsubmit="return false;">
|
||||
<form class="form-horizontal" data-bind="with: settingsViewModel" onsubmit="return false;">
|
||||
{% include "snippets/settings/server/serverOnlineCheckInterval.jinja2" %}
|
||||
</form>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
trust and that has a high availability.
|
||||
{% endtrans %}</p>
|
||||
|
||||
<form class="form-horizontal" data-bind="with: settingsViewModel, enable: !setup(), css {disabled: setup()}" onsubmit="return false;">
|
||||
<form class="form-horizontal" data-bind="with: settingsViewModel" onsubmit="return false;">
|
||||
{% include "snippets/settings/server/serverOnlineCheckHost.jinja2" %}
|
||||
{% include "snippets/settings/server/serverOnlineCheckPort.jinja2" %}
|
||||
{% include "snippets/settings/server/serverOnlineCheckTestConnectivity.jinja2" %}
|
||||
@@ -34,7 +34,7 @@
|
||||
side with the general connectivity check, leave the field empty.
|
||||
{% endtrans %}</p>
|
||||
|
||||
<form class="form-horizontal" data-bind="with: settingsViewModel, enable: !setup(), css {disabled: setup()}" onsubmit="return false;">
|
||||
<form class="form-horizontal" data-bind="with: settingsViewModel" onsubmit="return false;">
|
||||
<div class="control-group">
|
||||
{% include "snippets/settings/server/serverOnlineCheckName.jinja2" %}
|
||||
{% include "snippets/settings/server/serverOnlineCheckTestResolution.jinja2" %}
|
||||
@@ -47,8 +47,12 @@
|
||||
{% endtrans %}</p>
|
||||
|
||||
<div class="row-fluid">
|
||||
<a href="#" class="btn span6" data-bind="click: function() { if(!setup()){disableOnlineCheck()}}, enable: !setup(), css: {disabled: setup()}">{{ _('Disable Connectivity Check') }}</a>
|
||||
<a href="#" class="btn btn-primary span6" data-bind="click: function() { if(!setup()){enableOnlineCheck()}}, enable: !setup(), css: {disabled: setup()}">{{ _('Enable Connectivity Check') }}</a>
|
||||
<a href="#" class="btn span6" data-bind="click: function() { if(!setup() || decision()){disableOnlineCheck()}}, enable: !setup() || decision(), css: {disabled: setup() && !decision()}">
|
||||
{{ _('Disable Connectivity Check') }}
|
||||
</a>
|
||||
<a href="#" class="btn btn-primary span6" data-bind="click: function() { if(!setup() || !decision()){enableOnlineCheck()}}, enable: !setup() || !decision(), css: {disabled: setup() && decision()}">
|
||||
{{ _('Enable Connectivity Check') }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="onlinecheck_decision" style="display: none" data-bind="visible: setup()">
|
||||
|
||||
@@ -17,8 +17,12 @@
|
||||
{% endtrans %}</p>
|
||||
|
||||
<div class="row-fluid">
|
||||
<a href="#" class="btn btn-danger span6" data-bind="click: function() { if(!setup()){disablePluginBlacklist()}}, enable: !setup(), css: {disabled: setup()}">{{ _('Disable Plugin Blacklist Processing') }}</a>
|
||||
<a href="#" class="btn btn-primary span6" data-bind="click: function() { if(!setup()){enablePluginBlacklist()}}, enable: !setup(), css: {disabled: setup()}">{{ _('Enable Plugin Blacklist Processing') }}</a>
|
||||
<a href="#" class="btn btn-danger span6" data-bind="click: function() { if(!setup() || decision()){disablePluginBlacklist()}}, enable: !setup() || decision(), css: {disabled: setup() && !decision()}">
|
||||
{{ _('Disable Plugin Blacklist Processing') }}
|
||||
</a>
|
||||
<a href="#" class="btn btn-primary span6" data-bind="click: function() { if(!setup() || !decision()){enablePluginBlacklist()}}, enable: !setup() || !decision(), css: {disabled: setup() && decision()}">
|
||||
{{ _('Enable Plugin Blacklist Processing') }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="pluginblacklist_decision" style="display: none" data-bind="visible: setup()">
|
||||
|
||||
@@ -21,10 +21,10 @@ from octoprint.util.version import (
|
||||
)
|
||||
|
||||
SENTRY_URL_SERVER = (
|
||||
"https://53f015cb6c3046088019baed6ff5b653@o118517.ingest.sentry.io/1373987"
|
||||
"https://c11d13d9e92046bca4691ad1658dc543@o118517.ingest.sentry.io/1373987"
|
||||
)
|
||||
SENTRY_URL_COREUI = (
|
||||
"https://993cc8f6848b4ccca8c66be5769ccb50@o118517.ingest.sentry.io/1374096"
|
||||
"https://a987a79a328e405a9545b8a036b420ee@o118517.ingest.sentry.io/1374096"
|
||||
)
|
||||
|
||||
SETTINGS_DEFAULTS = {
|
||||
|
||||
@@ -103,6 +103,9 @@ GCODE.renderer = (function () {
|
||||
" segments"
|
||||
);
|
||||
|
||||
applyOffsets(layerNumStore);
|
||||
applyZoom(layerNumStore);
|
||||
|
||||
notifyIfViewportChanged();
|
||||
|
||||
var p1 = ctx.transformedPoint(0, 0);
|
||||
@@ -144,6 +147,51 @@ GCODE.renderer = (function () {
|
||||
}
|
||||
};
|
||||
|
||||
function getLayerBounds(layer) {
|
||||
if (!model || !model[layer]) return;
|
||||
|
||||
var cmds = model[layer];
|
||||
var i = 0;
|
||||
|
||||
// find bounds based on x/y moves with extrusion only
|
||||
// if you want to change that criterion, this is the place to do it
|
||||
|
||||
while (i < cmds.length) {
|
||||
if (cmds[i].extrude && (cmds[i].x !== undefined || cmds[i].y !== undefined))
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i == cmds.length) return;
|
||||
|
||||
// initialize with guaranteed defined values and cut out a bunch of
|
||||
// testing for undefined cases
|
||||
var minX = cmds[i].prevX,
|
||||
maxX = cmds[i].prevX,
|
||||
minY = cmds[i].prevY,
|
||||
maxY = cmds[i].prevY;
|
||||
|
||||
while (i < cmds.length) {
|
||||
if (cmds[i].extrude && (cmds[i].x !== undefined || cmds[i].y !== undefined)) {
|
||||
minX = Math.min(minX, cmds[i].prevX);
|
||||
maxX = Math.max(maxX, cmds[i].prevX);
|
||||
if (cmds[i].x !== undefined) {
|
||||
minX = Math.min(minX, cmds[i].x);
|
||||
maxX = Math.max(maxX, cmds[i].x);
|
||||
}
|
||||
minY = Math.min(minY, cmds[i].prevY);
|
||||
maxY = Math.max(maxY, cmds[i].prevY);
|
||||
if (cmds[i].y !== undefined) {
|
||||
minY = Math.min(minY, cmds[i].y);
|
||||
maxY = Math.max(maxY, cmds[i].y);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return {minX: minX, maxX: maxX, minY: minY, maxY: maxY};
|
||||
}
|
||||
|
||||
function trackTransforms(ctx) {
|
||||
var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
||||
var xform = svg.createSVGMatrix();
|
||||
@@ -270,9 +318,6 @@ GCODE.renderer = (function () {
|
||||
if (renderOptions["onDrag"] && renderOptions["onDrag"](pt) === false)
|
||||
return;
|
||||
|
||||
ctx.translate(pt.x - dragStart.x, pt.y - dragStart.y);
|
||||
reRender();
|
||||
|
||||
renderOptions["centerViewport"] = false;
|
||||
renderOptions["zoomInOnModel"] = false;
|
||||
renderOptions["zoomInOnBed"] = false;
|
||||
@@ -283,6 +328,9 @@ GCODE.renderer = (function () {
|
||||
scaleX = 1;
|
||||
scaleY = 1;
|
||||
|
||||
ctx.translate(pt.x - dragStart.x, pt.y - dragStart.y);
|
||||
reRender();
|
||||
|
||||
if (renderOptions["onInternalOptionChange"] !== undefined) {
|
||||
renderOptions["onInternalOptionChange"]({
|
||||
centerViewport: false,
|
||||
@@ -326,9 +374,6 @@ GCODE.renderer = (function () {
|
||||
// return to old position
|
||||
ctx.translate(-pt.x, -pt.y);
|
||||
|
||||
// render
|
||||
reRender();
|
||||
|
||||
// disable conflicting options
|
||||
renderOptions["zoomInOnModel"] = false;
|
||||
renderOptions["zoomInOnBed"] = false;
|
||||
@@ -339,6 +384,9 @@ GCODE.renderer = (function () {
|
||||
scaleX = 1;
|
||||
scaleY = 1;
|
||||
|
||||
// render
|
||||
reRender();
|
||||
|
||||
if (renderOptions["onInternalOptionChange"] !== undefined) {
|
||||
renderOptions["onInternalOptionChange"]({
|
||||
zoomInOnModel: false,
|
||||
@@ -836,41 +884,41 @@ GCODE.renderer = (function () {
|
||||
}
|
||||
};
|
||||
|
||||
var applyOffsets = function () {
|
||||
var applyOffsets = function (layerNum) {
|
||||
var canvasCenter;
|
||||
|
||||
// determine bed and model offsets
|
||||
if (ctx) ctx.translate(-offsetModelX, -offsetModelY);
|
||||
if (renderOptions["centerViewport"] || renderOptions["zoomInOnModel"]) {
|
||||
canvasCenter = ctx.transformedPoint(canvas.width / 2, canvas.height / 2);
|
||||
if (modelInfo) {
|
||||
offsetModelX =
|
||||
canvasCenter.x -
|
||||
(modelInfo.boundingBox.minX + modelInfo.boundingBox.maxX) / 2;
|
||||
offsetModelY =
|
||||
canvasCenter.y -
|
||||
(modelInfo.boundingBox.minY + modelInfo.boundingBox.maxY) / 2;
|
||||
layerBounds = getLayerBounds(layerNum);
|
||||
if (layerBounds) {
|
||||
offsetModelX = canvasCenter.x - (layerBounds.minX + layerBounds.maxX) / 2;
|
||||
offsetModelY = canvasCenter.y - (layerBounds.minY + layerBounds.maxY) / 2;
|
||||
} else {
|
||||
offsetModelX = 0;
|
||||
offsetModelY = 0;
|
||||
}
|
||||
offsetBedX = 0;
|
||||
offsetBedY = 0;
|
||||
} else if (modelInfo && renderOptions["moveModel"]) {
|
||||
offsetModelX =
|
||||
renderOptions["bed"]["x"] / 2 -
|
||||
(modelInfo.boundingBox.minX + modelInfo.boundingBox.maxX) / 2;
|
||||
offsetModelY =
|
||||
renderOptions["bed"]["y"] / 2 -
|
||||
(modelInfo.boundingBox.minY + modelInfo.boundingBox.maxY) / 2;
|
||||
offsetBedX =
|
||||
-1 *
|
||||
(renderOptions["bed"]["x"] / 2 -
|
||||
(modelInfo.boundingBox.minX + modelInfo.boundingBox.maxX) / 2);
|
||||
offsetBedY =
|
||||
-1 *
|
||||
(renderOptions["bed"]["y"] / 2 -
|
||||
(modelInfo.boundingBox.minY + modelInfo.boundingBox.maxY) / 2);
|
||||
} else if (renderOptions["moveModel"]) {
|
||||
layerBounds = getLayerBounds(layerNum);
|
||||
if (layerBounds) {
|
||||
offsetModelX =
|
||||
renderOptions["bed"]["x"] / 2 -
|
||||
(layerBounds.minX + layerBounds.maxX) / 2;
|
||||
offsetModelY =
|
||||
renderOptions["bed"]["y"] / 2 -
|
||||
(layerBounds.minY + layerBounds.maxY) / 2;
|
||||
offsetBedX =
|
||||
-1 *
|
||||
(renderOptions["bed"]["x"] / 2 -
|
||||
(layerBounds.minX + layerBounds.maxX) / 2);
|
||||
offsetBedY =
|
||||
-1 *
|
||||
(renderOptions["bed"]["y"] / 2 -
|
||||
(layerBounds.minY + layerBounds.maxY) / 2);
|
||||
}
|
||||
} else if (
|
||||
renderOptions["bed"]["circular"] ||
|
||||
renderOptions["bed"]["centeredOrigin"]
|
||||
@@ -889,7 +937,7 @@ GCODE.renderer = (function () {
|
||||
if (ctx) ctx.translate(offsetModelX, offsetModelY);
|
||||
};
|
||||
|
||||
var applyZoom = function () {
|
||||
var applyZoom = function (layerNum) {
|
||||
// get middle of canvas
|
||||
var pt = ctx.transformedPoint(canvas.width / 2, canvas.height / 2);
|
||||
|
||||
@@ -904,28 +952,36 @@ GCODE.renderer = (function () {
|
||||
transform = ctx.getTransform();
|
||||
}
|
||||
|
||||
if (modelInfo && renderOptions["zoomInOnModel"]) {
|
||||
// if we need to zoom in on model, scale factor is calculated by longer side of object in relation to that axis of canvas
|
||||
var width = modelInfo.boundingBox.maxX - modelInfo.boundingBox.minX;
|
||||
var length = modelInfo.boundingBox.maxY - modelInfo.boundingBox.minY;
|
||||
if (renderOptions["zoomInOnModel"]) {
|
||||
var layerBounds = getLayerBounds(layerNum);
|
||||
if (layerBounds) {
|
||||
// if we need to zoom in on model, scale factor is calculated by longer side of object in relation to that axis of canvas
|
||||
// limited arbitrarily to 50 x extrusion width, to prevent extreme disorienting zoom
|
||||
var width = Math.max(
|
||||
layerBounds.maxX - layerBounds.minX,
|
||||
renderOptions["extrusionWidth"] * 50
|
||||
);
|
||||
var length = Math.max(
|
||||
layerBounds.maxY - layerBounds.minY,
|
||||
renderOptions["extrusionWidth"] * 50
|
||||
);
|
||||
|
||||
var scaleF =
|
||||
width > length
|
||||
? (canvas.width - 10) / width
|
||||
: (canvas.height - 10) / length;
|
||||
if (transform.a && transform.d) {
|
||||
scaleX =
|
||||
(scaleF / transform.a) * (renderOptions["invertAxes"]["x"] ? -1 : 1);
|
||||
scaleY =
|
||||
(scaleF / transform.d) * (renderOptions["invertAxes"]["y"] ? 1 : -1);
|
||||
ctx.translate(pt.x, pt.y);
|
||||
ctx.scale(scaleX, scaleY);
|
||||
ctx.translate(-pt.x, -pt.y);
|
||||
var scaleF =
|
||||
width > length
|
||||
? (canvas.width - 10) / width
|
||||
: (canvas.height - 10) / length;
|
||||
if (transform.a && transform.d) {
|
||||
scaleX =
|
||||
(scaleF / transform.a) *
|
||||
(renderOptions["invertAxes"]["x"] ? -1 : 1);
|
||||
scaleY =
|
||||
(scaleF / transform.d) *
|
||||
(renderOptions["invertAxes"]["y"] ? 1 : -1);
|
||||
ctx.translate(pt.x, pt.y);
|
||||
ctx.scale(scaleX, scaleY);
|
||||
ctx.translate(-pt.x, -pt.y);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// reset scale to 1
|
||||
scaleX = 1;
|
||||
scaleY = 1;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1085,8 +1141,8 @@ GCODE.renderer = (function () {
|
||||
}
|
||||
|
||||
applyInversion();
|
||||
applyOffsets();
|
||||
applyZoom();
|
||||
scaleX = 1;
|
||||
scaleY = 1;
|
||||
|
||||
this.render(layerNum, 0, toProgress);
|
||||
},
|
||||
|
||||
@@ -21,13 +21,6 @@ $(function () {
|
||||
return _.sortBy(self.availableLoggers());
|
||||
});
|
||||
|
||||
self.configuredLoggersSorted = ko.computed(function () {
|
||||
return _.sortBy(self.configuredLoggers(), function (o) {
|
||||
o.level();
|
||||
return o.component;
|
||||
});
|
||||
});
|
||||
|
||||
// initialize list helper
|
||||
self.listHelper = new ItemListHelper(
|
||||
"logFiles",
|
||||
@@ -104,11 +97,15 @@ $(function () {
|
||||
levels.push(item);
|
||||
configuredLoggers.push(logger);
|
||||
});
|
||||
let sortedLevels = _.sortBy(levels, function (o) {
|
||||
return o.component;
|
||||
});
|
||||
self.configuredLoggers(levels);
|
||||
|
||||
// loggers
|
||||
var availableLoggers = _.without(response.loggers, configuredLoggers);
|
||||
var availableLoggers = _.difference(response.loggers, configuredLoggers);
|
||||
self.availableLoggers(availableLoggers);
|
||||
self.configuredLoggersChanged = false;
|
||||
};
|
||||
|
||||
self.fromSerialLogResponse = function (response) {
|
||||
@@ -180,6 +177,9 @@ $(function () {
|
||||
}
|
||||
|
||||
var component = self.availableLoggersName();
|
||||
if (!component) {
|
||||
return;
|
||||
}
|
||||
var level = self.availableLoggersLevel();
|
||||
|
||||
self.configuredLoggers.push({
|
||||
@@ -273,7 +273,7 @@ $(function () {
|
||||
);
|
||||
};
|
||||
|
||||
self.onServerReconnect = self.onUserLoggedIn = self.onEventSettingsUpdated = function () {
|
||||
self.onServerReconnect = self.onUserLoggedIn = self.onEventSettingsUpdated = self.onSettingsShown = function () {
|
||||
if (
|
||||
!self.loginState.hasPermission(
|
||||
self.access.permissions.PLUGIN_LOGGING_MANAGE
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
<div class="span8"><h5>{{ _('Name') }}</h5></div>
|
||||
<div class="span2"><h5>{{ _('Level') }}</h5></div>
|
||||
</div>
|
||||
<div data-bind="foreach: configuredLoggersSorted">
|
||||
<div data-bind="foreach: configuredLoggers">
|
||||
<div class="row-fluid" style="margin-bottom: 5px">
|
||||
<div class="span8">
|
||||
<span data-bind="text: component"></span>
|
||||
@@ -91,7 +91,7 @@
|
||||
<div>
|
||||
<div class="row-fluid" style="margin-bottom: 5px">
|
||||
<div class="span8">
|
||||
<select class="input-block-level" data-bind="options: availableLoggersSorted, value: availableLoggersName"></select>
|
||||
<select class="input-block-level" data-bind="options: availableLoggersSorted, optionsCaption: '{{ _('Select a logger...') }}', value: availableLoggersName, event: { change: addLogger }"></select>
|
||||
</div>
|
||||
<div class="span3">
|
||||
<select class="input-medium" data-bind="value: availableLoggersLevel">
|
||||
@@ -102,9 +102,6 @@
|
||||
<option value="CRITICAL">CRITICAL</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="span1">
|
||||
<a title="{{ _('Add')|edq }}" class="btn btn-primary" data-bind="click: $root.addLogger"><i class="icon-plus"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -47,6 +47,8 @@ from octoprint.util.version import (
|
||||
is_python_compatible,
|
||||
)
|
||||
|
||||
from . import exceptions
|
||||
|
||||
try:
|
||||
from os import scandir
|
||||
except ImportError:
|
||||
@@ -378,28 +380,43 @@ class PluginManagerPlugin(
|
||||
)
|
||||
|
||||
ext = exts[0]
|
||||
archive = tempfile.NamedTemporaryFile(delete=False, suffix=ext)
|
||||
archive.close()
|
||||
shutil.copy(upload_path, archive.name)
|
||||
|
||||
archive = tempfile.NamedTemporaryFile(
|
||||
delete=False, suffix="{ext}".format(**locals())
|
||||
)
|
||||
try:
|
||||
archive.close()
|
||||
shutil.copy(upload_path, archive.name)
|
||||
return self.command_install(
|
||||
path=archive.name,
|
||||
name=upload_name,
|
||||
force="force" in flask.request.values
|
||||
and flask.request.values["force"] in valid_boolean_trues,
|
||||
)
|
||||
finally:
|
||||
def perform_install(source, name, force=False):
|
||||
try:
|
||||
os.remove(archive.name)
|
||||
except Exception as e:
|
||||
self._logger.warning(
|
||||
"Could not remove temporary file {path} again: {message}".format(
|
||||
path=archive.name, message=str(e)
|
||||
)
|
||||
self.command_install(
|
||||
path=source,
|
||||
name=name,
|
||||
force=force,
|
||||
)
|
||||
finally:
|
||||
try:
|
||||
os.remove(archive.name)
|
||||
except Exception as e:
|
||||
self._logger.warning(
|
||||
"Could not remove temporary file {path} again: {message}".format(
|
||||
path=archive.name, message=str(e)
|
||||
)
|
||||
)
|
||||
|
||||
with self._install_lock:
|
||||
if self._install_task is not None:
|
||||
return make_response("There's already a plugin being installed", 409)
|
||||
|
||||
self._install_task = threading.Thread(
|
||||
target=perform_install,
|
||||
args=(archive.name, upload_name),
|
||||
kwargs={
|
||||
"force": "force" in flask.request.values
|
||||
and flask.request.values["force"] in valid_boolean_trues
|
||||
},
|
||||
)
|
||||
self._install_task.daemon = True
|
||||
self._install_task.start()
|
||||
|
||||
return jsonify(in_progress=True)
|
||||
|
||||
@octoprint.plugin.BlueprintPlugin.route("/export", methods=["GET"])
|
||||
@no_firstrun_access
|
||||
@@ -536,7 +553,7 @@ class PluginManagerPlugin(
|
||||
|
||||
with self._install_lock:
|
||||
if self._install_task is not None:
|
||||
return make_response("There's always a plugin being installed", 409)
|
||||
return make_response("There's already a plugin being installed", 409)
|
||||
|
||||
self._install_task = threading.Thread(
|
||||
target=self.command_install,
|
||||
@@ -634,7 +651,7 @@ class PluginManagerPlugin(
|
||||
|
||||
# determine type of path
|
||||
if self._is_archive(path):
|
||||
return self._command_install_archive(
|
||||
result = self._command_install_archive(
|
||||
path,
|
||||
source=source,
|
||||
source_type=source_type,
|
||||
@@ -644,31 +661,60 @@ class PluginManagerPlugin(
|
||||
)
|
||||
|
||||
elif self._is_pythonfile(path):
|
||||
return self._command_install_pythonfile(
|
||||
result = self._command_install_pythonfile(
|
||||
path, source=source, source_type=source_type, name=name
|
||||
)
|
||||
|
||||
else:
|
||||
self._logger.error(
|
||||
"{} is neither an archive nor a python file, can't install that.".format(
|
||||
source
|
||||
)
|
||||
raise exceptions.InvalidPackageFormat()
|
||||
|
||||
except requests.exceptions.HTTPError as e:
|
||||
self._logger.error("Could not fetch plugin from server, got {}".format(e))
|
||||
result = {
|
||||
"result": False,
|
||||
"source": source,
|
||||
"source_type": source_type,
|
||||
"reason": "Could not fetch plugin from server, got {}".format(e),
|
||||
}
|
||||
self._send_result_notification("install", result)
|
||||
|
||||
except exceptions.InvalidPackageFormat:
|
||||
self._logger.error(
|
||||
"{} is neither an archive nor a python file, can't install that.".format(
|
||||
source
|
||||
)
|
||||
result = {
|
||||
"result": False,
|
||||
"source": source,
|
||||
"source_type": source_type,
|
||||
"reason": "Could not install plugin from {}, was neither "
|
||||
"a plugin archive nor a single file plugin".format(source),
|
||||
}
|
||||
self._send_result_notification("install", result)
|
||||
return result
|
||||
)
|
||||
result = {
|
||||
"result": False,
|
||||
"source": source,
|
||||
"source_type": source_type,
|
||||
"reason": "Could not install plugin from {}, was neither "
|
||||
"a plugin archive nor a single file plugin".format(source),
|
||||
}
|
||||
self._send_result_notification("install", result)
|
||||
|
||||
except Exception:
|
||||
error_msg = (
|
||||
"Unexpected error while trying to install plugin from {}".format(
|
||||
source
|
||||
)
|
||||
)
|
||||
self._logger.exception(error_msg)
|
||||
result = {
|
||||
"result": False,
|
||||
"source": source,
|
||||
"source_type": source_type,
|
||||
"reason": error_msg,
|
||||
}
|
||||
self._send_result_notification("install", result)
|
||||
|
||||
finally:
|
||||
if folder is not None:
|
||||
folder.cleanup()
|
||||
self._install_task = None
|
||||
|
||||
return result
|
||||
|
||||
# noinspection DuplicatedCode
|
||||
def _command_install_archive(
|
||||
self,
|
||||
@@ -687,11 +733,19 @@ class PluginManagerPlugin(
|
||||
and not self._settings.get_boolean(["ignore_throttled"])
|
||||
):
|
||||
# currently throttled, we refuse to run
|
||||
return make_response(
|
||||
"System is currently throttled, refusing to install "
|
||||
"anything due to possible stability issues",
|
||||
409,
|
||||
error_msg = (
|
||||
"System is currently throttled, refusing to install anything"
|
||||
" due to possible stability issues"
|
||||
)
|
||||
self._logger.error(error_msg)
|
||||
result = {
|
||||
"result": False,
|
||||
"source": source,
|
||||
"source_type": source_type,
|
||||
"reason": error_msg,
|
||||
}
|
||||
self._send_result_notification("install", result)
|
||||
return result
|
||||
|
||||
try:
|
||||
# Py3
|
||||
@@ -761,11 +815,20 @@ class PluginManagerPlugin(
|
||||
"Looks like the plugin was already installed. Forcing a reinstall."
|
||||
)
|
||||
force = True
|
||||
except Exception:
|
||||
self._logger.exception("Could not install plugin from %s" % source)
|
||||
return make_response(
|
||||
"Could not install plugin from URL, see the log for more details", 500
|
||||
)
|
||||
except Exception as e:
|
||||
self._logger.exception("Could not install plugin from {}".format(source))
|
||||
self._logger.exception("Reason: {}".format(repr(e)))
|
||||
result = {
|
||||
"result": False,
|
||||
"source": source,
|
||||
"source_type": source_type,
|
||||
"reason": "Could not install plugin from {}, see the log for more details".format(
|
||||
source
|
||||
),
|
||||
}
|
||||
self._send_result_notification("install", result)
|
||||
return result
|
||||
|
||||
else:
|
||||
if force:
|
||||
# We don't use --upgrade here because that will also happily update all our dependencies - we'd rather
|
||||
@@ -773,16 +836,21 @@ class PluginManagerPlugin(
|
||||
pip_args += ["--ignore-installed", "--force-reinstall", "--no-deps"]
|
||||
try:
|
||||
returncode, stdout, stderr = self._call_pip(pip_args)
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
self._logger.exception(
|
||||
"Could not install plugin from {}".format(source)
|
||||
)
|
||||
return make_response(
|
||||
"Could not install plugin from source {}, see the log for more details".format(
|
||||
self._logger.exception("Reason: {}".format(repr(e)))
|
||||
result = {
|
||||
"result": False,
|
||||
"source": source,
|
||||
"source_type": source_type,
|
||||
"reason": "Could not install plugin from source {}, see the log for more details".format(
|
||||
source
|
||||
),
|
||||
500,
|
||||
)
|
||||
}
|
||||
self._send_result_notification("install", result)
|
||||
return result
|
||||
|
||||
try:
|
||||
result_line = list(
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2020 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
|
||||
class InvalidPackageFormat(Exception):
|
||||
pass
|
||||
@@ -435,23 +435,30 @@ $(function () {
|
||||
},
|
||||
done: function (e, data) {
|
||||
var response = data.result;
|
||||
if (response.result) {
|
||||
self._markDone();
|
||||
} else {
|
||||
self._markDone(response.reason);
|
||||
if (!response.in_progress) {
|
||||
if (response.result) {
|
||||
self._markDone();
|
||||
} else {
|
||||
self._markDone(response.reason);
|
||||
}
|
||||
}
|
||||
|
||||
self.uploadButton.unbind("click");
|
||||
self.uploadFilename(undefined);
|
||||
},
|
||||
fail: function (e, data) {
|
||||
new PNotify({
|
||||
title: gettext("Something went wrong"),
|
||||
text: gettext("Please consult octoprint.log for details"),
|
||||
type: "error",
|
||||
hide: false
|
||||
});
|
||||
self._markDone("Could not install plugin, unknown error.");
|
||||
if (data && data.errorThrown === "CONFLICT") {
|
||||
// there's already a plugin being installed
|
||||
self._markDone("There's already another plugin install in progress.");
|
||||
} else {
|
||||
new PNotify({
|
||||
title: gettext("Something went wrong"),
|
||||
text: gettext("Please consult octoprint.log for details"),
|
||||
type: "error",
|
||||
hide: false
|
||||
});
|
||||
self._markDone("Could not install plugin, unknown error.");
|
||||
}
|
||||
self.uploadButton.unbind("click");
|
||||
self.uploadFilename(undefined);
|
||||
}
|
||||
@@ -823,16 +830,23 @@ $(function () {
|
||||
var onSuccess = function (response) {
|
||||
self.installUrl("");
|
||||
},
|
||||
onError = function () {
|
||||
self._markDone(
|
||||
"Could not install plugin, unknown error, please consult octoprint.log for details"
|
||||
);
|
||||
new PNotify({
|
||||
title: gettext("Something went wrong"),
|
||||
text: gettext("Please consult octoprint.log for details"),
|
||||
type: "error",
|
||||
hide: false
|
||||
});
|
||||
onError = function (jqXHR) {
|
||||
if (jqXHR.status === 409) {
|
||||
// there's already a plugin being installed
|
||||
self._markDone(
|
||||
"There's already another plugin install in progress."
|
||||
);
|
||||
} else {
|
||||
self._markDone(
|
||||
"Could not install plugin, unknown error, please consult octoprint.log for details"
|
||||
);
|
||||
new PNotify({
|
||||
title: gettext("Something went wrong"),
|
||||
text: gettext("Please consult octoprint.log for details"),
|
||||
type: "error",
|
||||
hide: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (reinstall) {
|
||||
|
||||
@@ -92,7 +92,7 @@ class SoftwareUpdatePlugin(
|
||||
self._environment_ready = threading.Event()
|
||||
|
||||
self._storage_sufficient = True
|
||||
self.storage_info = {}
|
||||
self._storage_info = {}
|
||||
|
||||
self._console_logger = None
|
||||
|
||||
|
||||
@@ -241,7 +241,8 @@ class TrackingPlugin(
|
||||
return
|
||||
|
||||
uptime = int(monotonic_time() - self._startup_time)
|
||||
self._track("ping", octoprint_uptime=uptime)
|
||||
printer_state = self._printer.get_state_id()
|
||||
self._track("ping", octoprint_uptime=uptime, printer_state=printer_state)
|
||||
|
||||
def _track_pong(self):
|
||||
if not self._settings.get_boolean(["events", "pong"]):
|
||||
|
||||
@@ -9,8 +9,14 @@
|
||||
</p>
|
||||
|
||||
<div class="row-fluid">
|
||||
<a href="javascript:void(0)" class="btn span6" data-bind="click: function() { if(!setup()){disableUsage()}}, enable: !setup(), css: {disabled: setup()}"><i class="fas fa-spinner fa-spin" style="display: none" data-bind="visible: active() && decision() === false"></i> {{ _('Disable Anonymous Usage Tracking') }}</a>
|
||||
<a href="javascript:void(0)" class="btn btn-primary span6" data-bind="click: function() { if(!setup()){enableUsage()}}, enable: !setup(), css: {disabled: setup()}"><i class="fas fa-spinner fa-spin" style="display: none" data-bind="visible: active() && decision() === true"></i> {{ _('Enable Anonymous Usage Tracking') }}</a>
|
||||
<a href="javascript:void(0)" class="btn span6" data-bind="click: function() { if(!setup() || decision()){disableUsage()}}, enable: !setup() || decision(), css: {disabled: setup() && !decision()}">
|
||||
<i class="fas fa-spinner fa-spin" style="display: none" data-bind="visible: active() && decision() === false"></i>
|
||||
{{ _('Disable Anonymous Usage Tracking') }}
|
||||
</a>
|
||||
<a href="javascript:void(0)" class="btn btn-primary span6" data-bind="click: function() { if(!setup() || !decision()){enableUsage()}}, enable: !setup() || !decision(), css: {disabled: setup() && decision()}">
|
||||
<i class="fas fa-spinner fa-spin" style="display: none" data-bind="visible: active() && decision() === true"></i>
|
||||
{{ _('Enable Anonymous Usage Tracking') }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="tracking_decision" style="display: none" data-bind="visible: setup()">
|
||||
|
||||
@@ -202,7 +202,7 @@ class VirtualPrinter(object):
|
||||
|
||||
self._received_lines = 0
|
||||
self._resend_every_n = 0
|
||||
self._calculate_resend_every_n(self._settings.get(["resend_ratio"]))
|
||||
self._calculate_resend_every_n(self._settings.get_int(["resend_ratio"]))
|
||||
|
||||
self._dont_answer = False
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import time
|
||||
from frozendict import frozendict
|
||||
from past.builtins import basestring, long
|
||||
|
||||
import octoprint.util.json
|
||||
from octoprint import util as util
|
||||
from octoprint.events import Events, eventManager
|
||||
from octoprint.filemanager import FileDestinations, NoSuchStorage, valid_file_type
|
||||
@@ -276,7 +277,13 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
try:
|
||||
additional = hook(initial=initial)
|
||||
if additional and isinstance(additional, dict):
|
||||
octoprint.util.json.dump({name: additional})
|
||||
plugin_data[name] = additional
|
||||
except ValueError:
|
||||
self._logger.exception(
|
||||
"Invalid additional data from plugin {}".format(name),
|
||||
extra={"plugin": name},
|
||||
)
|
||||
except Exception:
|
||||
self._logger.exception(
|
||||
"Error while retrieving additional data from plugin {}, blacklisting it for further loops".format(
|
||||
@@ -437,6 +444,15 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
if name is None or not name:
|
||||
raise ValueError("name must be set")
|
||||
|
||||
# .capitalize() will lowercase all letters but the first
|
||||
# this code preserves existing CamelCase
|
||||
event_name = name[0].upper() + name[1:]
|
||||
|
||||
event_start = "GcodeScript{}Running".format(event_name)
|
||||
payload = context.get("event", None) if isinstance(context, dict) else None
|
||||
|
||||
eventManager().fire(event_start, payload)
|
||||
|
||||
result = self._comm.sendGcodeScript(
|
||||
name,
|
||||
part_of_job=part_of_job,
|
||||
@@ -446,6 +462,9 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
if not result and must_be_set:
|
||||
raise UnknownScript(name)
|
||||
|
||||
event_end = "GcodeScript{}Finished".format(event_name)
|
||||
eventManager().fire(event_end, payload)
|
||||
|
||||
def jog(self, axes, relative=True, speed=None, *args, **kwargs):
|
||||
if isinstance(axes, basestring):
|
||||
# legacy parameter format, there should be an amount as first anonymous positional arguments too
|
||||
|
||||
@@ -720,6 +720,11 @@ class Server(object):
|
||||
app, util.flask.permission_validator, permissions.Permissions.WEBCAM
|
||||
),
|
||||
] + access_validators_from_plugins
|
||||
systeminfo_validators = [
|
||||
util.tornado.access_validation_factory(
|
||||
app, util.flask.permission_validator, permissions.Permissions.SYSTEM
|
||||
)
|
||||
] + access_validators_from_plugins
|
||||
|
||||
timelapse_permission_validator = {
|
||||
"access_validation": util.tornado.validation_chain(*timelapse_validators)
|
||||
@@ -733,6 +738,9 @@ class Server(object):
|
||||
camera_permission_validator = {
|
||||
"access_validation": util.tornado.validation_chain(*camera_validators)
|
||||
}
|
||||
systeminfo_permission_validator = {
|
||||
"access_validation": util.tornado.validation_chain(*systeminfo_validators)
|
||||
}
|
||||
|
||||
no_hidden_files_validator = {
|
||||
"path_validation": util.tornado.path_validation_factory(
|
||||
@@ -772,6 +780,7 @@ class Server(object):
|
||||
timelapse_path_validator,
|
||||
),
|
||||
),
|
||||
# uploaded printables
|
||||
(
|
||||
r"/downloads/files/local/(.*)",
|
||||
util.tornado.LargeResponseHandler,
|
||||
@@ -787,6 +796,7 @@ class Server(object):
|
||||
additional_mime_types,
|
||||
),
|
||||
),
|
||||
# log files
|
||||
(
|
||||
r"/downloads/logs/([^/]*)",
|
||||
util.tornado.LargeResponseHandler,
|
||||
@@ -800,6 +810,12 @@ class Server(object):
|
||||
log_permission_validator,
|
||||
),
|
||||
),
|
||||
# system info bundle
|
||||
(
|
||||
r"/downloads/systeminfo.zip",
|
||||
util.tornado.SystemInfoBundleHandler,
|
||||
systeminfo_permission_validator,
|
||||
),
|
||||
# camera snapshot
|
||||
(
|
||||
r"/downloads/camera/current",
|
||||
|
||||
@@ -311,6 +311,7 @@ def getSettings():
|
||||
"allowFraming": s.getBoolean(["server", "allowFraming"]),
|
||||
},
|
||||
"devel": {"pluginTimings": s.getBoolean(["devel", "pluginTimings"])},
|
||||
"slicing": {"defaultSlicer": s.get(["slicing", "defaultSlicer"])},
|
||||
}
|
||||
|
||||
gcode_scripts = s.listScripts("gcode")
|
||||
@@ -1027,6 +1028,10 @@ def _saveSettings(data):
|
||||
logging.getLogger("PLUGIN_TIMINGS").setLevel(logging.DEBUG)
|
||||
logging.getLogger("PLUGIN_TIMINGS").debug("Enabling plugin timings logging")
|
||||
|
||||
if "slicing" in data:
|
||||
if "defaultSlicer" in data["slicing"]:
|
||||
s.set(["slicing", "defaultSlicer"], data["slicing"]["defaultSlicer"])
|
||||
|
||||
if "plugins" in data:
|
||||
for plugin in octoprint.plugin.plugin_manager().get_implementations(
|
||||
octoprint.plugin.SettingsPlugin
|
||||
|
||||
@@ -612,7 +612,16 @@ def _local_networks():
|
||||
logger = logging.getLogger(__name__)
|
||||
local_networks = netaddr.IPSet([])
|
||||
for entry in settings().get(["accessControl", "localNetworks"]):
|
||||
network = netaddr.IPNetwork(entry)
|
||||
try:
|
||||
network = netaddr.IPNetwork(entry)
|
||||
except Exception:
|
||||
logger.warning(
|
||||
"Invalid network definition configured in localNetworks: {}".format(
|
||||
entry
|
||||
)
|
||||
)
|
||||
continue
|
||||
|
||||
local_networks.add(network)
|
||||
logger.debug("Added network {} to localNetworks".format(network))
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ __author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
import json
|
||||
import logging
|
||||
import threading
|
||||
import time
|
||||
@@ -27,7 +26,7 @@ from octoprint.access.permissions import Permissions
|
||||
from octoprint.access.users import LoginStatusListener
|
||||
from octoprint.events import Events
|
||||
from octoprint.settings import settings
|
||||
from octoprint.util.json import JsonEncoding
|
||||
from octoprint.util.json import dump as json_dump
|
||||
|
||||
|
||||
class ThreadSafeSession(octoprint.vendor.sockjs.tornado.session.Session):
|
||||
@@ -67,11 +66,7 @@ class ThreadSafeSession(octoprint.vendor.sockjs.tornado.session.Session):
|
||||
class JsonEncodingSessionWrapper(wrapt.ObjectProxy):
|
||||
def send_message(self, msg, stats=True, binary=False):
|
||||
self.send_jsonified(
|
||||
json.dumps(
|
||||
octoprint.vendor.sockjs.tornado.util.bytes_to_str(msg),
|
||||
separators=(",", ":"),
|
||||
default=JsonEncoding.encode,
|
||||
),
|
||||
json_dump(octoprint.vendor.sockjs.tornado.util.bytes_to_str(msg)),
|
||||
stats,
|
||||
)
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import tornado.iostream
|
||||
import tornado.tcpserver
|
||||
import tornado.util
|
||||
import tornado.web
|
||||
from past.builtins import unicode
|
||||
from past.builtins import basestring, unicode
|
||||
|
||||
import octoprint.util
|
||||
|
||||
@@ -1402,6 +1402,146 @@ class DeprecatedEndpointHandler(CorsSupportMixin, tornado.web.RequestHandler):
|
||||
options = _handle_method
|
||||
|
||||
|
||||
class StaticZipBundleHandler(CorsSupportMixin, tornado.web.RequestHandler):
|
||||
def initialize(
|
||||
self, files=None, as_attachment=True, attachment_name=None, access_validation=None
|
||||
):
|
||||
if files is None:
|
||||
files = []
|
||||
if as_attachment and not attachment_name:
|
||||
raise ValueError("attachment name must be set if as_attachment is True")
|
||||
|
||||
self._files = files
|
||||
self._as_attachment = as_attachment
|
||||
self._attachment_name = attachment_name
|
||||
self._access_validator = access_validation
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
if self._access_validator is not None:
|
||||
self._access_validator(self.request)
|
||||
return self.stream_zip(self._files)
|
||||
|
||||
def get_attachment_name(self):
|
||||
return self._attachment_name
|
||||
|
||||
# noinspection PyCompatibility
|
||||
def normalize_files(self, files):
|
||||
result = []
|
||||
for f in files:
|
||||
if isinstance(f, basestring):
|
||||
result.append({"path": f})
|
||||
elif isinstance(f, dict) and ("path" in f or "iter" in f or "content" in f):
|
||||
result.append(f)
|
||||
return result
|
||||
|
||||
@tornado.gen.coroutine
|
||||
def stream_zip(self, files):
|
||||
self.set_header("Content-Type", "application/zip")
|
||||
if self._as_attachment:
|
||||
self.set_header(
|
||||
"Content-Disposition",
|
||||
'attachment; filename="{}"'.format(self.get_attachment_name()),
|
||||
)
|
||||
|
||||
import zipstream
|
||||
|
||||
z = zipstream.ZipFile()
|
||||
for f in self.normalize_files(files):
|
||||
# noinspection PyCompatibility
|
||||
name = f.get("name")
|
||||
path = f.get("path")
|
||||
iter = f.get("iter")
|
||||
content = f.get("content")
|
||||
|
||||
if path:
|
||||
z.write(path, arcname=name, compress_type=zipstream.ZIP_STORED)
|
||||
elif iter and name:
|
||||
z.write_iter(name, iter, compress_type=zipstream.ZIP_STORED)
|
||||
elif content and name:
|
||||
z.writestr(name, content, compress_type=zipstream.ZIP_STORED)
|
||||
|
||||
for chunk in z:
|
||||
try:
|
||||
self.write(chunk)
|
||||
yield self.flush()
|
||||
except tornado.iostream.StreamClosedError:
|
||||
return
|
||||
|
||||
|
||||
class SystemInfoBundleHandler(StaticZipBundleHandler):
|
||||
# noinspection PyMethodOverriding
|
||||
def initialize(self, access_validation=None):
|
||||
self._as_attachment = True
|
||||
self._attachment_name = "octoprint-systeminfo-{datetime}.zip"
|
||||
self._access_validator = access_validation
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
if self._access_validator is not None:
|
||||
self._access_validator(self.request)
|
||||
|
||||
from octoprint.cli.systeminfo import get_systeminfo
|
||||
from octoprint.server import (
|
||||
connectivityChecker,
|
||||
environmentDetector,
|
||||
printer,
|
||||
safe_mode,
|
||||
)
|
||||
from octoprint.settings import settings
|
||||
from octoprint.util import dict_flatten
|
||||
|
||||
systeminfo = get_systeminfo(environmentDetector, connectivityChecker)
|
||||
systeminfo["browser.user_agent"] = self.request.headers.get("User-Agent")
|
||||
systeminfo["octoprint.safe_mode"] = safe_mode is not None
|
||||
|
||||
terminaltxt = None
|
||||
if printer and printer.is_operational():
|
||||
firmware_info = printer.firmware_info
|
||||
if firmware_info:
|
||||
systeminfo.update(
|
||||
dict_flatten({"firmware": firmware_info["name"]}, prefix="printer")
|
||||
)
|
||||
|
||||
if hasattr(printer, "_log"):
|
||||
terminaltxt = list(printer._log)
|
||||
|
||||
logbase = settings().getBaseFolder("logs")
|
||||
|
||||
systeminfotxt = []
|
||||
for k in sorted(systeminfo.keys()):
|
||||
systeminfotxt.append("{}: {}".format(k, systeminfo[k]))
|
||||
|
||||
files = [
|
||||
{
|
||||
"name": "systeminfo.txt",
|
||||
"content": octoprint.util.to_bytes("\n".join(systeminfotxt)),
|
||||
},
|
||||
{"path": os.path.join(logbase, "octoprint.log"), "name": "octoprint.log"},
|
||||
{"path": os.path.join(logbase, "serial.log"), "name": "serial.log"},
|
||||
{
|
||||
"path": os.path.join(logbase, "plugin_softwareupdate_console.log"),
|
||||
"name": "plugin_softwareupdate_console.log",
|
||||
},
|
||||
{
|
||||
"path": os.path.join(logbase, "plugin_pluginmanager_console.log"),
|
||||
"name": "plugin_pluginmanager_console.log",
|
||||
},
|
||||
]
|
||||
if terminaltxt is not None:
|
||||
files.append(
|
||||
{
|
||||
"name": "terminal.txt",
|
||||
"content": octoprint.util.to_bytes("\n".join(terminaltxt)),
|
||||
}
|
||||
)
|
||||
|
||||
return self.stream_zip(files)
|
||||
|
||||
def get_attachment_name(self):
|
||||
import time
|
||||
|
||||
return "octoprint-systeminfo-{}.zip".format(time.strftime("%Y%m%d%H%M%S"))
|
||||
|
||||
|
||||
class GlobalHeaderTransform(tornado.web.OutputTransform):
|
||||
|
||||
HEADERS = {}
|
||||
|
||||
@@ -616,14 +616,16 @@ def index():
|
||||
if plugin is not None and isinstance(
|
||||
plugin.implementation, octoprint.plugin.UiPlugin
|
||||
):
|
||||
permissions = plugin.get_ui_permissions()
|
||||
permissions = plugin.implementation.get_ui_permissions()
|
||||
response = require_login(*permissions)
|
||||
if not response:
|
||||
response = plugin_view(plugin.implementation)
|
||||
if _logger.isEnabledFor(logging.DEBUG) and isinstance(
|
||||
response, Response
|
||||
):
|
||||
response.headers["X-Ui-Plugin"] = plugin._identifier
|
||||
response.headers[
|
||||
"X-Ui-Plugin"
|
||||
] = plugin.implementation._identifier
|
||||
else:
|
||||
response = require_login(*default_permissions)
|
||||
if not response:
|
||||
|
||||
@@ -365,7 +365,11 @@ default_settings = {
|
||||
"plugin_pi_support",
|
||||
],
|
||||
"usersettings": ["access", "interface"],
|
||||
"wizard": ["plugin_backup", "plugin_corewizard_acl"],
|
||||
"wizard": [
|
||||
"plugin_backup",
|
||||
"plugin_corewizard_acl",
|
||||
"plugin_corewizard_onlinecheck",
|
||||
],
|
||||
"about": [
|
||||
"about",
|
||||
"plugin_pi_support",
|
||||
|
||||
@@ -1 +1 @@
|
||||
.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn.active,.btn:active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:focus,.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class*=" icon-"],.btn-large [class^=icon-]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class*=" icon-"],.btn-small [class^=icon-]{margin-top:0}.btn-mini [class*=" icon-"],.btn-mini [class^=icon-]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type=submit].btn-block,input[type=reset].btn-block,input[type=button].btn-block{width:100%}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary.active,.btn-primary:active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning.active,.btn-warning:active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#da4f49;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-repeaLine truncated
|
||||
.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,0.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top, #fff, #e6e6e6);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#fff), to(#e6e6e6));background-image:-webkit-linear-gradient(top, #fff, #e6e6e6);background-image:-o-linear-gradient(top, #fff, #e6e6e6);background-image:linear-gradient(to bottom, #fff, #e6e6e6);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05)}.btn:hover,.btn:focus,.btn:active,.btn.active,.btn.disabled,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn:active,.btn.active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:hover,.btn:focus{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class^="icon-"],.btn-large [class*=" icon-"]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class^="icon-"],.btn-small [class*=" icon-"]{margin-top:0}.btn-mini [class^="icon-"],.btn-mini [class*=" icon-"]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type="submit"].btn-block,input[type="reset"].btn-block,input[type="button"].btn-block{width:100%}.btn-primary.active,.btn-warning.active,.btn-danger.active,.btn-success.active,.btn-info.active,.btn-inverse.active{color:rgba(255,255,255,0.75)}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#006dcc;background-image:-moz-linear-gradient(top, #08c, #04c);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#08c), to(#04c));background-image:-webkit-linear-gradient(top, #08c, #04c);background-image:-o-linear-gradient(top, #08c, #04c);background-image:linear-gradient(to bottom, #08c, #04c);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0044cc', GradientType=0);border-color:#04c #04c #002a80;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false)}.btn-primary:hover,.btn-primary:focus,.btn-primary:active,.btn-primary.active,.btn-primary.disabled,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary:active,.btn-primary.active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#faa732;background-image:-moz-linear-gradient(top, #fbb450, #f89406);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406));background-image:-webkit-linear-gradient(top, #fbb450, #f89406);background-image:-o-linear-gradient(top, #fbb450, #f89406);background-image:linear-gradient(to bottom, #fbb450, #f89406);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0);border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false)}.btnLine truncated
|
||||
@@ -1592,3 +1592,27 @@ var loadFromLocalStorage = function (key) {
|
||||
}
|
||||
return current;
|
||||
};
|
||||
|
||||
var deepMerge = function (target, source) {
|
||||
/**
|
||||
* Implements an object deep merge, which contrary to _.merge doesn't try to
|
||||
* merge arrays.
|
||||
*/
|
||||
if (!_.isObject(target)) {
|
||||
return target;
|
||||
}
|
||||
|
||||
_.forOwn(source, function (value, key) {
|
||||
if (
|
||||
target.hasOwnProperty(key) &&
|
||||
_.isPlainObject(target[key]) &&
|
||||
_.isPlainObject(value)
|
||||
) {
|
||||
target[key] = deepMerge(target[key], value);
|
||||
} else {
|
||||
target[key] = value;
|
||||
}
|
||||
});
|
||||
|
||||
return target;
|
||||
};
|
||||
@@ -406,7 +406,7 @@ $(function () {
|
||||
self.addTerminalFilter = function () {
|
||||
self.terminalFilters.push({
|
||||
name: "New",
|
||||
regex: "(Send: (Nd+s+)?M105)|(Recv:s+(oks+)?.*(B|Td*):d+)"
|
||||
regex: "(Send:\\s+(N\\d+\\s+)?M105)|(Recv:\\s+(ok\\s+)?.*(B|T\\d*):\\d+)"
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1142,7 +1142,7 @@ $(function () {
|
||||
// process all key-value-pairs here
|
||||
_.forOwn(data, function (value, key) {
|
||||
var observable = key;
|
||||
if (keyPrefix != undefined) {
|
||||
if (keyPrefix !== undefined) {
|
||||
observable = keyPrefix + "_" + observable;
|
||||
}
|
||||
|
||||
@@ -1161,7 +1161,7 @@ $(function () {
|
||||
mapping && mapping[key] ? mapping[key] : undefined,
|
||||
observable
|
||||
);
|
||||
if (subresult != undefined) {
|
||||
if (subresult !== undefined) {
|
||||
// we only set something on our result if we got something back
|
||||
result[key] = subresult;
|
||||
flag = true;
|
||||
@@ -1179,7 +1179,7 @@ $(function () {
|
||||
// map local observables based on our existing data
|
||||
var dataFromObservables = mapFromObservables(data, specialMappings);
|
||||
|
||||
data = _.merge(data, dataFromObservables);
|
||||
data = deepMerge(data, dataFromObservables);
|
||||
return data;
|
||||
};
|
||||
|
||||
|
||||
@@ -79,6 +79,8 @@ $(function () {
|
||||
self.save = function () {
|
||||
if (!CONFIG_ACCESS_CONTROL) return;
|
||||
|
||||
self.userSettingsDialog.trigger("beforeSave");
|
||||
|
||||
if (self.access_password() && !self.passwordMismatch()) {
|
||||
self.users.updatePassword(
|
||||
self.currentUser().name,
|
||||
@@ -162,6 +164,9 @@ $(function () {
|
||||
self.userSettingsDialog.on("hidden", function () {
|
||||
callViewModels(allViewModels, "onUserSettingsHidden");
|
||||
});
|
||||
self.userSettingsDialog.on("beforeSave", function () {
|
||||
callViewModels(allViewModels, "onUserSettingsBeforeSave");
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,3 +1,3 @@
|
||||
/*! modernizr 3.6.0 (Custom Build) | MIT *
|
||||
* https://modernizr.com/download/?-canvas-localstorage-svg-touchevents-webgl-setclasses !*/
|
||||
!function(e,t,n){function o(e,t){return typeof e===t}function a(){var e,t,n,a,s,r,i;for(var l in f)if(f.hasOwnProperty(l)){if(e=[],t=f[l],t.name&&(e.push(t.name.toLowerCase()),t.options&&t.options.aliases&&t.options.aliases.length))for(n=0;n<t.options.aliases.length;n++)e.push(t.options.aliases[n].toLowerCase());for(a=o(t.fn,"function")?t.fn():t.fn,s=0;s<e.length;s++)r=e[s],i=r.split("."),1===i.length?Modernizr[i[0]]=a:(!Modernizr[i[0]]||Modernizr[i[0]]instanceof Boolean||(Modernizr[i[0]]=new Boolean(Modernizr[i[0]])),Modernizr[i[0]][i[1]]=a),c.push((a?"":"no-")+i.join("-"))}}function s(e){var t=u.className,n=Modernizr._config.classPrefix||"";if(p&&(t=t.baseVal),Modernizr._config.enableJSClass){var o=new RegExp("(^|\\s)"+n+"no-js(\\s|$)");t=t.replace(o,"$1"+n+"js$2")}Modernizr._config.enableClasses&&(t+=" "+n+e.join(" "+n),p?u.className.baseVal=t:u.className=t)}function r(){return"function"!=typeof t.createElement?t.createElement(arguments[0]):p?t.createElementNS.call(t,"http://www.w3.org/2000/svg",arguments[0]):t.createElement.apply(t,arguments)}function i(){var e=t.body;return e||(e=r(p?"svg":"body"),e.fake=!0),e}function l(e,n,o,a){var s,l,c,f,d="modernizr",p=r("div"),v=i();if(parseInt(o,10))for(;o--;)c=r("div"),c.id=a?a[o]:d+(o+1),p.appendChild(c);return s=r("style"),s.type="text/css",s.id="s"+d,(v.fake?v:p).appendChild(s),v.appendChild(p),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(t.createTextNode(e)),p.id=d,v.fake&&(v.style.background="",v.style.overflow="hidden",f=u.style.overflow,u.style.overflow="hidden",u.appendChild(v)),l=n(p,e),v.fake?(v.parentNode.removeChild(v),u.style.overflow=f,u.offsetHeight):p.parentNode.removeChild(p),!!l}var c=[],f=[],d={_version:"3.6.0",_config:{classPrefix:"",enableClasses:!0,enableJSClass:!0,usePrefixes:!0},_q:[],on:function(e,t){var n=this;setTimeout(function(){t(n[e])},0)},addTest:function(e,t,n){f.push({name:e,fn:t,options:n})},addAsyncTest:function(e){f.push({name:null,fn:e})}},Modernizr=function(){};Modernizr.prototype=d,Modernizr=new Modernizr,Modernizr.addTest("svg",!!t.createElementNS&&!!t.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect),Modernizr.addTest("localstorage",function(){var e="modernizr";try{return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(t){return!1}});var u=t.documentElement,p="svg"===u.nodeName.toLowerCase();Modernizr.addTest("canvas",function(){var e=r("canvas");return!(!e.getContext||!e.getContext("2d"))}),Modernizr.addTest("webgl",function(){var t=r("canvas"),n="probablySupportsContext"in t?"probablySupportsContext":"supportsContext";return n in t?t[n]("webgl")||t[n]("experimental-webgl"):"WebGLRenderingContext"in e});var v=d._config.usePrefixes?" -webkit- -moz- -o- -ms- ".split(" "):["",""];d._prefixes=v;var m=d.testStyles=l;Modernizr.addTest("touchevents",function(){var n;if("ontouchstart"in e||e.DocumentTouch&&t instanceof DocumentTouch)n=!0;else{var o=["@media (",v.join("touch-enabled),("),"heartz",")","{#modernizr{top:9px;position:absolute}}"].join("");m(o,function(e){n=9===e.offsetTop})}return n}),a(),s(c),delete d.addTest,delete d.addAsyncTest;for(var g=0;g<Modernizr._q.length;g++)Modernizr._q[g]();e.Modernizr=Modernizr}(window,document);
|
||||
/*! modernizr 3.11.0 (Custom Build) | MIT *
|
||||
* https://modernizr.com/download/?-canvas-fetch-localstorage-svg-touchevents-webgl-setclasses !*/
|
||||
!function(e,t,n,o){function a(e,t){return typeof e===t}function r(){return"function"!=typeof n.createElement?n.createElement(arguments[0]):p?n.createElementNS.call(n,"http://www.w3.org/2000/svg",arguments[0]):n.createElement.apply(n,arguments)}function s(){var e=n.body;return e||(e=r(p?"svg":"body"),e.fake=!0),e}function i(e,t,o,a){var i,l,c,u,d="modernizr",p=r("div"),v=s();if(parseInt(o,10))for(;o--;)c=r("div"),c.id=a?a[o]:d+(o+1),p.appendChild(c);return i=r("style"),i.type="text/css",i.id="s"+d,(v.fake?v:p).appendChild(i),v.appendChild(p),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(n.createTextNode(e)),p.id=d,v.fake&&(v.style.background="",v.style.overflow="hidden",u=f.style.overflow,f.style.overflow="hidden",f.appendChild(v)),l=t(p,e),v.fake?(v.parentNode.removeChild(v),f.style.overflow=u,f.offsetHeight):p.parentNode.removeChild(p),!!l}function l(e,n,o){var a;if("getComputedStyle"in t){a=getComputedStyle.call(t,e,n);var r=t.console;if(null!==a)o&&(a=a.getPropertyValue(o));else if(r){var s=r.error?"error":"log";r[s].call(r,"getComputedStyle returning null, its possible modernizr test results are inaccurate")}}else a=!n&&e.currentStyle&&e.currentStyle[o];return a}var c=[],u={_version:"3.11.0",_config:{classPrefix:"",enableClasses:!0,enableJSClass:!0,usePrefixes:!0},_q:[],on:function(e,t){var n=this;setTimeout(function(){t(n[e])},0)},addTest:function(e,t,n){c.push({name:e,fn:t,options:n})},addAsyncTest:function(e){c.push({name:null,fn:e})}},Modernizr=function(){};Modernizr.prototype=u,Modernizr=new Modernizr;var d=[],f=n.documentElement,p="svg"===f.nodeName.toLowerCase();Modernizr.addTest("canvas",function(){var e=r("canvas");return!(!e.getContext||!e.getContext("2d"))}),Modernizr.addTest("localstorage",function(){var e="modernizr";try{return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return!1}}),Modernizr.addTest("svg",!!n.createElementNS&&!!n.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect),Modernizr.addTest("webgl",function(){return"WebGLRenderingContext"in t}),Modernizr.addTest("fetch","fetch"in t);var v=u._config.usePrefixes?" -webkit- -moz- -o- -ms- ".split(" "):["",""];u._prefixes=v;var h=function(){var e=t.matchMedia||t.msMatchMedia;return e?function(t){var n=e(t);return n&&n.matches||!1}:function(e){var t=!1;return i("@media "+e+" { #modernizr { position: absolute; } }",function(e){t="absolute"===l(e,null,"position")}),t}}();u.mq=h,Modernizr.addTest("touchevents",function(){if("ontouchstart"in t||t.TouchEvent||t.DocumentTouch&&n instanceof DocumentTouch)return!0;var e=["(",v.join("touch-enabled),("),"heartz",")"].join("");return h(e)}),function(){var e,t,n,o,r,s,i;for(var l in c)if(c.hasOwnProperty(l)){if(e=[],t=c[l],t.name&&(e.push(t.name.toLowerCase()),t.options&&t.options.aliases&&t.options.aliases.length))for(n=0;n<t.options.aliases.length;n++)e.push(t.options.aliases[n].toLowerCase());for(o=a(t.fn,"function")?t.fn():t.fn,r=0;r<e.length;r++)s=e[r],i=s.split("."),1===i.length?Modernizr[i[0]]=o:(Modernizr[i[0]]&&(!Modernizr[i[0]]||Modernizr[i[0]]instanceof Boolean)||(Modernizr[i[0]]=new Boolean(Modernizr[i[0]])),Modernizr[i[0]][i[1]]=o),d.push((o?"":"no-")+i.join("-"))}}(),function(e){var t=f.className,n=Modernizr._config.classPrefix||"";if(p&&(t=t.baseVal),Modernizr._config.enableJSClass){var o=new RegExp("(^|\\s)"+n+"no-js(\\s|$)");t=t.replace(o,"$1"+n+"js$2")}Modernizr._config.enableClasses&&(e.length>0&&(t+=" "+n+e.join(" "+n)),p?f.className.baseVal=t:f.className=t)}(d),delete u.addTest,delete u.addAsyncTest;for(var m=0;m<Modernizr._q.length;m++)Modernizr._q[m]();e.Modernizr=Modernizr}(window,window,document);
|
||||
@@ -1010,7 +1010,7 @@ ul.dropdown-menu li a {
|
||||
}
|
||||
|
||||
#footer_version,
|
||||
#footer_link {
|
||||
#footer_links {
|
||||
max-width: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,7 @@
|
||||
<strong data-bind="text: key"></strong>: <span data-bind="text: value"></span><br />
|
||||
</p>
|
||||
|
||||
<a href="javascript:void(0)" data-bind="click: copySystemInfo"><i class="far fa-copy"></i> {{ _('Copy') }}</a>
|
||||
|
||||
<a href="{{ url_for('index', _external=True) }}downloads/systeminfo.zip" class="btn btn-primary"><i class="fas fa-download"></i> {{ _('Download Systeminfo Bundle') }}</a>
|
||||
|
||||
<a href="javascript:void(0)" class="btn" data-bind="click: copySystemInfo"><i class="far fa-copy"></i> {{ _('Copy') }}</a>
|
||||
@@ -6,12 +6,22 @@ __copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms
|
||||
|
||||
|
||||
import collections
|
||||
import json
|
||||
|
||||
import frozendict
|
||||
|
||||
from octoprint.util import to_unicode
|
||||
|
||||
|
||||
def dump(obj):
|
||||
return json.dumps(
|
||||
obj,
|
||||
separators=(",", ":"),
|
||||
default=JsonEncoding.encode,
|
||||
allow_nan=False,
|
||||
)
|
||||
|
||||
|
||||
class JsonEncoding(object):
|
||||
|
||||
encoders = collections.OrderedDict()
|
||||
|
||||
+33
-46
@@ -6,7 +6,6 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agp
|
||||
__copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
|
||||
import io
|
||||
import logging
|
||||
import os
|
||||
import site
|
||||
@@ -16,7 +15,7 @@ import threading
|
||||
import pkg_resources
|
||||
import sarge
|
||||
|
||||
from octoprint.util import to_native_str, to_unicode
|
||||
from octoprint.util import to_unicode
|
||||
from octoprint.util.platform import CLOSE_FDS
|
||||
|
||||
from .commandline import CommandlineCaller, clean_ansi
|
||||
@@ -412,18 +411,9 @@ class PipCaller(CommandlineCaller):
|
||||
# variables, we can't for stuff like third party software we allow to update via the software
|
||||
# update plugin.
|
||||
#
|
||||
# What we do instead for these situations is try to install (and of course uninstall) the
|
||||
# testballoon dummy package, which collects that information for us. For pip <= 7 we could
|
||||
# have the testballoon provide us with the info needed through stdout, if pip was called
|
||||
# with --verbose anything printed to stdout within setup.py would be output. Pip 8 managed
|
||||
# to break this mechanism. Any (!) output within setup.py appears to be suppressed now, and
|
||||
# no combination of --log and multiple --verbose or -v arguments could get it to bring the
|
||||
# output back.
|
||||
#
|
||||
# So here's what we do now instead. Our sarge call sets an environment variable
|
||||
# "TESTBALLOON_OUTPUT" that points to a temporary file. If the testballoon sees that
|
||||
# variable set, it opens the file and writes to it the output it so far printed on stdout.
|
||||
# We then open the file and read in the data that way.
|
||||
# What we do instead for these situations is try to install the testballoon dummy package, which
|
||||
# collects that information for us. The install fails expectedly and pip prints the required
|
||||
# information together with its STDOUT (until pip v19) or STDERR (from pip v20 on).
|
||||
#
|
||||
# Yeah, I'm not happy with that either. But as long as there's no way to otherwise figure
|
||||
# out for a generic pip command whether OctoPrint can even install anything with that
|
||||
@@ -435,36 +425,33 @@ class PipCaller(CommandlineCaller):
|
||||
os.path.realpath(os.path.dirname(__file__)), "piptestballoon"
|
||||
)
|
||||
|
||||
from octoprint.util import temppath
|
||||
sarge_command = self.to_sarge_command(pip_command, "install", ".")
|
||||
try:
|
||||
# our testballoon is no real package, so this command will fail - that's ok though,
|
||||
# we only need the output produced within the pip environment
|
||||
p = sarge.run(
|
||||
sarge_command,
|
||||
close_fds=CLOSE_FDS,
|
||||
stdout=sarge.Capture(),
|
||||
stderr=sarge.Capture(),
|
||||
cwd=testballoon,
|
||||
)
|
||||
except Exception:
|
||||
self._logger.exception(
|
||||
"Error while trying to install testballoon to figure out pip setup"
|
||||
)
|
||||
return False, False, False, None
|
||||
|
||||
with temppath() as testballoon_output_file:
|
||||
sarge_command = self.to_sarge_command(pip_command, "install", ".")
|
||||
try:
|
||||
# our testballoon is no real package, so this command will fail - that's ok though,
|
||||
# we only need the output produced within the pip environment
|
||||
sarge.run(
|
||||
sarge_command,
|
||||
close_fds=CLOSE_FDS,
|
||||
stdout=sarge.Capture(),
|
||||
stderr=sarge.Capture(),
|
||||
cwd=testballoon,
|
||||
env={
|
||||
to_native_str("TESTBALLOON_OUTPUT"): to_native_str(
|
||||
testballoon_output_file
|
||||
)
|
||||
},
|
||||
)
|
||||
except Exception:
|
||||
self._logger.exception(
|
||||
"Error while trying to install testballoon to figure out pip setup"
|
||||
)
|
||||
return False, False, False, None
|
||||
|
||||
data = {}
|
||||
with io.open(testballoon_output_file, "rt", encoding="utf-8") as f:
|
||||
for line in f:
|
||||
key, value = line.split("=", 2)
|
||||
data[key] = value
|
||||
output = p.stdout.text + p.stderr.text
|
||||
data = {}
|
||||
for line in output.split("\n"):
|
||||
if (
|
||||
"PIP_INSTALL_DIR=" in line
|
||||
or "PIP_VIRTUAL_ENV=" in line
|
||||
or "PIP_WRITABLE=" in line
|
||||
):
|
||||
key, value = line.split("=", 2)
|
||||
data[key.strip()] = value.strip()
|
||||
|
||||
install_dir_str = data.get("PIP_INSTALL_DIR", None)
|
||||
virtual_env_str = data.get("PIP_VIRTUAL_ENV", None)
|
||||
@@ -475,9 +462,9 @@ class PipCaller(CommandlineCaller):
|
||||
and virtual_env_str is not None
|
||||
and writable_str is not None
|
||||
):
|
||||
install_dir = install_dir_str.strip()
|
||||
virtual_env = virtual_env_str.strip() == "True"
|
||||
writable = writable_str.strip() == "True"
|
||||
install_dir = install_dir_str
|
||||
virtual_env = virtual_env_str == "True"
|
||||
writable = writable_str == "True"
|
||||
|
||||
can_use_user_flag = not virtual_env and site.ENABLE_USER_SITE
|
||||
|
||||
|
||||
@@ -9,52 +9,36 @@ whether the install location is writable by the current user), and for that it
|
||||
only needs to be invoked by pip, the pip call doesn't have to be successful
|
||||
however.
|
||||
|
||||
If an environment variable "TESTBALLOON_OUTPUT" is set, it will be used as location
|
||||
to write a file with the figured out data to. Simply writing to stdout (the default
|
||||
behaviour if no such environment variable is set) is sadly not going to work out
|
||||
with versions of pip > 8.0.0, which capture all stdout output regardless of used
|
||||
--verbose or --log flags.
|
||||
Any output (STDOUT and STDERR) produced by this script is captured by pip and,
|
||||
until pip v19, printed via its STDOUT, from pip v20 on, via its STDERR. The
|
||||
parsing script hence needs to capture both to support all pip versions.
|
||||
"""
|
||||
|
||||
import io
|
||||
import os
|
||||
import sys
|
||||
from distutils.command.install import install as cmd_install
|
||||
from distutils.dist import Distribution
|
||||
|
||||
cmd = cmd_install(Distribution())
|
||||
cmd.finalize_options()
|
||||
|
||||
def produce_output(stream):
|
||||
from distutils.command.install import install as cmd_install
|
||||
from distutils.dist import Distribution
|
||||
install_dir = cmd.install_lib
|
||||
virtual_env = hasattr(sys, "real_prefix") or (
|
||||
hasattr(sys, "base_prefix") and sys.base_prefix != sys.prefix
|
||||
)
|
||||
writable = os.access(install_dir, os.W_OK)
|
||||
|
||||
cmd = cmd_install(Distribution())
|
||||
cmd.finalize_options()
|
||||
lines = [
|
||||
"PIP_INSTALL_DIR={}".format(install_dir),
|
||||
"PIP_VIRTUAL_ENV={}".format(virtual_env),
|
||||
"PIP_WRITABLE={}".format(writable),
|
||||
]
|
||||
|
||||
install_dir = cmd.install_lib
|
||||
virtual_env = hasattr(sys, "real_prefix") or (
|
||||
hasattr(sys, "base_prefix") and sys.base_prefix != sys.prefix
|
||||
)
|
||||
writable = os.access(install_dir, os.W_OK)
|
||||
# write to stdout
|
||||
for line in lines:
|
||||
print(line, file=sys.stdout)
|
||||
|
||||
lines = [
|
||||
"PIP_INSTALL_DIR={}".format(install_dir),
|
||||
"PIP_VIRTUAL_ENV={}".format(virtual_env),
|
||||
"PIP_WRITABLE={}".format(writable),
|
||||
]
|
||||
|
||||
for line in lines:
|
||||
print(line, file=stream)
|
||||
|
||||
stream.flush()
|
||||
|
||||
|
||||
path = os.environ.get("TESTBALLOON_OUTPUT", None)
|
||||
if path is not None:
|
||||
# environment variable set, write to a log
|
||||
path = os.path.abspath(path)
|
||||
with io.open(path, "wt+", encoding="utf-8") as output:
|
||||
produce_output(output)
|
||||
else:
|
||||
# write to stdout
|
||||
produce_output(sys.stdout)
|
||||
sys.stdout.flush()
|
||||
|
||||
# fail intentionally
|
||||
sys.exit(-1)
|
||||
Generated
+261
-254
File diff suppressed because it is too large.
Load diff
@@ -22,6 +22,7 @@
|
||||
"cypress-file-upload": "^4.0.7",
|
||||
"cypress-plugin-retries": "^1.5.2",
|
||||
"cypress-terminal-report": "^1.4.1",
|
||||
"cypress-wait-until": "^1.7.1"
|
||||
"cypress-wait-until": "^1.7.1",
|
||||
"ini": "^2.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2021 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
import unittest
|
||||
|
||||
from mock import ANY, MagicMock, call, patch
|
||||
|
||||
from octoprint.printer.standard import Printer
|
||||
|
||||
|
||||
class ScriptsTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# mock comm
|
||||
self.comm = MagicMock()
|
||||
|
||||
# mock event manager
|
||||
self.event_manager = MagicMock()
|
||||
|
||||
self.event_manager_patcher = patch("octoprint.printer.standard.eventManager")
|
||||
self.event_manager_getter = self.event_manager_patcher.start()
|
||||
self.event_manager_getter.return_value = self.event_manager
|
||||
|
||||
# mock plugin manager
|
||||
self.plugin_manager = MagicMock()
|
||||
self.plugin_manager.get_hooks.return_value = {}
|
||||
|
||||
self.plugin_manager_patcher = patch("octoprint.printer.standard.plugin_manager")
|
||||
self.plugin_manager_getter = self.plugin_manager_patcher.start()
|
||||
self.plugin_manager_getter.return_value = self.plugin_manager
|
||||
|
||||
# mock settings
|
||||
self.settings = MagicMock()
|
||||
self.settings.getInt.return_value = 1
|
||||
self.settings.getBoolean.return_value = False
|
||||
|
||||
self.settings_patcher = patch("octoprint.printer.standard.settings")
|
||||
self.settings_getter = self.settings_patcher.start()
|
||||
self.settings_getter.return_value = self.settings
|
||||
|
||||
self.printer = Printer(MagicMock(), MagicMock(), MagicMock())
|
||||
self.printer._comm = self.comm
|
||||
|
||||
def tearDown(self):
|
||||
self.settings_patcher.stop()
|
||||
self.plugin_manager_patcher.stop()
|
||||
self.event_manager_patcher.stop()
|
||||
|
||||
def test_event_name(self):
|
||||
self.printer.script("testEvent")
|
||||
|
||||
self.event_manager.fire.assert_any_call("GcodeScriptTestEventRunning", ANY)
|
||||
|
||||
def test_event_order(self):
|
||||
self.printer.script("EventOrder")
|
||||
|
||||
expected_order = [
|
||||
call("GcodeScriptEventOrderRunning", ANY),
|
||||
call("GcodeScriptEventOrderFinished", ANY),
|
||||
]
|
||||
|
||||
self.event_manager.fire.assert_has_calls(expected_order)
|
||||
|
||||
def test_payload_handling(self):
|
||||
expected_paylod = {"payloadKey": "payloadValue"}
|
||||
context = {"event": expected_paylod}
|
||||
|
||||
self.printer.script("GetPayload", context)
|
||||
|
||||
self.event_manager.fire.assert_called_with(ANY, expected_paylod)
|
||||
|
||||
self.printer.script("WrongPayload", [])
|
||||
|
||||
self.event_manager.fire.assert_called_with(ANY, None)
|
||||
|
||||
self.printer.script("WrongContext", {"noEvent": {}})
|
||||
|
||||
self.event_manager.fire.assert_called_with(ANY, None)
|
||||
Reference in new issue
Block a user