Vendoring octorest
This commit is contained in:
parent
3275563a18
commit
bee6f3b69a
76 changed files with 13557 additions and 0 deletions
projects/octorest/examples/basic
37
projects/octorest/examples/basic/basic.py
Normal file
37
projects/octorest/examples/basic/basic.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
from octorest import OctoRest
|
||||
|
||||
|
||||
def make_client():
|
||||
try:
|
||||
client = OctoRest(url="http://octopi.local", apikey="YouShallNotPass")
|
||||
return client
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def get_version():
|
||||
client = make_client()
|
||||
message = "You are using OctoPrint v" + client.version['server'] + "\n"
|
||||
return message
|
||||
|
||||
def get_printer_info():
|
||||
try:
|
||||
client = OctoRest(url="http://octopi.local", apikey="YouShallNotPass")
|
||||
message = ""
|
||||
message += str(client.version) + "\n"
|
||||
message += str(client.job_info()) + "\n"
|
||||
printing = client.printer()['state']['flags']['printing']
|
||||
if printing:
|
||||
message += "Currently printing!\n"
|
||||
else:
|
||||
message += "Not currently printing...\n"
|
||||
return message
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def main():
|
||||
c = make_client()
|
||||
for k in c.files()['files']:
|
||||
print(k['name'])
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue