Skip to content

Commit 7ed9160

Browse files
authored
Merge pull request #75 from smartin015/rc
v2.0.0 master merge
2 parents 88e1307 + 3109434 commit 7ed9160

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+6655
-2490
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ dist
88
.DS_Store
99
*.zip
1010
site/
11+
volume/

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ repos:
66
- id: end-of-file-fixer
77
- id: trailing-whitespace
88
- repo: https://github.com/psf/black
9-
rev: 21.12b0
9+
rev: 22.3.0
1010
hooks:
1111
- id: black
1212
- repo: https://github.com/pre-commit/pre-commit-hooks

.travis.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
jobs:
33
include:
44
- language: node_js
5-
node_js: node
5+
node_js:
6+
- 17
67
- language: python
7-
python: 3.6
8+
python: 3.7
89
install:
10+
- pip install setuptools==60.9.0 # https://github.com/pypa/setuptools/issues/3293
911
- pip install OctoPrint # Need OctoPrint to satisfy req's of `__init__.py`
1012
- pip install -r requirements.txt
1113
script:
12-
- python -m unittest discover -s continuousprint -p "*_test.py"
14+
- python3 -m unittest discover -p "*_test.py"
1315
notifications:
1416
email:
1517

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM python:3.7
2+
3+
RUN adduser oprint
4+
USER oprint
5+
6+
SHELL ["/bin/bash", "-c"]
7+
RUN python -m pip install virtualenv && cd ~ \
8+
&& git clone https://github.com/OctoPrint/OctoPrint && cd OctoPrint \
9+
&& python -m virtualenv venv && source ./venv/bin/activate && python -m pip install -e .[develop,plugins] \
10+
&& echo "source ~/OctoPrint/venv/bin/activate" >> ~/.bashrc \
11+
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash \
12+
&& . ~/.nvm/nvm.sh && nvm install v17 && nvm alias default v17 && nvm use default
13+
14+
15+
ADD . /home/oprint/continuousprint
16+
RUN cd ~/continuousprint && source ~/OctoPrint/venv/bin/activate && octoprint dev plugin:install
17+
CMD octoprint serve

api_examples/example.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,32 @@ def set_active(active=True):
1616
).json()
1717

1818

19+
def add_set(path, sd=False, count=1, jobName="Job", jobDraft=True):
20+
return requests.post(
21+
f"{HOST_URL}/plugin/continuousprint/set/add",
22+
headers={"X-Api-Key": UI_API_KEY},
23+
data=dict(
24+
path=path,
25+
sd=sd,
26+
count=count,
27+
jobName=jobName,
28+
jobDraft=jobDraft,
29+
),
30+
).json()
31+
32+
1933
def get_state():
2034
return requests.get(
21-
f"{HOST_URL}/plugin/continuousprint/state", headers={"X-Api-Key": UI_API_KEY}
35+
f"{HOST_URL}/plugin/continuousprint/state/get",
36+
headers={"X-Api-Key": UI_API_KEY},
2237
).json()
2338

2439

2540
if __name__ == "__main__":
26-
print(
27-
"Sending example requests - will stop printer and get its state in two requests"
28-
)
41+
print("Sending example requests to", HOST_URL)
42+
print("Stopping management")
2943
set_active(active=False)
44+
print("Adding an example set/job")
45+
add_set("example.gcode")
46+
print("Fetching queue state")
3047
print(get_state())

api_examples/jquery.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,19 @@ const setActive = function(active=true, callback) {
1212
}).done(callback);
1313
};
1414

15+
const addSet = function(data, callback) {
16+
data = {...data, sd: false, count: 1, jobName: 'Job', jobDraft: true};
17+
$.ajax({
18+
url: "plugin/continuousprint/set/add",
19+
type: "POST",
20+
dataType: "json",
21+
headers: {"X-Api-Key": UI_API_KEY},
22+
data
23+
}).done(callback)
24+
1525
const getState = function(callback) {
1626
$.ajax({
17-
url: "plugin/continuousprint/state",
27+
url: "plugin/continuousprint/state/get",
1828
type: "GET",
1929
dataType: "json",
2030
headers: {"X-Api-Key":UI_API_KEY},
@@ -24,5 +34,8 @@ const getState = function(callback) {
2434
console.log("Stopping print queue");
2535
setActive(false, function(data) {console.log('stopped');});
2636

37+
console.log("Adding new set/job");
38+
addSet({path: "example.gcode"}, function(data) {console.log(data);});
39+
2740
console.log("Getting state");
2841
getState(function(data) {console.log(data);});

0 commit comments

Comments
 (0)