Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
475a9f38ee | ||
|
|
0e5fda992b | ||
|
|
6a69a76edd | ||
|
|
d9c6e21c2e | ||
|
|
f12f75c9b7 | ||
|
|
8c1111cfef | ||
|
|
2222f1d204 | ||
|
|
35ec968973 | ||
|
|
fc53dab0b7 | ||
|
|
ceb85d3b77 | ||
|
|
c59c161d96 | ||
|
|
f027aaa730 | ||
|
|
cf86f08d04 | ||
|
|
c4fab1b7e6 | ||
|
|
fd1c6b2e7d | ||
|
|
b366ab4653 | ||
|
|
8b2f915cac | ||
|
|
e9f5b93901 | ||
|
|
7a8ebdfe2c | ||
|
|
78cacf6a0e | ||
|
|
fba5f9073d | ||
|
|
c2515f62e3 | ||
|
|
731fa83083 | ||
|
|
b7c0a4ca75 | ||
|
|
c32677caf5 | ||
|
|
ec13ebb642 | ||
|
|
3dce6ae949 | ||
|
|
ed4db2453e | ||
|
|
dd3ce4e7ed | ||
|
|
1d519a2170 | ||
|
|
584483a23a | ||
|
|
d08393d450 | ||
|
|
a39be1d2d3 | ||
|
|
c847ed9d13 | ||
|
|
fb75e911e6 | ||
|
|
e3c09568fd | ||
|
|
c0c6b6829a | ||
|
|
388e45ae11 | ||
|
|
f5e3588357 | ||
|
|
9d94889a45 | ||
|
|
fc19f5bd4a | ||
|
|
93667604f9 | ||
|
|
100cb872ad | ||
|
|
89dac1ce12 | ||
|
|
da3ab33a0a | ||
|
|
168ba50274 | ||
|
|
c1688774c9 | ||
|
|
b0a1884982 | ||
|
|
cb8aa9b07c | ||
|
|
afaf80fac6 | ||
|
|
2397867d28 | ||
|
|
0753c1ef6f | ||
|
|
2a50c109d6 | ||
|
|
93e495f921 | ||
|
|
498eeb2faf | ||
|
|
0c966efe73 | ||
|
|
423d3d9a18 | ||
|
|
460fc8342e | ||
|
|
e4d3803b2f | ||
|
|
ec4e75e672 | ||
|
|
9ba981a2ea | ||
|
|
67719d98b3 | ||
|
|
ea28a4d902 | ||
|
|
a22f93193c | ||
|
|
600e7ca42b | ||
|
|
ff28dd9f26 | ||
|
|
12dd7fbff6 | ||
|
|
510b699503 | ||
|
|
f640542c75 | ||
|
|
2596a99a24 | ||
|
|
17c3e7a875 | ||
|
|
10d550466e | ||
|
|
e7ee1d8046 | ||
|
|
c1b658e374 | ||
|
|
6cd28614d5 | ||
|
|
fecf4ba1d8 | ||
|
|
3b897defd4 | ||
|
|
4ac94e099e | ||
|
|
c5b5af3c1c | ||
|
|
57ff7be3af | ||
|
|
fdd1eff4c2 | ||
|
|
8baf2c3f44 | ||
|
|
eb9c96003a | ||
|
|
4f3937de09 | ||
|
|
add76c821c | ||
|
|
16c8647e21 | ||
|
|
0f922283f8 | ||
|
|
a6de25e864 | ||
|
|
0d733b8c2e | ||
|
|
df60defca7 | ||
|
|
cf7f72e240 | ||
|
|
1ae36c9aff | ||
|
|
a4b0d340a7 | ||
|
|
c1c1cccc56 | ||
|
|
f88bae066c | ||
|
|
44e38f0fcd | ||
|
|
cc6c208899 | ||
|
|
9487e4d0b2 | ||
|
|
ed798e4c6f | ||
|
|
fe73d0d93c | ||
|
|
bb519ae88b | ||
|
|
a2fcb1cf2f | ||
|
|
4cc41b05ea | ||
|
|
9dbf0e6bd4 | ||
|
|
65f53f3d86 | ||
|
|
658c5578e2 | ||
|
|
ba54bd3006 | ||
|
|
0ce7930653 | ||
|
|
48b13d550c | ||
|
|
f5e90a1aa4 | ||
|
|
3a7919149c | ||
|
|
a5ab135f82 | ||
|
|
95e87eb197 | ||
|
|
00bffb1efe | ||
|
|
3b2769310d | ||
|
|
5f3478279b | ||
|
|
013b5fff92 | ||
|
|
0fcb15d875 | ||
|
|
cd955e9a46 | ||
|
|
5fd8ea61e6 | ||
|
|
b416ff9766 | ||
|
|
04ff3c33e1 | ||
|
|
efe9c68e9a | ||
|
|
01cdb5e18c | ||
|
|
486a172211 | ||
|
|
084b5bfdd9 | ||
|
|
8f7ed765df | ||
|
|
8f6ba79a86 | ||
|
|
24677639f2 | ||
|
|
1613aef58e | ||
|
|
eedcfc0ac3 | ||
|
|
8e4c1f5246 | ||
|
|
d813a0cc86 | ||
|
|
7489b3c398 | ||
|
|
6e009d2544 | ||
|
|
59054cc1e5 | ||
|
|
b820719fc7 | ||
|
|
924a01128b | ||
|
|
8fe132bd32 | ||
|
|
b78fbc91cc | ||
|
|
a4d90b55d2 | ||
|
|
d1efcb75e6 | ||
|
|
88b99a4444 | ||
|
|
2231e81efd | ||
|
|
dc45341303 | ||
|
|
121b8c5e2c | ||
|
|
dc41ab1974 | ||
|
|
220bf41cb8 | ||
|
|
fcb9eaebda | ||
|
|
f02ce51960 | ||
|
|
e5845726f8 | ||
|
|
b151152c00 | ||
|
|
decf25d83e | ||
|
|
a1d95dd44b | ||
|
|
c01216cfab | ||
|
|
a47b5187bb | ||
|
|
40d71f1242 | ||
|
|
3088c3be0b | ||
|
|
135249c554 | ||
|
|
9c49a1caa6 | ||
|
|
814c3a1519 | ||
|
|
281599ecd9 | ||
|
|
f026da0a35 | ||
|
|
2f12c7f650 | ||
|
|
f03631f043 | ||
|
|
0b273c96aa | ||
|
|
5c942be033 | ||
|
|
52f4d6c231 | ||
|
|
e2eadd124b | ||
|
|
dce7a330d7 | ||
|
|
ac9e2b19cb | ||
|
|
45d612fecc | ||
|
|
1d0a2287f8 | ||
|
|
61195f0676 | ||
|
|
eb89369c6f | ||
|
|
d8dc8131a2 | ||
|
|
eaa890ab12 | ||
|
|
d20b6e70de | ||
|
|
cc0f1e29f7 | ||
|
|
13365e1f81 | ||
|
|
9f0c66d790 | ||
|
|
462d281a61 | ||
|
|
44b085abf6 | ||
|
|
fffd862c2b | ||
|
|
b38b50f4b4 | ||
|
|
db2ca0b353 | ||
|
|
fd7b282ede | ||
|
|
8da9e1e9e8 | ||
|
|
c7dee8d67d | ||
|
|
94408fd2dd | ||
|
|
bbd4dd5a23 | ||
|
|
923c2e14be | ||
|
|
7c42913205 | ||
|
|
4334939ea2 | ||
|
|
45d2e0e119 | ||
|
|
a25355072c | ||
|
|
241ec251a2 | ||
|
|
68191cfbf4 | ||
|
|
c5b56ae11b | ||
|
|
cc47b41bae | ||
|
|
397de4e3a7 | ||
|
|
e335055a98 | ||
|
|
8398073334 | ||
|
|
f2ad1654a4 | ||
|
|
20c1a408c4 | ||
|
|
06e32c211f | ||
|
|
58e1556eb0 | ||
|
|
c1211b23d2 | ||
|
|
cdc7ae594c | ||
|
|
58086a2928 |
No files matched your search
@@ -1,22 +1,4 @@
|
||||
parserOptions:
|
||||
ecmaVersion: 2018
|
||||
|
||||
overrides:
|
||||
- files:
|
||||
- "src/octoprint/static/js/**.js"
|
||||
- "src/octoprint/plugins/**.js"
|
||||
env:
|
||||
browser: true
|
||||
jquery: true
|
||||
es6: true
|
||||
- files:
|
||||
- "tests/cypress/**"
|
||||
env:
|
||||
node: true
|
||||
es6: true
|
||||
cypress/globals: true
|
||||
extends:
|
||||
- "plugin:cypress/recommended"
|
||||
|
||||
plugins:
|
||||
- cypress
|
||||
env:
|
||||
browser: true
|
||||
jquery: true
|
||||
es2018: true
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
# pre-commit version updates
|
||||
b4f265d9f67508677e1697e74e248b895da7f43c
|
||||
2231e81efd32d649798f7a58cdb1755e34902d8a
|
||||
|
||||
# Switch to black formatting
|
||||
1f93b2355a2816918e11a55e61b42010d15a6720
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
version: 2
|
||||
updates:
|
||||
# Check for updates to GitHub Actions every week
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
@@ -4,10 +4,14 @@ devel:
|
||||
enableRateLimiter: false
|
||||
enableCsrfProtection: false
|
||||
plugins:
|
||||
virtual_printer:
|
||||
enabled: true
|
||||
softwareupdate:
|
||||
checks:
|
||||
octoprint:
|
||||
disabled: true
|
||||
tracking:
|
||||
enabled: false
|
||||
virtual_printer:
|
||||
enabled: true
|
||||
server:
|
||||
firstRun: false
|
||||
onlineCheck:
|
||||
|
||||
@@ -15,7 +15,10 @@ meta:
|
||||
ci/cd:
|
||||
- ".github/fixtures/**/*"
|
||||
- ".github/workflows/*"
|
||||
- ".github/dependabot.yml"
|
||||
- ".github/issue-validation.yml"
|
||||
- ".github/labeler.yml"
|
||||
- ".github/pr-validation.yml"
|
||||
|
||||
docker:
|
||||
- ".github/workflows/trigger_docker.yml"
|
||||
|
||||
@@ -2,9 +2,17 @@ approve_label: "approved"
|
||||
problem_label: "needs some work"
|
||||
ignore_label: "skip validation"
|
||||
|
||||
allowed_targets: ["maintenance", "devel", "staging/maintenance", "staging/devel"]
|
||||
allowed_targets:
|
||||
["maintenance", "devel", "staging/bugfix", "staging/maintenance", "staging/devel"]
|
||||
forbidden_sources:
|
||||
["master", "maintenance", "devel", "staging/maintenance", "staging/devel"]
|
||||
[
|
||||
"master",
|
||||
"maintenance",
|
||||
"devel",
|
||||
"staging/bugfix",
|
||||
"staging/maintenance",
|
||||
"staging/devel"
|
||||
]
|
||||
|
||||
labels:
|
||||
docs:
|
||||
|
||||
@@ -73,7 +73,7 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
- name: 🏗 Set up test dependencies
|
||||
run: |
|
||||
npm -g install node-qunit-puppeteer@2.1.0
|
||||
npm -g install node-qunit-puppeteer@2.1.2
|
||||
- name: 🚀 Run helpers.js test suite
|
||||
run: |
|
||||
node-qunit-puppeteer tests/static/js/test-helpers.html
|
||||
@@ -110,7 +110,6 @@ jobs:
|
||||
name: 🧪 E2E tests
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
steps:
|
||||
- name: ⬇ Checkout code
|
||||
uses: actions/checkout@v3
|
||||
@@ -120,11 +119,13 @@ jobs:
|
||||
with:
|
||||
name: dist
|
||||
path: dist
|
||||
|
||||
- name: 🏗 Set up Python 3.7
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: 3.7
|
||||
- name: 🚀 Install wheel
|
||||
|
||||
- name: 🏗 Install OctoPrint build
|
||||
run: |
|
||||
pip install dist/OctoPrint-*-py2.py3-none-any.whl
|
||||
|
||||
@@ -133,30 +134,63 @@ jobs:
|
||||
mkdir e2econfig
|
||||
cp -r .github/fixtures/with_acl/* e2econfig
|
||||
|
||||
- name: 🚀 Run Cypress
|
||||
uses: cypress-io/github-action@v4.2.0
|
||||
with:
|
||||
working-directory: tests/cypress
|
||||
browser: chrome
|
||||
start: "octoprint -b ${{ github.workspace }}/e2econfig serve --host 127.0.0.1 --port 5000"
|
||||
wait-on: "http://127.0.0.1:5000/online.txt"
|
||||
env:
|
||||
CYPRESS_DEPLOYSENTINEL_ENABLED: "true"
|
||||
CYPRESS_DEPLOYSENTINEL_UPLOAD_ON_PASSES: "true"
|
||||
CYPRESS_DEPLOYSENTINEL_KEY: ${{ secrets.DEPLOYSENTINEL_APIKEY }}
|
||||
- name: 🏗 Prepare Playwright env
|
||||
working-directory: ./tests/playwright
|
||||
run: |
|
||||
npm ci
|
||||
PLAYWRIGHT_VERSION=$(npm ls --json @playwright/test | jq --raw-output '.dependencies["@playwright/test"].version')
|
||||
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
|
||||
|
||||
- name: ⬆ Upload screenshots
|
||||
- name: 🧰 Cache Playwright browser binaries
|
||||
uses: actions/cache@v3
|
||||
id: playwright-cache
|
||||
with:
|
||||
path: "~/.cache/ms-playwright"
|
||||
key: "${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}"
|
||||
restore-keys: |
|
||||
${{ runner.os }}-playwright-
|
||||
|
||||
- name: 🏗 Install Playwright browser binaries & OS dependencies
|
||||
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
||||
working-directory: ./tests/playwright
|
||||
run: |
|
||||
npx playwright install --with-deps
|
||||
|
||||
- name: 🏗 Install Playwright OS dependencies
|
||||
if: steps.playwright-cache.outputs.cache-hit == 'true'
|
||||
working-directory: ./tests/playwright
|
||||
run: |
|
||||
npx playwright install-deps
|
||||
|
||||
- name: 🎭 Run Playwright
|
||||
working-directory: ./tests/playwright
|
||||
run: |
|
||||
npx playwright test
|
||||
env:
|
||||
OCTOPRINT_SERVER_BASE: ${{ github.workspace }}/e2econfig
|
||||
|
||||
- name: 🔎 Check octoprint.log for errors
|
||||
run: |
|
||||
log=${{ github.workspace }}/e2econfig/logs/octoprint.log
|
||||
if grep "\- ERROR \-" $log; then
|
||||
echo "::error::Errors were logged to octoprint.log"
|
||||
grep -Pazo '(?m)^\N+\- ERROR \-\N*\n(^\N*?\n)*?(?=\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3} \- )' $log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: ⬆ Upload Playwright report
|
||||
uses: actions/upload-artifact@v3
|
||||
if: always()
|
||||
with:
|
||||
name: playwright-report
|
||||
path: tests/playwright/playwright-report
|
||||
|
||||
- name: ⬆ Upload OctoPrint logs
|
||||
uses: actions/upload-artifact@v3
|
||||
if: failure()
|
||||
with:
|
||||
name: cypress-screenshots
|
||||
path: tests/cypress/screenshots
|
||||
- name: ⬆ Upload videos
|
||||
uses: actions/upload-artifact@v1
|
||||
if: always()
|
||||
with:
|
||||
name: cypress-videos
|
||||
path: tests/cypress/videos
|
||||
name: octoprint-logs
|
||||
path: ${{ github.workspace }}/e2econfig/logs
|
||||
|
||||
publish-on-testpypi:
|
||||
name: 📦 Publish on TestPyPI
|
||||
@@ -175,7 +209,7 @@ jobs:
|
||||
name: dist
|
||||
path: dist
|
||||
- name: 📦 Publish to index
|
||||
uses: pypa/gh-action-pypi-publish@master
|
||||
uses: pypa/gh-action-pypi-publish@release/v1
|
||||
continue-on-error: true
|
||||
with:
|
||||
password: ${{ secrets.testpypi_password }}
|
||||
@@ -193,7 +227,7 @@ jobs:
|
||||
name: dist
|
||||
path: dist
|
||||
- name: 📦 Publish to index
|
||||
uses: pypa/gh-action-pypi-publish@master
|
||||
uses: pypa/gh-action-pypi-publish@release/v1
|
||||
with:
|
||||
password: ${{ secrets.pypi_password }}
|
||||
|
||||
@@ -208,7 +242,7 @@ jobs:
|
||||
OCTOPRINT_VERSION=$(echo $GITHUB_REF | cut -d/ -f3)
|
||||
echo "OCTOPRINT_VERSION=$OCTOPRINT_VERSION" >> $GITHUB_ENV
|
||||
- name: 🚀 Repository Dispatch
|
||||
uses: peter-evans/repository-dispatch@v1
|
||||
uses: peter-evans/repository-dispatch@v2
|
||||
with:
|
||||
token: ${{ secrets.REPODISPATCH_TOKEN }}
|
||||
repository: OctoPrint/OctoPi-UpToDate
|
||||
|
||||
@@ -10,11 +10,11 @@ jobs:
|
||||
name: 🔒 Lock issues & PRs closed over a year
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: dessant/lock-threads@v2
|
||||
- uses: dessant/lock-threads@v4
|
||||
with:
|
||||
github-token: ${{ github.token }}
|
||||
issue-lock-comment: ""
|
||||
pr-lock-comment: ""
|
||||
issue-comment: ""
|
||||
pr-comment: ""
|
||||
|
||||
cleanup:
|
||||
name: 🧹 Close issues marked as incomplete & older than 14 days
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
steps:
|
||||
- id: date
|
||||
run: |
|
||||
echo "::set-output name=CUTOFF::`date --date='14 days ago' +'%Y-%m-%d'`"
|
||||
echo "CUTOFF=`date --date='14 days ago' +'%Y-%m-%d'`" >> $GITHUB_OUTPUT
|
||||
- uses: OctoPrint/actions/close-by-query@main
|
||||
with:
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
|
||||
@@ -15,7 +15,7 @@ jobs:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: 🔀 Merge master into maintenance
|
||||
uses: robotology/gh-action-nightly-merge@v1.3.3
|
||||
uses: robotology/gh-action-nightly-merge@v1.4.0
|
||||
with:
|
||||
stable_branch: "master"
|
||||
development_branch: "maintenance"
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: 🔀 Merge staging/bugfix into maintenance
|
||||
uses: robotology/gh-action-nightly-merge@v1.3.3
|
||||
uses: robotology/gh-action-nightly-merge@v1.4.0
|
||||
with:
|
||||
stable_branch: "staging/bugfix"
|
||||
development_branch: "maintenance"
|
||||
@@ -33,7 +33,7 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: 🔀 Merge staging/maintenance into maintenance
|
||||
uses: robotology/gh-action-nightly-merge@v1.3.3
|
||||
uses: robotology/gh-action-nightly-merge@v1.4.0
|
||||
with:
|
||||
stable_branch: "staging/bugfix"
|
||||
development_branch: "maintenance"
|
||||
@@ -42,7 +42,7 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: 🔀 Merge maintenance into devel
|
||||
uses: robotology/gh-action-nightly-merge@v1.3.3
|
||||
uses: robotology/gh-action-nightly-merge@v1.4.0
|
||||
with:
|
||||
stable_branch: "maintenance"
|
||||
development_branch: "devel"
|
||||
|
||||
@@ -8,7 +8,7 @@ jobs:
|
||||
pr-automation:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/labeler@v3
|
||||
- uses: actions/labeler@v4
|
||||
with:
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
|
||||
|
||||
@@ -55,24 +55,23 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: 👀 Determine latest release
|
||||
id: latest
|
||||
uses: foosel/github-action-get-latest-release@master
|
||||
with:
|
||||
repository: "OctoPrint/OctoPrint"
|
||||
run: |
|
||||
OCTOPRINT_VERSION=$(curl -i https://github.com/OctoPrint/OctoPrint/releases/latest | grep -i location: | head -n1 | awk -F/ '{print $NF}' | tr -d '\r')
|
||||
echo "OCTOPRINT_VERSION=$OCTOPRINT_VERSION" >> $GITHUB_ENV
|
||||
- name: 🐍 Set up Python ${{ matrix.python }}
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python }}
|
||||
- name: 👷 Build and install latest release
|
||||
run: |
|
||||
pip install https://github.com/OctoPrint/OctoPrint/archive/${{ steps.latest.outputs.release }}.zip
|
||||
pip install https://github.com/OctoPrint/OctoPrint/archive/${{ env.OCTOPRINT_VERSION }}.zip
|
||||
- name: 📧 Discord success notification
|
||||
continue-on-error: true
|
||||
env:
|
||||
DISCORD_WEBHOOK: ${{ secrets.discord_webhook }}
|
||||
uses: Ilshidur/action-discord@master
|
||||
with:
|
||||
args: "☑️ Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ steps.latest.outputs.release }}` was successful"
|
||||
args: "☑️ Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ env.OCTOPRINT_VERSION }}` was successful"
|
||||
- name: 📧 Discord failure notification
|
||||
continue-on-error: true
|
||||
if: failure()
|
||||
@@ -80,4 +79,4 @@ jobs:
|
||||
DISCORD_WEBHOOK: ${{ secrets.discord_webhook }}
|
||||
uses: Ilshidur/action-discord@master
|
||||
with:
|
||||
args: "🚫 Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ steps.latest.outputs.release }}` failed"
|
||||
args: "🚫 Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ env.OCTOPRINT_VERSION }}` failed"
|
||||
@@ -15,7 +15,7 @@ jobs:
|
||||
if: github.repository == 'OctoPrint/OctoPrint' && github.event_name != 'push'
|
||||
steps:
|
||||
- name: 🚀 Repository Dispatch
|
||||
uses: peter-evans/repository-dispatch@v1
|
||||
uses: peter-evans/repository-dispatch@v2
|
||||
with:
|
||||
token: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
||||
repository: ${{ github.repository_owner }}/octoprint-docker
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
if: github.repository == 'OctoPrint/OctoPrint' && github.event_name == 'push' && github.ref == 'refs/heads/maintenance'
|
||||
steps:
|
||||
- name: 🚀 Repository Dispatch
|
||||
uses: peter-evans/repository-dispatch@v1
|
||||
uses: peter-evans/repository-dispatch@v2
|
||||
with:
|
||||
token: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
||||
repository: ${{ github.repository_owner }}/octoprint-docker
|
||||
@@ -39,7 +39,7 @@ jobs:
|
||||
if: github.repository == 'OctoPrint/OctoPrint' && github.event_name == 'push' && github.ref == 'refs/heads/devel'
|
||||
steps:
|
||||
- name: 🚀 Repository Dispatch
|
||||
uses: peter-evans/repository-dispatch@v1
|
||||
uses: peter-evans/repository-dispatch@v2
|
||||
with:
|
||||
token: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
||||
repository: ${{ github.repository_owner }}/octoprint-docker
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
name: Trigger doc build
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- maintenance
|
||||
- devel
|
||||
release:
|
||||
types:
|
||||
- released
|
||||
@@ -12,7 +16,7 @@ jobs:
|
||||
if: github.repository == 'OctoPrint/OctoPrint'
|
||||
steps:
|
||||
- name: 🚀 Repository Dispatch
|
||||
uses: peter-evans/repository-dispatch@v1
|
||||
uses: peter-evans/repository-dispatch@v2
|
||||
with:
|
||||
token: ${{ secrets.REPODISPATCH_TOKEN }}
|
||||
repository: OctoPrint/docs.octoprint.org
|
||||
|
||||
@@ -41,7 +41,3 @@ pypy
|
||||
|
||||
venv*
|
||||
testconf*
|
||||
|
||||
node_modules
|
||||
tests/cypress/screenshots
|
||||
tests/cypress/videos
|
||||
@@ -1,7 +1,9 @@
|
||||
exclude: ^(src/octoprint/vendor/|src/octoprint/static/js/lib|src/octoprint/static/vendor|tests/static/js/lib|tests/util/_files|scripts/|translations/|.*\.css|.*\.svg)
|
||||
default_language_version:
|
||||
python: python3.10
|
||||
exclude: ^(src/octoprint/vendor/|src/octoprint/static/js/lib|src/octoprint/static/vendor|src/octoprint_setuptools|tests/static/js/lib|tests/util/_files|scripts/|translations/|.*\.css|.*\.svg)
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.1.0
|
||||
rev: v4.4.0
|
||||
hooks:
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
@@ -14,7 +16,7 @@ repos:
|
||||
args: ["--remove"]
|
||||
exclude: "setup.py|versioneer.py|src/octoprint_setuptools/__init__.py"
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v2.31.0
|
||||
rev: v3.3.1
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: ["--py37-plus"]
|
||||
@@ -43,34 +45,29 @@ repos:
|
||||
hooks:
|
||||
- id: isort
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 22.3.0
|
||||
rev: 23.1.0
|
||||
hooks:
|
||||
- id: black
|
||||
additional_dependencies:
|
||||
- click==8.0.4
|
||||
- repo: https://github.com/pycqa/flake8
|
||||
rev: 3.9.2
|
||||
rev: 6.0.0
|
||||
hooks:
|
||||
- id: flake8
|
||||
args: [--config=setup.cfg]
|
||||
additional_dependencies:
|
||||
- flake8-bugbear==22.3.20
|
||||
- importlib-metadata<5.0
|
||||
- flake8-bugbear==23.2.13
|
||||
exclude: ^(docs/)
|
||||
- repo: https://github.com/pre-commit/mirrors-prettier
|
||||
rev: v2.5.1
|
||||
rev: v2.7.1
|
||||
hooks:
|
||||
- id: prettier
|
||||
- repo: https://github.com/pre-commit/mirrors-eslint
|
||||
rev: v8.8.0
|
||||
rev: v8.35.0
|
||||
hooks:
|
||||
- id: eslint
|
||||
additional_dependencies:
|
||||
- eslint@7.19.0
|
||||
- eslint-plugin-cypress@2.11.2
|
||||
files: \.js$
|
||||
exclude: ^(src/octoprint/vendor/|tests/static/js/lib|tests/util/_files|docs/|scripts/|translations/)
|
||||
- repo: https://github.com/codespell-project/codespell
|
||||
rev: v2.1.0
|
||||
rev: v2.2.2
|
||||
hooks:
|
||||
- id: codespell
|
||||
exclude: ^(src/octoprint/vendor/|tests/static/js/lib|tests/util/_files|tests/playwright|scripts/)
|
||||
@@ -1,7 +1,7 @@
|
||||
[main]
|
||||
host = https://www.transifex.com
|
||||
|
||||
[octoprint.messages]
|
||||
[o:octoprint:p:octoprint:r:messages]
|
||||
file_filter = translations/<lang>/LC_MESSAGES/messages.po
|
||||
source_file = translations/messages.pot
|
||||
source_lang = en
|
||||
@@ -18,21 +18,21 @@ prerelease
|
||||
HEAD
|
||||
\(detached.*
|
||||
|
||||
# maintenance is currently the branch for preparation of maintenance release 1.9.0
|
||||
# maintenance is currently the branch for preparation of maintenance release 1.10.0
|
||||
# so are any fix/... and improve/... branches
|
||||
maintenance 1.9.0 fa2c4680cca0d1d6b46e6c1ed68ceea4d9b79afb pep440-dev
|
||||
fix/.* 1.9.0 fa2c4680cca0d1d6b46e6c1ed68ceea4d9b79afb pep440-dev
|
||||
improve/.* 1.9.0 fa2c4680cca0d1d6b46e6c1ed68ceea4d9b79afb pep440-dev
|
||||
maintenance 1.10.0 cd955e9a46782119b36cc22b8dea5652ebbf9774 pep440-dev
|
||||
fix/.* 1.10.0 cd955e9a46782119b36cc22b8dea5652ebbf9774 pep440-dev
|
||||
improve/.* 1.10.0 cd955e9a46782119b36cc22b8dea5652ebbf9774 pep440-dev
|
||||
|
||||
# staging/bugfix is the branch for preparation of the 1.8.7 bugfix release
|
||||
# staging/bugfix is the branch for preparation of the 1.9.x bugfix releases
|
||||
# so are any bug/... branches
|
||||
staging/bugfix 1.8.7 1875623f05e14c3a197c6ff324f02dce55cec7d2 pep440-dev
|
||||
bug/.* 1.8.7 1875623f05e14c3a197c6ff324f02dce55cec7d2 pep440-dev
|
||||
staging/bugfix 1.9.3 f027aaa7300f70b046525a49245b33c43dd198c1 pep440-dev
|
||||
bug/.* 1.9.3 f027aaa7300f70b046525a49245b33c43dd198c1 pep440-dev
|
||||
|
||||
# staging/maintenance is currently the branch for preparation of 1.8.0rc6
|
||||
# staging/maintenance is currently the branch for preparation of 1.9.0rc7
|
||||
# so is regressionfix/...
|
||||
staging/maintenance 1.8.0rc6 45598764e6c7f6257de87a98d15964209ddc9e09 pep440-dev
|
||||
regressionfix/.* 1.8.0rc6 45598764e6c7f6257de87a98d15964209ddc9e09 pep440-dev
|
||||
staging/maintenance 1.9.0rc7 9ba981a2ea789030927fc49b6ad166bc68f6b5f9 pep440-dev
|
||||
regressionfix/.* 1.9.0rc7 9ba981a2ea789030927fc49b6ad166bc68f6b5f9 pep440-dev
|
||||
|
||||
# staging/devel is currently inactive (but has the 1.4.1rc4 namespace)
|
||||
staging/devel 1.4.1rc4 650d54d1885409fa1d411eb54b9e8c7ff428910f pep440-dev
|
||||
|
||||
@@ -175,6 +175,11 @@ date of first contribution):
|
||||
* [Frederik Kemner](https://github.com/040medien)
|
||||
* [Moiz Rasheed](https://github.com/msrasheed)
|
||||
* [Scott Martin](https://github.com/smartin015)
|
||||
* [Shyam Sunder](https://github.com/sgsunder)
|
||||
* [Conny Rasch](https://github.com/CMR-DEV)
|
||||
* [Christopher Perrin](https://github.com/cperrin88)
|
||||
* [Martin Bartsch](https://github.com/kaenguruhs)
|
||||
* [Matthias Weis](https://github.com/mad73923)
|
||||
|
||||
OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by
|
||||
[Daid Braam](https://github.com/daid). Parts of its communication layer and
|
||||
|
||||
@@ -20,7 +20,7 @@ and released under the [GNU Affero General Public License V3](https://www.gnu.or
|
||||
|
||||
Its website can be found at [octoprint.org](https://octoprint.org/?utm_source=github&utm_medium=readme).
|
||||
|
||||
The community forum is available at [community.octoprint.org](https://community.octoprint.org/?utm_source=github&utm_medium=readme). It also serves as central knowledge base.
|
||||
The community forum is available at [community.octoprint.org](https://community.octoprint.org/?utm_source=github&utm_medium=readme). It also serves as a central knowledge base.
|
||||
|
||||
An invite to the Discord server can be found at [discord.octoprint.org](https://discord.octoprint.org).
|
||||
|
||||
|
||||
@@ -9,43 +9,45 @@ thanks to everyone who contributed!
|
||||
* 3D-TECH
|
||||
* 3DPrinterOS
|
||||
* Al Mucci
|
||||
* Arnljot Arntsen
|
||||
* Ash King
|
||||
* Ben Fritsch
|
||||
* BigTreeTech
|
||||
* Boris Hussein
|
||||
* Brad Jackson
|
||||
* Calvin Vette
|
||||
* Christian Petropolis
|
||||
* Christian Wolf
|
||||
* Christian Würthner
|
||||
* Christoph Sigrist
|
||||
* Codense Consulting Oy
|
||||
* Creality3D
|
||||
* DeltaMaker 3D Printers
|
||||
* Dennis Breining
|
||||
* Dima Gorbenko
|
||||
* Douglas Floyd
|
||||
* Ed Crump
|
||||
* Ernesto Martinez
|
||||
* Franziska Kunsmann
|
||||
* Hog Duske
|
||||
* James Mackay
|
||||
* Jacob Renstrom
|
||||
* Jeff Green
|
||||
* Jeff Moe
|
||||
* jeffiel
|
||||
* Jeremy Cole
|
||||
* John Cassel
|
||||
* Julian Melo
|
||||
* Justin Kaufman
|
||||
* Kaile Riser
|
||||
* Kazuhiro Ogura
|
||||
* Kenneth Jiang
|
||||
* Kurt Wubbels
|
||||
* Kyle Menigoz
|
||||
* Lachlan Bell
|
||||
* Lefteris Lertas
|
||||
* LulzBot
|
||||
* Makerbase
|
||||
* Makespace Madrid
|
||||
* Mark Greenwald
|
||||
* Mark Walker
|
||||
* Michael Aumock
|
||||
* Mike Kershaw
|
||||
* Michael Badagliacco
|
||||
* Mike Labanov
|
||||
* Mosaic Manufacturing
|
||||
* Norman Jaffe
|
||||
* Obico
|
||||
@@ -56,16 +58,12 @@ thanks to everyone who contributed!
|
||||
* Randy C. Will
|
||||
* Ranjib Dey
|
||||
* Richard McGuire
|
||||
* Richard Michaud
|
||||
* Richard Stocks
|
||||
* Robert Gusek
|
||||
* Sean Jensen-Grey
|
||||
* Sebastien Andrivet
|
||||
* SimplyPrint
|
||||
* Stefan Krister
|
||||
* Steve Dougherty
|
||||
* Steve Thompson
|
||||
* TJ Horner
|
||||
* Ulrich Kempken
|
||||
|
||||
and 2145 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [GitHub Sponsors](https://github.com/users/foosel/sponsorship)!
|
||||
and 1970 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [GitHub Sponsors](https://github.com/users/foosel/sponsorship)!
|
||||
@@ -44,7 +44,7 @@
|
||||
* [emoji](https://github.com/carpedm20/emoji/): BSD
|
||||
* [feedparser](https://github.com/kurtmckee/feedparser): BSD
|
||||
* [filetype](https://h2non.github.io/filetype.py/): MIT
|
||||
* [Flask](http://flask.pocoo.org/): BSD
|
||||
* [Flask](https://flask.palletsprojects.com/): BSD
|
||||
* [Flask-Assets](http://github.com/miracle2k/flask-assets): BSD
|
||||
* [Flask-Babel](http://github.com/mitsuhiko/flask-babel): BSD
|
||||
* [Flask-Login](https://github.com/maxcountryman/flask-login): MIT
|
||||
@@ -55,7 +55,7 @@
|
||||
* [futures](https://github.com/agronholm/pythonfutures): Python
|
||||
* [monotonic](https://github.com/atdt/monotonic): Apache License 2.0
|
||||
* [netaddr](https://github.com/drkjam/netaddr/): BSD
|
||||
* [netifaces](https://bitbucket.org/al45tair/netifaces): MIT
|
||||
* [netifaces2](https://github.com/SamuelYvon/netifaces-2): MIT
|
||||
* [pathvalidate](https://pathvalidate.readthedocs.io/en/latest/index.html): MIT
|
||||
* [pkginfo](http://pypi.python.org/pypi/pkginfo/): Python
|
||||
* [psutil](https://github.com/giampaolo/psutil): BSD
|
||||
|
||||
@@ -48,7 +48,7 @@ Issue a command for an unrendered timelapse
|
||||
Current only supports to render the unrendered timelapse ``name`` via the
|
||||
``render`` command.
|
||||
|
||||
Requires the ``TIMELAPSE_ADMIN`` permission.
|
||||
Requires the ``TIMELAPSE_MANAGE_UNRENDERED`` permission.
|
||||
|
||||
:json command: The command to issue, currently only ``render`` is supported
|
||||
|
||||
@@ -64,7 +64,7 @@ Delete an unrendered timelapse
|
||||
Returns a :ref:`timelapse list <sec-api-timelapse-datamodel-list>` in the
|
||||
response body.
|
||||
|
||||
Requires the ``TIMELAPSE_DELETE`` permission.
|
||||
Requires the ``TIMELAPSE_MANAGE_UNRENDERED`` permission.
|
||||
|
||||
:param unrendered: If provided and true, also include unrendered timelapses in the response
|
||||
|
||||
|
||||
@@ -10,7 +10,26 @@ The OctoPrint Plugin Manager comes bundled with OctoPrint.
|
||||
It allows management of installed plugins (listing, enabling, disabling
|
||||
and uninstalling) and installing new plugins from the official
|
||||
`OctoPrint Plugin Repository <http://plugins.octoprint.org>`_, web addresses
|
||||
or uploaded file archives.
|
||||
or uploaded files.
|
||||
|
||||
Installing from URL or file uploads currently supports the following file
|
||||
formats:
|
||||
|
||||
* ``.zip``, ``.tar.gz``, ``.tgz``, ``.tar``, ``.gz``, ``.whl``: Will be considered to be
|
||||
plugin archive and installed via ``pip``.
|
||||
* ``.py``: Will be considered to be a single file plugin and installed by copying it
|
||||
into ``~/.octoprint/plugins``.
|
||||
* ``.json``: Will be considered to be either a plugin manager export file (created by the Export button) or a manually created
|
||||
list of URLs to install from, e.g.
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
[
|
||||
"https://github.com/jneilliii/OctoPrint-BedLevelVisualizer/archive/master.zip",
|
||||
"https://github.com/eyal0/OctoPrint-PrintTimeGenius/archive/master.zip"
|
||||
]
|
||||
|
||||
The plugin manager will feed all contained URLs to the same logic as above.
|
||||
|
||||
.. _fig-bundledplugins-pluginmanager-mainscreen:
|
||||
.. figure:: ../images/bundledplugins-pluginmanager-mainscreen.png
|
||||
|
||||
@@ -871,10 +871,6 @@ Use the following settings to configure the server:
|
||||
# reset the setting to false
|
||||
startOnceInSafeMode: false
|
||||
|
||||
# Signals to OctoPrint that the last startup was incomplete. OctoPrint will then startup
|
||||
# in safe mode
|
||||
incompleteStartup: false
|
||||
|
||||
# Set this to true to make OctoPrint ignore incomplete startups. Helpful for development.
|
||||
ignoreIncompleteStartup: false
|
||||
|
||||
|
||||
@@ -61,6 +61,8 @@ When the virtual environment is activated you can then:
|
||||
* build the documentation running ``sphinx-build -b html . _build`` in the ``docs``
|
||||
folder -- the documentation will be available in the newly created ``_build``
|
||||
directory. You can simply browse it locally by opening ``index.html``
|
||||
* check whether there are newer versions of OctoPrint's dependencies available via
|
||||
``python setup.py scan_deps``
|
||||
|
||||
.. _sec-development-environment-source-linux:
|
||||
|
||||
|
||||
@@ -198,11 +198,20 @@ There many configuration options via ``config.yaml`` for the virtual printer tha
|
||||
m115FormatString: "FIRMWARE_NAME: {firmware_name} PROTOCOL_VERSION:1.0"
|
||||
|
||||
# Whether to include capability report in M115 output
|
||||
m115ReportCapabilites: false
|
||||
m115ReportCapabilities: true
|
||||
|
||||
# Capabilities to report if capability report is enabled
|
||||
capabilities:
|
||||
AUTOREPORT_TEMP: true
|
||||
AUTOREPORT_TEMP: true
|
||||
AUTOREPORT_SD_STATUS: true
|
||||
AUTOREPORT_POS: false
|
||||
EMERGENCY_PARSER: true
|
||||
EXTENDED_M20: false
|
||||
LFN_WRITE: false
|
||||
|
||||
# Whether to include area report in the M115 output (M115_GEOMETRY_REPORT in Marlin)
|
||||
m115ReportArea: false
|
||||
|
||||
# Simulated ambient temperature in °C
|
||||
ambientTemperature: 21.3
|
||||
|
||||
@@ -519,6 +519,7 @@ PrintCancelled
|
||||
* ``position.f``: last feedrate for move commands **sent through OctoPrint** (note that if you modified the
|
||||
feedrate outside of OctoPrint, e.g. through the printer controller, or if you are printing from SD, this will
|
||||
NOT be accurate)
|
||||
* ``fileposition``: position in the file in bytes at the time of cancellation
|
||||
|
||||
.. deprecated:: 1.3.0
|
||||
|
||||
@@ -550,6 +551,7 @@ PrintPaused
|
||||
* ``position.f``: last feedrate for move commands **sent through OctoPrint** (note that if you modified the
|
||||
feedrate outside of OctoPrint, e.g. through the printer controller, or if you are printing from SD, this will
|
||||
NOT be accurate)
|
||||
* ``fileposition``: position in the file in bytes at the time of pausing
|
||||
|
||||
.. deprecated:: 1.3.0
|
||||
|
||||
@@ -610,9 +612,13 @@ ChartMarked
|
||||
|
||||
Payload:
|
||||
|
||||
* ``type``: the marking's ID. Built-in types are ``print``, ``done``, ``cancel``, ``pause``, and ``resume``. Plugins may set arbitrary types
|
||||
* ``label``: the human-readable short label of the marking
|
||||
* ``time``: the epoch time of marking
|
||||
* ``type``: The marking's ID. Built-in types are ``print``, ``done``, ``cancel``, ``pause``, and ``resume``.
|
||||
Plugins may set arbitrary types, which should be prefixed, e.g. ``pluginname_eventtype``. In the UI, the type
|
||||
ID is used to stylize the marking label.
|
||||
* ``label``: The human-readable short label of the marking, ideally one short word. Optional but recommended; if
|
||||
not specified, the UI will display the ``type``. The label may be localized in the UI.
|
||||
* ``time``: The epoch time of marking. Defaults to the event fire time if not specified. Plugins may set a time
|
||||
in the past if it makes sense for the event.
|
||||
|
||||
.. versionadded:: 1.9.0
|
||||
|
||||
|
||||
@@ -213,6 +213,9 @@ to the persisted pause position on resume, making sure to also reset the extrude
|
||||
.. code-block:: jinja
|
||||
:caption: ``afterPrintPaused`` script
|
||||
|
||||
; (optional) disable stepper inactivity timeout - uncomment if you printer disables steppers during pause and supports this command
|
||||
;M18 S0
|
||||
|
||||
{% if pause_position.x is not none %}
|
||||
; relative XYZE
|
||||
G91
|
||||
|
||||
|
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 83 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 406 KiB |
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 71 KiB |
@@ -60,7 +60,7 @@
|
||||
:param string message: The type of message for which to register
|
||||
:param function handler: The handler function
|
||||
|
||||
.. js:function:: OctoPrintClient.socker.removeMessage(message, handler)
|
||||
.. js:function:: OctoPrintClient.socket.removeMessage(message, handler)
|
||||
|
||||
Removes the ``handler`` for messages of type ``message``.
|
||||
|
||||
|
||||
@@ -7,12 +7,13 @@ Internal Modules
|
||||
.. toctree::
|
||||
:maxdepth: 3
|
||||
|
||||
access.rst
|
||||
cli.rst
|
||||
filemanager.rst
|
||||
plugin.rst
|
||||
printer.rst
|
||||
schema.rst
|
||||
server.rst
|
||||
settings.rst
|
||||
slicing.rst
|
||||
users.rst
|
||||
util.rst
|
||||
@@ -0,0 +1,111 @@
|
||||
.. _sec-modules-schema:
|
||||
|
||||
octoprint.schema
|
||||
----------------
|
||||
|
||||
.. automodule:: octoprint.schema
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. _sec-modules-schema-config:
|
||||
|
||||
octoprint.schema.config
|
||||
-----------------------
|
||||
|
||||
.. automodule:: octoprint.schema.config
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: octoprint.schema.config.access_control
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: octoprint.schema.config.api
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: octoprint.schema.config.appearance
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: octoprint.schema.config.controls
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: octoprint.schema.config.devel
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: octoprint.schema.config.estimation
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: octoprint.schema.config.events
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: octoprint.schema.config.feature
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: octoprint.schema.config.folder
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: octoprint.schema.config.gcode_analysis
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: octoprint.schema.config.plugins
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: octoprint.schema.config.printer_parameters
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: octoprint.schema.config.printer_profiles
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: octoprint.schema.config.scripts
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: octoprint.schema.config.serial
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: octoprint.schema.config.server
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: octoprint.schema.config.slicing
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: octoprint.schema.config.system
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: octoprint.schema.config.temperature
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: octoprint.schema.config.terminalfilters
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: octoprint.schema.config.webcam
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
.. _sec-modules-schema-webcam:
|
||||
|
||||
octoprint.schema.webcam
|
||||
-----------------------
|
||||
|
||||
.. automodule:: octoprint.schema.webcam
|
||||
:members:
|
||||
:undoc-members:
|
||||
@@ -20,7 +20,7 @@ development environment::
|
||||
$ virtualenv venv
|
||||
[...]
|
||||
$ source venv/bin/activate
|
||||
(venv) $ pip install -e .[develop,plugins]
|
||||
(venv) $ pip install -e '.[develop,plugins]'
|
||||
[...]
|
||||
(venv) $ octoprint --help
|
||||
Usage: octoprint [OPTIONS] COMMAND [ARGS]...
|
||||
@@ -161,7 +161,7 @@ Then we can use the ``octoprint dev plugin:new`` command [#f1]_ to generate a ne
|
||||
email [you@example.com]: you@somewhere.net
|
||||
github_username [you]: yourGithubName
|
||||
plugin_version [0.1.0]: 1.0.0
|
||||
plugin_description [TODO]: A quick "Hello World" example plugin for OCtoPrint
|
||||
plugin_description [TODO]: A quick "Hello World" example plugin for OctoPrint
|
||||
plugin_license [AGPLv3]:
|
||||
plugin_homepage [https://github.com/yourGithubName/OctoPrint-Helloworld]:
|
||||
plugin_source [https://github.com/yourGithubName/OctoPrint-Helloworld]:
|
||||
@@ -176,6 +176,9 @@ Then we can use the ``octoprint dev plugin:new`` command [#f1]_ to generate a ne
|
||||
This will create a project structure in the ``OctoPrint-HelloWorld`` folder we just changed to that looks like this::
|
||||
|
||||
extras/
|
||||
github/
|
||||
bug_report.yml
|
||||
feature_request.yml
|
||||
README.txt
|
||||
helloworld.md
|
||||
octoprint_helloworld/
|
||||
@@ -198,6 +201,7 @@ This will create a project structure in the ``OctoPrint-HelloWorld`` folder we j
|
||||
README.md
|
||||
requirements.txt
|
||||
setup.py
|
||||
setup.cfg
|
||||
|
||||
While we'll need some of those folders later on, we'll now delete everything that we don't need right now first, that
|
||||
will make it easier to understand what folder does what later on. Delete the following folders and anything in them:
|
||||
@@ -217,6 +221,7 @@ The final project structure should look like this for now::
|
||||
MANIFEST.in
|
||||
README.md
|
||||
requirements.txt
|
||||
setup.cfg
|
||||
setup.py
|
||||
|
||||
Out of curiosity, take a look into the ``setup.py`` file. The cookiecutter template should have prefilled all the
|
||||
@@ -385,6 +390,7 @@ Our plugin's directory structure should now look like this::
|
||||
README.md
|
||||
requirements.txt
|
||||
setup.py
|
||||
setup.cfg
|
||||
|
||||
Restart OctoPrint and open the web interface in your browser (make sure to clear your browser's cache!).
|
||||
|
||||
@@ -473,7 +479,7 @@ Also adjust your plugin's ``templates/helloworld_navbar.jinja2`` like this:
|
||||
|
||||
OctoPrint injects the template variables that your plugin defines prefixed with ``plugin_<plugin identifier>_`` into
|
||||
the template renderer, so your ``url`` got turned into ``plugin_helloworld_url`` which you can now use as a simple
|
||||
`Jinja2 Variable <http://jinja.octoprint.org/templates.html#variables>`_ in your plugin's template.
|
||||
`Jinja2 Variable <https://jinja.palletsprojects.com/templates.html#variables>`_ in your plugin's template.
|
||||
|
||||
Restart OctoPrint and shift-reload the page in your browser (to make sure you really get a fresh copy). The link should
|
||||
still work and point to the URL we defined as default.
|
||||
@@ -633,6 +639,7 @@ look like this::
|
||||
README.md
|
||||
requirements.txt
|
||||
setup.py
|
||||
setup.cfg
|
||||
|
||||
We need to tell OctoPrint about this new static asset so that it will properly inject it into the page. For this we
|
||||
just need to subclass :class:`~octoprint.plugin.AssetPlugin` and override its method :func:`~octoprint.plugin.AssetPlugin.get_assets`
|
||||
@@ -1041,10 +1048,9 @@ might show what's possible with a few lines of code already. Finally, just take
|
||||
|
||||
.. seealso::
|
||||
|
||||
`Jinja Template Designer Documentation <http://jinja.octoprint.org/templates.html>`_
|
||||
`Jinja Template Designer Documentation <https://jinja.palletsprojects.com/templates.html>`_
|
||||
Jinja's Template Designer Documentation describes the syntax and semantics of the template language used
|
||||
by OctoPrint's frontend. Linked here are the docs for Jinja 2.8.1, which OctoPrint still
|
||||
relies on for backwards compatibility reasons [#f3]_.
|
||||
by OctoPrint's frontend.
|
||||
|
||||
.. rubric:: Footnotes
|
||||
|
||||
@@ -1057,7 +1063,3 @@ might show what's possible with a few lines of code already. Finally, just take
|
||||
.. [#f2] Refer to the `LESS documentation <http://lesscss.org/#using-less>`_ on how to do that. If you are developing
|
||||
your plugin under Windows you might also want to give `WinLESS <http://winless.org/>`_ a look which will run
|
||||
in the background and keep your CSS files up to date with your various project's LESS files automatically.
|
||||
.. [#f3] Please always consult the Jinja documentation at `jinja.octoprint.org <http://jinja.octoprint.org>`_ instead of
|
||||
the current stable documentation available at Jinja's project page. The reason for that is that for backwards
|
||||
compatibility reasons OctoPrint currently sadly has to rely on an older version of Jinja. The documentation
|
||||
available at `jinja.octoprint.org <http://jinja.octoprint.org>`_ matches that older version.
|
||||
@@ -1177,6 +1177,42 @@ octoprint.plugin.backup.additional_excludes
|
||||
|
||||
See :ref:`here <sec-bundledplugins-backup-hooks-excludes>`.
|
||||
|
||||
.. _sec-plugins-hook-plugin-backup-before-backup:
|
||||
|
||||
octoprint.plugin.backup.before_backup
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. versionadded:: 1.9.0
|
||||
|
||||
See :ref:`here <sec-bundledplugins-backup-hooks-before-backup>`.
|
||||
|
||||
.. _sec-plugins-hook-plugin-backup-after-backup:
|
||||
|
||||
octoprint.plugin.backup.after_backup
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. versionadded:: 1.9.0
|
||||
|
||||
See :ref:`here <sec-bundledplugins-backup-hooks-after-backup>`.
|
||||
|
||||
.. _sec-plugins-hook-plugin-backup-before-restore:
|
||||
|
||||
octoprint.plugin.backup.before_restore
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. versionadded:: 1.9.0
|
||||
|
||||
See :ref:`here <sec-bundledplugins-backup-hooks-before-restore>`.
|
||||
|
||||
.. _sec-plugins-hook-plugin-backup-after-restore:
|
||||
|
||||
octoprint.plugin.backup.after_restore
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. versionadded:: 1.9.0
|
||||
|
||||
See :ref:`here <sec-bundledplugins-backup-hooks-after-restore>`.
|
||||
|
||||
.. _sec-plugins-hook-plugin-pluginmanager-reconnect:
|
||||
|
||||
octoprint.plugin.pluginmanager.reconnect_hooks
|
||||
@@ -1360,7 +1396,7 @@ octoprint.printer.sdcardupload
|
||||
to be created on the ``sdcard`` storage. ``elapsed`` is the elapsed time in seconds.
|
||||
|
||||
If the hook is going to handle the upload, it must return the (future) remote filename of the file on the ``sdcard``
|
||||
storage. If it returns ``None`` (or an otherwise falsy value), OctoPrint will interpret this as the hook not going to
|
||||
storage. If it returns ``None`` (or an otherwise false-y value), OctoPrint will interpret this as the hook not going to
|
||||
handle the file upload, in which case the next hook or - if no other hook is registered - the default implementation
|
||||
will be called.
|
||||
|
||||
|
||||
@@ -198,33 +198,6 @@ The following plugin mixins are currently available:
|
||||
Please note that all plugin mixins inherit from :class:`~octoprint.plugin.core.Plugin` and
|
||||
:class:`~octoprint.plugin.types.OctoPrintPlugin`, which also provide attributes of interest to plugin developers.
|
||||
|
||||
.. _sec-plugins-mixins-startupplugin:
|
||||
|
||||
StartupPlugin
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: octoprint.plugin.StartupPlugin
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
.. _sec-plugins-mixins-shutdownplugin:
|
||||
|
||||
ShutdownPlugin
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: octoprint.plugin.ShutdownPlugin
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
.. _sec-plugins-mixins-settingsplugin:
|
||||
|
||||
SettingsPlugin
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: octoprint.plugin.SettingsPlugin
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
.. _sec-plugins-mixins-assetplugin:
|
||||
|
||||
AssetPlugin
|
||||
@@ -234,42 +207,6 @@ AssetPlugin
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
.. _sec-plugins-mixins-templateplugin:
|
||||
|
||||
TemplatePlugin
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: octoprint.plugin.TemplatePlugin
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
.. _sec-plugins-mixins-wizardplugin:
|
||||
|
||||
WizardPlugin
|
||||
~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: octoprint.plugin.WizardPlugin
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
.. _sec-plugins-mixins-uiplugin:
|
||||
|
||||
UiPlugin
|
||||
~~~~~~~~
|
||||
|
||||
.. autoclass:: octoprint.plugin.UiPlugin
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
.. _sec-plugins-mixins-simpleapiplugin:
|
||||
|
||||
SimpleApiPlugin
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: octoprint.plugin.SimpleApiPlugin
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
.. _sec-plugins-mixins-blueprintplugin:
|
||||
|
||||
BlueprintPlugin
|
||||
@@ -297,12 +234,12 @@ ProgressPlugin
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
.. _sec-plugins-mixins-slicerplugin:
|
||||
.. _sec-plugins-mixins-reloadneeding:
|
||||
|
||||
SlicerPlugin
|
||||
~~~~~~~~~~~~
|
||||
ReloadNeedingPlugin
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: octoprint.plugin.SlicerPlugin
|
||||
.. autoclass:: octoprint.plugin.ReloadNeedingPlugin
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
@@ -315,11 +252,83 @@ RestartNeedingPlugin
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
.. _sec-plugins-mixins-reloadneeding:
|
||||
.. _sec-plugins-mixins-settingsplugin:
|
||||
|
||||
ReloadNeedingPlugin
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
SettingsPlugin
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: octoprint.plugin.ReloadNeedingPlugin
|
||||
.. autoclass:: octoprint.plugin.SettingsPlugin
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
.. _sec-plugins-mixins-shutdownplugin:
|
||||
|
||||
ShutdownPlugin
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: octoprint.plugin.ShutdownPlugin
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
.. _sec-plugins-mixins-simpleapiplugin:
|
||||
|
||||
SimpleApiPlugin
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: octoprint.plugin.SimpleApiPlugin
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
.. _sec-plugins-mixins-slicerplugin:
|
||||
|
||||
SlicerPlugin
|
||||
~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: octoprint.plugin.SlicerPlugin
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
.. _sec-plugins-mixins-startupplugin:
|
||||
|
||||
StartupPlugin
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: octoprint.plugin.StartupPlugin
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
.. _sec-plugins-mixins-templateplugin:
|
||||
|
||||
TemplatePlugin
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: octoprint.plugin.TemplatePlugin
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
.. _sec-plugins-mixins-uiplugin:
|
||||
|
||||
UiPlugin
|
||||
~~~~~~~~
|
||||
|
||||
.. autoclass:: octoprint.plugin.UiPlugin
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
.. _sec-plugins-mixins-webcamproviderplugin:
|
||||
|
||||
WebcamProviderPlugin
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: octoprint.plugin.WebcamProviderPlugin
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
.. _sec-plugins-mixins-wizardplugin:
|
||||
|
||||
WizardPlugin
|
||||
~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: octoprint.plugin.WizardPlugin
|
||||
:members:
|
||||
:show-inheritance:
|
||||
@@ -26,7 +26,6 @@ cache = {}
|
||||
|
||||
class OnlineIncludeReader(LiteralIncludeReader):
|
||||
def read_file(self, filename: str, location: Any = None) -> list[str]:
|
||||
|
||||
global cache
|
||||
try:
|
||||
if filename in cache:
|
||||
|
||||
@@ -8,7 +8,7 @@ Environment="LC_ALL=C.UTF-8"
|
||||
Environment="LANG=C.UTF-8"
|
||||
Type=exec
|
||||
User=pi
|
||||
ExecStart=/home/pi/OctoPrint/venv/bin/octoprint
|
||||
ExecStart=/home/pi/OctoPrint/venv/bin/octoprint serve
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -15,7 +15,7 @@ lookupfile = .versioneer-lookup
|
||||
|
||||
[flake8]
|
||||
max-line-length = 90
|
||||
extend-ignore = E203, E231, E265, E266, E402, E501, E731
|
||||
extend-ignore = E203, E231, E265, E266, E402, E501, E731, B023, B903, B904, B907, B950, W503
|
||||
select = B,C,E,F,W,T4,B9
|
||||
exclude =
|
||||
src/octoprint/vendor
|
||||
|
||||
@@ -36,54 +36,55 @@ SETUP_REQUIRES = []
|
||||
bundled_plugins = [
|
||||
"OctoPrint-FileCheck>=2021.2.23",
|
||||
"OctoPrint-FirmwareCheck>=2021.10.11",
|
||||
"OctoPrint-PiSupport>=2022.3.28",
|
||||
"OctoPrint-PiSupport>=2023.5.24",
|
||||
]
|
||||
core_deps = [
|
||||
"argon2_cffi>=21.3.0,<22",
|
||||
"cachelib>=0.2,<0.3",
|
||||
"Click>=8.0.3,<9",
|
||||
"colorlog>=6,<7",
|
||||
"emoji>=1.4.2,<2",
|
||||
"feedparser>=6.0.8,<7",
|
||||
"filetype>=1.0.7,<2",
|
||||
"Babel>=2.12.1,<2.13", # breaking changes can happen on minor version increases
|
||||
"cachelib>=0.10.2,<0.11",
|
||||
"Click>=8.1.3,<9",
|
||||
"colorlog>=6.7.0,<7",
|
||||
"emoji>=2.2.0,<3",
|
||||
"feedparser>=6.0.10,<7",
|
||||
"filetype>=1.2.0,<2",
|
||||
"Flask-Assets>=2.0,<3",
|
||||
"Flask-Babel>=2.0,<3",
|
||||
"Flask-Babel>=3.1.0,<4",
|
||||
"Flask-Login>=0.6.2,<0.7", # breaking changes can happen on minor version increases
|
||||
"Flask-Limiter>=2.6,<3",
|
||||
"flask>=2.2,<2.3", # breaking changes can happen on minor version increases (with deprecation warnings)
|
||||
"frozendict>=2.0,<3",
|
||||
"future>=0.18.2,<1", # not really needed anymore, but leaving in for py2/3 compat plugins
|
||||
"markdown>=3.2.2,<4",
|
||||
"Flask-Limiter>=3.3.0,<4",
|
||||
"flask>=2.2.3,<2.3", # breaking changes can happen on minor version increases (with deprecation warnings)
|
||||
"frozendict>=2.3.7,<3",
|
||||
"future>=0.18.3,<1", # not really needed anymore, but leaving in for py2/3 compat plugins
|
||||
"markdown>=3.4.3,<4",
|
||||
"netaddr>=0.8,<0.9", # changelog hints at breaking changes on minor version increases
|
||||
"netifaces>=0.11,<1",
|
||||
"netifaces2>=0.0.14,<0.1",
|
||||
"passlib>=1.7.4,<2",
|
||||
"pathvalidate>=2.4.1,<3",
|
||||
"pkginfo>=1.7.1,<2",
|
||||
"psutil>=5.8,<6",
|
||||
"pydantic>=1.10.2,<2",
|
||||
"pylru>=1.2,<2",
|
||||
"pyserial>=3.4,<4",
|
||||
"PyYAML>=5.4.1,<6",
|
||||
"requests>=2.26.0,<3",
|
||||
"sarge==0.1.6",
|
||||
"semantic_version>=2.8.5,<3",
|
||||
"sentry-sdk>=1.5.7,<2",
|
||||
"tornado>=6.0.4,<7",
|
||||
"watchdog>=1,<2",
|
||||
"websocket-client>=1.2.1,<2",
|
||||
"werkzeug>=2.2,<2.3", # breaking changes can happen on minor version increases
|
||||
"wrapt>=1.14,<1.15",
|
||||
"zeroconf>=0.33,<0.34", # breaking changes can happen on minor version increases
|
||||
"zipstream-ng>=1.3.4,<2.0.0",
|
||||
"pathvalidate>=2.5.2,<3",
|
||||
"pkginfo>=1.9.6,<2",
|
||||
"psutil>=5.9.4,<6",
|
||||
"pydantic>=1.10.7,<2",
|
||||
"pylru>=1.2.1,<2",
|
||||
"pyserial>=3.5,<4",
|
||||
"PyYAML>=6.0.1,<7", # changelog at https://github.com/yaml/pyyaml/blob/master/CHANGES
|
||||
"requests>=2.28.2,<3",
|
||||
"sarge==0.1.7.post1",
|
||||
"semantic_version>=2.10.0,<3",
|
||||
"sentry-sdk>=1.19.1,<2",
|
||||
"tornado>=6.2,<7",
|
||||
"watchdog>=2.3.1,<3",
|
||||
"websocket-client>=1.5.1,<2",
|
||||
"werkzeug>=2.2.3,<2.3", # breaking changes can happen on minor version increases
|
||||
"wrapt>=1.15,<1.16",
|
||||
"zeroconf==0.39.4", # final version to include universal wheel, later takes ages to compiles on rpi, piwheels has no wheels for latest either
|
||||
"zipstream-ng>=1.5.0,<2.0.0",
|
||||
]
|
||||
vendored_deps = [
|
||||
"blinker>=1.4,<2", # dependency of flask_principal
|
||||
"blinker>=1.6.1,<2", # dependency of flask_principal
|
||||
"class-doc>=0.2.6,<0.3", # dependency of with_attrs_docs
|
||||
"regex", # dependency of awesome-slugify
|
||||
"unidecode", # dependency of awesome-slugify
|
||||
]
|
||||
plugin_deps = [
|
||||
"OctoPrint-Setuptools>=1.0.1", # makes sure plugins can import this on setup.py based install
|
||||
# "OctoPrint-Setuptools>=1.0.3", # makes sure plugins can import this on setup.py based install
|
||||
"wheel", # makes sure plugins can be built as wheels in OctoPrint's venv, see #4682
|
||||
]
|
||||
|
||||
@@ -99,23 +100,23 @@ EXTRA_REQUIRES = {
|
||||
"develop": [
|
||||
# Testing dependencies
|
||||
"ddt",
|
||||
"mock>=4,<5",
|
||||
"mock>=5.0.1,<6",
|
||||
"pytest-doctest-custom>=1.0.0,<2",
|
||||
"pytest>=6.2.5,<7",
|
||||
"pytest>=7.3.0,<8",
|
||||
# pre-commit
|
||||
"pre-commit",
|
||||
# profiler
|
||||
"pyinstrument",
|
||||
],
|
||||
# Dependencies for developing OctoPrint plugins
|
||||
"plugins": ["cookiecutter>=1.7.2,<1.8"],
|
||||
"plugins": ["cookiecutter>=2.1.1,<3"],
|
||||
# Dependencies for building the documentation
|
||||
"docs": [
|
||||
"readthedocs-sphinx-ext>=2.1.5,<3",
|
||||
"sphinx_rtd_theme>=1,<2",
|
||||
"sphinx>=4,<5",
|
||||
"sphinxcontrib-httpdomain>=1.8.0,<2",
|
||||
"sphinxcontrib-mermaid>=0.7.1,<0.8",
|
||||
"sphinx",
|
||||
"sphinxcontrib-httpdomain",
|
||||
"sphinxcontrib-mermaid",
|
||||
"sphinx_rtd_theme",
|
||||
"readthedocs-sphinx-ext",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -164,6 +165,91 @@ def copy_files_build_py_factory(files, baseclass):
|
||||
)
|
||||
|
||||
|
||||
class ScanDepsCommand(setuptools.Command):
|
||||
description = "Scan dependencies for updates"
|
||||
user_options = []
|
||||
|
||||
PYPI = "https://pypi.org/simple/{package}/"
|
||||
|
||||
def initialize_options(self):
|
||||
pass
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
from collections import namedtuple
|
||||
|
||||
import pkg_resources
|
||||
import requests
|
||||
from packaging.version import parse as parse_version
|
||||
|
||||
Update = namedtuple("Update", ["name", "spec", "current", "latest"])
|
||||
update_lower_bounds = []
|
||||
update_bounds = []
|
||||
|
||||
all_requires = list(INSTALL_REQUIRES)
|
||||
for value in EXTRA_REQUIRES.values():
|
||||
all_requires += value
|
||||
|
||||
for r in all_requires:
|
||||
requirement = pkg_resources.Requirement.parse(r)
|
||||
|
||||
resp = requests.get(
|
||||
self.PYPI.format(package=requirement.project_name),
|
||||
headers={"Accept": "application/vnd.pypi.simple.v1+json"},
|
||||
)
|
||||
resp.raise_for_status()
|
||||
|
||||
def safe_parse_version(version):
|
||||
try:
|
||||
return parse_version(version)
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
data = resp.json()
|
||||
versions = list(
|
||||
filter(
|
||||
lambda x: x and not x.is_prerelease and not x.is_devrelease,
|
||||
map(lambda x: safe_parse_version(x), data.get("versions", [])),
|
||||
)
|
||||
)
|
||||
if not versions:
|
||||
continue
|
||||
|
||||
lower = None
|
||||
for spec in requirement.specs:
|
||||
if spec[0] == ">=":
|
||||
lower = spec[1]
|
||||
break
|
||||
|
||||
latest = versions[-1]
|
||||
|
||||
update = Update(requirement.project_name, str(requirement), lower, latest)
|
||||
|
||||
if str(latest) not in requirement:
|
||||
update_bounds.append(update)
|
||||
elif lower and parse_version(lower) < latest:
|
||||
update_lower_bounds.append(update)
|
||||
|
||||
def print_update(update):
|
||||
print(
|
||||
f"{update.spec}: latest {update.latest}, pypi: https://pypi.org/project/{update.name}/"
|
||||
)
|
||||
|
||||
print("")
|
||||
print("The following dependencies can get their lower bounds updated:")
|
||||
print("")
|
||||
for update in update_lower_bounds:
|
||||
print_update(update)
|
||||
|
||||
print("")
|
||||
print("The following dependencies should get looked at for a full update:")
|
||||
print("")
|
||||
for update in update_bounds:
|
||||
print_update(update)
|
||||
|
||||
|
||||
def get_cmdclass():
|
||||
# make sure these are always available, even when run by dependabot
|
||||
global versioneer, octoprint_setuptools, md_to_html_build_py_factory
|
||||
@@ -205,6 +291,8 @@ def get_cmdclass():
|
||||
cmdclass["build_py"] if "build_py" in cmdclass else _build_py,
|
||||
)
|
||||
|
||||
cmdclass["scan_deps"] = ScanDepsCommand
|
||||
|
||||
return cmdclass
|
||||
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ def init_platform(
|
||||
)
|
||||
settings_incomplete_startup_safemode = (
|
||||
"incomplete_startup"
|
||||
if settings.getBoolean(["server", "incompleteStartup"])
|
||||
if os.path.exists(os.path.join(settings._basedir, ".incomplete_startup"))
|
||||
and not settings.getBoolean(["server", "ignoreIncompleteStartup"])
|
||||
else None
|
||||
)
|
||||
@@ -265,6 +265,7 @@ def init_logging(
|
||||
# default logging configuration
|
||||
if default_config is None:
|
||||
simple_format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
||||
date_format = "%Y-%m-%d %H:%M:%S"
|
||||
default_config = {
|
||||
"version": 1,
|
||||
"formatters": {
|
||||
@@ -281,6 +282,13 @@ def init_logging(
|
||||
},
|
||||
},
|
||||
"serial": {"format": "%(asctime)s - %(message)s"},
|
||||
"tornado": {
|
||||
"()": "tornado.log.LogFormatter",
|
||||
"color": False,
|
||||
"format": simple_format,
|
||||
"datefmt": date_format,
|
||||
},
|
||||
"auth": {"format": "%(asctime)s - %(message)s"},
|
||||
"timings": {"format": "%(asctime)s - %(message)s"},
|
||||
"timingscsv": {"format": "%(asctime)s;%(func)s;%(timing)f"},
|
||||
},
|
||||
@@ -311,6 +319,24 @@ def init_logging(
|
||||
),
|
||||
"delay": True,
|
||||
},
|
||||
"tornadoFile": {
|
||||
"class": "octoprint.logging.handlers.TornadoLogHandler",
|
||||
"level": "DEBUG",
|
||||
"formatter": "tornado",
|
||||
"when": "D",
|
||||
"backupCount": 1,
|
||||
"filename": os.path.join(
|
||||
settings.getBaseFolder("logs"), "tornado.log"
|
||||
),
|
||||
},
|
||||
"authFile": {
|
||||
"class": "octoprint.logging.handlers.AuthLogHandler",
|
||||
"level": "DEBUG",
|
||||
"formatter": "auth",
|
||||
"when": "D",
|
||||
"backupCount": 1,
|
||||
"filename": os.path.join(settings.getBaseFolder("logs"), "auth.log"),
|
||||
},
|
||||
"pluginTimingsFile": {
|
||||
"class": "octoprint.logging.handlers.PluginTimingsLogHandler",
|
||||
"level": "DEBUG",
|
||||
@@ -338,12 +364,22 @@ def init_logging(
|
||||
"handlers": ["serialFile"],
|
||||
"propagate": False,
|
||||
},
|
||||
"AUTH": {
|
||||
"level": "INFO",
|
||||
"handlers": ["authFile"],
|
||||
"propagate": False,
|
||||
},
|
||||
"PLUGIN_TIMINGS": {
|
||||
"level": "INFO",
|
||||
"handlers": ["pluginTimingsFile", "pluginTimingsCsvFile"],
|
||||
"propagate": False,
|
||||
},
|
||||
"PLUGIN_TIMINGS.octoprint.plugin": {"level": "INFO"},
|
||||
"tornado.access": {
|
||||
"level": "INFO",
|
||||
"handlers": ["tornadoFile"],
|
||||
"propagate": False,
|
||||
},
|
||||
"octoprint": {"level": "INFO"},
|
||||
"octoprint.util": {"level": "INFO"},
|
||||
"octoprint.plugins": {"level": "INFO"},
|
||||
@@ -507,6 +543,42 @@ def init_settings_plugin_config_migration_and_cleanup(plugin_manager):
|
||||
]
|
||||
|
||||
|
||||
def init_webcam_compat_overlay(settings, plugin_manager):
|
||||
import logging
|
||||
|
||||
import octoprint.webcams
|
||||
|
||||
def set_overlay():
|
||||
default_webcam = octoprint.webcams.get_default_webcam(
|
||||
settings=settings, plugin_manager=plugin_manager
|
||||
)
|
||||
if default_webcam is None:
|
||||
settings.remove_overlay("webcam_compat")
|
||||
return
|
||||
|
||||
if not default_webcam.config or not default_webcam.config.compat:
|
||||
settings.remove_overlay("webcam_compat")
|
||||
return
|
||||
|
||||
logging.getLogger(__name__).info(
|
||||
f"Installing webcam compat overlay for configured default webcam {default_webcam}"
|
||||
)
|
||||
overlay = {"webcam": default_webcam.config.compat.dict(by_alias=True)}
|
||||
settings.add_overlay(
|
||||
overlay,
|
||||
key="webcam_compat",
|
||||
at_end=True,
|
||||
deprecated="Please use the webcam system introduced with 1.9.0, this compatibility layer will be removed in a future release.",
|
||||
replace=True,
|
||||
)
|
||||
|
||||
def callback(path, current_value, new_value):
|
||||
set_overlay()
|
||||
|
||||
set_overlay()
|
||||
settings.add_path_update_callback(["webcam", "defaultWebcam"], callback)
|
||||
|
||||
|
||||
def init_custom_events(plugin_manager):
|
||||
import logging
|
||||
|
||||
@@ -791,7 +863,7 @@ def get_plugin_blacklist(settings, connectivity_checker=None):
|
||||
if isinstance(result, list):
|
||||
return result
|
||||
|
||||
def fetch_blacklist_from_url(url, timeout=3, cache=None):
|
||||
def fetch_blacklist_from_url(url, timeout=3.05, cache=None):
|
||||
result = []
|
||||
try:
|
||||
r = requests.get(url, timeout=timeout)
|
||||
|
||||
@@ -1,4 +1,19 @@
|
||||
import logging
|
||||
|
||||
ADMIN_GROUP = "admins"
|
||||
USER_GROUP = "users"
|
||||
GUEST_GROUP = "guests"
|
||||
READONLY_GROUP = "readonly"
|
||||
|
||||
|
||||
def auth_log(message):
|
||||
logging.getLogger("AUTH").info(message)
|
||||
|
||||
|
||||
login_mechanisms = login_mechanism_lut = {
|
||||
"http": "credentials",
|
||||
"autologin": "autologin",
|
||||
"remember_me": "Remember Me cookie",
|
||||
"basic_auth": "Basic Authorization header",
|
||||
"remote_user": "Remote User header",
|
||||
}
|
||||
@@ -13,7 +13,7 @@ from octoprint.util import atomic_write, yaml
|
||||
from octoprint.vendor.flask_principal import Need, Permission
|
||||
|
||||
GroupNeed = partial(Need, "group")
|
||||
GroupNeed.__doc__ = """A need with the method preset to `"group"`."""
|
||||
GroupNeed.__doc__ = """A need with the method preset to `group`."""
|
||||
|
||||
|
||||
class GroupPermission(Permission):
|
||||
|
||||
@@ -80,7 +80,8 @@ class OctoPrintPermission(Permission):
|
||||
Overridden from Permission.allows to make sure the Identity provides ALL
|
||||
required needs instead of ANY required need.
|
||||
|
||||
:param identity: The identity
|
||||
Arguments:
|
||||
identity (octoprint.vendor.flask_principal.Identity): The identity to check
|
||||
"""
|
||||
if self.needs and len(self.needs.intersection(identity.provides)) != len(
|
||||
self.needs
|
||||
@@ -96,7 +97,8 @@ class OctoPrintPermission(Permission):
|
||||
"""Create a new OctoPrintPermission with the requirements of the union of this
|
||||
and other.
|
||||
|
||||
:param other: The other permission
|
||||
Arguments:
|
||||
other (OctoPrintPermission): The other permission
|
||||
"""
|
||||
p = self.__class__(self._name, self._description, *self.needs.union(other.needs))
|
||||
p.excludes.update(self.excludes.union(other.excludes))
|
||||
@@ -144,7 +146,7 @@ class PluginOctoPrintPermission(OctoPrintPermission):
|
||||
class PluginIdentityContext:
|
||||
"""Identity context for not initialized Permissions
|
||||
|
||||
Needed to support @Permissions.PLUGIN_X_Y.require()
|
||||
Needed to support `@Permissions.PLUGIN_X_Y.require()`
|
||||
|
||||
Will search the permission when needed
|
||||
"""
|
||||
@@ -195,7 +197,7 @@ class PluginIdentityContext:
|
||||
class PluginPermissionDecorator(Permission):
|
||||
"""Decorator Class for not initialized Permissions
|
||||
|
||||
Needed to support @Permissions.PLUGIN_X_Y.require()
|
||||
Needed to support `@Permissions.PLUGIN_X_Y.require()`
|
||||
"""
|
||||
|
||||
def __init__(self, key):
|
||||
@@ -268,7 +270,6 @@ class PermissionsMetaClass(type):
|
||||
|
||||
|
||||
class Permissions(metaclass=PermissionsMetaClass):
|
||||
|
||||
# Special permission
|
||||
ADMIN = OctoPrintPermission(
|
||||
"Admin",
|
||||
@@ -415,7 +416,7 @@ class Permissions(metaclass=PermissionsMetaClass):
|
||||
)
|
||||
TIMELAPSE_DELETE = OctoPrintPermission(
|
||||
"Timelapse Delete",
|
||||
gettext("Allows to delete timelapse videos and unrendered timelapses"),
|
||||
gettext("Allows to delete timelapse videos"),
|
||||
RoleNeed("timelapse_delete"),
|
||||
default_groups=[USER_GROUP],
|
||||
)
|
||||
|
||||
@@ -27,7 +27,7 @@ try:
|
||||
|
||||
# test if we can actually hash and verify, if not we won't use this backend
|
||||
hash = argon2.hash("test")
|
||||
argon2.verify("test", hash)
|
||||
assert argon2.verify("test", hash)
|
||||
|
||||
password_hashers.append(argon2)
|
||||
except Exception:
|
||||
|
||||
@@ -38,21 +38,22 @@ def init_platform_for_cli(ctx):
|
||||
Plugin implementations will be initialized, but only with a subset of the usual
|
||||
property injections:
|
||||
|
||||
* _identifier and everything else parsed from metadata
|
||||
* _logger
|
||||
* _connectivity_checker
|
||||
* _environment_detector
|
||||
* _event_bus
|
||||
* _plugin_manager
|
||||
* _settings
|
||||
- `_identifier` and everything else parsed from metadata
|
||||
- `_logger`
|
||||
- `_connectivity_checker`
|
||||
- `_environment_detector`
|
||||
- `_event_bus`
|
||||
- `_plugin_manager`
|
||||
- `_settings`
|
||||
|
||||
Returns: the same list of components as returned by ``init_platform``
|
||||
Returns: the same list of components as returned by `init_platform`
|
||||
"""
|
||||
|
||||
from octoprint import (
|
||||
init_custom_events,
|
||||
init_platform,
|
||||
init_settings_plugin_config_migration_and_cleanup,
|
||||
init_webcam_compat_overlay,
|
||||
)
|
||||
from octoprint import octoprint_plugin_inject_factory as opif
|
||||
from octoprint import settings_plugin_inject_factory as spif
|
||||
@@ -94,6 +95,7 @@ def init_platform_for_cli(ctx):
|
||||
plugin_manager.initialize_implementations()
|
||||
|
||||
init_settings_plugin_config_migration_and_cleanup(plugin_manager)
|
||||
init_webcam_compat_overlay(settings, plugin_manager)
|
||||
|
||||
return components
|
||||
|
||||
@@ -110,10 +112,10 @@ class HiddenOption(click.Option):
|
||||
|
||||
def hidden_option(*param_decls, **attrs):
|
||||
"""Attaches a hidden option to the command. All positional arguments are
|
||||
passed as parameter declarations to :class:`Option`; all keyword
|
||||
passed as parameter declarations to [Option][click.Option]; all keyword
|
||||
arguments are forwarded unchanged. This is equivalent to creating an
|
||||
:class:`Option` instance manually and attaching it to the
|
||||
:attr:`Command.params` list.
|
||||
[Option][click.Option] instance manually and attaching it to the
|
||||
[Command.params][click.Command.params] list.
|
||||
"""
|
||||
|
||||
import inspect
|
||||
@@ -160,7 +162,7 @@ def bulk_options(options):
|
||||
"""
|
||||
Utility decorator to decorate a function with a list of click decorators.
|
||||
|
||||
The provided list of ``options`` will be reversed to ensure correct
|
||||
The provided list of `options` will be reversed to ensure correct
|
||||
processing order (inverse from what would be intuitive).
|
||||
"""
|
||||
|
||||
@@ -180,7 +182,7 @@ def standard_options(hidden=False):
|
||||
"""
|
||||
Decorator to add the standard options shared among all "octoprint" commands.
|
||||
|
||||
If ``hidden`` is set to ``True``, the options will be available on the command but not
|
||||
If `hidden` is set to `True`, the options will be available on the command but not
|
||||
listed in its help page.
|
||||
"""
|
||||
|
||||
@@ -360,7 +362,6 @@ from .systeminfo import cli as systeminfo_commands # noqa: E402
|
||||
@click.version_option(version=octoprint.__version__, allow_from_autoenv=False)
|
||||
@click.pass_context
|
||||
def octo(ctx, **kwargs):
|
||||
|
||||
if ctx.invoked_subcommand is None:
|
||||
# We have to support calling the octoprint command without any
|
||||
# sub commands to remain backwards compatible.
|
||||
|
||||
@@ -11,7 +11,7 @@ click.disable_unicode_literals_warning = True
|
||||
|
||||
class OctoPrintDevelCommands(click.MultiCommand):
|
||||
"""
|
||||
Custom `click.MultiCommand <http://click.pocoo.org/5/api/#click.MultiCommand>`_
|
||||
Custom [click.MultiCommand][]
|
||||
implementation that provides commands relevant for (plugin) development
|
||||
based on availability of development dependencies.
|
||||
"""
|
||||
@@ -208,10 +208,12 @@ class OctoPrintDevelCommands(click.MultiCommand):
|
||||
"""
|
||||
Installs the local plugin in development mode.
|
||||
|
||||
Note: This can NOT be used to install plugins from remote locations
|
||||
such as the plugin repository! It is strictly for local development
|
||||
of plugins, to ensure the plugin is installed (editable) into the
|
||||
same python environment that OctoPrint is installed under.
|
||||
!!! note:
|
||||
|
||||
This can NOT be used to install plugins from remote locations
|
||||
such as the plugin repository! It is strictly for local development
|
||||
of plugins, to ensure the plugin is installed (editable) into the
|
||||
same python environment that OctoPrint is installed under.
|
||||
"""
|
||||
|
||||
import os
|
||||
@@ -259,7 +261,10 @@ class OctoPrintDevelCommands(click.MultiCommand):
|
||||
)
|
||||
@click.option("--all", "all_files", is_flag=True, help="Build all less files")
|
||||
@click.option(
|
||||
"--list", "list_files", is_flag=True, help="List all available files and exit"
|
||||
"--list",
|
||||
"list_files",
|
||||
is_flag=True,
|
||||
help="List all available files and exit",
|
||||
)
|
||||
def command(files, all_files, list_files):
|
||||
import shutil
|
||||
@@ -312,12 +317,24 @@ class OctoPrintDevelCommands(click.MultiCommand):
|
||||
|
||||
# Check that lessc is installed
|
||||
less = shutil.which("lessc")
|
||||
if not less:
|
||||
|
||||
# Check that less-plugin-clean-css is installed
|
||||
if less:
|
||||
_, _, stderr = self.command_caller.call(
|
||||
[less, "--clean-css"], logged=False
|
||||
)
|
||||
clean_css = not any(
|
||||
map(lambda x: "Unable to load plugin clean-css" in x, stderr)
|
||||
)
|
||||
else:
|
||||
clean_css = False
|
||||
|
||||
if not less or not clean_css:
|
||||
click.echo(
|
||||
"lessc is not installed/not available, please install it first"
|
||||
"lessc or less-plugin-clean-css is not installed/not available, please install it first"
|
||||
)
|
||||
click.echo(
|
||||
"Try `npm i -g less` to install it (NOT lessc in this command!)"
|
||||
"Try `npm i -g less less-plugin-clean-css` to install both (note that it does NOT say 'lessc' in this command!)"
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
@@ -327,10 +344,9 @@ class OctoPrintDevelCommands(click.MultiCommand):
|
||||
sys.exit(1)
|
||||
|
||||
# Build command line, with necessary options
|
||||
# TODO -x is deprecated, find replacement?
|
||||
less_command = [
|
||||
less,
|
||||
"-x",
|
||||
"--clean-css=--s1 --advanced --compatibility=ie8",
|
||||
available_files[less_file]["source"],
|
||||
available_files[less_file]["output"],
|
||||
]
|
||||
|
||||
@@ -30,17 +30,14 @@ LOGGING_CONFIG = {
|
||||
|
||||
class OctoPrintPluginCommands(click.MultiCommand):
|
||||
"""
|
||||
Custom `click.MultiCommand <http://click.pocoo.org/5/api/#click.MultiCommand>`_
|
||||
implementation that collects commands from the plugin hook
|
||||
:ref:`octoprint.cli.commands <sec-plugins-hook-cli-commands>`.
|
||||
Custom [click.MultiCommand][] implementation that collects commands from the plugin hook
|
||||
[octoprint.cli.commands][plugin-guide.concepts.hooks.octoprint.cli.commands].
|
||||
|
||||
.. attribute:: settings
|
||||
|
||||
The global :class:`~octoprint.settings.Settings` instance.
|
||||
|
||||
.. attribute:: plugin_manager
|
||||
|
||||
The :class:`~octoprint.plugin.core.PluginManager` instance.
|
||||
Attributes:
|
||||
settings (octoprint.settings.Settings): The global [Settings][octoprint.settings.Settings]
|
||||
instance.
|
||||
plugin_manager (octoprint.plugin.core.PluginManager): The global [PluginManager][octoprint.plugin.core.PluginManager]
|
||||
instance.
|
||||
"""
|
||||
|
||||
sep = ":"
|
||||
|
||||
@@ -230,8 +230,8 @@ server_options = bulk_options(
|
||||
),
|
||||
]
|
||||
)
|
||||
"""Decorator to add the options shared among the server commands: ``--host``, ``--port``, ``-4``, ``-6``
|
||||
``--logging``, ``--iknowwhatimdoing`` and ``--debug``."""
|
||||
"""Decorator to add the options shared among the server commands: `--host`, `--port`, `-4`, `-6`
|
||||
`--logging`, `--iknowwhatimdoing` and `--debug`."""
|
||||
|
||||
daemon_options = bulk_options(
|
||||
[
|
||||
@@ -244,7 +244,7 @@ daemon_options = bulk_options(
|
||||
)
|
||||
]
|
||||
)
|
||||
"""Decorator to add the options for the daemon subcommand: ``--pid``."""
|
||||
"""Decorator to add the options for the daemon subcommand: `--pid`."""
|
||||
|
||||
# ~~ "octoprint serve" and "octoprint daemon" commands
|
||||
|
||||
|
||||
@@ -81,6 +81,25 @@ def get_systeminfo_bundle(systeminfo, logbase, printer=None, plugin_manager=None
|
||||
if hasattr(printer, "_log"):
|
||||
z.add(to_bytes("\n".join(printer._log)), arcname="terminal.txt")
|
||||
|
||||
# Add reconstructed M115 response, if available
|
||||
if printer._comm and printer._comm._firmware_info:
|
||||
comm = printer._comm
|
||||
m115 = "Reconstructed M115 response:\n\n>>> M115\n<<< "
|
||||
m115 += " ".join([f"{k}:{v}" for k, v in comm._firmware_info.items()])
|
||||
|
||||
if comm._firmware_capabilities:
|
||||
m115 += (
|
||||
"\n<<< "
|
||||
+ "\n<<< ".join(
|
||||
[
|
||||
f"Cap:{k}:{'1' if v else '0'}"
|
||||
for k, v in comm._firmware_capabilities.items()
|
||||
]
|
||||
)
|
||||
+ "\n\n"
|
||||
)
|
||||
z.add(to_bytes(m115), arcname="m115.txt")
|
||||
|
||||
# add systeminfo
|
||||
systeminfotxt = []
|
||||
for k in sorted(systeminfo.keys()):
|
||||
@@ -92,6 +111,7 @@ def get_systeminfo_bundle(systeminfo, logbase, printer=None, plugin_manager=None
|
||||
for log in (
|
||||
"octoprint.log",
|
||||
"serial.log",
|
||||
"tornado.log",
|
||||
):
|
||||
logpath = os.path.join(logbase, log)
|
||||
if os.path.exists(logpath):
|
||||
@@ -118,12 +138,16 @@ def get_systeminfo_bundle(systeminfo, logbase, printer=None, plugin_manager=None
|
||||
z.add_path(content, arcname=log)
|
||||
elif callable(content):
|
||||
# content generating callable
|
||||
z.add(to_bytes(content()), arcname=log)
|
||||
try:
|
||||
z.add(to_bytes(content()), arcname=log)
|
||||
except Exception:
|
||||
logging.getLogger(__name__).exception(
|
||||
f"Error while executing callable for additional bundle content {log} for plugin {name}",
|
||||
extra={"plugin": name},
|
||||
)
|
||||
except Exception:
|
||||
logging.getLogger(__name__).exception(
|
||||
"Error while retrieving additional bundle contents for plugin {}".format(
|
||||
name
|
||||
),
|
||||
f"Error while retrieving additional bundle contents for plugin {name}",
|
||||
extra={"plugin": name},
|
||||
)
|
||||
|
||||
|
||||
@@ -63,8 +63,8 @@ class Daemon:
|
||||
sys.stdout.flush()
|
||||
sys.stderr.flush()
|
||||
si = open(os.devnull, encoding="utf-8")
|
||||
so = open(os.devnull, "at+", encoding="utf-8")
|
||||
se = open(os.devnull, "at+", encoding="utf-8")
|
||||
so = open(os.devnull, "a+", encoding="utf-8")
|
||||
se = open(os.devnull, "a+", encoding="utf-8")
|
||||
|
||||
os.dup2(si.fileno(), sys.stdin.fileno())
|
||||
os.dup2(so.fileno(), sys.stdout.fileno())
|
||||
@@ -160,7 +160,7 @@ class Daemon:
|
||||
|
||||
def set_pid(self, pid):
|
||||
"""Write the pid to the pidfile."""
|
||||
with open(self.pidfile, "wt+", encoding="utf-8") as f:
|
||||
with open(self.pidfile, "w+", encoding="utf-8") as f:
|
||||
f.write(str(pid) + "\n")
|
||||
|
||||
def remove_pidfile(self):
|
||||
|
||||
@@ -167,7 +167,7 @@ class EnvironmentDetector:
|
||||
|
||||
dumped_environment = yaml.dump(environment, pretty=True).strip()
|
||||
environment_lines = "\n".join(
|
||||
map(lambda l: f"| {l}", dumped_environment.split("\n"))
|
||||
map(lambda x: f"| {x}", dumped_environment.split("\n"))
|
||||
)
|
||||
return "Detected environment is Python {} under {} ({}). Details:\n{}".format(
|
||||
environment["python"]["version"],
|
||||
|
||||
@@ -180,19 +180,19 @@ def get_content_type_mapping_for_extension(extension, subtree=None):
|
||||
return None
|
||||
|
||||
|
||||
def valid_extension(extension, type=None):
|
||||
def valid_extension(extension, type=None, tree=None):
|
||||
if not type:
|
||||
return extension in get_all_extensions()
|
||||
return extension in get_all_extensions(subtree=tree)
|
||||
else:
|
||||
extensions = get_extensions(type)
|
||||
extensions = get_extensions(type, subtree=tree)
|
||||
if extensions:
|
||||
return extension in extensions
|
||||
|
||||
|
||||
def valid_file_type(filename, type=None):
|
||||
def valid_file_type(filename, type=None, tree=None):
|
||||
_, extension = os.path.splitext(filename)
|
||||
extension = extension[1:].lower()
|
||||
return valid_extension(extension, type=type)
|
||||
return valid_extension(extension, type=type, tree=tree)
|
||||
|
||||
|
||||
def get_file_type(filename):
|
||||
|
||||
@@ -48,18 +48,18 @@ class QueueEntry(
|
||||
)
|
||||
):
|
||||
"""
|
||||
A :class:`QueueEntry` for processing through the :class:`AnalysisQueue`. Wraps the entry's properties necessary
|
||||
A `QueueEntry` for processing through the [AnalysisQueue][octoprint.filemanager.analysis.AnalysisQueue]. Wraps the entry's properties necessary
|
||||
for processing.
|
||||
|
||||
Arguments:
|
||||
name (str): Name of the file to analyze.
|
||||
path (str): Storage location specific path to the file to analyze.
|
||||
type (str): Type of file to analyze, necessary to map to the correct :class:`AbstractAnalysisQueue` sub class.
|
||||
At the moment, only ``gcode`` is supported here.
|
||||
type (str): Type of file to analyze, necessary to map to the correct [AbstractAnalysisQueue][octoprint.filemanager.analysis.AbstractAnalysisQueue] sub class.
|
||||
At the moment, only `gcode` is supported here.
|
||||
location (str): Location the file is located on.
|
||||
absolute_path (str): Absolute path on disk through which to access the file.
|
||||
printer_profile (PrinterProfile): :class:`PrinterProfile` which to use for analysis.
|
||||
analysis (dict): :class:`GcodeAnalysisQueue` results from prior analysis, or ``None`` if there is none.
|
||||
printer_profile (octoprint.printer.profile.PrinterProfile): [PrinterProfile][octoprint.printer.profile.PrinterProfile] which to use for analysis.
|
||||
analysis (dict): [GcodeAnalysisQueue][octoprint.filemanager.analysis.GcodeAnalysisQueue] results from prior analysis, or `None` if there is none.
|
||||
"""
|
||||
|
||||
def __str__(self):
|
||||
@@ -74,17 +74,21 @@ class AnalysisAborted(Exception):
|
||||
|
||||
class AnalysisQueue:
|
||||
"""
|
||||
OctoPrint's :class:`AnalysisQueue` can manage various :class:`AbstractAnalysisQueue` implementations, mapped
|
||||
by their machine code type.
|
||||
OctoPrint's `AnalysisQueue` can manage various [AbstractAnalysisQueue][octoprint.filemanager.analysis.AbstractAnalysisQueue]
|
||||
implementations, mapped by their machine code type.
|
||||
|
||||
By invoking :meth:`register_finish_callback` it is possible to register oneself as a callback to be invoked each
|
||||
time the analysis of a queue entry finishes. The call parameters will be the finished queue entry as the first
|
||||
and the analysis result as the second parameter. It is also possible to remove the registration again by invoking
|
||||
:meth:`unregister_finish_callback`.
|
||||
By invoking [register_finish_callback][octoprint.filemanager.analysis.AnalysisQueue.register_finish_callback]
|
||||
it is possible to register oneself as a callback to be invoked each time the analysis
|
||||
of a queue entry finishes. The call parameters will be the finished queue entry as
|
||||
the first and the analysis result as the second parameter. It is also possible to
|
||||
remove the registration again by invoking [unregister_finish_callback][octoprint.filemanager.analysis.AnalysisQueue.unregister_finish_callback].
|
||||
|
||||
:meth:`enqueue` allows enqueuing :class:`QueueEntry` instances to analyze. If the :attr:`QueueEntry.type` is unknown
|
||||
(no specific child class of :class:`AbstractAnalysisQueue` is registered for it), nothing will happen. Otherwise the
|
||||
entry will be enqueued with the type specific analysis queue.
|
||||
[enqueue][octoprint.filemanager.analysis.AnalysisQueue.enqueue] allows enqueuing
|
||||
[QueueEntry][octoprint.filemanager.analysis.QueueEntry] instances to analyze. If the
|
||||
[QueueEntry.type][octoprint.filemanager.analysis.QueueEntry.type] is unknown (no
|
||||
specific child class of [AbstractAnalysisQueue][octoprint.filemanager.analysis.AbstractAnalysisQueue]
|
||||
is registered for it), nothing will happen. Otherwise the entry will be enqueued
|
||||
with the type specific analysis queue.
|
||||
"""
|
||||
|
||||
def __init__(self, queue_factories):
|
||||
@@ -154,18 +158,10 @@ class AnalysisQueue:
|
||||
|
||||
class AbstractAnalysisQueue:
|
||||
"""
|
||||
The :class:`AbstractAnalysisQueue` is the parent class of all specific analysis queues such as the
|
||||
:class:`GcodeAnalysisQueue`. It offers methods to enqueue new entries to analyze and pausing and resuming analysis
|
||||
The `AbstractAnalysisQueue` is the parent class of all specific analysis queues such
|
||||
as the [GcodeAnalysisQueue][octoprint.filemanager.analysis.GcodeAnalysisQueue]. It
|
||||
offers methods to enqueue new entries to analyze and pausing and resuming analysis
|
||||
processing.
|
||||
|
||||
Arguments:
|
||||
finished_callback (callable): Callback that will be called upon finishing analysis of an entry in the queue.
|
||||
The callback will be called with the analyzed entry as the first argument and the analysis result as
|
||||
returned from the queue implementation as the second parameter.
|
||||
|
||||
.. automethod:: _do_analysis
|
||||
|
||||
.. automethod:: _do_abort
|
||||
"""
|
||||
|
||||
LOW_PRIO = 100
|
||||
@@ -174,6 +170,16 @@ class AbstractAnalysisQueue:
|
||||
HIGH_PRIO_ABORTED = 0
|
||||
|
||||
def __init__(self, finished_callback):
|
||||
"""
|
||||
Initializes the queue.
|
||||
|
||||
Arguments:
|
||||
finished_callback (callable): Callback that will be called upon finishing
|
||||
analysis of an entry in the queue. The callback will be called with the
|
||||
analyzed entry as the first argument and the analysis result as returned
|
||||
from the queue implementation as the second parameter.
|
||||
|
||||
"""
|
||||
self._logger = logging.getLogger(__name__)
|
||||
|
||||
self._finished_callback = finished_callback
|
||||
@@ -197,15 +203,15 @@ class AbstractAnalysisQueue:
|
||||
|
||||
def enqueue(self, entry, high_priority=False):
|
||||
"""
|
||||
Enqueues an ``entry`` for analysis by the queue.
|
||||
Enqueues an `entry` for analysis by the queue.
|
||||
|
||||
If ``high_priority`` is True (defaults to False), the entry will be prioritized and hence processed before
|
||||
If `high_priority` is `True` (defaults to `False`), the entry will be prioritized and hence processed before
|
||||
other entries in the queue with normal priority.
|
||||
|
||||
Arguments:
|
||||
entry (QueueEntry): The :class:`QueueEntry` to analyze.
|
||||
high_priority (boolean): Whether to process the provided entry with high priority (True) or not
|
||||
(False, default)
|
||||
entry (QueueEntry): The entry to analyze.
|
||||
high_priority (bool): Whether to process the provided entry with high priority (`True`) or not
|
||||
(`False`, default)
|
||||
"""
|
||||
|
||||
if settings().get(["gcodeAnalysis", "runAt"]) == "never":
|
||||
@@ -340,14 +346,14 @@ class AbstractAnalysisQueue:
|
||||
|
||||
def _do_analysis(self, high_priority=False):
|
||||
"""
|
||||
Performs the actual analysis of the current entry which can be accessed via ``self._current``. Needs to be
|
||||
Performs the actual analysis of the current entry which can be accessed via `self._current`. Needs to be
|
||||
overridden by sub classes.
|
||||
|
||||
Arguments:
|
||||
high_priority (bool): Whether the current entry has high priority or not.
|
||||
|
||||
Returns:
|
||||
object: The result of the analysis which will be forwarded to the ``finished_callback`` provided during
|
||||
object: The result of the analysis which will be forwarded to the `finished_callback` provided during
|
||||
construction.
|
||||
"""
|
||||
return None
|
||||
@@ -361,66 +367,36 @@ class AbstractAnalysisQueue:
|
||||
|
||||
class GcodeAnalysisQueue(AbstractAnalysisQueue):
|
||||
"""
|
||||
A queue to analyze GCODE files. Analysis results are :class:`dict` instances structured as follows:
|
||||
A queue to analyze GCODE files. Analysis results are [dict][] instances structured as follows:
|
||||
|
||||
.. list-table::
|
||||
:widths: 25 70
|
||||
|
||||
- * **Key**
|
||||
* **Description**
|
||||
- * ``estimatedPrintTime``
|
||||
* Estimated time the file take to print, in seconds
|
||||
- * ``filament``
|
||||
* Substructure describing estimated filament usage. Keys are ``tool0`` for the first extruder, ``tool1`` for
|
||||
the second and so on. For each tool extruded length and volume (based on diameter) are provided.
|
||||
- * ``filament.toolX.length``
|
||||
* The extruded length in mm
|
||||
- * ``filament.toolX.volume``
|
||||
* The extruded volume in cm³
|
||||
- * ``printingArea``
|
||||
* Bounding box of the printed object in the print volume (minimum and maximum coordinates)
|
||||
- * ``printingArea.minX``
|
||||
* Minimum X coordinate of the printed object
|
||||
- * ``printingArea.maxX``
|
||||
* Maximum X coordinate of the printed object
|
||||
- * ``printingArea.minY``
|
||||
* Minimum Y coordinate of the printed object
|
||||
- * ``printingArea.maxY``
|
||||
* Maximum Y coordinate of the printed object
|
||||
- * ``printingArea.minZ``
|
||||
* Minimum Z coordinate of the printed object
|
||||
- * ``printingArea.maxZ``
|
||||
* Maximum Z coordinate of the printed object
|
||||
- * ``dimensions``
|
||||
* Dimensions of the printed object in X, Y, Z
|
||||
- * ``dimensions.width``
|
||||
* Width of the printed model along the X axis, in mm
|
||||
- * ``dimensions.depth``
|
||||
* Depth of the printed model along the Y axis, in mm
|
||||
- * ``dimensions.height``
|
||||
* Height of the printed model along the Z axis, in mm
|
||||
- * ``travelArea``
|
||||
* Bounding box of all machine movements (minimum and maximum coordinates)
|
||||
- * ``travelArea.minX``
|
||||
* Minimum X coordinate of the machine movement
|
||||
- * ``travelArea.maxX``
|
||||
* Maximum X coordinate of the machine movement
|
||||
- * ``travelArea.minY``
|
||||
* Minimum Y coordinate of the machine movement
|
||||
- * ``travelArea.maxY``
|
||||
* Maximum Y coordinate of the machine movement
|
||||
- * ``travelArea.minZ``
|
||||
* Minimum Z coordinate of the machine movement
|
||||
- * ``travelArea.maxZ``
|
||||
* Maximum Z coordinate of the machine movement
|
||||
- * ``travelDimensions``
|
||||
* Dimensions of the travel area in X, Y, Z
|
||||
- * ``travelDimensions.width``
|
||||
* Width of the travel area along the X axis, in mm
|
||||
- * ``travelDimensions.depth``
|
||||
* Depth of the travel area along the Y axis, in mm
|
||||
- * ``travelDimensions.height``
|
||||
* Height of the travel area along the Z axis, in mm
|
||||
| Name | Type | Description |
|
||||
| ---- | ---- | ----------- |
|
||||
| `estimatedPrintTime` | `int` | Estimated time the file take to print, in seconds |
|
||||
| `filament.*` | `dict` | Substructure describing estimated filament usage. Keys are `tool0` for the first extruder, `tool1` for the second and so on. For each tool extruded length and volume (based on diameter) are provided. |
|
||||
| `filament.toolX.length` | `float` | The extruded length in mm |
|
||||
| `filament.toolX.volume` | `float` | The extruded volume in cm³ |
|
||||
| `printingArea.*` | `dict` | Bounding box of the printed object in the print volume (minimum and maximum coordinates) |
|
||||
| `printingArea.minX` | `float` | Minimum X coordinate of the printed object |
|
||||
| `printingArea.maxX` | `float` | Maximum X coordinate of the printed object |
|
||||
| `printingArea.minY` | `float` | Minimum Y coordinate of the printed object |
|
||||
| `printingArea.maxY` | `float` | Maximum Y coordinate of the printed object |
|
||||
| `printingArea.minZ` | `float` | Minimum Z coordinate of the printed object |
|
||||
| `printingArea.maxZ` | `float` | Maximum Z coordinate of the printed object |
|
||||
| `dimensions.*` | `dict` | Dimensions of the printed object in X, Y, Z |
|
||||
| `dimensions.width` | `float` | Width of the printed model along the X axis, in mm |
|
||||
| `dimensions.depth` | `float` | Depth of the printed model along the Y axis, in mm |
|
||||
| `dimensions.height` | `float` | Height of the printed model along the Z axis, in mm |
|
||||
| `travelArea.*` | `dict` | Bounding box of all machine movements (minimum and maximum coordinates) |
|
||||
| `travelArea.minX` | `float` | Minimum X coordinate of the machine movements |
|
||||
| `travelArea.maxX` | `float` | Maximum X coordinate of the machine movements |
|
||||
| `travelArea.minY` | `float` | Minimum Y coordinate of the machine movements |
|
||||
| `travelArea.maxY` | `float` | Maximum Y coordinate of the machine movements |
|
||||
| `travelArea.minZ` | `float` | Minimum Z coordinate of the machine movements |
|
||||
| `travelArea.maxZ` | `float` | Maximum Z coordinate of the machine movements |
|
||||
| `travelDimensions.*` | `dict` | Dimensions of the travel area in X, Y, Z |
|
||||
| `travelDimensions.width` | `float` | Width of the travel area along the X axis, in mm |
|
||||
| `travelDimensions.depth` | `float` | Depth of the travel area along the X axis, in mm |
|
||||
| `travelDimensions.height` | `float` | Height of the travel area along the X axis, in mm |
|
||||
"""
|
||||
|
||||
def __init__(self, finished_callback):
|
||||
|
||||
@@ -2,6 +2,7 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agp
|
||||
|
||||
|
||||
class FileDestinations:
|
||||
"""File destinations supported by the file manager."""
|
||||
|
||||
SDCARD = "sdcard"
|
||||
LOCAL = "local"
|
||||
@@ -32,12 +32,13 @@ class StorageInterface:
|
||||
@property
|
||||
def analysis_backlog(self):
|
||||
"""
|
||||
Get an iterator over all items stored in the storage that need to be analysed by the :class:`~octoprint.filemanager.AnalysisQueue`.
|
||||
Get an iterator over all items stored in the storage that need to be analysed by the [AnalysisQueue][octoprint.filemanager.AnalysisQueue].
|
||||
|
||||
The yielded elements are expected as storage specific absolute paths to the respective files. Don't forget
|
||||
to recurse into folders if your storage adapter supports those.
|
||||
|
||||
:return: an iterator yielding all un-analysed files in the storage
|
||||
Returns:
|
||||
(iterator): an iterator yielding all un-analysed files in the storage
|
||||
"""
|
||||
# empty generator pattern, yield is intentionally unreachable
|
||||
return
|
||||
@@ -51,40 +52,53 @@ class StorageInterface:
|
||||
|
||||
def last_modified(self, path=None, recursive=False):
|
||||
"""
|
||||
Get the last modification date of the specified ``path`` or ``path``'s subtree.
|
||||
Get the last modification date of the specified `path` or `path`'s subtree.
|
||||
|
||||
Args:
|
||||
path (str or None): Path for which to determine the subtree's last modification date. If left out or
|
||||
set to None, defatuls to storage root.
|
||||
recursive (bool): Whether to determine only the date of the specified ``path`` (False, default) or
|
||||
the whole ``path``'s subtree (True).
|
||||
path (str | None): Path for which to determine the subtree's last modification date. If left out or
|
||||
set to None, defaults to storage root.
|
||||
recursive (bool): Whether to determine only the date of the specified `path` (`False`, default) or
|
||||
the whole `path`'s subtree (True).
|
||||
|
||||
Returns: (float) The last modification date of the indicated subtree
|
||||
Returns:
|
||||
(float): The last modification date of the indicated subtree
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def file_in_path(self, path, filepath):
|
||||
"""
|
||||
Returns whether the file indicated by ``file`` is inside ``path`` or not.
|
||||
:param string path: the path to check
|
||||
:param string filepath: path to the file
|
||||
:return: ``True`` if the file is inside the path, ``False`` otherwise
|
||||
Returns whether the file indicated by `file` is inside `path` or not.
|
||||
|
||||
Arguments:
|
||||
path (str): the path to check
|
||||
filepath (str): path to the file
|
||||
|
||||
Returns:
|
||||
(bool): `True` if the file is inside the path, `False` otherwise
|
||||
"""
|
||||
return NotImplementedError()
|
||||
|
||||
def file_exists(self, path):
|
||||
"""
|
||||
Returns whether the file indicated by ``path`` exists or not.
|
||||
:param string path: the path to check for existence
|
||||
:return: ``True`` if the file exists, ``False`` otherwise
|
||||
Returns whether the file indicated by `path` exists or not.
|
||||
|
||||
Arguments:
|
||||
path (str): the path to check for existence
|
||||
|
||||
Returns:
|
||||
(bool): `True` if the file exists, `False` otherwise
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def folder_exists(self, path):
|
||||
"""
|
||||
Returns whether the folder indicated by ``path`` exists or not.
|
||||
:param string path: the path to check for existence
|
||||
:return: ``True`` if the folder exists, ``False`` otherwise
|
||||
Returns whether the folder indicated by `path` exists or not.
|
||||
|
||||
Arguments:
|
||||
path (str): the path to check for existence
|
||||
|
||||
Returns:
|
||||
bool: `True` if the folder exists, `False` otherwise
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@@ -92,112 +106,127 @@ class StorageInterface:
|
||||
self, path=None, filter=None, recursive=True, level=0, force_refresh=False
|
||||
):
|
||||
"""
|
||||
List all files in storage starting at ``path``. If ``recursive`` is set to True (the default), also dives into
|
||||
List all files in storage starting at `path`. If `recursive` is set to `True` (the default), also dives into
|
||||
subfolders.
|
||||
|
||||
An optional filter function can be supplied which will be called with a file name and file data and which has
|
||||
to return True if the file is to be included in the result or False if not.
|
||||
|
||||
The data structure of the returned result will be a dictionary mapping from file names to entry data. File nodes
|
||||
will contain their metadata here, folder nodes will contain their contained files and folders. Example::
|
||||
will contain their metadata here, folder nodes will contain their contained files and folders.
|
||||
|
||||
{
|
||||
"some_folder": {
|
||||
"name": "some_folder",
|
||||
"path": "some_folder",
|
||||
"type": "folder",
|
||||
"children": {
|
||||
"some_sub_folder": {
|
||||
"name": "some_sub_folder",
|
||||
"path": "some_folder/some_sub_folder",
|
||||
"type": "folder",
|
||||
"typePath": ["folder"],
|
||||
"children": { ... }
|
||||
},
|
||||
"some_file.gcode": {
|
||||
"name": "some_file.gcode",
|
||||
"path": "some_folder/some_file.gcode",
|
||||
"type": "machinecode",
|
||||
"typePath": ["machinecode", "gcode"],
|
||||
"hash": "<sha1 hash>",
|
||||
"links": [ ... ],
|
||||
...
|
||||
},
|
||||
...
|
||||
}
|
||||
"test.gcode": {
|
||||
"name": "test.gcode",
|
||||
"path": "test.gcode",
|
||||
"type": "machinecode",
|
||||
"typePath": ["machinecode", "gcode"],
|
||||
"hash": "<sha1 hash>",
|
||||
"links": [...],
|
||||
...
|
||||
},
|
||||
"test.stl": {
|
||||
"name": "test.stl",
|
||||
"path": "test.stl",
|
||||
"type": "model",
|
||||
"typePath": ["model", "stl"],
|
||||
"hash": "<sha1 hash>",
|
||||
"links": [...],
|
||||
...
|
||||
},
|
||||
...
|
||||
}
|
||||
Example:
|
||||
|
||||
:param string path: base path from which to recursively list all files, optional, if not supplied listing will start
|
||||
from root of base folder
|
||||
:param function filter: a filter that matches the files that are to be returned, may be left out in which case no
|
||||
filtering will take place
|
||||
:param bool recursive: will also step into sub folders for building the complete list if set to True, otherwise will only
|
||||
do one step down into sub folders to be able to populate the ``children``.
|
||||
:return: a dictionary mapping entry names to entry data that represents the whole file list
|
||||
``` json
|
||||
{
|
||||
"some_folder": {
|
||||
"name": "some_folder",
|
||||
"path": "some_folder",
|
||||
"type": "folder",
|
||||
"children": {
|
||||
"some_sub_folder": {
|
||||
"name": "some_sub_folder",
|
||||
"path": "some_folder/some_sub_folder",
|
||||
"type": "folder",
|
||||
"typePath": ["folder"],
|
||||
"children": { ... }
|
||||
},
|
||||
"some_file.gcode": {
|
||||
"name": "some_file.gcode",
|
||||
"path": "some_folder/some_file.gcode",
|
||||
"type": "machinecode",
|
||||
"typePath": ["machinecode", "gcode"],
|
||||
"hash": "<sha1 hash>",
|
||||
"links": [ ... ],
|
||||
...
|
||||
},
|
||||
...
|
||||
}
|
||||
"test.gcode": {
|
||||
"name": "test.gcode",
|
||||
"path": "test.gcode",
|
||||
"type": "machinecode",
|
||||
"typePath": ["machinecode", "gcode"],
|
||||
"hash": "<sha1 hash>",
|
||||
"links": [...],
|
||||
...
|
||||
},
|
||||
"test.stl": {
|
||||
"name": "test.stl",
|
||||
"path": "test.stl",
|
||||
"type": "model",
|
||||
"typePath": ["model", "stl"],
|
||||
"hash": "<sha1 hash>",
|
||||
"links": [...],
|
||||
...
|
||||
},
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Arguments:
|
||||
path (str): base path from which to recursively list all files, optional, if not supplied listing will start
|
||||
from root of base folder
|
||||
filter (function): a filter that matches the files that are to be returned, may be left out in which case no
|
||||
filtering will take place
|
||||
recursive (bool): will also step into sub folders for building the complete list if set to `True`, otherwise will only
|
||||
do one step down into sub folders to be able to populate the `children`.
|
||||
|
||||
Returns:
|
||||
(dict): a nested dictionary mapping entry names to entry data that represents the whole file list
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def add_folder(self, path, ignore_existing=True, display=None):
|
||||
"""
|
||||
Adds a folder as ``path``
|
||||
Adds a folder as `path`
|
||||
|
||||
The ``path`` will be sanitized.
|
||||
The `path` will be sanitized.
|
||||
|
||||
:param string path: the path of the new folder
|
||||
:param bool ignore_existing: if set to True, no error will be raised if the folder to be added already exists
|
||||
:param str display: display name of the folder
|
||||
:return: the sanitized name of the new folder to be used for future references to the folder
|
||||
Arguments:
|
||||
path (str): the path of the new folder
|
||||
ignore_existing (bool): if set to `True`, no error will be raised if the folder to be added already exists
|
||||
display (str): display name of the folder
|
||||
|
||||
Returns:
|
||||
(str): the sanitized name of the new folder to be used for future references to the folder
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def remove_folder(self, path, recursive=True):
|
||||
"""
|
||||
Removes the folder at ``path``
|
||||
Removes the folder at `path`
|
||||
|
||||
:param string path: the path of the folder to remove
|
||||
:param bool recursive: if set to True, contained folders and files will also be removed, otherwise an error will
|
||||
be raised if the folder is not empty (apart from any metadata files) when it's to be removed
|
||||
Arguments:
|
||||
path (str): the path of the folder to remove
|
||||
recursive (bool): if set to `True`, contained folders and files will also be removed, otherwise an error will
|
||||
be raised if the folder is not empty (apart from any metadata files) when it's to be removed
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def copy_folder(self, source, destination):
|
||||
"""
|
||||
Copies the folder ``source`` to ``destination``
|
||||
Copies the folder `source` to `destination`
|
||||
|
||||
:param string source: path to the source folder
|
||||
:param string destination: path to destination
|
||||
Arguments:
|
||||
source (str): path to the source folder
|
||||
destination (str): path to destination
|
||||
|
||||
:return: the path in the storage to the copy of the folder
|
||||
Returns:
|
||||
(str): the new path in the storage to the copy of the folder
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def move_folder(self, source, destination):
|
||||
"""
|
||||
Moves the folder ``source`` to ``destination``
|
||||
Moves the folder `source` to `destination`
|
||||
|
||||
:param string source: path to the source folder
|
||||
:param string destination: path to destination
|
||||
Arguments:
|
||||
source (str): path to the source folder
|
||||
destination (str): path to destination
|
||||
|
||||
:return: the new path in the storage to the folder
|
||||
Returns:
|
||||
(str): the new path in the storage to the folder
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@@ -211,50 +240,58 @@ class StorageInterface:
|
||||
display=None,
|
||||
):
|
||||
"""
|
||||
Adds the file ``file_object`` as ``path``
|
||||
Adds the file `file_object` as `path`
|
||||
|
||||
:param string path: the file's new path, will be sanitized
|
||||
:param object file_object: a file object that provides a ``save`` method which will be called with the destination path
|
||||
where the object should then store its contents
|
||||
:param object printer_profile: the printer profile associated with this file (if any)
|
||||
:param list links: any links to add with the file
|
||||
:param bool allow_overwrite: if set to True no error will be raised if the file already exists and the existing file
|
||||
and its metadata will just be silently overwritten
|
||||
:param str display: display name of the file
|
||||
:return: the sanitized name of the file to be used for future references to it
|
||||
Arguments:
|
||||
path (str): the path of the new file, will be sanitized
|
||||
file_object (object): a file object that provides a `save` method which will be called with the destination path
|
||||
where the object should then store its contents
|
||||
printer_profile (object): the printer profile associated with this file (if any)
|
||||
links (list): any links to add with the file
|
||||
allow_overwrite (bool): if set to `True` no error will be raised if the file already exists and the existing file
|
||||
and its metadata will just be silently overwritten
|
||||
display (str): display name of the file
|
||||
|
||||
Returns:
|
||||
(str): the sanitized name of the file to be used for future references to it
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def remove_file(self, path):
|
||||
"""
|
||||
Removes the file at ``path``
|
||||
Removes the file at `path`
|
||||
|
||||
Will also take care of deleting the corresponding entries
|
||||
in the metadata and deleting all links pointing to the file.
|
||||
|
||||
:param string path: path of the file to remove
|
||||
Arguments:
|
||||
path (str): path of the file to remove
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def copy_file(self, source, destination):
|
||||
"""
|
||||
Copies the file ``source`` to ``destination``
|
||||
Copies the file `source` to `destination`
|
||||
|
||||
:param string source: path to the source file
|
||||
:param string destination: path to destination
|
||||
Arguments:
|
||||
source (str): path to the source file
|
||||
destination (str): path to destination
|
||||
|
||||
:return: the path in the storage to the copy of the file
|
||||
Returns:
|
||||
(str): the new path in the storage to the copy of the file
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def move_file(self, source, destination):
|
||||
"""
|
||||
Moves the file ``source`` to ``destination``
|
||||
Moves the file `source` to `destination`
|
||||
|
||||
:param string source: path to the source file
|
||||
:param string destination: path to destination
|
||||
Arguments:
|
||||
source (str): path to the source file
|
||||
destination (str): path to destination
|
||||
|
||||
:return: the new path in the storage to the file
|
||||
Returns:
|
||||
(str): the new path in the storage to the file
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@@ -262,173 +299,212 @@ class StorageInterface:
|
||||
"""
|
||||
Returns whether the file at path has been analysed yet
|
||||
|
||||
:param path: virtual path to the file for which to retrieve the metadata
|
||||
Arguments:
|
||||
path (str): path to the file to check
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_metadata(self, path):
|
||||
"""
|
||||
Retrieves the metadata for the file ``path``.
|
||||
Retrieves the metadata for the file `path`.
|
||||
|
||||
:param path: virtual path to the file for which to retrieve the metadata
|
||||
:return: the metadata associated with the file
|
||||
Arguments:
|
||||
path (str): virtual path to the file for which to retrieve the metadata
|
||||
|
||||
Returns:
|
||||
(dict): the metadata associated with the file
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def add_link(self, path, rel, data):
|
||||
"""
|
||||
Adds a link of relation ``rel`` to file ``path`` with the given ``data``.
|
||||
Adds a link of relation `rel` to file `path` with the given `data`.
|
||||
|
||||
The following relation types are currently supported:
|
||||
|
||||
* ``model``: adds a link to a model from which the file was created/sliced, expected additional data is the ``name``
|
||||
and optionally the ``hash`` of the file to link to. If the link can be resolved against another file on the
|
||||
current ``path``, not only will it be added to the links of ``name`` but a reverse link of type ``machinecode``
|
||||
referring to ``name`` and its hash will also be added to the linked ``model`` file
|
||||
* ``machinecode``: adds a link to a file containing machine code created from the current file (model), expected
|
||||
additional data is the ``name`` and optionally the ``hash`` of the file to link to. If the link can be resolved
|
||||
against another file on the current ``path``, not only will it be added to the links of ``name`` but a reverse
|
||||
link of type ``model`` referring to ``name`` and its hash will also be added to the linked ``model`` file.
|
||||
* ``web``: adds a location on the web associated with this file (e.g. a website where to download a model),
|
||||
expected additional data is a ``href`` attribute holding the website's URL and optionally a ``retrieved``
|
||||
attribute describing when the content was retrieved
|
||||
- `model`: adds a link to a model from which the file was created/sliced, expected additional data is the `name`
|
||||
and optionally the `hash` of the file to link to. If the link can be resolved against another file on the
|
||||
current `path`, not only will it be added to the links of `name` but a reverse link of type `machinecode`
|
||||
referring to `name` and its hash will also be added to the linked `model` file
|
||||
- `machinecode`: adds a link to a file containing machine code created from the current file (model), expected
|
||||
additional data is the `name` and optionally the `hash` of the file to link to. If the link can be resolved
|
||||
against another file on the current `path`, not only will it be added to the links of `name` but a reverse
|
||||
link of type `model` referring to `name` and its hash will also be added to the linked `model` file.
|
||||
- `web`: adds a location on the web associated with this file (e.g. a website where to download a model),
|
||||
expected additional data is a `href` attribute holding the website's URL and optionally a `retrieved`
|
||||
attribute describing when the content was retrieved
|
||||
|
||||
Note that adding ``model`` links to files identifying as models or ``machinecode`` links to files identifying
|
||||
Note that adding `model` links to files identifying as models or `machinecode` links to files identifying
|
||||
as machine code will be refused.
|
||||
|
||||
:param path: path of the file for which to add a link
|
||||
:param rel: type of relation of the link to add (currently ``model``, ``machinecode`` and ``web`` are supported)
|
||||
:param data: additional data of the link to add
|
||||
Arguments:
|
||||
path (str): path of the file for which to add a link
|
||||
rel (str): type of relation of the link to add (currently `model`, `machinecode` and `web` are supported)
|
||||
data (dict): additional data of the link to add
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def remove_link(self, path, rel, data):
|
||||
"""
|
||||
Removes the link consisting of ``rel`` and ``data`` from file ``name`` on ``path``.
|
||||
Removes the link consisting of `rel` and `data` from file `path`.
|
||||
|
||||
:param path: path of the file from which to remove the link
|
||||
:param rel: type of relation of the link to remove (currently ``model``, ``machinecode`` and ``web`` are supported)
|
||||
:param data: additional data of the link to remove, must match existing link
|
||||
Arguments:
|
||||
path (str): path of the file from which to remove the link
|
||||
rel (str): type of relation of the link to remove (currently `model`, `machinecode` and `web` are supported)
|
||||
data (dict): additional data of the link to remove, must match existing link
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_additional_metadata(self, path, key):
|
||||
"""
|
||||
Fetches additional metadata at ``key`` from the metadata of ``path``.
|
||||
Fetches additional metadata at `key` from the metadata of `path`.
|
||||
|
||||
:param path: the virtual path to the file for which to fetch additional metadata
|
||||
:param key: key of metadata to fetch
|
||||
Arguments:
|
||||
path (str): virtual path to the file for which to fetch additional metadata
|
||||
key (str): key of metadata to fetch
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def set_additional_metadata(self, path, key, data, overwrite=False, merge=False):
|
||||
"""
|
||||
Adds additional metadata to the metadata of ``path``. Metadata in ``data`` will be saved under ``key``.
|
||||
Adds additional metadata to the metadata of `path`. Metadata in `data` will be saved under `key`.
|
||||
|
||||
If ``overwrite`` is set and ``key`` already exists in ``name``'s metadata, the current value will be overwritten.
|
||||
If `overwrite` is set and `key` already exists in `path`'s metadata, the current value will be overwritten.
|
||||
|
||||
If ``merge`` is set and ``key`` already exists and both ``data`` and the existing data under ``key`` are dictionaries,
|
||||
If `merge` is set and `key` already exists and both `data` and the existing data under `key` are dictionaries,
|
||||
the two dictionaries will be merged recursively.
|
||||
|
||||
:param path: the virtual path to the file for which to add additional metadata
|
||||
:param key: key of metadata to add
|
||||
:param data: metadata to add
|
||||
:param overwrite: if True and ``key`` already exists, it will be overwritten
|
||||
:param merge: if True and ``key`` already exists and both ``data`` and the existing data are dictionaries, they
|
||||
will be merged
|
||||
Arguments:
|
||||
path (str): virtual path to the file for which to add additional metadata
|
||||
key (str): key of metadata to add
|
||||
data (dict): metadata to add
|
||||
overwrite (bool): if set to `True` and `key` already exists, it will be overwritten
|
||||
merge (bool): if set to `True` and `key` already exists and both `data` and the existing data are dictionaries,
|
||||
they will be merged
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def remove_additional_metadata(self, path, key):
|
||||
"""
|
||||
Removes additional metadata under ``key`` for ``name`` on ``path``
|
||||
Removes additional metadata under `key` for `name` on `path`
|
||||
|
||||
:param path: the virtual path to the file for which to remove the metadata under ``key``
|
||||
:param key: the key to remove
|
||||
Arguments:
|
||||
path (str): virtual path to the file for which to remove additional metadata
|
||||
key (str): key of metadata to remove
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def canonicalize(self, path):
|
||||
"""
|
||||
Canonicalizes the given ``path``. The ``path`` may consist of both folder and file name, the underlying
|
||||
Canonicalizes the given `path`.
|
||||
|
||||
The `path` may consist of both folder and file name, the underlying
|
||||
implementation must separate those if necessary.
|
||||
|
||||
By default, this calls :func:`~octoprint.filemanager.StorageInterface.sanitize`, which also takes care
|
||||
By default, this calls [StorageInterface.sanitize][octoprint.filemanager.storage.StorageInterface.sanitize], which also takes care
|
||||
of stripping any invalid characters.
|
||||
|
||||
Args:
|
||||
path: the path to canonicalize
|
||||
Arguments:
|
||||
path (str): the path to canonicalize
|
||||
|
||||
Returns:
|
||||
a 2-tuple containing the canonicalized path and file name
|
||||
|
||||
(tuple): a 2-tuple containing the canonicalized path and file name
|
||||
"""
|
||||
return self.sanitize(path)
|
||||
|
||||
def sanitize(self, path):
|
||||
"""
|
||||
Sanitizes the given ``path``, stripping it of all invalid characters. The ``path`` may consist of both
|
||||
folder and file name, the underlying implementation must separate those if necessary and sanitize individually.
|
||||
Sanitizes the given `path`, stripping it of all invalid characters.
|
||||
|
||||
:param string path: the path to sanitize
|
||||
:return: a 2-tuple containing the sanitized path and file name
|
||||
The `path` may consist of both folder and file name, the underlying
|
||||
implementation must separate those if necessary and sanitize individually.
|
||||
|
||||
Arguments:
|
||||
path (str): the path to sanitize
|
||||
|
||||
Returns:
|
||||
(tuple): a 2-tuple containing the sanitized path and file name
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def sanitize_path(self, path):
|
||||
"""
|
||||
Sanitizes the given folder-only ``path``, stripping it of all invalid characters.
|
||||
:param string path: the path to sanitize
|
||||
:return: the sanitized path
|
||||
Sanitizes the given folder-only `path`, stripping it of all invalid characters.
|
||||
|
||||
Arguments:
|
||||
path (str): the path to sanitize
|
||||
|
||||
Returns:
|
||||
(str): the sanitized path
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def sanitize_name(self, name):
|
||||
"""
|
||||
Sanitizes the given file ``name``, stripping it of all invalid characters.
|
||||
:param string name: the file name to sanitize
|
||||
:return: the sanitized name
|
||||
Sanitizes the given file `name`, stripping it of all invalid characters.
|
||||
|
||||
Arguments:
|
||||
name (str): the file name to sanitize
|
||||
|
||||
Returns:
|
||||
(str): the sanitized file name
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def split_path(self, path):
|
||||
"""
|
||||
Split ``path`` into base directory and file name.
|
||||
:param path: the path to split
|
||||
:return: a tuple (base directory, file name)
|
||||
Split `path` into base directory and file name.
|
||||
|
||||
Arguments:
|
||||
path (str): the path to split
|
||||
|
||||
Returns:
|
||||
(tuple): a 2-tuple containing the base directory and file name
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def join_path(self, *path):
|
||||
"""
|
||||
Join path elements together
|
||||
:param path: path elements to join
|
||||
:return: joined representation of the path to be usable as fully qualified path for further operations
|
||||
|
||||
Arguments:
|
||||
path (str): the path elements to join
|
||||
|
||||
Returns:
|
||||
(str): joined representation of the path to be usable as fully qualified path for further operations
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def path_on_disk(self, path):
|
||||
"""
|
||||
Retrieves the path on disk for ``path``.
|
||||
Retrieves the path on disk for `path`.
|
||||
|
||||
Note: if the storage is not on disk and there exists no path on disk to refer to it, this method should
|
||||
raise an :class:`io.UnsupportedOperation`
|
||||
!!! note
|
||||
|
||||
Opposite of :func:`path_in_storage`.
|
||||
If the storage is not on disk and there exists no path on disk to refer to it, this method should
|
||||
raise an [io.UnsupportedOperation][]
|
||||
|
||||
:param string path: the virtual path for which to retrieve the path on disk
|
||||
:return: the path on disk to ``path``
|
||||
Opposite of `path_in_storage`.
|
||||
|
||||
Arguments:
|
||||
path (str): the virtual path for which to retrieve the path on disk
|
||||
|
||||
Returns:
|
||||
(str): the path on disk to `path`
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def path_in_storage(self, path):
|
||||
"""
|
||||
Retrieves the equivalent in the storage adapter for ``path``.
|
||||
Retrieves the equivalent in the storage adapter for `path`.
|
||||
|
||||
Opposite of :func:`path_on_disk`.
|
||||
Opposite of `path_on_disk`.
|
||||
|
||||
:param string path: the path for which to retrieve the storage path
|
||||
:return: the path in storage to ``path``
|
||||
Arguments:
|
||||
path (str): the path on disk for which to retrieve the storage path
|
||||
|
||||
Returns:
|
||||
(str): the path in storage to `path`
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@@ -455,22 +531,23 @@ class StorageError(Exception):
|
||||
|
||||
class LocalFileStorage(StorageInterface):
|
||||
"""
|
||||
The ``LocalFileStorage`` is a storage implementation which holds all files, folders and metadata on disk.
|
||||
The `LocalFileStorage` is a storage implementation which holds all files, folders and metadata on disk.
|
||||
|
||||
Metadata is managed inside ``.metadata.json`` files in the respective folders, indexed by the sanitized filenames
|
||||
Metadata is managed inside `.metadata.json` files in the respective folders, indexed by the sanitized filenames
|
||||
stored within the folder. Metadata access is managed through an LRU cache to minimize access overhead.
|
||||
|
||||
This storage type implements :func:`path_on_disk`.
|
||||
This storage type implements `path_on_disk`.
|
||||
"""
|
||||
|
||||
def __init__(self, basefolder, create=False, really_universal=False):
|
||||
"""
|
||||
Initializes a ``LocalFileStorage`` instance under the given ``basefolder``, creating the necessary folder
|
||||
if necessary and ``create`` is set to ``True``.
|
||||
Initializes a `LocalFileStorage` instance under the given `basefolder`, creating the necessary folder
|
||||
if necessary and `create` is set to `True`.
|
||||
|
||||
:param string basefolder: the path to the folder under which to create the storage
|
||||
:param bool create: ``True`` if the folder should be created if it doesn't exist yet, ``False`` otherwise
|
||||
:param bool really_universal: ``True`` if the file names should be forced to really universal, ``False`` otherwise
|
||||
Arguments:
|
||||
basefolder (str): the path to the folder under which to create the storage
|
||||
create (bool): `True` if the folder should be created if it doesn't exist yet, `False` otherwise
|
||||
really_universal (bool): `True` if the file names should be forced to be really universal, `False` otherwise
|
||||
"""
|
||||
self._logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -1121,18 +1198,26 @@ class LocalFileStorage(StorageInterface):
|
||||
|
||||
def sanitize(self, path):
|
||||
"""
|
||||
Returns a ``(path, name)`` tuple derived from the provided ``path``.
|
||||
Returns a `(path, name)` tuple derived from the provided `path`.
|
||||
|
||||
``path`` may be:
|
||||
* a storage path
|
||||
* an absolute file system path
|
||||
* a tuple or list containing all individual path elements
|
||||
* a string representation of the path
|
||||
* with or without a file name
|
||||
`path` may be:
|
||||
- a storage path
|
||||
- an absolute file system path
|
||||
- a tuple or list containing all individual path elements
|
||||
- a string representation of the path
|
||||
- with or without a file name
|
||||
|
||||
Note that for a ``path`` without a trailing slash the last part will be considered a file name and
|
||||
hence be returned at second position. If you only need to convert a folder path, be sure to
|
||||
include a trailing slash for a string ``path`` or an empty last element for a list ``path``.
|
||||
!!! note
|
||||
|
||||
For a `path` without a trailing slash the last part will be considered a file name and
|
||||
hence be returned at second position. If you only need to convert a folder path, be sure to
|
||||
include a trailing slash for a string `path` or an empty last element for a list `path`.
|
||||
|
||||
Arguments:
|
||||
path (str | list | tuple): The path to sanitize
|
||||
|
||||
Returns:
|
||||
(tuple): The sanitized path and name
|
||||
"""
|
||||
|
||||
path, name = self.canonicalize(path)
|
||||
@@ -1161,18 +1246,35 @@ class LocalFileStorage(StorageInterface):
|
||||
return path, name
|
||||
|
||||
def sanitize_name(self, name):
|
||||
"""
|
||||
Raises a :class:`ValueError` for a ``name`` containing ``/`` or ``\\``. Otherwise
|
||||
sanitizes the given ``name`` using ``octoprint.files.sanitize_filename``. Also
|
||||
strips any leading ``.``.
|
||||
r"""
|
||||
Sanitizes the given `name` using `sanitize_filename`.
|
||||
|
||||
Strips any leading `.`.
|
||||
|
||||
Arguments:
|
||||
name (str): The name to sanitize
|
||||
|
||||
Returns:
|
||||
(str): The sanitized name
|
||||
|
||||
Raises:
|
||||
ValueError: If the name contains `/` or `\`
|
||||
"""
|
||||
return sanitize_filename(name, really_universal=self._really_universal)
|
||||
|
||||
def sanitize_path(self, path):
|
||||
"""
|
||||
Ensures that the on disk representation of ``path`` is located under the configured basefolder. Resolves all
|
||||
relative path elements (e.g. ``..``) and sanitizes folder names using :func:`sanitize_name`. Final path is the
|
||||
absolute path including leading ``basefolder`` path.
|
||||
Sanitizes the given `path`.
|
||||
|
||||
Ensures that the on disk representation of `path` is located under the configured `basefolder`.
|
||||
Resolves all relative path elements (e.g. `..`) and sanitizes folder names using `sanitize_name`.
|
||||
The final path is the absolute path, including the leading `basefolder` path.
|
||||
|
||||
Arguments:
|
||||
path (str): The path to sanitize
|
||||
|
||||
Returns:
|
||||
(str): The sanitized path
|
||||
"""
|
||||
path = to_unicode(path)
|
||||
|
||||
@@ -1653,6 +1755,8 @@ class LocalFileStorage(StorageInterface):
|
||||
"type": "folder",
|
||||
"typePath": ["folder"],
|
||||
}
|
||||
if entry_stat:
|
||||
entry_data["date"] = int(entry_stat.st_mtime)
|
||||
|
||||
result[entry_name] = entry_data
|
||||
except Exception:
|
||||
|
||||
@@ -7,10 +7,10 @@ def log_to_handler(logger, handler, level, msg, exc_info=None, extra=None, *args
|
||||
Logs to the provided handler only.
|
||||
|
||||
Arguments:
|
||||
logger: logger to log to
|
||||
handler: handler to restrict logging to
|
||||
level: level to log at
|
||||
msg: message to log
|
||||
logger (logging.Logger): logger to log to
|
||||
handler (logging.Handler): handler to restrict logging to
|
||||
level (int): level to log at
|
||||
msg (str): message to log
|
||||
exc_info: optional exception info
|
||||
extra: optional extra data
|
||||
*args: log args
|
||||
@@ -51,18 +51,18 @@ def log_to_handler(logger, handler, level, msg, exc_info=None, extra=None, *args
|
||||
|
||||
def get_handler(name, logger=None):
|
||||
"""
|
||||
Retrieves the handler named ``name``.
|
||||
Retrieves the handler named `name`.
|
||||
|
||||
If optional ``logger`` is provided, search will be
|
||||
If optional `logger` is provided, search will be
|
||||
limited to that logger, otherwise the root logger will be
|
||||
searched.
|
||||
|
||||
Arguments:
|
||||
name: the name of the handler to look for
|
||||
logger: (optional) the logger to search in, root logger if not provided
|
||||
name (str): the name of the handler to look for
|
||||
logger (logging.loggers.Logger): (optional) the logger to search in, root logger if not provided
|
||||
|
||||
Returns:
|
||||
the handler if it could be found, None otherwise
|
||||
(logging.handlers.Handler | None): the handler if it could be found, `None` otherwise
|
||||
"""
|
||||
import logging
|
||||
|
||||
@@ -116,13 +116,13 @@ def get_divider_line(c, message=None, length=78, indent=3):
|
||||
AssertionError: indent is not an int
|
||||
|
||||
Arguments:
|
||||
c: character to use for the line
|
||||
message: message to print in the line
|
||||
length: length of the line
|
||||
indent: indentation of message in line
|
||||
c (str): character to use for the line
|
||||
message (str): message to print in the line
|
||||
length (int): length of the line
|
||||
indent (int): indentation of message in line
|
||||
|
||||
Returns:
|
||||
formatted divider line
|
||||
(str): formatted divider line
|
||||
"""
|
||||
|
||||
assert isinstance(c, str), "c is not text"
|
||||
@@ -143,6 +143,16 @@ def get_divider_line(c, message=None, length=78, indent=3):
|
||||
|
||||
|
||||
def prefix_multilines(text: str, prefix: str = ": ") -> str:
|
||||
"""
|
||||
Prefixes all lines of the given text with the given prefix.
|
||||
|
||||
Arguments:
|
||||
text (str): text to prefix
|
||||
prefix (str): prefix to use
|
||||
|
||||
Returns:
|
||||
(str): prefixed text
|
||||
"""
|
||||
from octoprint.util import to_unicode
|
||||
|
||||
lines = text.splitlines()
|
||||
|
||||
@@ -8,7 +8,6 @@ class TornadoAccessFilter(logging.Filter):
|
||||
status, request_line, rtt = record.args
|
||||
|
||||
if status == 409:
|
||||
|
||||
_, url, _ = request_line.split()
|
||||
u = urllib.parse.urlparse(url)
|
||||
if u.path in ("/api/printer",):
|
||||
|
||||
@@ -66,7 +66,6 @@ class OctoPrintStreamHandler(AsyncLogHandlerMixin, logging.StreamHandler):
|
||||
class TriggeredRolloverLogHandler(
|
||||
AsyncLogHandlerMixin, logging.handlers.RotatingFileHandler
|
||||
):
|
||||
|
||||
do_rollover = False
|
||||
suffix_template = "%Y-%m-%d_%H-%M-%S"
|
||||
file_pattern = re.compile(r"^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}$")
|
||||
@@ -137,6 +136,14 @@ class PluginTimingsLogHandler(TriggeredRolloverLogHandler):
|
||||
pass
|
||||
|
||||
|
||||
class TornadoLogHandler(CleaningTimedRotatingFileHandler):
|
||||
pass
|
||||
|
||||
|
||||
class AuthLogHandler(CleaningTimedRotatingFileHandler):
|
||||
pass
|
||||
|
||||
|
||||
class RecordingLogHandler(logging.Handler):
|
||||
def __init__(self, target=None, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
"""
|
||||
This module represents OctoPrint's plugin subsystem. This includes management and helper methods as well as the
|
||||
registered plugin types.
|
||||
|
||||
.. autofunction:: plugin_manager
|
||||
|
||||
.. autofunction:: plugin_settings
|
||||
|
||||
.. autofunction:: call_plugin
|
||||
|
||||
.. autoclass:: PluginSettings
|
||||
:members:
|
||||
"""
|
||||
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
@@ -48,44 +39,48 @@ def plugin_manager(
|
||||
compatibility_ignored_list=None,
|
||||
):
|
||||
"""
|
||||
Factory method for initially constructing and consecutively retrieving the :class:`~octoprint.plugin.core.PluginManager`
|
||||
Factory method for initially constructing and consecutively retrieving the [PluginManager][octoprint.plugin.core.PluginManager]
|
||||
singleton.
|
||||
|
||||
Will set the logging prefix to `octoprint.plugins.`.
|
||||
|
||||
Arguments:
|
||||
init (boolean): A flag indicating whether this is the initial call to construct the singleton (True) or not
|
||||
(False, default). If this is set to True and the plugin manager has already been initialized, a :class:`ValueError`
|
||||
init (bool): A flag indicating whether this is the initial call to construct the singleton (`True`) or not
|
||||
(`False`, default). If this is set to `True` and the plugin manager has already been initialized, a [ValueError][]
|
||||
will be raised. The same will happen if the plugin manager has not yet been initialized and this is set to
|
||||
False.
|
||||
plugin_folders (list): A list of folders (as strings containing the absolute path to them) in which to look for
|
||||
potential plugin modules. If not provided this defaults to the configured ``plugins`` base folder and
|
||||
``src/plugins`` within OctoPrint's code base.
|
||||
potential plugin modules. If not provided this defaults to the configured `plugins` base folder and
|
||||
`src/plugins` within OctoPrint's code base.
|
||||
plugin_bases (list): A list of recognized plugin base classes for which to look for provided implementations. If not
|
||||
provided this defaults to :class:`~octoprint.plugin.OctoPrintPlugin`.
|
||||
provided this defaults to `octoprint.plugin.types.OctoPrintPlugin`.
|
||||
plugin_entry_points (list): A list of entry points pointing to modules which to load as plugins. If not provided
|
||||
this defaults to the entry point ``octoprint.plugin``.
|
||||
this defaults to the entry point `octoprint.plugin`.
|
||||
plugin_disabled_list (list): A list of plugin identifiers that are currently disabled. If not provided this
|
||||
defaults to all plugins for which ``enabled`` is set to ``False`` in the settings.
|
||||
defaults to all plugins for which `enabled` is set to `False` in the settings.
|
||||
plugin_sorting_order (dict): A dict containing a custom sorting orders for plugins. The keys are plugin identifiers,
|
||||
mapped to dictionaries containing the sorting contexts as key and the custom sorting value as value.
|
||||
plugin_blacklist (list): A list of plugin identifiers/identifier-requirement tuples
|
||||
that are currently blacklisted.
|
||||
plugin_restart_needing_hooks (list): A list of hook namespaces which cause a plugin to need a restart in order
|
||||
be enabled/disabled. Does not have to contain full hook identifiers, will be matched with startswith similar
|
||||
to logging handlers
|
||||
be enabled/disabled. Does not have to contain full hook identifiers, will be matched with glob patterns. If
|
||||
not provided this defaults to `octoprint.server.http.*`, `octoprint.printer.factory`,
|
||||
`octoprint.access.permissions` and `octoprint.timelapse.extensions`.
|
||||
plugin_obsolete_hooks (list): A list of hooks that have been declared obsolete. Plugins implementing them will
|
||||
not be enabled since they might depend on functionality that is no longer available.
|
||||
not be enabled since they might depend on functionality that is no longer available. If not provided this
|
||||
defaults to `octoprint.comm.protocol.gcode`.
|
||||
plugin_considered_bundled (list): A list of plugin identifiers that are considered bundled plugins even if
|
||||
installed separately.
|
||||
installed separately. If not provided this defaults to `firmware_check`, `file_check` and `pi_support`.
|
||||
plugin_validators (list): A list of additional plugin validators through which to process each plugin.
|
||||
compatibility_ignored_list (list): A list of plugin keys for which it will be ignored if they are flagged as
|
||||
incompatible. This is for development purposes only and should not be used in production.
|
||||
|
||||
Returns:
|
||||
PluginManager: A fully initialized :class:`~octoprint.plugin.core.PluginManager` instance to be used for plugin
|
||||
(octoprint.plugin.core.PluginManager): A fully initialized `PluginManager` instance to be used for plugin
|
||||
management tasks.
|
||||
|
||||
Raises:
|
||||
ValueError: ``init`` was True although the plugin manager was already initialized, or it was False although
|
||||
ValueError: `init` was `True` although the plugin manager was already initialized, or it was `False` although
|
||||
the plugin manager was not yet initialized.
|
||||
"""
|
||||
|
||||
@@ -105,13 +100,19 @@ def plugin_manager(
|
||||
"octoprint.printer.factory",
|
||||
"octoprint.access.permissions",
|
||||
"octoprint.timelapse.extensions",
|
||||
]
|
||||
] # if changed update docs above!
|
||||
|
||||
if plugin_obsolete_hooks is None:
|
||||
plugin_obsolete_hooks = ["octoprint.comm.protocol.gcode"]
|
||||
plugin_obsolete_hooks = [
|
||||
"octoprint.comm.protocol.gcode"
|
||||
] # if changed update docs above!
|
||||
|
||||
if plugin_considered_bundled is None:
|
||||
plugin_considered_bundled = ["firmware_check", "file_check", "pi_support"]
|
||||
plugin_considered_bundled = [
|
||||
"firmware_check",
|
||||
"file_check",
|
||||
"pi_support",
|
||||
] # if changed update docs above!
|
||||
|
||||
if plugin_validators is None:
|
||||
plugin_validators = [_validate_plugin]
|
||||
@@ -122,7 +123,7 @@ def plugin_manager(
|
||||
plugin_folders,
|
||||
plugin_bases,
|
||||
plugin_entry_points,
|
||||
logging_prefix="octoprint.plugins.",
|
||||
logging_prefix="octoprint.plugins.", # if changed update docs above!
|
||||
plugin_disabled_list=plugin_disabled_list,
|
||||
plugin_sorting_order=plugin_sorting_order,
|
||||
plugin_blacklist=plugin_blacklist,
|
||||
@@ -145,17 +146,17 @@ def plugin_settings(
|
||||
settings=None,
|
||||
):
|
||||
"""
|
||||
Factory method for creating a :class:`PluginSettings` instance.
|
||||
Factory method for creating a `PluginSettings` instance.
|
||||
|
||||
Arguments:
|
||||
plugin_key (string): The plugin identifier for which to create the settings instance.
|
||||
plugin_key (str): The plugin identifier for which to create the settings instance.
|
||||
defaults (dict): The default settings for the plugin, if different from get_settings_defaults.
|
||||
get_preprocessors (dict): The getter preprocessors for the plugin.
|
||||
set_preprocessors (dict): The setter preprocessors for the plugin.
|
||||
settings (octoprint.settings.Settings): The settings instance to use.
|
||||
|
||||
Returns:
|
||||
PluginSettings: A fully initialized :class:`PluginSettings` instance to be used to access the plugin's
|
||||
(octoprint.plugin.PluginSettings): A fully initialized `PluginSettings` instance to be used to access the plugin's
|
||||
settings
|
||||
"""
|
||||
if settings is None:
|
||||
@@ -171,18 +172,18 @@ def plugin_settings(
|
||||
|
||||
def plugin_settings_for_settings_plugin(plugin_key, instance, settings=None):
|
||||
"""
|
||||
Factory method for creating a :class:`PluginSettings` instance for a given :class:`SettingsPlugin` instance.
|
||||
Factory method for creating a `PluginSettings` instance for a given `SettingsPlugin` instance.
|
||||
|
||||
Will return `None` if the provided `instance` is not a :class:`SettingsPlugin` instance.
|
||||
Will return `None` if the provided `instance` is not a [SettingsPlugin][octoprint.plugin.types.SettingsPlugin] instance.
|
||||
|
||||
Arguments:
|
||||
plugin_key (string): The plugin identifier for which to create the settings instance.
|
||||
implementation (octoprint.plugin.SettingsPlugin): The :class:`SettingsPlugin` instance.
|
||||
instance (octoprint.plugin.types.SettingsPlugin): The `SettingsPlugin` instance.
|
||||
settings (octoprint.settings.Settings): The settings instance to use. Defaults to the global OctoPrint settings.
|
||||
|
||||
Returns:
|
||||
PluginSettings or None: A fully initialized :class:`PluginSettings` instance to be used to access the plugin's
|
||||
settings, or `None` if the provided `instance` was not a class:`SettingsPlugin`
|
||||
(octoprint.plugin.PluginSettings | None): A fully initialized `PluginSettings` instance to be used to access the plugin's
|
||||
settings, or `None` if the provided `instance` was not a `SettingsPlugin`
|
||||
"""
|
||||
if not isinstance(instance, SettingsPlugin):
|
||||
return None
|
||||
@@ -212,43 +213,45 @@ def call_plugin(
|
||||
error_callback=None,
|
||||
sorting_context=None,
|
||||
initialized=True,
|
||||
manager=None,
|
||||
):
|
||||
"""
|
||||
Helper method to invoke the indicated ``method`` on all registered plugin implementations implementing the
|
||||
indicated ``types``. Allows providing method arguments and registering callbacks to call in case of success
|
||||
Helper method to invoke the indicated `method` on all registered plugin implementations implementing the
|
||||
indicated `types`. Allows providing method arguments and registering callbacks to call in case of success
|
||||
and/or failure of each call which can be used to return individual results to the calling code.
|
||||
|
||||
Example:
|
||||
|
||||
.. sourcecode:: python
|
||||
``` python
|
||||
def my_success_callback(name, plugin, result):
|
||||
print("{name} was called successfully and returned {result!r}".format(**locals()))
|
||||
|
||||
def my_success_callback(name, plugin, result):
|
||||
print("{name} was called successfully and returned {result!r}".format(**locals()))
|
||||
def my_error_callback(name, plugin, exc):
|
||||
print("{name} raised an exception: {exc!s}".format(**locals()))
|
||||
|
||||
def my_error_callback(name, plugin, exc):
|
||||
print("{name} raised an exception: {exc!s}".format(**locals()))
|
||||
|
||||
octoprint.plugin.call_plugin(
|
||||
[octoprint.plugin.StartupPlugin],
|
||||
"on_startup",
|
||||
args=(my_host, my_port),
|
||||
callback=my_success_callback,
|
||||
error_callback=my_error_callback
|
||||
)
|
||||
octoprint.plugin.call_plugin(
|
||||
[octoprint.plugin.StartupPlugin],
|
||||
"on_startup",
|
||||
args=(my_host, my_port),
|
||||
callback=my_success_callback,
|
||||
error_callback=my_error_callback
|
||||
)
|
||||
```
|
||||
|
||||
Arguments:
|
||||
types (list): A list of plugin implementation types to match against.
|
||||
method (string): Name of the method to call on all matching implementations.
|
||||
args (tuple): A tuple containing the arguments to supply to the called ``method``. Optional.
|
||||
kwargs (dict): A dictionary containing the keyword arguments to supply to the called ``method``. Optional.
|
||||
callback (function): A callback to invoke after an implementation has been called successfully. Will be called
|
||||
with the three arguments ``name``, ``plugin`` and ``result``. ``name`` will be the plugin identifier,
|
||||
``plugin`` the plugin implementation instance itself and ``result`` the result returned from the
|
||||
``method`` invocation.
|
||||
error_callback (function): A callback to invoke after the call of an implementation resulted in an exception.
|
||||
Will be called with the three arguments ``name``, ``plugin`` and ``exc``. ``name`` will be the plugin
|
||||
identifier, ``plugin`` the plugin implementation instance itself and ``exc`` the caught exception.
|
||||
initialized (boolean): Ignored.
|
||||
method (str): Name of the method to call on all matching implementations.
|
||||
args (tuple): A tuple containing the arguments to supply to the called `method`. Optional.
|
||||
kwargs (dict): A dictionary containing the keyword arguments to supply to the called `method`. Optional.
|
||||
callback (callable): A callback to invoke after an implementation has been called successfully. Will be called
|
||||
with the three arguments `name`, `plugin` and `result`. `name` will be the plugin identifier,
|
||||
`plugin` the plugin implementation instance itself and `result` the result returned from the
|
||||
`method` invocation.
|
||||
error_callback (callable): A callback to invoke after the call of an implementation resulted in an exception.
|
||||
Will be called with the three arguments `name`, `plugin` and `exc`. `name` will be the plugin
|
||||
identifier, `plugin` the plugin implementation instance itself and `exc` the caught exception.
|
||||
initialized (bool): Ignored.
|
||||
manager (octoprint.plugin.core.PluginManager | None): The plugin manager to use. If not provided, the global plugin manager
|
||||
"""
|
||||
|
||||
if not isinstance(types, (list, tuple)):
|
||||
@@ -257,12 +260,12 @@ def call_plugin(
|
||||
args = []
|
||||
if kwargs is None:
|
||||
kwargs = {}
|
||||
if manager is None:
|
||||
manager = plugin_manager()
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
plugins = plugin_manager().get_implementations(
|
||||
*types, sorting_context=sorting_context
|
||||
)
|
||||
plugins = manager.get_implementations(*types, sorting_context=sorting_context)
|
||||
for plugin in plugins:
|
||||
if not hasattr(plugin, "_identifier"):
|
||||
continue
|
||||
@@ -284,107 +287,22 @@ def call_plugin(
|
||||
|
||||
class PluginSettings:
|
||||
"""
|
||||
The :class:`PluginSettings` class is the interface for plugins to their own or globally defined settings.
|
||||
The `PluginSettings` class is the interface for plugins to their own or globally defined settings.
|
||||
|
||||
It provides some convenience methods for directly accessing plugin settings via the regular
|
||||
:class:`octoprint.settings.Settings` interfaces as well as means to access plugin specific folder locations.
|
||||
[Settings][octoprint.settings.Settings] interfaces as well as means to access plugin specific folder locations.
|
||||
|
||||
All getter and setter methods will ensure that plugin settings are stored in their correct location within the
|
||||
settings structure by modifying the supplied paths accordingly.
|
||||
|
||||
Arguments:
|
||||
settings (Settings): The :class:`~octoprint.settings.Settings` instance on which to operate.
|
||||
settings (octoprint.settings.Settings): The `Settings` instance on which to operate.
|
||||
plugin_key (str): The plugin identifier of the plugin for which to create this instance.
|
||||
defaults (dict): The plugin's defaults settings, will be used to determine valid paths within the plugin's
|
||||
settings structure
|
||||
|
||||
.. method:: get(path, merged=False, asdict=False)
|
||||
|
||||
Retrieves a raw value from the settings for ``path``, optionally merging the raw value with the default settings
|
||||
if ``merged`` is set to True.
|
||||
|
||||
:param path: The path for which to retrieve the value.
|
||||
:type path: list, tuple
|
||||
:param boolean merged: Whether to merge the returned result with the default settings (True) or not (False,
|
||||
default).
|
||||
:returns: The retrieved settings value.
|
||||
:rtype: object
|
||||
|
||||
.. method:: get_int(path, min=None, max=None)
|
||||
|
||||
Like :func:`get` but tries to convert the retrieved value to ``int``. If ``min`` is provided and the retrieved
|
||||
value is less than it, it will be returned instead of the value. Likewise for ``max`` - it will be returned if
|
||||
the value is greater than it.
|
||||
|
||||
.. method:: get_float(path, min=None, max=None)
|
||||
|
||||
Like :func:`get` but tries to convert the retrieved value to ``float``. If ``min`` is provided and the retrieved
|
||||
value is less than it, it will be returned instead of the value. Likewise for ``max`` - it will be returned if
|
||||
the value is greater than it.
|
||||
|
||||
.. method:: get_boolean(path)
|
||||
|
||||
Like :func:`get` but tries to convert the retrieved value to ``boolean``.
|
||||
|
||||
.. method:: set(path, value, force=False)
|
||||
|
||||
Sets the raw value on the settings for ``path``.
|
||||
|
||||
:param path: The path for which to retrieve the value.
|
||||
:type path: list, tuple
|
||||
:param object value: The value to set.
|
||||
:param boolean force: If set to True, the modified configuration will even be written back to disk if
|
||||
the value didn't change.
|
||||
|
||||
.. method:: set_int(path, value, force=False, min=None, max=None)
|
||||
|
||||
Like :func:`set` but ensures the value is an ``int`` through attempted conversion before setting it.
|
||||
If ``min`` and/or ``max`` are provided, it will also be ensured that the value is greater than or equal
|
||||
to ``min`` and less than or equal to ``max``. If that is not the case, the limit value (``min`` if less than
|
||||
that, ``max`` if greater than that) will be set instead.
|
||||
|
||||
.. method:: set_float(path, value, force=False, min=None, max=None)
|
||||
|
||||
Like :func:`set` but ensures the value is an ``float`` through attempted conversion before setting it.
|
||||
If ``min`` and/or ``max`` are provided, it will also be ensured that the value is greater than or equal
|
||||
to ``min`` and less than or equal to ``max``. If that is not the case, the limit value (``min`` if less than
|
||||
that, ``max`` if greater than that) will be set instead.
|
||||
|
||||
.. method:: set_boolean(path, value, force=False)
|
||||
|
||||
Like :func:`set` but ensures the value is an ``boolean`` through attempted conversion before setting it.
|
||||
|
||||
.. method:: save(force=False, trigger_event=False)
|
||||
|
||||
Saves the settings to ``config.yaml`` if there are active changes. If ``force`` is set to ``True`` the settings
|
||||
will be saved even if there are no changes. Settings ``trigger_event`` to ``True`` will cause a ``SettingsUpdated``
|
||||
:ref:`event <sec-events-available_events-settings>` to get triggered.
|
||||
|
||||
:param force: Force saving to ``config.yaml`` even if there are no changes.
|
||||
:type force: boolean
|
||||
:param trigger_event: Trigger the ``SettingsUpdated`` :ref:`event <sec-events-available_events-settings>` on save.
|
||||
:type trigger_event: boolean
|
||||
|
||||
.. method:: add_overlay(overlay, at_end=False, key=None)
|
||||
|
||||
Adds a new config overlay for the plugin's settings. Will return the overlay's key in the map.
|
||||
|
||||
:param overlay: Overlay dict to add
|
||||
:type overlay: dict
|
||||
:param at_end: Whether to add overlay at end or start (default) of config hierarchy
|
||||
:type at_end: boolean
|
||||
:param key: Key to use to identify overlay. If not set one will be built based on the overlay's hash
|
||||
:type key: str
|
||||
:rtype: str
|
||||
|
||||
.. method:: remove_overlay(key)
|
||||
|
||||
Removes an overlay from the settings based on its key. Return ``True`` if the overlay could be found and was
|
||||
removed, ``False`` otherwise.
|
||||
|
||||
:param key: The key of the overlay to remove
|
||||
:type key: str
|
||||
:rtype: boolean
|
||||
defaults (dict): The plugin's defaults settings.
|
||||
get_preprocessors (dict): The plugin's get preprocessors. A dict of settings paths to callables that will
|
||||
be called with the value of the setting and should return the processed value.
|
||||
set_preprocessors (dict): The plugin's set preprocessors. A dict of settings paths to callables that will
|
||||
be called with the value of the setting and should return the processed value.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
@@ -396,169 +314,345 @@ class PluginSettings:
|
||||
set_preprocessors=None,
|
||||
):
|
||||
self.settings = settings
|
||||
""" The `Settings` instance on which to operate. """
|
||||
|
||||
self.plugin_key = plugin_key
|
||||
""" The plugin identifier of the plugin for which this instance was created. """
|
||||
|
||||
self.defaults = None
|
||||
""" The plugin's defaults settings, prefixed with the plugin's settings path. """
|
||||
|
||||
if defaults is not None:
|
||||
self.defaults = {"plugins": {}}
|
||||
self.defaults["plugins"][plugin_key] = defaults
|
||||
self.defaults["plugins"][plugin_key]["_config_version"] = None
|
||||
else:
|
||||
self.defaults = None
|
||||
|
||||
self.get_preprocessors = {"plugins": {}}
|
||||
""" The plugin's get preprocessors, prefixed with the plugin's settings path. """
|
||||
|
||||
if get_preprocessors is None:
|
||||
get_preprocessors = {}
|
||||
self.get_preprocessors = {"plugins": {}}
|
||||
self.get_preprocessors["plugins"][plugin_key] = get_preprocessors
|
||||
|
||||
self.set_preprocessors = {"plugins": {}}
|
||||
""" The plugin's set preprocessors, prefixed with the plugin's settings path. """
|
||||
|
||||
if set_preprocessors is None:
|
||||
set_preprocessors = {}
|
||||
self.set_preprocessors = {"plugins": {}}
|
||||
self.set_preprocessors["plugins"][plugin_key] = set_preprocessors
|
||||
|
||||
def prefix_path_in_args(args, index=0):
|
||||
result = []
|
||||
if index == 0:
|
||||
result.append(self._prefix_path(args[0]))
|
||||
result.extend(args[1:])
|
||||
else:
|
||||
args_before = args[: index - 1]
|
||||
args_after = args[index + 1 :]
|
||||
result.extend(args_before)
|
||||
result.append(self._prefix_path(args[index]))
|
||||
result.extend(args_after)
|
||||
return result
|
||||
|
||||
def add_getter_kwargs(kwargs):
|
||||
if "defaults" not in kwargs and self.defaults is not None:
|
||||
kwargs.update(defaults=self.defaults)
|
||||
if "preprocessors" not in kwargs:
|
||||
kwargs.update(preprocessors=self.get_preprocessors)
|
||||
return kwargs
|
||||
|
||||
def add_setter_kwargs(kwargs):
|
||||
if "defaults" not in kwargs and self.defaults is not None:
|
||||
kwargs.update(defaults=self.defaults)
|
||||
if "preprocessors" not in kwargs:
|
||||
kwargs.update(preprocessors=self.set_preprocessors)
|
||||
return kwargs
|
||||
|
||||
def wrap_overlay(args):
|
||||
result = list(args)
|
||||
overlay = result[0]
|
||||
result[0] = {"plugins": {plugin_key: overlay}}
|
||||
return result
|
||||
|
||||
self.access_methods = {
|
||||
"has": ("has", prefix_path_in_args, add_getter_kwargs),
|
||||
"get": ("get", prefix_path_in_args, add_getter_kwargs),
|
||||
"get_int": ("getInt", prefix_path_in_args, add_getter_kwargs),
|
||||
"get_float": ("getFloat", prefix_path_in_args, add_getter_kwargs),
|
||||
"get_boolean": ("getBoolean", prefix_path_in_args, add_getter_kwargs),
|
||||
"set": ("set", prefix_path_in_args, add_setter_kwargs),
|
||||
"set_int": ("setInt", prefix_path_in_args, add_setter_kwargs),
|
||||
"set_float": ("setFloat", prefix_path_in_args, add_setter_kwargs),
|
||||
"set_boolean": ("setBoolean", prefix_path_in_args, add_setter_kwargs),
|
||||
"remove": ("remove", prefix_path_in_args, lambda x: x),
|
||||
"add_overlay": ("add_overlay", wrap_overlay, lambda x: x),
|
||||
"remove_overlay": ("remove_overlay", lambda x: x, lambda x: x),
|
||||
}
|
||||
self.deprecated_access_methods = {
|
||||
"getInt": "get_int",
|
||||
"getFloat": "get_float",
|
||||
"getBoolean": "get_boolean",
|
||||
"setInt": "set_int",
|
||||
"setFloat": "set_float",
|
||||
"setBoolean": "set_boolean",
|
||||
}
|
||||
|
||||
def _prefix_path(self, path=None):
|
||||
if path is None:
|
||||
path = list()
|
||||
return ["plugins", self.plugin_key] + path
|
||||
|
||||
def _add_getter_kwargs(self, kwargs):
|
||||
if "defaults" not in kwargs and self.defaults is not None:
|
||||
kwargs.update(defaults=self.defaults)
|
||||
if "preprocessors" not in kwargs:
|
||||
kwargs.update(preprocessors=self.get_preprocessors)
|
||||
return kwargs
|
||||
|
||||
def _add_setter_kwargs(self, kwargs):
|
||||
if "defaults" not in kwargs and self.defaults is not None:
|
||||
kwargs.update(defaults=self.defaults)
|
||||
if "preprocessors" not in kwargs:
|
||||
kwargs.update(preprocessors=self.set_preprocessors)
|
||||
return kwargs
|
||||
|
||||
def _wrap_overlay(self, args):
|
||||
result = list(args)
|
||||
overlay = result[0]
|
||||
result[0] = {"plugins": {self.plugin_key: overlay}}
|
||||
return result
|
||||
|
||||
def has(self, path, **kwargs):
|
||||
"""
|
||||
Checks whether a value for `path` is present in the settings.
|
||||
|
||||
Arguments:
|
||||
path (list, tuple): The path for which to check the value.
|
||||
|
||||
Returns:
|
||||
(bool): Whether a value for `path` is present in the settings.
|
||||
"""
|
||||
return self.settings.has(
|
||||
self._prefix_path(path), **self._add_getter_kwargs(kwargs)
|
||||
)
|
||||
|
||||
def get(self, path, **kwargs):
|
||||
"""
|
||||
Retrieves a raw value from the settings for `path`, optionally merging the raw value with the default settings
|
||||
if `merged` is set to True.
|
||||
|
||||
Arguments:
|
||||
path (list, tuple): The path for which to retrieve the value.
|
||||
merged (bool): Whether to merge the returned result with the default settings (True) or not (False,
|
||||
default).
|
||||
asdict (bool): Whether to return the result as a dictionary (True) or not (False, default).
|
||||
|
||||
Returns:
|
||||
(object): The retrieved settings value.
|
||||
"""
|
||||
return self.settings.get(
|
||||
self._prefix_path(path), **self._add_getter_kwargs(kwargs)
|
||||
)
|
||||
|
||||
def get_int(self, path, **kwargs):
|
||||
"""
|
||||
Like `get` but tries to convert the retrieved value to [int][]. If `min` is provided and the retrieved
|
||||
value is less than it, it will be returned instead of the value. Likewise for `max` - it will be returned if
|
||||
the value is greater than it.
|
||||
|
||||
Arguments:
|
||||
path (list, tuple): The path for which to retrieve the value.
|
||||
min (int): The minimum value to return.
|
||||
max (int): The maximum value to return.
|
||||
|
||||
Returns:
|
||||
(int | None): The retrieved settings value, converted to an integer, if possible, `None` otherwise
|
||||
"""
|
||||
return self.settings.getInt(
|
||||
self._prefix_path(path), **self._add_getter_kwargs(kwargs)
|
||||
)
|
||||
|
||||
def get_float(self, path, **kwargs):
|
||||
"""
|
||||
Like `get` but tries to convert the retrieved value to [float][]. If `min` is provided and the retrieved
|
||||
value is less than it, it will be returned instead of the value. Likewise for `max` - it will be returned if
|
||||
the value is greater than it.
|
||||
|
||||
Arguments:
|
||||
path (list, tuple): The path for which to retrieve the value.
|
||||
min (float): The minimum value to return.
|
||||
max (float): The maximum value to return.
|
||||
|
||||
Returns:
|
||||
(float | None): The retrieved settings value, converted to a float, if possible, `None` otherwise
|
||||
"""
|
||||
return self.settings.getFloat(
|
||||
self._prefix_path(path), **self._add_getter_kwargs(kwargs)
|
||||
)
|
||||
|
||||
def get_boolean(self, path, **kwargs):
|
||||
"""
|
||||
Like `get` but tries to convert the retrieved value to [bool][].
|
||||
|
||||
Arguments:
|
||||
path (list, tuple): The path for which to retrieve the value.
|
||||
|
||||
Returns:
|
||||
(bool | None): The retrieved settings value, converted to a boolean, if possible, `None` otherwise
|
||||
"""
|
||||
return self.settings.getBoolean(
|
||||
self._prefix_path(path), **self._add_getter_kwargs(kwargs)
|
||||
)
|
||||
|
||||
def set(self, path, value, **kwargs):
|
||||
"""
|
||||
Sets the raw value on the settings for `path`.
|
||||
|
||||
Arguments:
|
||||
path (list, tuple): The path for which to set the value.
|
||||
value (object): The value to set.
|
||||
force (bool): If set to True, the modified configuration will be written back to disk even if
|
||||
the value didn't change.
|
||||
"""
|
||||
return self.settings.set(
|
||||
self._prefix_path(path), value, **self._add_setter_kwargs(kwargs)
|
||||
)
|
||||
|
||||
def set_int(self, path, value, **kwargs):
|
||||
"""
|
||||
Like `set` but ensures the value is an [int][] through attempted conversion before setting it.
|
||||
|
||||
If `min` and/or `max` are provided, it will also be ensured that the value is greater than or equal
|
||||
to `min` and less than or equal to `max`. If that is not the case, the limit value (`min` if less than
|
||||
that, `max` if greater than that) will be set instead.
|
||||
|
||||
Arguments:
|
||||
path (list, tuple): The path for which to set the value.
|
||||
value (object): The value to set.
|
||||
min (int): The minimum value to set.
|
||||
max (int): The maximum value to set.
|
||||
"""
|
||||
return self.settings.setInt(
|
||||
self._prefix_path(path), value, **self._add_setter_kwargs(kwargs)
|
||||
)
|
||||
|
||||
def set_float(self, path, value, **kwargs):
|
||||
"""
|
||||
Like `set` but ensures the value is an [float][] through attempted conversion before setting it.
|
||||
|
||||
If `min` and/or `max` are provided, it will also be ensured that the value is greater than or equal
|
||||
to `min` and less than or equal to `max`. If that is not the case, the limit value (`min` if less than
|
||||
that, `max` if greater than that) will be set instead.
|
||||
|
||||
Arguments:
|
||||
path (list, tuple): The path for which to set the value.
|
||||
value (object): The value to set.
|
||||
min (float): The minimum value to set.
|
||||
max (float): The maximum value to set.
|
||||
"""
|
||||
return self.settings.setFloat(
|
||||
self._prefix_path(path), value, **self._add_setter_kwargs(kwargs)
|
||||
)
|
||||
|
||||
def set_boolean(self, path, value, **kwargs):
|
||||
"""
|
||||
Like `set` but ensures the value is an [bool][] through attempted conversion before setting it.
|
||||
|
||||
Arguments:
|
||||
path (list, tuple): The path for which to set the value.
|
||||
value (object): The value to set.
|
||||
"""
|
||||
return self.settings.setBoolean(
|
||||
self._prefix_path(path), value, **self._add_setter_kwargs(kwargs)
|
||||
)
|
||||
|
||||
def remove(self, path, **kwargs):
|
||||
"""
|
||||
Removes the value for `path` from the settings.
|
||||
|
||||
Arguments:
|
||||
path (list, tuple): The path for which to remove the value.
|
||||
"""
|
||||
return self.settings.remove(self._prefix_path(path), **kwargs)
|
||||
|
||||
def add_overlay(self, overlay, **kwargs):
|
||||
"""
|
||||
Adds an overlay for th plugin to the settings.
|
||||
|
||||
Arguments:
|
||||
overlay (dict): The overlay to add.
|
||||
|
||||
Returns:
|
||||
(str): The key under which the overlay was added.
|
||||
"""
|
||||
return self.settings.add_overlay(*self._wrap_overlay(overlay), **kwargs)
|
||||
|
||||
def remove_overlay(self, key):
|
||||
"""
|
||||
Removes an overlay from the settings by `key`.
|
||||
|
||||
Arguments:
|
||||
key (str): The key of the overlay to remove.
|
||||
"""
|
||||
return self.settings.remove_overlay(key)
|
||||
|
||||
def global_has(self, path, **kwargs):
|
||||
"""
|
||||
Checks whether the global settings structure has a value for `path`.
|
||||
|
||||
Directly forwards to [octoprint.settings.Settings.has][].
|
||||
"""
|
||||
return self.settings.has(path, **kwargs)
|
||||
|
||||
def global_remove(self, path, **kwargs):
|
||||
"""
|
||||
Removes the value for `path` from the global settings structure.
|
||||
|
||||
Directly forwards to [octoprint.settings.Settings.remove][].
|
||||
"""
|
||||
return self.settings.remove(path, **kwargs)
|
||||
|
||||
def global_get(self, path, **kwargs):
|
||||
"""
|
||||
Getter for retrieving settings not managed by the plugin itself from the core settings structure. Use this
|
||||
to access global settings outside of your plugin.
|
||||
Gets a value from the global settings structure.
|
||||
|
||||
Directly forwards to :func:`octoprint.settings.Settings.get`.
|
||||
Directly forwards to [octoprint.settings.Settings.get][]. See its documentation for possible
|
||||
parameters.
|
||||
"""
|
||||
return self.settings.get(path, **kwargs)
|
||||
|
||||
def global_get_int(self, path, **kwargs):
|
||||
"""
|
||||
Like :func:`global_get` but directly forwards to :func:`octoprint.settings.Settings.getInt`.
|
||||
Gets a value from the global settings structure and tries to convert it to [int][].
|
||||
|
||||
Directly forwards to [octoprint.settings.Settings.getInt][]. See its documentation for possible
|
||||
parameters.
|
||||
"""
|
||||
return self.settings.getInt(path, **kwargs)
|
||||
|
||||
def global_get_float(self, path, **kwargs):
|
||||
"""
|
||||
Like :func:`global_get` but directly forwards to :func:`octoprint.settings.Settings.getFloat`.
|
||||
Gets a value from the global settings structure and tries to convert it to [float][].
|
||||
|
||||
Directly forwards to [octoprint.settings.Settings.getFloat][]. See its documentation for possible
|
||||
parameters.
|
||||
"""
|
||||
return self.settings.getFloat(path, **kwargs)
|
||||
|
||||
def global_get_boolean(self, path, **kwargs):
|
||||
"""
|
||||
Like :func:`global_get` but directly orwards to :func:`octoprint.settings.Settings.getBoolean`.
|
||||
Gets a value from the global settings structure and tries to convert it to [bool][].
|
||||
|
||||
Directly forwards to [octoprint.settings.Settings.getBoolean][]. See its documentation for possible
|
||||
parameters.
|
||||
"""
|
||||
return self.settings.getBoolean(path, **kwargs)
|
||||
|
||||
def global_set(self, path, value, **kwargs):
|
||||
"""
|
||||
Setter for modifying settings not managed by the plugin itself on the core settings structure. Use this
|
||||
to modify global settings outside of your plugin.
|
||||
Sets a value in the global settings structure.
|
||||
|
||||
Directly forwards to :func:`octoprint.settings.Settings.set`.
|
||||
Directly forwards to [octoprint.settings.Settings.set][]. See its documentation for possible
|
||||
parameters.
|
||||
"""
|
||||
self.settings.set(path, value, **kwargs)
|
||||
|
||||
def global_set_int(self, path, value, **kwargs):
|
||||
"""
|
||||
Like :func:`global_set` but directly forwards to :func:`octoprint.settings.Settings.setInt`.
|
||||
Sets a value in the global settings structure and tries to convert it to [int][].
|
||||
|
||||
Directly forwards to [octoprint.settings.Settings.setInt][]. See its documentation for possible
|
||||
parameters.
|
||||
"""
|
||||
self.settings.setInt(path, value, **kwargs)
|
||||
|
||||
def global_set_float(self, path, value, **kwargs):
|
||||
"""
|
||||
Like :func:`global_set` but directly forwards to :func:`octoprint.settings.Settings.setFloat`.
|
||||
Sets a value in the global settings structure and tries to convert it to [float][].
|
||||
|
||||
Directly forwards to [octoprint.settings.Settings.setFloat][]. See its documentation for possible
|
||||
parameters.
|
||||
"""
|
||||
self.settings.setFloat(path, value, **kwargs)
|
||||
|
||||
def global_set_boolean(self, path, value, **kwargs):
|
||||
"""
|
||||
Like :func:`global_set` but directly forwards to :func:`octoprint.settings.Settings.setBoolean`.
|
||||
Sets a value in the global settings structure and tries to convert it to [bool][].
|
||||
|
||||
Directly forwards to [octoprint.settings.Settings.setBoolean][]. See its documentation for possible
|
||||
parameters.
|
||||
"""
|
||||
self.settings.setBoolean(path, value, **kwargs)
|
||||
|
||||
def global_get_basefolder(self, folder_type, **kwargs):
|
||||
"""
|
||||
Retrieves a globally defined basefolder of the given ``folder_type``. Directly forwards to
|
||||
:func:`octoprint.settings.Settings.getBaseFolder`.
|
||||
Retrieves a globally defined basefolder of the given `folder_type`.
|
||||
|
||||
Directly forwards to [octoprint.settings.Settings.getBaseFolder][].
|
||||
"""
|
||||
return self.settings.getBaseFolder(folder_type, **kwargs)
|
||||
|
||||
def get_plugin_logfile_path(self, postfix=None):
|
||||
"""
|
||||
Retrieves the path to a logfile specifically for the plugin. If ``postfix`` is not supplied, the logfile
|
||||
will be named ``plugin_<plugin identifier>.log`` and located within the configured ``logs`` folder. If a
|
||||
postfix is supplied, the name will be ``plugin_<plugin identifier>_<postfix>.log`` at the same location.
|
||||
Retrieves the path to a logfile specifically for the plugin.
|
||||
|
||||
Plugins may use this for specific logging tasks. For example, a :class:`~octoprint.plugin.SlicingPlugin` might
|
||||
If `postfix` is not supplied, the logfile will be named `plugin_<plugin identifier>.log` and located within the
|
||||
configured `logs` folder. If a postfix is supplied, the name will be `plugin_<plugin identifier>_<postfix>.log`
|
||||
at the same location.
|
||||
|
||||
Plugins may use this for specific logging tasks. For example, a [octoprint.plugin.types.SlicerPlugin][] might
|
||||
want to create a log file for logging the output of the slicing engine itself if some debug flag is set.
|
||||
|
||||
Arguments:
|
||||
postfix (str): Postfix of the logfile for which to create the path. If set, the file name of the log file
|
||||
will be ``plugin_<plugin identifier>_<postfix>.log``, if not it will be
|
||||
``plugin_<plugin identifier>.log``.
|
||||
will be `plugin_<plugin identifier>_<postfix>.log`, if not it will be `plugin_<plugin identifier>.log`.
|
||||
|
||||
Returns:
|
||||
str: Absolute path to the log file, directly usable by the plugin.
|
||||
(str): Absolute path to the log file, directly usable by the plugin.
|
||||
"""
|
||||
filename = "plugin_" + self.plugin_key
|
||||
if postfix is not None:
|
||||
@@ -577,7 +671,58 @@ class PluginSettings:
|
||||
os.makedirs(path)
|
||||
return path
|
||||
|
||||
@deprecated(
|
||||
"getInt has been renamed to get_int",
|
||||
includedoc="Replaced by [octoprint.plugin.types.OctoPrintPlugin.get_int][]",
|
||||
)
|
||||
def getInt(self, *args, **kwargs):
|
||||
return self.get_int(*args, **kwargs)
|
||||
|
||||
@deprecated(
|
||||
"getFloat has been renamed to get_float",
|
||||
includedoc="Replaced by [octoprint.plugin.types.OctoPrintPlugin.get_float][]",
|
||||
)
|
||||
def getFloat(self, *args, **kwargs):
|
||||
return self.get_float(*args, **kwargs)
|
||||
|
||||
@deprecated(
|
||||
"getBoolean has been renamed to get_boolean",
|
||||
includedoc="Replaced by [octoprint.plugin.types.OctoPrintPlugin.get_boolean][]",
|
||||
)
|
||||
def getBoolean(self, *args, **kwargs):
|
||||
return self.get_boolean(*args, **kwargs)
|
||||
|
||||
@deprecated(
|
||||
"setInt has been renamed to set_int",
|
||||
includedoc="Replaced by [octoprint.plugin.types.OctoPrintPlugin.set_int][]",
|
||||
)
|
||||
def setInt(self, *args, **kwargs):
|
||||
return self.set_int(*args, **kwargs)
|
||||
|
||||
@deprecated(
|
||||
"setFloat has been renamed to set_float",
|
||||
includedoc="Replaced by [octoprint.plugin.types.OctoPrintPlugin.set_float][]",
|
||||
)
|
||||
def setFloat(self, *args, **kwargs):
|
||||
return self.set_float(*args, **kwargs)
|
||||
|
||||
@deprecated(
|
||||
"setBoolean has been renamed to set_boolean",
|
||||
includedoc="Replaced by [octoprint.plugin.types.OctoPrintPlugin.set_boolean][]",
|
||||
)
|
||||
def setBoolean(self, *args, **kwargs):
|
||||
return self.set_boolean(*args, **kwargs)
|
||||
|
||||
def get_all_data(self, **kwargs):
|
||||
"""
|
||||
Returns all data stored for this plugin.
|
||||
|
||||
Arguments:
|
||||
merged (bool): Whether to merge the data with the defaults. Defaults to `True`.
|
||||
asdict (bool): Whether to return the data as a dict. Defaults to `True`.
|
||||
defaults (bool): Which defaults to use. Defaults to the plugin defaults.
|
||||
preprocessors (list): List of preprocessors to apply to the data. Defaults to the plugin preprocessors.
|
||||
"""
|
||||
merged = kwargs.get("merged", True)
|
||||
asdict = kwargs.get("asdict", True)
|
||||
defaults = kwargs.get("defaults", self.defaults)
|
||||
@@ -595,36 +740,10 @@ class PluginSettings:
|
||||
return self.settings.get(self._prefix_path(), **kwargs)
|
||||
|
||||
def clean_all_data(self):
|
||||
"""
|
||||
Removes all data stored for this plugin.
|
||||
"""
|
||||
self.settings.remove(self._prefix_path())
|
||||
|
||||
def __getattr__(self, item):
|
||||
all_access_methods = list(self.access_methods.keys()) + list(
|
||||
self.deprecated_access_methods.keys()
|
||||
)
|
||||
if item in all_access_methods:
|
||||
decorator = None
|
||||
if item in self.deprecated_access_methods:
|
||||
new = self.deprecated_access_methods[item]
|
||||
decorator = deprecated(
|
||||
f"{item} has been renamed to {new}",
|
||||
stacklevel=2,
|
||||
)
|
||||
item = new
|
||||
|
||||
settings_name, args_mapper, kwargs_mapper = self.access_methods[item]
|
||||
if hasattr(self.settings, settings_name) and callable(
|
||||
getattr(self.settings, settings_name)
|
||||
):
|
||||
orig_func = getattr(self.settings, settings_name)
|
||||
if decorator is not None:
|
||||
orig_func = decorator(orig_func)
|
||||
|
||||
def _func(*args, **kwargs):
|
||||
return orig_func(*args_mapper(args), **kwargs_mapper(kwargs))
|
||||
|
||||
_func.__name__ = item
|
||||
_func.__doc__ = orig_func.__doc__ if "__doc__" in dir(orig_func) else None
|
||||
|
||||
return _func
|
||||
|
||||
return getattr(self.settings, item)
|
||||
@@ -38,7 +38,6 @@ class ActionCommandPromptPlugin(
|
||||
octoprint.plugin.SimpleApiPlugin,
|
||||
octoprint.plugin.TemplatePlugin,
|
||||
):
|
||||
|
||||
COMMAND = "M876"
|
||||
CAP_PROMPT_SUPPORT = "PROMPT_SUPPORT"
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ class AnnouncementPlugin(
|
||||
octoprint.plugin.TemplatePlugin,
|
||||
octoprint.plugin.EventHandlerPlugin,
|
||||
):
|
||||
|
||||
# noinspection PyMissingConstructor
|
||||
def __init__(self):
|
||||
self._cached_channel_configs = None
|
||||
@@ -437,7 +436,7 @@ class AnnouncementPlugin(
|
||||
|
||||
if data is None:
|
||||
# cache not allowed or empty, fetch from network
|
||||
if self._connectivity_checker.online:
|
||||
if self._connectivity_checker.check_immediately():
|
||||
data = self._get_channel_data_from_network(key, config)
|
||||
else:
|
||||
self._logger.info(
|
||||
@@ -488,7 +487,7 @@ class AnnouncementPlugin(
|
||||
url = config["url"]
|
||||
try:
|
||||
start = time.monotonic()
|
||||
r = requests.get(url, timeout=30)
|
||||
r = requests.get(url, timeout=3.05)
|
||||
r.raise_for_status()
|
||||
self._logger.info(
|
||||
"Loaded channel {} from {} in {:.2}s".format(
|
||||
|
||||
@@ -1 +1 @@
|
||||
table th.settings_plugin_announcements_channels_name,table td.settings_plugin_announcements_channels_name{text-overflow:ellipsis;text-align:left}table th.settings_plugin_announcements_channels_actions,table td.settings_plugin_announcements_channels_actions{text-align:center;width:80px}table th.settings_plugin_announcements_channels_actions a,table td.settings_plugin_announcements_channels_actions a{text-decoration:none;color:#000}table th.settings_plugin_announcements_channels_actions a.disabled,table td.settings_plugin_announcements_channels_actions a.disabled{color:#ccc;cursor:default}#plugin_announcements_dialog .unread{font-weight:bold}#plugin_announcements_dialog article{padding-right:20px}#plugin_announcements_dialog article.read{opacity:.5}#plugin_announcements_dialog article.read:hover{opacity:1}#plugin_announcements_dialog article .actions{background-color:#f5f5f5;border-radius:2px;padding:2px 5px;margin-top:5px}#plugin_announcements_dialog article .actions .markread{float:right}#plugin_announcements_dialog article .actions a{color:black}#plugin_announcements_dialog .modal-footer .configurelink{float:left}
|
||||
table td.settings_plugin_announcements_channels_name,table th.settings_plugin_announcements_channels_name{text-overflow:ellipsis;text-align:left}table td.settings_plugin_announcements_channels_actions,table th.settings_plugin_announcements_channels_actions{text-align:center;width:80px}table td.settings_plugin_announcements_channels_actions a,table th.settings_plugin_announcements_channels_actions a{text-decoration:none;color:#000}table td.settings_plugin_announcements_channels_actions a.disabled,table th.settings_plugin_announcements_channels_actions a.disabled{color:#ccc;cursor:default}#plugin_announcements_dialog .unread{font-weight:700}#plugin_announcements_dialog article{padding-right:20px}#plugin_announcements_dialog article.read{opacity:.5}#plugin_announcements_dialog article.read:hover{opacity:1}#plugin_announcements_dialog article .actions{background-color:#f5f5f5;border-radius:2px;padding:2px 5px;margin-top:5px}#plugin_announcements_dialog article .actions .markread{float:right}#plugin_announcements_dialog article .actions a{color:#000}#plugin_announcements_dialog .modal-footer .configurelink{float:left}
|
||||
@@ -218,6 +218,8 @@ class AppKeysPlugin(
|
||||
@octoprint.plugin.BlueprintPlugin.route("/auth/<app_token>", methods=["GET"])
|
||||
@no_firstrun_access
|
||||
def handle_auth_dialog(self, app_token):
|
||||
from octoprint.server.util.csrf import add_csrf_cookie
|
||||
|
||||
user_id = current_user.get_name()
|
||||
required_user = flask.request.args.get("user", None)
|
||||
|
||||
@@ -256,7 +258,7 @@ class AppKeysPlugin(
|
||||
).replace("%(app)s", app_id),
|
||||
)
|
||||
)
|
||||
return add_non_caching_response_headers(response)
|
||||
return add_csrf_cookie(add_non_caching_response_headers(response))
|
||||
|
||||
@octoprint.plugin.BlueprintPlugin.route("/decision/<user_token>", methods=["POST"])
|
||||
@restricted_access
|
||||
|
||||
@@ -1 +1 @@
|
||||
#settings_plugin_appkeys_userkeys_table .settings_plugin_appkeys_actions,#settings_plugin_appkeys_allkeys_table .settings_plugin_appkeys_actions{width:75px;text-align:center}#settings_plugin_appkeys_userkeys_table .settings_plugin_appkeys_actions a,#settings_plugin_appkeys_allkeys_table .settings_plugin_appkeys_actions a{color:black}#settings_plugin_appkeys_userkeys_table .settings_plugin_appkeys_user,#settings_plugin_appkeys_allkeys_table .settings_plugin_appkeys_user{width:100px}#settings_plugin_appkeys_userkeys_table .settings_plugin_appkeys_checkbox,#settings_plugin_appkeys_allkeys_table .settings_plugin_appkeys_checkbox{text-align:center;width:10px}#settings_plugin_appkeys_userkeys_table .settings_plugin_appkeys_checkbox input[type="checkbox"],#settings_plugin_appkeys_allkeys_table .settings_plugin_appkeys_checkbox input[type="checkbox"]{margin-top:0}#plugin_appkeys_keygenerated .control-text{display:inline-block}
|
||||
#settings_plugin_appkeys_allkeys_table .settings_plugin_appkeys_actions,#settings_plugin_appkeys_userkeys_table .settings_plugin_appkeys_actions{width:75px;text-align:center}#settings_plugin_appkeys_allkeys_table .settings_plugin_appkeys_actions a,#settings_plugin_appkeys_userkeys_table .settings_plugin_appkeys_actions a{color:#000}#settings_plugin_appkeys_allkeys_table .settings_plugin_appkeys_user,#settings_plugin_appkeys_userkeys_table .settings_plugin_appkeys_user{width:100px}#settings_plugin_appkeys_allkeys_table .settings_plugin_appkeys_checkbox,#settings_plugin_appkeys_userkeys_table .settings_plugin_appkeys_checkbox{text-align:center;width:10px}#settings_plugin_appkeys_allkeys_table .settings_plugin_appkeys_checkbox input[type=checkbox],#settings_plugin_appkeys_userkeys_table .settings_plugin_appkeys_checkbox input[type=checkbox]{margin-top:0}#plugin_appkeys_keygenerated .control-text{display:inline-block}
|
||||
@@ -1 +1 @@
|
||||
body{padding-top:40px;padding-bottom:40px;background-color:#f5f5f5}#auth-choice,#auth-done,#auth-error,#auth-offline{max-width:300px;padding:19px 29px 29px;margin:0 auto 20px;background-color:#fff;border:1px solid #e5e5e5;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;-webkit-box-shadow:0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:0 1px 2px rgba(0,0,0,0.05);box-shadow:0 1px 2px rgba(0,0,0,0.05);text-align:center}.form-auth-heading{margin-bottom:10px}
|
||||
body{padding-top:40px;padding-bottom:40px;background-color:#f5f5f5}#auth-choice,#auth-done,#auth-error,#auth-offline{max-width:300px;padding:19px 29px 29px;margin:0 auto 20px;background-color:#fff;border:1px solid #e5e5e5;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;-webkit-box-shadow:0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:0 1px 2px rgba(0,0,0,.05);box-shadow:0 1px 2px rgba(0,0,0,.05);text-align:center}.form-auth-heading{margin-bottom:10px}
|
||||
@@ -76,7 +76,7 @@
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<button class="btn btn-primary" data-bind="click: generateKey">Generate</button>
|
||||
<button class="btn btn-primary" data-bind="click: generateKey">{{ _('Generate') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -60,7 +60,6 @@ class BackupPlugin(
|
||||
octoprint.plugin.StartupPlugin,
|
||||
octoprint.plugin.WizardPlugin,
|
||||
):
|
||||
|
||||
_pip_caller = None
|
||||
|
||||
_backup_in_progress = threading.Lock()
|
||||
@@ -168,7 +167,6 @@ class BackupPlugin(
|
||||
@no_firstrun_access
|
||||
@Permissions.PLUGIN_BACKUP_ACCESS.require(403)
|
||||
def create_backup(self):
|
||||
|
||||
data = flask.request.json
|
||||
exclude = data.get("exclude", [])
|
||||
filename = self._build_backup_filename(settings=self._settings)
|
||||
@@ -840,7 +838,7 @@ class BackupPlugin(
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
r = requests.get(url, timeout=30)
|
||||
r = requests.get(url, timeout=3.05)
|
||||
r.raise_for_status()
|
||||
except Exception:
|
||||
logger.exception(
|
||||
@@ -922,7 +920,6 @@ class BackupPlugin(
|
||||
)
|
||||
|
||||
with cls._backup_in_progress:
|
||||
|
||||
if name is None:
|
||||
name = cls._build_backup_filename(settings)
|
||||
|
||||
@@ -971,7 +968,9 @@ class BackupPlugin(
|
||||
final_path = os.path.join(datafolder, name)
|
||||
|
||||
own_folder = datafolder
|
||||
defaults = [os.path.join(basedir, "config.yaml"),] + [
|
||||
defaults = [
|
||||
os.path.join(basedir, "config.yaml"),
|
||||
] + [
|
||||
os.path.join(basedir, folder)
|
||||
for folder in default_settings["folder"].keys()
|
||||
]
|
||||
@@ -1179,7 +1178,6 @@ class BackupPlugin(
|
||||
on_restore_start(path)
|
||||
|
||||
try:
|
||||
|
||||
with zipfile.ZipFile(path, "r") as zip:
|
||||
# read metadata
|
||||
try:
|
||||
|
||||
@@ -1 +1 @@
|
||||
#settings_plugin_backup_backup_table .settings_plugin_backup_actions{width:75px;text-align:center}#settings_plugin_backup_backup_table .settings_plugin_backup_actions a{color:black}#settings_plugin_backup_backup_table .settings_plugin_backup_date{width:200px;text-align:right}#settings_plugin_backup_backup_table .settings_plugin_backup_size{width:100px;text-align:right}#settings_plugin_backup_backup_table .settings_plugin_backup_checkbox{text-align:center;width:10px}#settings_plugin_backup_backup_table .settings_plugin_backup_checkbox input[type="checkbox"]{margin-top:0}#settings_plugin_backup_restoredialog_output .message{font-weight:bold}#settings_plugin_backup_restoredialog_output .error{font-weight:bold;color:#990000}#settings_plugin_backup_restoredialog_output .stdout{color:#333333}#settings_plugin_backup_restoredialog_output .stderr{color:#990000}#settings_plugin_backup_restoredialog_output .call{color:#000099}
|
||||
#settings_plugin_backup_backup_table .settings_plugin_backup_actions{width:75px;text-align:center}#settings_plugin_backup_backup_table .settings_plugin_backup_actions a{color:#000}#settings_plugin_backup_backup_table .settings_plugin_backup_date{width:200px;text-align:right}#settings_plugin_backup_backup_table .settings_plugin_backup_size{width:100px;text-align:right}#settings_plugin_backup_backup_table .settings_plugin_backup_checkbox{text-align:center;width:10px}#settings_plugin_backup_backup_table .settings_plugin_backup_checkbox input[type=checkbox]{margin-top:0}#settings_plugin_backup_restoredialog_output .message{font-weight:700}#settings_plugin_backup_restoredialog_output .error{font-weight:700;color:#900}#settings_plugin_backup_restoredialog_output .stdout{color:#333}#settings_plugin_backup_restoredialog_output .stderr{color:#900}#settings_plugin_backup_restoredialog_output .call{color:#009}
|
||||
@@ -0,0 +1,248 @@
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
import threading
|
||||
|
||||
import requests
|
||||
from flask_babel import gettext
|
||||
|
||||
import octoprint.plugin
|
||||
from octoprint.schema.webcam import RatioEnum, Webcam, WebcamCompatibility
|
||||
from octoprint.webcams import WebcamNotAbleToTakeSnapshotException
|
||||
|
||||
|
||||
class ClassicWebcamPlugin(
|
||||
octoprint.plugin.AssetPlugin,
|
||||
octoprint.plugin.TemplatePlugin,
|
||||
octoprint.plugin.SettingsPlugin,
|
||||
octoprint.plugin.WebcamProviderPlugin,
|
||||
octoprint.plugin.WizardPlugin,
|
||||
):
|
||||
def __init__(self):
|
||||
self._capture_mutex = threading.Lock()
|
||||
self._webcam_name = "classic"
|
||||
|
||||
# ~~ TemplatePlugin API
|
||||
|
||||
def get_assets(self):
|
||||
return {
|
||||
"js": [
|
||||
"js/classicwebcam.js",
|
||||
"js/classicwebcam_settings.js",
|
||||
"js/classicwebcam_wizard.js",
|
||||
],
|
||||
"less": ["less/classicwebcam.less"],
|
||||
"css": ["css/classicwebcam.css"],
|
||||
}
|
||||
|
||||
def get_template_configs(self):
|
||||
return [
|
||||
{
|
||||
"type": "settings",
|
||||
"template": "classicwebcam_settings.jinja2",
|
||||
"custom_bindings": True,
|
||||
},
|
||||
{
|
||||
"type": "webcam",
|
||||
"name": "Classic Webcam",
|
||||
"template": "classicwebcam_webcam.jinja2",
|
||||
"custom_bindings": True,
|
||||
"suffix": "_real",
|
||||
},
|
||||
{
|
||||
"type": "wizard",
|
||||
"name": "Classic Webcam Wizard",
|
||||
"template": "classicwebcam_wizard.jinja2",
|
||||
"suffix": "_wizard",
|
||||
},
|
||||
]
|
||||
|
||||
# ~~ WebcamProviderPlugin API
|
||||
|
||||
def get_webcam_configurations(self):
|
||||
streamRatio = self._settings.get(["streamRatio"])
|
||||
if streamRatio == "4:3":
|
||||
streamRatio = RatioEnum.four_three
|
||||
else:
|
||||
streamRatio = RatioEnum.sixteen_nine
|
||||
webRtcServers = self._settings.get(["streamWebrtcIceServers"])
|
||||
cacheBuster = self._settings.get_boolean(["cacheBuster"])
|
||||
stream = self._get_stream_url()
|
||||
snapshot = self._get_snapshot_url()
|
||||
flipH = self._settings.get_boolean(["flipH"])
|
||||
flipV = self._settings.get_boolean(["flipV"])
|
||||
rotate90 = self._settings.get_boolean(["rotate90"])
|
||||
snapshotSslValidation = self._settings.get_boolean(["snapshotSslValidation"])
|
||||
|
||||
try:
|
||||
streamTimeout = int(self._settings.get(["streamTimeout"]))
|
||||
except Exception:
|
||||
streamTimeout = 5
|
||||
|
||||
try:
|
||||
snapshotTimeout = int(self._settings.get(["snapshotTimeout"]))
|
||||
except Exception:
|
||||
snapshotTimeout = 5
|
||||
|
||||
return [
|
||||
Webcam(
|
||||
name=self._webcam_name,
|
||||
displayName="Classic Webcam",
|
||||
flipH=flipH,
|
||||
flipV=flipV,
|
||||
rotate90=rotate90,
|
||||
snapshotDisplay=snapshot,
|
||||
canSnapshot=self._can_snapshot(),
|
||||
compat=WebcamCompatibility(
|
||||
stream=stream,
|
||||
streamTimeout=streamTimeout,
|
||||
streamRatio=streamRatio,
|
||||
cacheBuster=cacheBuster,
|
||||
streamWebrtcIceServers=webRtcServers,
|
||||
snapshot=snapshot,
|
||||
snapshotTimeout=snapshotTimeout,
|
||||
snapshotSslValidation=snapshotSslValidation,
|
||||
),
|
||||
extras=dict(
|
||||
stream=stream,
|
||||
streamTimeout=streamTimeout,
|
||||
streamRatio=streamRatio,
|
||||
streamWebrtcIceServers=webRtcServers,
|
||||
cacheBuster=cacheBuster,
|
||||
),
|
||||
),
|
||||
]
|
||||
|
||||
def _get_snapshot_url(self):
|
||||
return self._settings.get(["snapshot"])
|
||||
|
||||
def _get_stream_url(self):
|
||||
return self._settings.get(["stream"])
|
||||
|
||||
def _can_snapshot(self):
|
||||
snapshot = self._get_snapshot_url()
|
||||
return snapshot is not None and snapshot.strip() != ""
|
||||
|
||||
def take_webcam_snapshot(self, _):
|
||||
snapshot_url = self._get_snapshot_url()
|
||||
if not self._can_snapshot():
|
||||
raise WebcamNotAbleToTakeSnapshotException(self._webcam_name)
|
||||
|
||||
with self._capture_mutex:
|
||||
self._logger.debug(f"Capturing image from {snapshot_url}")
|
||||
r = requests.get(
|
||||
snapshot_url,
|
||||
stream=True,
|
||||
timeout=self._settings.get_int(["snapshotTimeout"]),
|
||||
verify=self._settings.get_boolean(["snapshotSslValidation"]),
|
||||
)
|
||||
r.raise_for_status()
|
||||
return r.iter_content(chunk_size=1024)
|
||||
|
||||
# ~~ SettingsPlugin API
|
||||
|
||||
def get_settings_defaults(self):
|
||||
return dict(
|
||||
flipH=False,
|
||||
flipV=False,
|
||||
rotate90=False,
|
||||
stream="",
|
||||
streamTimeout=5,
|
||||
streamRatio="16:9",
|
||||
streamWebrtcIceServers=["stun:stun.l.google.com:19302"],
|
||||
snapshot="",
|
||||
cacheBuster=False,
|
||||
snapshotSslValidation=True,
|
||||
snapshotTimeout=5,
|
||||
)
|
||||
|
||||
def get_settings_version(self):
|
||||
return 1
|
||||
|
||||
def on_settings_migrate(self, target, current):
|
||||
if current is None:
|
||||
config = self._settings.global_get(["webcam"])
|
||||
if config:
|
||||
self._logger.info(
|
||||
"Migrating settings from webcam to plugins.classicwebcam..."
|
||||
)
|
||||
|
||||
# flipH
|
||||
self._settings.set_boolean(["flipH"], config.get("flipH", False))
|
||||
self._settings.global_remove(["webcam", "flipH"])
|
||||
|
||||
# flipV
|
||||
self._settings.set_boolean(["flipV"], config.get("flipV", False))
|
||||
self._settings.global_remove(["webcam", "flipV"])
|
||||
|
||||
# rotate90
|
||||
self._settings.set_boolean(["rotate90"], config.get("rotate90", False))
|
||||
self._settings.global_remove(["webcam", "rotate90"])
|
||||
|
||||
# stream
|
||||
self._settings.set(["stream"], config.get("stream", ""))
|
||||
self._settings.global_remove(["webcam", "stream"])
|
||||
|
||||
# streamTimeout
|
||||
self._settings.set_int(["streamTimeout"], config.get("streamTimeout", 5))
|
||||
self._settings.global_remove(["webcam", "streamTimeout"])
|
||||
|
||||
# streamRatio
|
||||
self._settings.set(["streamRatio"], config.get("streamRatio", "16:9"))
|
||||
self._settings.global_remove(["webcam", "streamRatio"])
|
||||
|
||||
# streamWebrtcIceServers
|
||||
self._settings.set(
|
||||
["streamWebrtcIceServers"],
|
||||
config.get(
|
||||
"streamWebrtcIceServers", ["stun:stun.l.google.com:19302"]
|
||||
),
|
||||
)
|
||||
self._settings.global_remove(["webcam", "streamWebrtcIceServers"])
|
||||
|
||||
# snapshot
|
||||
self._settings.set(["snapshot"], config.get("snapshot", ""))
|
||||
self._settings.global_remove(["webcam", "snapshot"])
|
||||
|
||||
# cacheBuster
|
||||
self._settings.set_boolean(
|
||||
["cacheBuster"], config.get("cacheBuster", False)
|
||||
)
|
||||
self._settings.global_remove(["webcam", "cacheBuster"])
|
||||
|
||||
# snapshotTimeout
|
||||
self._settings.set_int(
|
||||
["snapshotTimeout"], config.get("snapshotTimeout", 5)
|
||||
)
|
||||
self._settings.global_remove(["webcam", "snapshotTimeout"])
|
||||
|
||||
# snapshotSslValidation
|
||||
self._settings.set_boolean(
|
||||
["snapshotSslValidation"], config.get("snapshotSslValidation", True)
|
||||
)
|
||||
self._settings.global_remove(["webcam", "snapshotSslValidation"])
|
||||
|
||||
# ~~ WizardPlugin API
|
||||
|
||||
def is_wizard_required(self):
|
||||
required = (
|
||||
not self._get_stream_url()
|
||||
or not self._get_snapshot_url()
|
||||
or not self._settings.global_get(["webcam", "ffmpegPath"])
|
||||
)
|
||||
firstrun = self._settings.global_get(["server", "firstRun"])
|
||||
return required and firstrun
|
||||
|
||||
def get_wizard_version(self):
|
||||
return 1
|
||||
|
||||
|
||||
__plugin_name__ = gettext("Classic Webcam")
|
||||
__plugin_author__ = "Christian Würthner"
|
||||
__plugin_description__ = "Provides a simple webcam viewer in OctoPrint's UI, images provided by an MJPEG webcam."
|
||||
__plugin_disabling_discouraged__ = gettext(
|
||||
"This plugin provides the standard webcam in OctoPrint. If you do not have any other plugin providing a webcam set up, the webcam section in the control tab will no longer be visible."
|
||||
)
|
||||
__plugin_license__ = "AGPLv3"
|
||||
__plugin_pythoncompat__ = ">=3.7,<4"
|
||||
__plugin_implementation__ = ClassicWebcamPlugin()
|
||||
@@ -0,0 +1 @@
|
||||
#webcam_video_container{width:100%;position:relative;outline:0}#webcam_video_container .video-controls{position:absolute;bottom:0;right:8px;z-index:10;opacity:.4}#webcam_video_container:hover .video-controls{opacity:1}#webcam_video_container #webcam_hls,#webcam_video_container #webcam_rtsp{width:100%;height:100%}#webcam_video_container .webcam_rotated{position:relative;width:100%;padding-bottom:56.25%;display:flex;justify-content:center;align-items:center;margin:auto}#webcam_video_container .webcam_rotated .rotation_target{position:absolute;transform:rotate(-90deg);width:100%}#webcam_img_container,#webcam_video_container .webcam_unrotated{width:100%;position:relative}#webcam_video_container .webcam_rotated .rotation_target div{width:100%;height:100%}#webcam_img_container{outline:0;background-color:#000}#webcam_img_container .keycontrol_overlay{position:absolute;left:10px;right:10px;bottom:10px;background:rgba(0,0,0,.5);font-size:85%;color:#fff;padding:0}#webcam_img_container .keycontrol_overlay kbd{border:1px solid #eee;border-radius:3px;margin-left:2px;margin-right:2px;font-size:90%;padding:2px;min-width:1em}#webcam_img_container .keycontrol_overlay .keycontrol_overlay_heading{position:relative;padding:10px;font-weight:700}#webcam_img_container .keycontrol_overlay .keycontrol_overlay_column{position:relative;width:45%;padding:10px;float:left}#webcam_img_container .nowebcam{position:absolute;top:0;left:0;right:0;bottom:0}#webcam_img_container .nowebcam .text{color:#fff;text-align:center;position:relative;margin:auto;width:80%;top:50%;transform:translateY(-50%);display:block}#webcam_img_container .nowebcam .text.webcam_loading{animation:pulsate 3s ease-out;animation-iteration-count:infinite}#webcam_img_container .webcam_rotated{position:relative;width:100%;padding-bottom:100%;pointer-events:none}#webcam_img_container .webcam_rotated .webcam_fixed_ratio{position:absolute;transform:rotate(-90deg);top:0;bottom:0;pointer-events:none}#webcam_img_container .webcam_rotated .webcam_fixed_ratio .webcam_fixed_ratio_inner{width:100%;height:100%;pointer-events:none}#webcam_img_container .webcam_unrotated .webcam_fixed_ratio{width:100%;pointer-events:none;padding-bottom:100%;position:relative}#webcam_img_container .webcam_unrotated .webcam_fixed_ratio.ratio43{padding-bottom:75%}#webcam_img_container .webcam_unrotated .webcam_fixed_ratio.ratio169{padding-bottom:56.25%}#webcam_img_container .webcam_unrotated .webcam_fixed_ratio.ratio1610{padding-bottom:62.5%}#webcam_img_container .webcam_unrotated .webcam_fixed_ratio .webcam_fixed_ratio_inner{position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none}#webcam_img_container img{width:100%;height:100%;object-fit:contain}#webcamTestContainer{min-height:384px}
|
||||
@@ -0,0 +1,353 @@
|
||||
$(function () {
|
||||
function ClassicWebcamViewModel(parameters) {
|
||||
var self = this;
|
||||
|
||||
self.loginState = parameters[0];
|
||||
self.settings = parameters[1];
|
||||
self.webcamStreamVisible = false;
|
||||
|
||||
self.webcamDisableTimeout = undefined;
|
||||
self.webcamLoaded = ko.observable(false);
|
||||
self.webcamMjpgEnabled = ko.observable(false);
|
||||
self.webcamHlsEnabled = ko.observable(false);
|
||||
self.webcamWebRTCEnabled = ko.observable(false);
|
||||
self.webcamError = ko.observable(false);
|
||||
self.webcamMuted = ko.observable(true);
|
||||
self.webRTCPeerConnection = null;
|
||||
self.webcamElementHls = null;
|
||||
self.webcamElementWebrtc = null;
|
||||
|
||||
self.webcamRatioClass = ko.pureComputed(function () {
|
||||
if (self.settings.streamRatio() == "4:3") {
|
||||
return "ratio43";
|
||||
} else {
|
||||
return "ratio169";
|
||||
}
|
||||
});
|
||||
|
||||
self.onBeforeBinding = function () {
|
||||
// Subscribe to rotation event to ensure we update calculations.
|
||||
// We need to wait for the CSS to be updated by KO, thus we use a timeout to
|
||||
// ensure our calculations run after the CSS was updated
|
||||
self.settings.rotate90.subscribe(function () {
|
||||
window.setTimeout(function () {
|
||||
self._updateVideoTagWebcamLayout();
|
||||
}, 1);
|
||||
});
|
||||
|
||||
self.streamUrlEscaped = ko.pureComputed(function () {
|
||||
return encodeURI(self.settings.streamUrl());
|
||||
});
|
||||
|
||||
self.webcamStreamType = ko.pureComputed(function () {
|
||||
try {
|
||||
return self.determineWebcamStreamType(self.streamUrlEscaped());
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
self.webcamError(true);
|
||||
return "mjpg";
|
||||
}
|
||||
});
|
||||
|
||||
self.webcamStreamValid = ko.pureComputed(function () {
|
||||
var url = self.streamUrlEscaped();
|
||||
return !url || validateWebcamUrl(url);
|
||||
});
|
||||
};
|
||||
|
||||
self.onWebcamVisibilityChange = function (visible) {
|
||||
self.webcamStreamVisible = visible;
|
||||
if (self.webcamStreamVisible) {
|
||||
self._enableWebcam();
|
||||
} else {
|
||||
self._disableWebcam();
|
||||
}
|
||||
};
|
||||
|
||||
self.onEventSettingsUpdated = function (payload) {
|
||||
// the webcam url might have changed, make sure we replace it now if the
|
||||
// view is visible
|
||||
self._enableWebcamIfVisible();
|
||||
};
|
||||
|
||||
self._getActiveWebcamVideoElement = function () {
|
||||
if (self.webcamWebRTCEnabled()) {
|
||||
return self.webcamElementWebrtc;
|
||||
} else {
|
||||
return self.webcamElementHls;
|
||||
}
|
||||
};
|
||||
|
||||
self.launchWebcamPictureInPicture = function () {
|
||||
self._getActiveWebcamVideoElement().requestPictureInPicture();
|
||||
};
|
||||
|
||||
self.launchWebcamFullscreen = function () {
|
||||
self._getActiveWebcamVideoElement().requestFullscreen();
|
||||
};
|
||||
|
||||
self.toggleWebcamMute = function () {
|
||||
self.webcamMuted(!self.webcamMuted());
|
||||
self.webcamElementWebrtc.muted = self.webcamMuted();
|
||||
self.webcamElementHls.muted = self.webcamMuted();
|
||||
};
|
||||
|
||||
self._disableWebcam = function () {
|
||||
// only disable webcam stream if element is out of view for more than 5s,
|
||||
// otherwise we might cause more load by the constant connection creation
|
||||
// than by the actual webcam stream
|
||||
|
||||
// safari bug doesn't release the mjpeg stream, so we just disable this for
|
||||
// safari.
|
||||
if (OctoPrint.coreui.browser.safari) {
|
||||
return;
|
||||
}
|
||||
|
||||
var timeout = self.settings.streamTimeout() || 5;
|
||||
self.webcamDisableTimeout = setTimeout(function () {
|
||||
log.debug("Unloading webcam stream after", timeout, "seconds");
|
||||
$("#webcam_image").attr("src", "");
|
||||
self.webcamLoaded(false);
|
||||
}, timeout * 1000);
|
||||
};
|
||||
|
||||
self._enableWebcamIfVisible = function () {
|
||||
if (self.webcamStreamVisible) {
|
||||
self._enableWebcam();
|
||||
}
|
||||
};
|
||||
|
||||
self._enableWebcam = function () {
|
||||
if (self.webcamDisableTimeout != undefined) {
|
||||
clearTimeout(self.webcamDisableTimeout);
|
||||
}
|
||||
|
||||
// If disabled then we dont need to do anything
|
||||
if (self.settings.webcamEnabled() == false) {
|
||||
console.log("Webcam not enabled");
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine stream type and switch to corresponding webcam.
|
||||
var streamType = self.webcamStreamType();
|
||||
if (streamType == "mjpg") {
|
||||
self._switchToMjpgWebcam();
|
||||
} else if (streamType == "hls") {
|
||||
self._switchToHlsWebcam();
|
||||
} else if (isWebRTCAvailable() && streamType == "webrtc") {
|
||||
self._switchToWebRTCWebcam();
|
||||
} else {
|
||||
throw "Unknown stream type " + streamType;
|
||||
}
|
||||
};
|
||||
|
||||
self.onWebcamLoaded = function () {
|
||||
if (self.webcamLoaded()) return;
|
||||
|
||||
log.debug("Webcam stream loaded");
|
||||
self.webcamLoaded(true);
|
||||
self.webcamError(false);
|
||||
};
|
||||
|
||||
self.onWebcamErrored = function () {
|
||||
log.debug("Webcam stream failed to load/was unloaded");
|
||||
self.webcamLoaded(false);
|
||||
self.webcamError(true);
|
||||
};
|
||||
|
||||
self.onUserPermissionsChanged =
|
||||
self.onUserLoggedIn =
|
||||
self.onUserLoggedOut =
|
||||
function () {
|
||||
self.syncWebcamElements();
|
||||
};
|
||||
|
||||
self.syncWebcamElements = function () {
|
||||
self.webcamElementHls = document.getElementById("webcam_hls");
|
||||
self.webcamElementWebrtc = document.getElementById("webcam_webrtc");
|
||||
};
|
||||
|
||||
self.onStartup = function () {
|
||||
self.syncWebcamElements();
|
||||
};
|
||||
|
||||
self._switchToMjpgWebcam = function () {
|
||||
var webcamImage = $("#webcam_image");
|
||||
var currentSrc = webcamImage.attr("src");
|
||||
|
||||
// safari bug doesn't release the mjpeg stream, so we just set it up the once
|
||||
if (OctoPrint.coreui.browser.safari && currentSrc != undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
var newSrc = self.streamUrlEscaped();
|
||||
|
||||
if (currentSrc != newSrc) {
|
||||
if (self.settings.cacheBuster()) {
|
||||
if (newSrc.lastIndexOf("?") > -1) {
|
||||
newSrc += "&";
|
||||
} else {
|
||||
newSrc += "?";
|
||||
}
|
||||
newSrc += new Date().getTime();
|
||||
}
|
||||
|
||||
self.webcamLoaded(false);
|
||||
self.webcamError(false);
|
||||
webcamImage.attr("src", newSrc);
|
||||
|
||||
self.webcamHlsEnabled(false);
|
||||
self.webcamMjpgEnabled(true);
|
||||
self.webcamWebRTCEnabled(false);
|
||||
}
|
||||
};
|
||||
|
||||
self._switchToHlsWebcam = function () {
|
||||
var video = self.webcamElementHls;
|
||||
video.onresize = self._updateVideoTagWebcamLayout;
|
||||
|
||||
// Ensure WebRTC is unloaded
|
||||
if (self.webRTCPeerConnection != null) {
|
||||
self.webRTCPeerConnection.close();
|
||||
self.webRTCPeerConnection = null;
|
||||
}
|
||||
|
||||
// Check for native playback options: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/canPlayType
|
||||
if (
|
||||
video != null &&
|
||||
typeof video.canPlayType != undefined &&
|
||||
video.canPlayType("application/vnd.apple.mpegurl") == "probably"
|
||||
) {
|
||||
video.src = self.streamUrlEscaped();
|
||||
} else if (Hls.isSupported()) {
|
||||
self.hls = new Hls();
|
||||
self.hls.loadSource(self.streamUrlEscaped());
|
||||
self.hls.attachMedia(video);
|
||||
}
|
||||
|
||||
self.webcamMjpgEnabled(false);
|
||||
self.webcamHlsEnabled(true);
|
||||
self.webcamWebRTCEnabled(false);
|
||||
};
|
||||
|
||||
self._switchToWebRTCWebcam = function () {
|
||||
if (!isWebRTCAvailable()) {
|
||||
return;
|
||||
}
|
||||
var video = self.webcamElementWebrtc;
|
||||
video.onresize = self._updateVideoTagWebcamLayout;
|
||||
|
||||
// Ensure HLS is unloaded
|
||||
if (self.hls != null) {
|
||||
self.webcamElementHls.src = null;
|
||||
self.hls.destroy();
|
||||
self.hls = null;
|
||||
}
|
||||
|
||||
// Close any existing, disconnected connection
|
||||
if (
|
||||
self.webRTCPeerConnection != null &&
|
||||
self.webRTCPeerConnection.connectionState != "connected"
|
||||
) {
|
||||
self.webRTCPeerConnection.close();
|
||||
self.webRTCPeerConnection = null;
|
||||
}
|
||||
|
||||
// Open a new connection if necessary
|
||||
if (self.webRTCPeerConnection == null) {
|
||||
self.webRTCPeerConnection = startWebRTC(
|
||||
video,
|
||||
self.streamUrlEscaped(),
|
||||
self.settings.streamWebrtcIceServers()
|
||||
);
|
||||
}
|
||||
|
||||
self.webcamMjpgEnabled(false);
|
||||
self.webcamHlsEnabled(false);
|
||||
self.webcamWebRTCEnabled(true);
|
||||
};
|
||||
|
||||
self._updateVideoTagWebcamLayout = function () {
|
||||
// Get all elements we need
|
||||
var player = self._getActiveWebcamVideoElement();
|
||||
var rotationContainer = document.querySelector(
|
||||
"#webcam_video_container .webcam_rotated"
|
||||
);
|
||||
var rotationTarget = document.querySelector(
|
||||
"#webcam_video_container .webcam_rotated .rotation_target"
|
||||
);
|
||||
var unrotationContainer = document.querySelector(
|
||||
"#webcam_video_container .webcam_unrotated"
|
||||
);
|
||||
var unrotationTarget = document.querySelector(
|
||||
"#webcam_video_container .webcam_unrotated .rotation_target"
|
||||
);
|
||||
|
||||
// If we found the rotation container, the view is rotated 90 degrees. This
|
||||
// means we need to manually calculate the player dimensions and apply them
|
||||
// to the rotation target where height = width and width = height (to
|
||||
// accommodate the rotation). The target is centered in the container and
|
||||
// rotated around its center, so after we manually resized the container
|
||||
// everything will layout nicely.
|
||||
if (rotationContainer && player.videoWidth && player.videoHeight) {
|
||||
// Calculate the height the video will have in the UI, based on the
|
||||
// video width and the aspect ratio.
|
||||
var aspectRatio = player.videoWidth / player.videoHeight;
|
||||
var height = aspectRatio * rotationContainer.offsetWidth;
|
||||
|
||||
// Enforce the height on the rotation container and the rotation target.
|
||||
// Width of the container will be 100%, height will be calculated
|
||||
//
|
||||
// The size of the rotation target (the element that has the 90 deg
|
||||
// transform) is the inverse size of the container (so height -> width
|
||||
// and width -> height)
|
||||
rotationContainer.style.height = height + "px";
|
||||
rotationTarget.style.height = rotationContainer.offsetWidth + "px";
|
||||
rotationTarget.style.width = rotationContainer.offsetHeight + "px";
|
||||
|
||||
// Remove the padding we used to give the element an initial height.
|
||||
rotationContainer.style.paddingBottom = 0;
|
||||
}
|
||||
|
||||
// We are not rotated, clean up all changes we might have done before
|
||||
if (unrotationContainer) {
|
||||
unrotationContainer.style.height = null;
|
||||
unrotationContainer.style.paddingBottom = 0;
|
||||
unrotationTarget.style.height = null;
|
||||
unrotationTarget.style.width = null;
|
||||
}
|
||||
};
|
||||
|
||||
self.determineWebcamStreamType = function (streamUrl) {
|
||||
if (!streamUrl) {
|
||||
throw "Empty streamUrl. Cannot determine stream type.";
|
||||
}
|
||||
|
||||
var parsed = validateWebcamUrl(streamUrl);
|
||||
if (!parsed) {
|
||||
throw "Invalid streamUrl. Cannot determine stream type.";
|
||||
}
|
||||
|
||||
if (parsed.protocol === "webrtc:" || parsed.protocol === "webrtcs:") {
|
||||
return "webrtc";
|
||||
}
|
||||
|
||||
var lastDotPosition = parsed.pathname.lastIndexOf(".");
|
||||
if (lastDotPosition !== -1) {
|
||||
var extension = parsed.pathname.substring(lastDotPosition + 1);
|
||||
if (extension.toLowerCase() === "m3u8") {
|
||||
return "hls";
|
||||
}
|
||||
}
|
||||
|
||||
// By default, 'mjpg' is the stream type.
|
||||
return "mjpg";
|
||||
};
|
||||
}
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
construct: ClassicWebcamViewModel,
|
||||
dependencies: ["loginStateViewModel", "classicWebcamSettingsViewModel"],
|
||||
elements: ["#classicwebcam_container"]
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,236 @@
|
||||
$(function () {
|
||||
function ClassicWebcamSettingsViewModel(parameters) {
|
||||
var self = this;
|
||||
|
||||
self.loginState = parameters[0];
|
||||
self.settings = parameters[1];
|
||||
self._subscriptions = [];
|
||||
|
||||
self.webRtcServersToText = function (list) {
|
||||
self.streamWebrtcIceServersText(self.streamWebrtcIceServers().join(", "));
|
||||
};
|
||||
|
||||
self.textToWebRtcServers = function (list) {
|
||||
self.streamWebrtcIceServers(
|
||||
splitTextToArray(self.streamWebrtcIceServersText(), ",", true)
|
||||
);
|
||||
};
|
||||
|
||||
self.onBeforeBinding = function () {
|
||||
self.snapshotUrl = self.settings.settings.plugins.classicwebcam.snapshot;
|
||||
self.flipH = self.settings.settings.plugins.classicwebcam.flipH;
|
||||
self.flipV = self.settings.settings.plugins.classicwebcam.flipV;
|
||||
self.rotate90 = self.settings.settings.plugins.classicwebcam.rotate90;
|
||||
self.streamUrl = self.settings.settings.plugins.classicwebcam.stream;
|
||||
self.webcamEnabled = self.settings.settings.webcam.webcamEnabled;
|
||||
self.streamRatio = self.settings.settings.plugins.classicwebcam.streamRatio;
|
||||
self.streamTimeout =
|
||||
self.settings.settings.plugins.classicwebcam.streamTimeout;
|
||||
self.streamWebrtcIceServers =
|
||||
self.settings.settings.plugins.classicwebcam.streamWebrtcIceServers;
|
||||
self.streamWebrtcIceServersText = ko.observable("");
|
||||
self.cacheBuster = self.settings.settings.plugins.classicwebcam.cacheBuster;
|
||||
self.available_ratios = ["16:9", "4:3"];
|
||||
|
||||
self.webRtcServersToText();
|
||||
self.streamWebrtcIceServers.subscribe(function (value) {
|
||||
self.webRtcServersToText();
|
||||
});
|
||||
};
|
||||
|
||||
self.onSettingsBeforeSave = function () {
|
||||
self.textToWebRtcServers();
|
||||
};
|
||||
|
||||
self.onUserSettingsHidden = function () {
|
||||
self.webRtcServersToText();
|
||||
};
|
||||
|
||||
self.streamUrlEscaped = ko.pureComputed(function () {
|
||||
return encodeURI(self.streamUrl());
|
||||
});
|
||||
|
||||
self.streamType = ko.pureComputed(function () {
|
||||
try {
|
||||
return determineWebcamStreamType(self.streamUrlEscaped());
|
||||
} catch (e) {
|
||||
return "";
|
||||
}
|
||||
});
|
||||
|
||||
self.streamValid = ko.pureComputed(function () {
|
||||
var url = self.streamUrlEscaped();
|
||||
return !url || validateWebcamUrl(url);
|
||||
});
|
||||
|
||||
self.testWebcamStreamUrlBusy = ko.observable(false);
|
||||
self.testWebcamStreamUrl = function () {
|
||||
var url = self.streamUrlEscaped();
|
||||
if (!url) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.testWebcamStreamUrlBusy()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var text = gettext(
|
||||
"If you see your webcam stream below, the entered stream URL is ok."
|
||||
);
|
||||
|
||||
var streamType;
|
||||
try {
|
||||
streamType = self.streamType();
|
||||
} catch (e) {
|
||||
streamType = "";
|
||||
}
|
||||
|
||||
var webcam_element;
|
||||
var webrtc_peer_connection;
|
||||
if (streamType === "mjpg") {
|
||||
webcam_element = $('<img src="' + url + '">');
|
||||
} else if (streamType === "hls") {
|
||||
webcam_element = $(
|
||||
'<video id="webcam_hls" muted autoplay style="width: 100%"/>'
|
||||
);
|
||||
video_element = webcam_element[0];
|
||||
if (video_element.canPlayType("application/vnd.apple.mpegurl")) {
|
||||
video_element.src = url;
|
||||
} else if (Hls.isSupported()) {
|
||||
var hls = new Hls();
|
||||
hls.loadSource(url);
|
||||
hls.attachMedia(video_element);
|
||||
}
|
||||
} else if (isWebRTCAvailable() && streamType === "webrtc") {
|
||||
webcam_element = $(
|
||||
'<video id="webcam_webrtc" muted autoplay playsinline controls style="width: 100%"/>'
|
||||
);
|
||||
video_element = webcam_element[0];
|
||||
|
||||
webrtc_peer_connection = startWebRTC(
|
||||
video_element,
|
||||
url,
|
||||
self.streamWebrtcIceServers()
|
||||
);
|
||||
} else {
|
||||
throw "Unknown stream type " + streamType;
|
||||
}
|
||||
|
||||
var message = $("<div id='webcamTestContainer'></div>")
|
||||
.append($("<p></p>"))
|
||||
.append(text)
|
||||
.append(webcam_element);
|
||||
|
||||
self.testWebcamStreamUrlBusy(true);
|
||||
showMessageDialog({
|
||||
title: gettext("Stream test"),
|
||||
message: message,
|
||||
onclose: function () {
|
||||
self.testWebcamStreamUrlBusy(false);
|
||||
if (webrtc_peer_connection != null) {
|
||||
webrtc_peer_connection.close();
|
||||
webrtc_peer_connection = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
self.testWebcamSnapshotUrlBusy = ko.observable(false);
|
||||
self.testWebcamSnapshotUrl = function (viewModel, event) {
|
||||
if (!self.snapshotUrl()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.testWebcamSnapshotUrlBusy()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var errorText = gettext(
|
||||
"Could not retrieve snapshot URL, please double check the URL"
|
||||
);
|
||||
var errorTitle = gettext("Snapshot test failed");
|
||||
|
||||
self.testWebcamSnapshotUrlBusy(true);
|
||||
OctoPrint.util
|
||||
.testUrl(self.snapshotUrl(), {
|
||||
method: "GET",
|
||||
response: "bytes",
|
||||
timeout: self.settings.settings.webcam.snapshotTimeout(),
|
||||
validSsl: self.settings.settings.webcam.snapshotSslValidation(),
|
||||
content_type_whitelist: ["image/*"],
|
||||
content_type_guess: true
|
||||
})
|
||||
.done(function (response) {
|
||||
if (!response.result) {
|
||||
if (
|
||||
response.status &&
|
||||
response.response &&
|
||||
response.response.content_type
|
||||
) {
|
||||
// we could contact the server, but something else was wrong, probably the mime type
|
||||
errorText = gettext(
|
||||
"Could retrieve the snapshot URL, but it didn't look like an " +
|
||||
"image. Got this as a content type header: <code>%(content_type)s</code>. Please " +
|
||||
"double check that the URL is returning static images, not multipart data " +
|
||||
"or videos."
|
||||
);
|
||||
errorText = _.sprintf(errorText, {
|
||||
content_type: _.escape(response.response.content_type)
|
||||
});
|
||||
}
|
||||
|
||||
showMessageDialog({
|
||||
title: errorTitle,
|
||||
message: errorText,
|
||||
onclose: function () {
|
||||
self.testWebcamSnapshotUrlBusy(false);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
var content = response.response.content;
|
||||
var contentType = response.response.assumed_content_type;
|
||||
|
||||
var mimeType = "image/jpeg";
|
||||
if (contentType) {
|
||||
mimeType = contentType.split(";")[0];
|
||||
}
|
||||
|
||||
var text = gettext(
|
||||
"If you see your webcam snapshot picture below, the entered snapshot URL is ok."
|
||||
);
|
||||
showMessageDialog({
|
||||
title: gettext("Snapshot test"),
|
||||
message: $(
|
||||
"<p>" +
|
||||
text +
|
||||
'</p><p><img src="data:' +
|
||||
mimeType +
|
||||
";base64," +
|
||||
content +
|
||||
'" style="border: 1px solid black" /></p>'
|
||||
),
|
||||
onclose: function () {
|
||||
self.testWebcamSnapshotUrlBusy(false);
|
||||
}
|
||||
});
|
||||
})
|
||||
.fail(function () {
|
||||
showMessageDialog({
|
||||
title: errorTitle,
|
||||
message: errorText,
|
||||
onclose: function () {
|
||||
self.testWebcamSnapshotUrlBusy(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
construct: ClassicWebcamSettingsViewModel,
|
||||
dependencies: ["loginStateViewModel", "settingsViewModel"],
|
||||
elements: ["#classicwebcam_settings"]
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
$(function () {
|
||||
function ClassicWebcamWizardViewModel(parameters) {
|
||||
var self = this;
|
||||
|
||||
self.settingsViewModel = parameters[0];
|
||||
|
||||
self.onWizardFinish = function () {
|
||||
if (self.settingsViewModel.streamUrl()) {
|
||||
return "reload";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
construct: ClassicWebcamWizardViewModel,
|
||||
dependencies: ["classicWebcamSettingsViewModel"],
|
||||
elements: ["#wizard_classicwebcam"]
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,183 @@
|
||||
#webcam_video_container {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
outline: none;
|
||||
|
||||
.video-controls {
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
right: 8px;
|
||||
z-index: 10;
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
.video-controls {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
#webcam_hls,
|
||||
#webcam_rtsp {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.webcam_rotated {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
padding-bottom: 56.25%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin: auto;
|
||||
|
||||
.rotation_target {
|
||||
position: absolute;
|
||||
transform: rotate(-90deg);
|
||||
width: 100%;
|
||||
|
||||
div {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.webcam_unrotated {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
#webcam_img_container {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
outline: none;
|
||||
|
||||
background-color: black;
|
||||
|
||||
.keycontrol_overlay {
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
right: 10px;
|
||||
bottom: 10px;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
font-size: 85%;
|
||||
color: white;
|
||||
padding: 0;
|
||||
|
||||
kbd {
|
||||
border: 1px solid #eeeeee;
|
||||
border-radius: 3px;
|
||||
margin-left: 2px;
|
||||
margin-right: 2px;
|
||||
font-size: 90%;
|
||||
padding: 2px;
|
||||
min-width: 1em;
|
||||
}
|
||||
|
||||
.keycontrol_overlay_heading {
|
||||
position: relative;
|
||||
padding: 10px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.keycontrol_overlay_column {
|
||||
position: relative;
|
||||
width: 45%;
|
||||
padding: 10px;
|
||||
float: left;
|
||||
}
|
||||
}
|
||||
|
||||
.nowebcam {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
|
||||
.text {
|
||||
color: white;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
margin: auto;
|
||||
width: 80%;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
display: block;
|
||||
|
||||
&.webcam_loading {
|
||||
animation: pulsate 3s ease-out;
|
||||
animation-iteration-count: infinite;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.webcam_rotated {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
padding-bottom: 100%;
|
||||
pointer-events: none;
|
||||
|
||||
.webcam_fixed_ratio {
|
||||
position: absolute;
|
||||
transform: rotate(-90deg);
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
pointer-events: none;
|
||||
|
||||
.webcam_fixed_ratio_inner {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.webcam_unrotated {
|
||||
.webcam_fixed_ratio {
|
||||
width: 100%;
|
||||
pointer-events: none;
|
||||
|
||||
padding-bottom: 100%;
|
||||
|
||||
&.ratio43 {
|
||||
padding-bottom: 75%;
|
||||
}
|
||||
|
||||
&.ratio169 {
|
||||
padding-bottom: 56.25%;
|
||||
}
|
||||
|
||||
&.ratio1610 {
|
||||
padding-bottom: 62.5%;
|
||||
}
|
||||
|
||||
position: relative;
|
||||
|
||||
.webcam_fixed_ratio_inner {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
}
|
||||
|
||||
// Predict height of webcam test container for modal positioning
|
||||
// height is 3/4 the fixed modal width, for 4:3 webcam stream.
|
||||
// Yes it's hardcoded, but so is the modal width.
|
||||
#webcamTestContainer {
|
||||
min-height: 384px;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<div id="classicwebcam_settings">
|
||||
<h3>{{ _('Stream') }}</h3>
|
||||
<form class="form-horizontal" onsubmit="return false;">
|
||||
{% include "snippets/classicwebcamStreamUrl.jinja2" %}
|
||||
{% include "snippets/classicwebcamStreamRatio.jinja2" %}
|
||||
{% include "snippets/classicwebcamOrientation.jinja2" %}
|
||||
|
||||
<div>
|
||||
<div><small><a href="#" class="muted" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', parent: '.form-horizontal', container: '.hide' }"><i class="fas fa-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
|
||||
<div class="hide">
|
||||
{% include "snippets/classicwebcamStreamTimeout.jinja2" %}
|
||||
{% include "snippets/classicwebcamCacheBuster.jinja2" %}
|
||||
{% include "snippets/classicwebcamStreamWebrtcIceServers.jinja2" %}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<h3>{{ _('Snapshots & Timelapse') }}</h3>
|
||||
|
||||
<form class="form-horizontal" onsubmit="return false;">
|
||||
{% include "snippets/classicwebcamSnapshotUrl.jinja2" %}
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,47 @@
|
||||
<div id="classicwebcam_container">
|
||||
<!-- Init style with display none to hide the content while we are binding -->
|
||||
<div id="webcam_video_container" tabindex="0" data-bind="visible: webcamWebRTCEnabled() || webcamHlsEnabled(), css: { webcam_rotated: settings.rotate90(), webcam_unrotated: !settings.rotate90() }" style="display: none;">
|
||||
<div class="video-controls btn-group action-buttons">
|
||||
<div class="btn btn-mini" data-bind="click: function(data, event) { $root.launchWebcamFullscreen() }"><i class="fas fa-expand"></i></div>
|
||||
<div class="btn btn-mini" data-bind="visible: document.pictureInPictureEnabled, click: function(data, event) { $root.launchWebcamPictureInPicture() }"><i class="fas fa-images"></i></div>
|
||||
<div class="btn btn-mini" data-bind="click: function(data, event) { $root.toggleWebcamMute() }">
|
||||
<!-- ko if: webcamMuted() -->
|
||||
<i class="fas fa-volume-mute"></i>
|
||||
<!-- /ko -->
|
||||
<!-- ko ifnot: webcamMuted() -->
|
||||
<i class="fas fa-volume-up"></i>
|
||||
<!-- /ko -->
|
||||
</div>
|
||||
</div>
|
||||
<div data-bind="css: { webcam_rotated: settings.rotate90(), webcam_unrotated: !settings.rotate90() }">
|
||||
<div class="rotation_target">
|
||||
<div data-bind="css: { flipH: settings.flipH(), flipV: settings.flipV() }">
|
||||
<video id="webcam_webrtc" muted autoplay playsinline style="width: 100%" data-bind="visible: webcamWebRTCEnabled()"></video>
|
||||
<video id="webcam_hls" muted autoplay playsinline style="width: 100%" data-bind="visible: webcamHlsEnabled()"></video>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Init style with display none to hide the content while we are binding -->
|
||||
<div id="webcam_img_container" tabindex="0" data-bind="visible: webcamMjpgEnabled()" style="display: none;">
|
||||
<div class="nowebcam" data-bind="visible: !webcamLoaded()">
|
||||
<div class="text webcam_loading" data-bind="visible: !webcamLoaded() && !webcamError()">
|
||||
<p><strong>{{ _('Webcam stream loading...') }}</strong></p>
|
||||
</div>
|
||||
<div class="text webcam_error" data-bind="visible: !webcamLoaded() && webcamError()">
|
||||
<p><strong>{{ _('Webcam stream not loaded') }}</strong></p>
|
||||
<p data-bind="visible: !loginState.isAdmin()"><small>{{ _('It might not be configured correctly or require authentication. To have this fixed, get in touch with an administrator of this OctoPrint instance.') }}</small></p>
|
||||
<p data-bind="visible: loginState.isAdmin"><small>{{ _('It might not be configured correctly or require authentication. You can change the URL of the stream under "Settings" > "Classic Webcam" > "Stream URL". If you don\'t have a webcam you can also just disable webcam support there.') }}</small></p>
|
||||
<p data-bind="visible: loginState.isUser"><small>{{ _('Currently configured stream URL') }}: <a target="_blank" rel="noreferrer" data-bind="attr: {href: settings.streamUrl}, text: settings.streamUrl"></a></small></p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="webcam_rotator" data-bind="css: { webcam_rotated: settings.rotate90(), webcam_unrotated: !settings.rotate90() }">
|
||||
<div class="webcam_fixed_ratio" data-bind="css: webcamRatioClass">
|
||||
<div class="webcam_fixed_ratio_inner">
|
||||
<img id="webcam_image" data-bind="css: { flipH: settings.flipH(), flipV: settings.flipV() }, event: { load: onWebcamLoaded, error: onWebcamErrored }, visible: !webcamError()">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -25,18 +25,7 @@
|
||||
a fully qualified URL reachable <strong>from the OctoPrint server</strong>.
|
||||
</p>{% endtrans %}
|
||||
|
||||
<form class="form-horizontal" data-bind="with: settingsViewModel" onsubmit="return false;">
|
||||
{% include "snippets/settings/webcam/webcamStreamUrl.jinja2" %}
|
||||
{% include "snippets/settings/webcam/webcamSnapshotUrl.jinja2" %}
|
||||
</form>
|
||||
|
||||
<h4>{{ _('Timelapse Recordings') }}</h4>
|
||||
|
||||
{% trans %}<p>
|
||||
To render the snapshots into timelapse recordings, OctoPrint also needs to
|
||||
know the correct <strong>path to FFMPEG</strong>.
|
||||
</p>{% endtrans %}
|
||||
|
||||
<form class="form-horizontal" data-bind="with: settingsViewModel" onsubmit="return false;">
|
||||
{% include "snippets/settings/webcam/ffmpegPath.jinja2" %}
|
||||
<form id="wizard_classicwebcam" class="form-horizontal" data-bind="with: settingsViewModel" onsubmit="return false;">
|
||||
{% include "snippets/classicwebcamStreamUrl.jinja2" %}
|
||||
{% include "snippets/classicwebcamSnapshotUrl.jinja2" %}
|
||||
</form>
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class="control-group" title="{{ _('Enable the cache buster on the webcam URl')|edq }}">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: webcam_cacheBuster" id="settings-webcamCacheBuster">
|
||||
<input type="checkbox" data-bind="checked: cacheBuster" id="settings-webcamCacheBuster">
|
||||
{{ _('Enable Cache buster') }}
|
||||
<span class="help-block">
|
||||
<span class="label label-warning">{{ _("Warning") }}</span>
|
||||
@@ -0,0 +1,17 @@
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: flipH" id="settings-webcamFlipH"> {{ _('Flip webcam horizontally') }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: flipV" id="settings-webcamFlipV"> {{ _('Flip webcam vertically') }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: rotate90" id="settings-webcamRotate90"> {{ _('Rotate webcam 90 degrees counter clockwise') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,10 @@
|
||||
<div class="control-group" title="{{ _('URL to use for retrieving webcam snapshot images for timelapse creation')|edq }}">
|
||||
<label class="control-label" for="settings-webcamSnapshotUrl">{{ _('Snapshot URL') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="text" class="input-block-level" data-bind="value: snapshotUrl, valueUpdate: 'afterkeydown'" id="settings-webcamSnapshotUrl">
|
||||
<button class="btn" type="button" data-bind="click: testWebcamSnapshotUrl, enable: snapshotUrl() && !testWebcamSnapshotUrlBusy(), css: {disabled: !snapshotUrl() || testWebcamSnapshotUrlBusy()}"><i class="fas fa-spinner fa-spin" data-bind="visible: testWebcamSnapshotUrlBusy"></i> {{ _('Test') }}</button>
|
||||
</div>
|
||||
<span class="help-inline">{% trans %}Fully qualified URL, needs to be reachable by OctoPrint's server{% endtrans %}</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class="control-group" title="{{ _('Aspect ratio of the webcam stream, either 16:9 or 4:3')|edq }}">
|
||||
<label class="control-label" for="settings-webcamStreamRatio">{{ _('Stream aspect ratio') }}</label>
|
||||
<div class="controls">
|
||||
<select data-bind="options: webcam_available_ratios, value: webcam_streamRatio" id="settings-webcamStreamRatio"></select>
|
||||
<select data-bind="options: available_ratios, value: streamRatio" id="settings-webcamStreamRatio"></select>
|
||||
<span class="help-inline">{% trans %}If the stream has a different aspect ratio than configured here it will be letterboxed.{% endtrans %}</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -2,7 +2,7 @@
|
||||
<label class="control-label" for="settings-webcamStreamTimeout">{{ _('Stream timeout') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" min="1" class="input-mini text-right" data-bind="value: webcam_streamTimeout" id="settings-webcamStreamTimeout">
|
||||
<input type="number" min="1" class="input-mini text-right" data-bind="value: streamTimeout" id="settings-webcamStreamTimeout">
|
||||
<span class="add-on">sec</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,13 @@
|
||||
<div class="control-group" title="{{ _('URL to embed into the UI for live viewing of the webcam stream')|edq }}" data-bind="css: { error: !streamValid() }">
|
||||
<label class="control-label" for="settings-webcamStreamUrl">{{ _('Stream URL') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="text" class="input-block-level" data-bind="value: streamUrl, valueUpdate: 'afterkeydown'" id="settings-webcamStreamUrl">
|
||||
<button class="btn" type="button" data-bind="click: testWebcamStreamUrl, enable: !testWebcamStreamUrlBusy() && streamValid(), css: {disabled: testWebcamStreamUrlBusy() || !streamValid()}"><i class="fas fa-spinner fa-spin" data-bind="visible: testWebcamStreamUrlBusy"></i> {{ _('Test') }}</button>
|
||||
</div>
|
||||
<span class="help-block">
|
||||
<p>{% trans %}Needs to be reachable from the browser displaying the OctoPrint UI, used to embed the webcam stream into the page.{% endtrans %}</p>
|
||||
<p data-bind="visible: streamType() === 'webrtc'">{% trans %}<strong>Heads-up!</strong> WebRTC support is still in beta and subject to change, monitor the changelog of future versions closely for heads-ups regarding the WebRTC support in OctoPrint.{% endtrans %}</p>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class="control-group" title="{{ _('ICE server (STUN and/or TURN) to use for WebRTC')|edq }}">
|
||||
<label class="control-label" for="settings-webcamStreamWebrtcIceServers">{{ _('WebRTC ICE endpoint') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: webcam_streamWebrtcIceServers, valueUpdate: 'afterkeydown'" id="settings-webcamStreamWebrtcIceServers">
|
||||
<input type="text" class="input-block-level" data-bind="value: streamWebrtcIceServersText, valueUpdate: 'afterkeydown'" id="settings-webcamStreamWebrtcIceServers">
|
||||
<span class="help-block"><span class="label">{{ _('WebRTC') }}</span> {% trans %}Only used for WebRTC streams. Optionally specify the ICE server(s) (STUN and/or TURN) to use for WebRTC. Multiple servers should be separated by a comma. If unsure, leave at the default of <code>stun:stun.l.google.com:19302</code>.{% endtrans %}</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -16,7 +16,6 @@ class CoreWizardPlugin(
|
||||
octoprint.plugin.BlueprintPlugin,
|
||||
Subwizards,
|
||||
):
|
||||
|
||||
# ~~ TemplatePlugin API
|
||||
|
||||
def get_template_configs(self):
|
||||
|
||||
@@ -106,34 +106,6 @@ $(function () {
|
||||
};
|
||||
}
|
||||
|
||||
function CoreWizardWebcamViewModel(parameters) {
|
||||
var self = this;
|
||||
|
||||
self.settingsViewModel = parameters[0];
|
||||
|
||||
self.required = false;
|
||||
|
||||
self.onWizardDetails = function (response) {
|
||||
self.required =
|
||||
response &&
|
||||
response.corewizard &&
|
||||
response.corewizard.details &&
|
||||
response.corewizard.details.webcam &&
|
||||
response.corewizard.details.webcam.required;
|
||||
};
|
||||
|
||||
self.onWizardFinish = function () {
|
||||
if (!self.required) return;
|
||||
if (
|
||||
self.settingsViewModel.webcam_streamUrl() ||
|
||||
(self.settingsViewModel.webcam_snapshotUrl() &&
|
||||
self.settingsViewModel.webcam_ffmpegPath())
|
||||
) {
|
||||
return "reload";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function CoreWizardServerCommandsViewModel(parameters) {
|
||||
var self = this;
|
||||
|
||||
@@ -359,11 +331,6 @@ $(function () {
|
||||
dependencies: ["loginStateViewModel"],
|
||||
elements: ["#wizard_plugin_corewizard_acl"]
|
||||
},
|
||||
{
|
||||
construct: CoreWizardWebcamViewModel,
|
||||
dependencies: ["settingsViewModel"],
|
||||
elements: ["#wizard_plugin_corewizard_webcam"]
|
||||
},
|
||||
{
|
||||
construct: CoreWizardServerCommandsViewModel,
|
||||
dependencies: ["settingsViewModel"],
|
||||
|
||||
@@ -37,25 +37,6 @@ class ServerCommandsSubwizard:
|
||||
return gettext("Server Commands")
|
||||
|
||||
|
||||
# noinspection PyUnresolvedReferences,PyMethodMayBeStatic
|
||||
class WebcamSubwizard:
|
||||
def _is_webcam_wizard_firstrunonly(self):
|
||||
return True
|
||||
|
||||
def _is_webcam_wizard_required(self):
|
||||
webcam_snapshot_url = self._settings.global_get(["webcam", "snapshot"])
|
||||
webcam_stream_url = self._settings.global_get(["webcam", "stream"])
|
||||
ffmpeg_path = self._settings.global_get(["webcam", "ffmpeg"])
|
||||
|
||||
return not (webcam_snapshot_url and webcam_stream_url and ffmpeg_path)
|
||||
|
||||
def _get_webcam_wizard_details(self):
|
||||
return {"required": self._is_webcam_wizard_required()}
|
||||
|
||||
def _get_webcam_wizard_name(self):
|
||||
return gettext("Webcam & Timelapse")
|
||||
|
||||
|
||||
# noinspection PyUnresolvedReferences,PyMethodMayBeStatic
|
||||
class AclSubwizard:
|
||||
def _is_acl_wizard_firstrunonly(self):
|
||||
|
||||
@@ -42,7 +42,6 @@ class DiscoveryPlugin(
|
||||
octoprint.plugin.BlueprintPlugin,
|
||||
octoprint.plugin.SettingsPlugin,
|
||||
):
|
||||
|
||||
ssdp_multicast_addr = "239.255.255.250" # IPv6: ff0X::c
|
||||
|
||||
ssdp_multicast_port = 1900
|
||||
@@ -688,7 +687,6 @@ class DiscoveryPlugin(
|
||||
)
|
||||
|
||||
class Request(BaseHTTPRequestHandler):
|
||||
|
||||
# noinspection PyMissingConstructor
|
||||
def __init__(self, request_text):
|
||||
self.rfile = BytesIO(request_text)
|
||||
|
||||
@@ -18,10 +18,10 @@ from octoprint.util.version import (
|
||||
)
|
||||
|
||||
SENTRY_URL_SERVER = (
|
||||
"https://faa02914ec8f42139e12a36482cfdb60@o118517.ingest.sentry.io/1373987"
|
||||
"https://ba4e3d61c37a4d219e1cd81bdc1417a7@o118517.ingest.sentry.io/1373987"
|
||||
)
|
||||
SENTRY_URL_COREUI = (
|
||||
"https://be7a53389fb045b48d6c384bb8ee89eb@o118517.ingest.sentry.io/1374096"
|
||||
"https://2382252761de4d318e5f83be0816efaa@o118517.ingest.sentry.io/1374096"
|
||||
)
|
||||
|
||||
SETTINGS_DEFAULTS = {
|
||||
@@ -158,7 +158,9 @@ def _enable_errortracking():
|
||||
|
||||
unique_id = str(uuid.uuid4())
|
||||
s.set(
|
||||
["plugins", "errortracking", "unique_id"], unique_id, defaults=plugin_defaults
|
||||
["plugins", "errortracking", "unique_id"],
|
||||
unique_id,
|
||||
defaults=plugin_defaults,
|
||||
)
|
||||
s.save()
|
||||
|
||||
|
||||
@@ -16,6 +16,9 @@ class EventManagerPlugin(
|
||||
"subscriptions": [],
|
||||
}
|
||||
events = self._settings.global_get(["events"])
|
||||
for event in events.get("subscriptions", []):
|
||||
if "name" not in event:
|
||||
event["name"] = event["command"]
|
||||
if events:
|
||||
my_settings["subscriptions"] = sorted(
|
||||
events.get("subscriptions", []), key=(lambda x: x["event"])
|
||||
|
||||
@@ -42,6 +42,7 @@ class GcodeviewerPlugin(
|
||||
},
|
||||
{
|
||||
"type": "settings",
|
||||
"name": gettext("GCode Viewer"),
|
||||
"template": "gcodeviewer_settings.jinja2",
|
||||
"custom_bindings": True,
|
||||
},
|
||||
|
||||
@@ -1 +1 @@
|
||||
#gcode .progress{width:588px}#gcode .progress .bar{-webkit-transition:width 0s linear;-moz-transition:width 0s linear;-o-transition:width 0s linear;transition:width 0s linear}#gcode .canvas_container{position:relative}#gcode .canvas_container:hover,#gcode .canvas_container:active{outline:0}#gcode .layer-buttons{padding-top:5px;padding-bottom:7px}#gcode #gcode_layer_slider{position:absolute;right:0;top:0;height:568px;float:right}#gcode #gcode_layer_slider .slider-handle{width:14px;height:14px;margin-left:-3px;margin-top:-7px}#gcode #gcode_command_slider .slider-handle{width:14px;height:14px;margin-left:-7px;margin-top:-3px}
|
||||
#gcode .progress{width:588px}#gcode .progress .bar{-webkit-transition:width 0s linear;-moz-transition:width 0s linear;-o-transition:width 0s linear;transition:width 0s linear}#gcode .canvas_container{position:relative}#gcode .canvas_container:active,#gcode .canvas_container:hover{outline:0}#gcode .layer-buttons{padding-top:5px;padding-bottom:7px}#gcode #gcode_layer_slider{position:absolute;right:0;top:0;height:568px;float:right}#gcode #gcode_layer_slider .slider-handle{width:14px;height:14px;margin-left:-3px;margin-top:-7px}#gcode #gcode_command_slider .slider-handle{width:14px;height:14px;margin-left:-7px;margin-top:-3px}
|
||||
@@ -345,8 +345,6 @@ $(function () {
|
||||
|
||||
self.currentlyPrinting = false;
|
||||
|
||||
self.errorCount = 0;
|
||||
|
||||
self.layerSlider = undefined;
|
||||
self.layerCommandSlider = undefined;
|
||||
|
||||
@@ -496,8 +494,8 @@ $(function () {
|
||||
};
|
||||
|
||||
self._configureContainerElement = function (containerElement) {
|
||||
// Prevent the default browser action for the mouse wheel down event. The desired behavor is to have the
|
||||
// gocde canvas pan on mouse down + drag, which happens. But if we don't prevent the default action, the browser
|
||||
// Prevent the default browser action for the mouse wheel down event. The desired behavior is to have the
|
||||
// gcode canvas pan on mouse down + drag, which happens. But if we don't prevent the default action, the browser
|
||||
// will also scroll the entire page.
|
||||
containerElement.mousedown(function (event) {
|
||||
// Middle mouse button
|
||||
@@ -507,10 +505,16 @@ $(function () {
|
||||
});
|
||||
};
|
||||
|
||||
self.loadFile = function (path, date, size) {
|
||||
self.loadFile = function (path, date, size, force) {
|
||||
self.enableReload(false);
|
||||
self.needsLoad = false;
|
||||
if (self.status === "idle" && self.errorCount < 3) {
|
||||
if (
|
||||
self.status === "idle" &&
|
||||
(force ||
|
||||
(self.cachedPath !== path &&
|
||||
self.cachedDate !== date &&
|
||||
self.cachedSize !== size))
|
||||
) {
|
||||
self.status = "request";
|
||||
|
||||
self.cachedPath = path;
|
||||
@@ -546,7 +550,12 @@ $(function () {
|
||||
|
||||
self.reload = function () {
|
||||
if (!self.enableReload()) return;
|
||||
self.loadFile(self.loadedFilepath, self.loadedFileDate, self.loadedFileSize);
|
||||
self.loadFile(
|
||||
self.loadedFilepath,
|
||||
self.loadedFileDate,
|
||||
self.loadedFileSize,
|
||||
true
|
||||
);
|
||||
};
|
||||
|
||||
self.fromHistoryData = function (data) {
|
||||
@@ -609,7 +618,6 @@ $(function () {
|
||||
) {
|
||||
self._renderPercentage(data.progress.completion);
|
||||
}
|
||||
self.errorCount = 0;
|
||||
} else {
|
||||
if (self.status === "idle") self.clear();
|
||||
if (
|
||||
@@ -889,8 +897,11 @@ $(function () {
|
||||
self.onTabChange = function (current, previous) {
|
||||
self.tabActive = current === "#gcode";
|
||||
if (self.tabActive && self.needsLoad) {
|
||||
self.loadFile(self.selectedFile.path(), self.selectedFile.date()),
|
||||
self.selectedFile.size();
|
||||
self.loadFile(
|
||||
self.selectedFile.path(),
|
||||
self.selectedFile.date(),
|
||||
self.selectedFile.size()
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||