Skip to content

Commit a7ddaa8

Browse files
authored
Merge pull request #51 from smartin015/rc
Merge v1.5.0
2 parents a5cefc3 + e8cd800 commit a7ddaa8

22 files changed

+867
-266
lines changed

.github/workflows/coverage.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CodeCov
2+
3+
on:
4+
# Trigger the workflow on push or pull request,
5+
# but only for the main branch
6+
workflow_dispatch:
7+
push:
8+
branches:
9+
- master
10+
pull_request:
11+
branches:
12+
- master
13+
14+
jobs:
15+
run:
16+
name: CodeCov
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Check out Git repository
21+
uses: actions/checkout@v2
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@master
25+
with:
26+
python-version: 3.8
27+
28+
- name: Generate Report
29+
run: |
30+
pip install coverage
31+
cd continuousprint && coverage run -m unittest '*_test.py'
32+
- name: Upload to Codecov
33+
uses: codecov/codecov-action@v2

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ jobs:
3636
black: true
3737
flake8: true
3838
# These must match .pre-commit-config.yaml
39-
flake8_args: "--max-line-length=88 --ignore=E203,E266,E501,W503,F403,F401,E402"
39+
flake8_args: "--max-line-length=88 --ignore=E203,E266,E501,W503,F403,F401,E402,F821"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ dist
77
*.egg*
88
.DS_Store
99
*.zip
10+
site/

README.md

Lines changed: 6 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Continuous Print Queue Plugin
22

