Skip to content

Commit

Permalink
Merge pull request #75 from smartin015/rc
Browse files Browse the repository at this point in the history
v2.0.0 master merge
  • Loading branch information
smartin015 authored Jun 16, 2022
2 parents 88e1307 + 3109434 commit 7ed9160
Show file tree
Hide file tree
Showing 72 changed files with 6,655 additions and 2,490 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ dist
.DS_Store
*.zip
site/
volume/
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 21.12b0
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
jobs:
include:
- language: node_js
node_js: node
node_js:
- 17
- language: python
python: 3.6
python: 3.7
install:
- pip install setuptools==60.9.0 # https://github.com/pypa/setuptools/issues/3293
- pip install OctoPrint # Need OctoPrint to satisfy req's of `__init__.py`
- pip install -r requirements.txt
script:
- python -m unittest discover -s continuousprint -p "*_test.py"
- python3 -m unittest discover -p "*_test.py"
notifications:
email:
- [email protected]
Expand Down
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:3.7

RUN adduser oprint
USER oprint

SHELL ["/bin/bash", "-c"]
RUN python -m pip install virtualenv && cd ~ \
&& git clone https://github.com/OctoPrint/OctoPrint && cd OctoPrint \
&& python -m virtualenv venv && source ./venv/bin/activate && python -m pip install -e .[develop,plugins] \
&& echo "source ~/OctoPrint/venv/bin/activate" >> ~/.bashrc \
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash \
&& . ~/.nvm/nvm.sh && nvm install v17 && nvm alias default v17 && nvm use default


ADD . /home/oprint/continuousprint
RUN cd ~/continuousprint && source ~/OctoPrint/venv/bin/activate && octoprint dev plugin:install
CMD octoprint serve
25 changes: 21 additions & 4 deletions api_examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,32 @@ def set_active(active=True):
).json()


def add_set(path, sd=False, count=1, jobName="Job", jobDraft=True):
return requests.post(
f"{HOST_URL}/plugin/continuousprint/set/add",
headers={"X-Api-Key": UI_API_KEY},
data=dict(
path=path,
sd=sd,
count=count,
jobName=jobName,
jobDraft=jobDraft,
),
).json()


def get_state():
return requests.get(
f"{HOST_URL}/plugin/continuousprint/state", headers={"X-Api-Key": UI_API_KEY}
f"{HOST_URL}/plugin/continuousprint/state/get",
headers={"X-Api-Key": UI_API_KEY},
).json()


if __name__ == "__main__":
print(
"Sending example requests - will stop printer and get its state in two requests"
)
print("Sending example requests to", HOST_URL)
print("Stopping management")
set_active(active=False)
print("Adding an example set/job")
add_set("example.gcode")
print("Fetching queue state")
print(get_state())
15 changes: 14 additions & 1 deletion api_examples/jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,19 @@ const setActive = function(active=true, callback) {
}).done(callback);
};

const addSet = function(data, callback) {
data = {...data, sd: false, count: 1, jobName: 'Job', jobDraft: true};
$.ajax({
url: "plugin/continuousprint/set/add",
type: "POST",
dataType: "json",
headers: {"X-Api-Key": UI_API_KEY},
data
}).done(callback)

const getState = function(callback) {
$.ajax({
url: "plugin/continuousprint/state",
url: "plugin/continuousprint/state/get",
type: "GET",
dataType: "json",
headers: {"X-Api-Key":UI_API_KEY},
Expand All @@ -24,5 +34,8 @@ const getState = function(callback) {
console.log("Stopping print queue");
setActive(false, function(data) {console.log('stopped');});

console.log("Adding new set/job");
addSet({path: "example.gcode"}, function(data) {console.log(data);});

console.log("Getting state");
getState(function(data) {console.log(data);});
Loading

0 comments on commit 7ed9160

Please sign in to comment.