Пример #1
0
 def get_printer_state(printer: Printer):
     """
     Returns information about current state of printer including job info if is OctoPrint printing or paused
     """
     client = OctoClient(url=printer.url, apikey=printer.apikey)
     status = client.printer()
     if status["state"]["text"] == "Printing" or status["state"]["text"] == "Paused":
         job_info = client.job_info()
         status["job"] = job_info["job"]
         status["job"]["progress"] = job_info["progress"]
     return status
Пример #2
0
def pause_print():
    try:
        client = OctoClient(url=URL, apikey=API_KEY)
        flags = client.printer()['state']['flags']
        if flags['printing']:
            client.pause()
            print("Print paused.")
            print("Layer: " + str(LAYER))
        elif flags['paused'] or flags['pausing']:
            print("Print already paused.")
        else:
            print("Print cancelled or error occurred.")
    except Exception as e:
        print(e)