3+
![build status](https://img.shields.io/travis/smartin015/continuousprint/master?style=plastic)
4+
![code coverage](https://img.shields.io/codecov/c/github/smartin015/continuousprint/master)
5+
36
This plugin automates your printing!
47

58
* **Add gcode files to the queue and set a number of times to print each.** The plugin will print them in sequence, running "bed clearing" script after each.
@@ -8,150 +11,8 @@ This plugin automates your printing!
811

912
WARNING: Your printer must have a method of clearing the bed automatically, with correct GCODE instructions set up in this plugin's settings page - damage to your printer may occur if this is not done correctly. If you want to manually remove prints, look in the plugin settings for details on how to use `@pause` so the queue is paused before another print starts.
1013

11-
# Setup
12-
13-
## Add the plugin
14-
15-
1. In the OctoPrint UI, go to `Settings` -> `Plugin Manager` -> `Get More`
16-
1. Search for "Continuous Print", and click Install, following any instructions
17-
* If you can't find the plugin, you can also put https://github.com/smartin015/continuousprint/archive/master.zip into the "...from URL" section of the Get More page.
18-
1. Restart OctoPrint
19-
20-
That's it! Now let's configure it to work with your printer.
21-
22-
## Configure the plugin
23-
24-
Go to `Settings` -> `Continuous Print` and ensure the bed cleaning and queue finished scripts are correct for your 3D printer.
25-
26-
You can also enable settings here for compatibility with [The Spaghetti Detective](https://www.thespaghettidetective.com/) for automatic retries when the print starts failing.
27-
28-
## Add prints to the queue
29-
30-
1. Navigate to the file you wish to add in the Files dialog on the left of the page.
31-
1. Add it to the print queue by clicking the `+` button to the right of the file name.
32-
* If you want to print more than one, you can click multiple times to add more copies, or set a specific count in the `Continuous Print` tab.
33-
34-
## Start the queue
35-
36-
The print queue won't start your prints just yet. To run the queue:
37-
38-
1. Click the 'Continuous Print` tab (it may be hidden in the extra tabs fold-out on the right)
39-
1. Double check the order and count of your prints - set the count and order using the buttons and number box to the right of the queued print, and delete with the red `X`.
40-
1. Click `Start Managing`.
41-
42-
The plugin will wait until your printer is ready to start a print, then it'll begin with the top of the queue and proceed until the bottom.
43-
44-
Note that when it's time to clear the print bed or finish up, a temporary `cp_\*.gcode` file will appear in your local files, and disappear when it completes. This is a change from older "gcode injecting" behavior that is necessary to support [at-commands](https://docs.octoprint.org/en/master/features/atcommands.html) in the clearing and finish scripts.
45-
46-
## Inspect queue items
47-
48-
As the print queue is managed and prints complete, you can see the status of individual prints by clicking the small triangle to the left of any individual queue item.
49-
50-
This opens a sub-panel showing individual print stats and results.
51-
52-
## Stop the queue
53-
54-
When all prints are finished, the plugin stops managing the queue and waits for you to start it again.
55-
56-
If you need to stop early, click `Stop Managing` (**Note: any currently running print will continue unless you cancel it**)
57-
58-
## Clean up the queue
59-
60-
Click the triple-dot menu for several convenient queue cleanup options. You can also remove individual queue items with the red `X` next to the item.
61-
62-
# Development
63-
64-
*Based on the instructions at https://docs.octoprint.org/en/master/plugins/gettingstarted.html*
65-
66-
Install octoprint locally:
67-
68-
```shell
69-
git clone https://github.com/OctoPrint/OctoPrint
70-
cd OctoPrint
71-
virtualenv venv
72-
source venv/bin/activate
73-
pip install -e .
74-
```
75-
76-
In the same terminal as the one where you activated the environment, Install the plugin in dev mode and launch the server:
77-
78-
```shell
79-
git clone https://github.com/smartin015/continuousprint.git
80-
cd continuousprint
81-
octoprint dev plugin:install
82-
pre-commit install # Cleans up files when you commit them - see https://pre-commit.com/. Note that venv must be activated or else flake8 raises improper errors
83-
octoprint serve
84-
```
85-
86-
You should see "Successfully installed continuousprint" when running the install command, and you can view the page at http://localhost:5000.
87-
88-
## Testing
89-
90-
Backend unit tests are currently run manually:
91-
```
92-
python3 continuousprint/print_queue_test.py
93-
python3 continuousprint/driver_test.py
94-
```
95-
96-
Frontend unit tests require some additional setup (make sure [yarn](https://classic.yarnpkg.com/lang/en/docs/install/#debian-stable) and its dependencies are installed):
97-
98-
```
99-
cd .../continuousprint
100-
yarn install
101-
yarn run test
102-
```
103-
104-
This will run all frontend JS test files (`continuousprint/static/js/\*.test.js`). You can also `yarn run watch-test` to set up a test process which re-runs whenever you save a JS test file.
105-
106-
## Installing dev version on OctoPi
107-
108-
Users of [OctoPi](https://octoprint.org/download/) can install a development version directly on their pi as follows:
109-
110-
1. `ssh pi@<your octopi hostname>` and provide your password (the default is `raspberry`, but for security reasons you should change it with `passwd` when you can)
111-
1. `git clone https://github.com/smartin015/continuousprint.git`
112-
1. Uninstall any existing continuous print installations (see `Settings` -> `Plugin Manager` in the browser)
113-
1. `cd continuousprint && ~/oprint/bin/python3 setup.py install`
114-
115-
Note that we're using the bundled version of python3 that comes with octoprint, **NOT** the system installed python3. If you try the latter, it'll give an error that sounds like octoprint isn't installed.
116-
117-
## Developer tips
118-
119-
* The backend (`__init__.py` and dependencies) stores a flattened representation of the print queue and
120-
iterates through it from beginning to end. Each item is loaded as a QueueItem (see `print_queue.py`).
121-
* The frontend talks to the backend with the flattened queue, but operates on an inmemory structured version:
122-
* Each flattened queue item is loaded as a `CPQueueItem` (see continuousprint/static/js/continuousprint_queueitem.js)
123-
* Sets of the same queue item are aggregated into a `CPQueueSet` (see continuousprint/static/js/continuousprint_queueset.js)
124-
* Multiple queuesets are grouped together and run one or more times as a `CPJob` (see continuousprint/static/js/continuousprint_job.js)
125-
* For simplicity, each level only understands the level below it - e.g. a Job doesn't care about QueueItems.
126-
* Remember, you can enable the virtual printer under `Virtual Printer` in OctoPrint settings.
127-
* Octoprint currently uses https://fontawesome.com/v5.15/icons/ for icons.
128-
* Drag-and-drop functionality uses SortableJS wrapped with Knockout-SortableJS, both of which are heavily customized. For more details on changes see:
129-
* Applied fix from https://github.com/SortableJS/knockout-sortablejs/pull/13
130-
* Applied fix from https://github.com/SortableJS/knockout-sortablejs/issues/14
131-
* Discussion at https://github.com/smartin015/continuousprint/issues/14 (conflict with a different `knockout-sortable` library)
132-
133-
## QA
134-
135-
Check these before releasing:
136-
137-
* All buttons under the triple-dot menu work as intended
138-
* Jobs and items can be drag-reordered
139-
* Jobs can't be dragged into items, items can't be dragged outside jobs
140-
* Adding a file from the Files dialog works as intended
141-
* Setting the count for jobs and items behaves as expected
142-
* [At-commands](https://docs.octoprint.org/en/master/features/atcommands.html) work in clearing/finish scripts
143-
* Temporary gcode files are cleaned up after use
144-
* Pausing and resuming the print works
145-
* Cancelling restarts the print
146-
* Print queue can be started and stopped; queue items complete in order
147-
* Stylings look good in light and dark themes
14+
# Documentation
14815

149-
## Potential future work
16+
See https://smartin015.github.io/continuousprint/ for all documentation on installation, setup, queueing strategies, and development.
15017

151-
* File integrity checking (resilience to renames/deletions)
152-
* Save/remember and allow re-adding of jobs
153-
* Improved queue history/status with more stats
154-
* Segmented status bars to better indicate run completion
155-
* Client library to support queue management automation
156-
* Bed clearing profiles for specific printers
157-
* Multi-user queue modification with attribution (shows who added which prints, prevents overwriting others' jobs)
18+
See also [here](https://octo-plugin-stats2-a6l7lv6h7-smartin015.vercel.app/) for adoption stats.

api_examples/example.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import requests
2+
3+
# See https://docs.octoprint.org/en/master/api/general.html#authorization for
4+
# where to get this value
5+
UI_API_KEY = "CHANGEME"
6+
7+
# Change this to match your printer
8+
HOST_URL = "http://localhost:5000"
9+
10+
11+
def set_active(active=True):
12+
return requests.post(
13+
f"{HOST_URL}/plugin/continuousprint/set_active",
14+
headers={"X-Api-Key": UI_API_KEY},
15+
data={"active": active},
16+
).json()
17+
18+
19+
def get_state():
20+
return requests.get(
21+
f"{HOST_URL}/plugin/continuousprint/state", headers={"X-Api-Key": UI_API_KEY}
22+
).json()
23+
24+
25+
if __name__ == "__main__":
26+
print(
27+
"Sending example requests - will stop printer and get its state in two requests"
28+
)
29+
set_active(active=False)
30+
print(get_state())

api_examples/jquery.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// See https://docs.octoprint.org/en/master/api/general.html#authorization for
2+
// where to get this value
3+
const UI_API_KEY = "YOUR_KEY_HERE";
4+
5+
const setActive = function(active=true, callback) {
6+
$.ajax({
7+
url: "plugin/continuousprint/set_active",
8+
type: "POST",
9+
dataType: "json",
10+
headers: {"X-Api-Key":UI_API_KEY},
11+
data: {active}
12+
}).done(callback);
13+
};
14+
15+
const getState = function(callback) {
16+
$.ajax({
17+
url: "plugin/continuousprint/state",
18+
type: "GET",
19+
dataType: "json",
20+
headers: {"X-Api-Key":UI_API_KEY},
21+
}).done(callback)
22+
};
23+
24+
console.log("Stopping print queue");
25+
setActive(false, function(data) {console.log('stopped');});
26+
27+
console.log("Getting state");
28+
getState(function(data) {console.log(data);});

0 commit comments

Comments
 (0)