From c3ba9c84532279289f8e5a6673f422b696398dfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sat, 24 Feb 2018 14:59:30 +0100 Subject: [PATCH] Fix upload_cli --- src/octoprint/util/comm.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 05babc295..d81800d1a 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -3978,6 +3978,7 @@ def upload_cli(): self._path = path self._target = target + self._state = None def on_comm_file_transfer_started(self, filename, filesize): # transfer started, report @@ -3990,6 +3991,8 @@ def upload_cli(): self.finished.set() def on_comm_state_change(self, state): + self._state = state + if state in (MachineCom.STATE_ERROR, MachineCom.STATE_CLOSED_WITH_ERROR): # report and exit on errors logger.error("Error/closed with error, exiting.") @@ -3997,14 +4000,22 @@ def upload_cli(): self.finished.set() elif state in (MachineCom.STATE_OPERATIONAL,) and not self.started: - # start transfer once we are operational - self.comm.startFileTransfer(self._path, os.path.basename(self._path), self._target) + def run(): + logger.info("Looks like we are operational, waiting a bit for everything to settle") + time.sleep(15) + if self._state in (MachineCom.STATE_OPERATIONAL,) and not self.started: + # start transfer once we are operational + self.comm.startFileTransfer(self._path, os.path.basename(self._path), self._target) + + thread = threading.Thread(target=run) + thread.daemon = True + thread.start() callback = MyMachineComCallback(path, target) # mock printer profile manager profile = dict(heatedBed=False, - extruder=dict(count=1)) + extruder=dict(count=1, sharedNozzle=False)) printer_profile_manager = Object() printer_profile_manager.get_current_or_default = lambda: profile