コード例 #1
0
 def on_connection_registered(self, plabric_api_key):
     self._p.plabric_socket.send_msg(key='lr')
     self._p.plabric_socket.send_msg(key='close')
     self._p.plabric_socket.send_msg(
         key='jr_slave', data={'api_key': plabric_api_key})
     self._p.plabric_api_key = plabric_api_key
     storage = Storage(self._p.plugin)
     storage.save_setting('plabric_api_key', plabric_api_key)
コード例 #2
0
    def download_temporal_file(self, data):
        class Response(APIProtocol):
            def __init__(self, p, file_path):
                self._p = p
                self._file_path = file_path

            def on_succeed(self, response):
                self._p.upload_file(data=data, file_path=self._file_path)

            def on_error(self, error):
                self._p.set_error(error)

        destination = Storage(self.plugin).get_file_temporal_path("tmp.gcode")
        self.plabric_api.download_temporal_file(
            file_id=data['params']['file_id'],
            destination=destination,
            plabric_api_key=self.plabric_api_key,
            callback=Response(self, file_path=destination))
コード例 #3
0
ファイル: main.py プロジェクト: plabric/Octoprint-Plabric
    def __init__(self, plugin):
        self.plugin = plugin
        self.error = ''
        self.loading = False
        self.user_nick = None
        self.step = None
        self.set_step(Step.LOGIN_NEEDED)

        self.plabric_api = None
        self.plabric_socket = None
        self.plabric_webrtc = None
        self.octoprint_api = None
        self.octoprint_socket = None
        self.video_streamer = None

        self.plabric_api_key = Storage(
            self.plugin).get_saved_setting('plabric_api_key')
        self.plabric_token = None
        self.octoprint_api_key = None

        self.init()
        self._waiting_for_reconnect = False
        self.retry_time = randrange(30, 120)
コード例 #4
0
 def disable(self):
     self.disconnect()
     self.plabric_api_key = None
     _logger.log('Disabling Plabric Plugin')
     Storage(self.plugin).clear_setting('plabric_api_key')
コード例 #5
0
 def on_succeed(self, response):
     Storage(self._p.plugin).delete_file_temporal(path=file_path)
     self._p.call_octoprint_api_succeed(data=data,
                                        response=response)