opulo-inc / farm-upload

A bulk file uploading tool for 3D printer farms.
https://opulo.io/
Other
32 stars 13 forks source link

add octoprint and prusa support + refactor Printer Type #4

Open d3vyce opened 3 weeks ago

d3vyce commented 3 weeks ago

I refactor Printer class to allow multiple 3D printer vendor.

To add a new printer type class have to be a child class of Printer. It is then possible to add different variables depending on the type of printer: for example, a token for the use of an API. The class must contain 3 functions:

Here's a snipset of a typical class:

class XXXXX(Printer):
    def __init__(self, config: dict) -> None:
        Printer.__init__(self, config)

        self.xxx = config.get("xxx")
        self.yyy= config.get("yyy")

    def connect(self) -> None:
        # code to connect
        self.connected = True

    def send(self, filename: str, file: io.BytesIO, logger: queue.Queue) -> bool:
        for _ in range(1, MAX_SEND_RETRY+1):
                # code to send file
                return True
        return False

    def disconnect(self) -> None:
        # code to disconnect
        self.connected = False

I've also added (and tested) integration with octoprint and prusa (mini, mk4, xl).