From 0578b3d117614ef6febe77d1c43644a39d6a8ada Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sun, 11 Oct 2020 13:28:18 +0200 Subject: [PATCH] Refactor spinner logic to on/off methods --- dropship/dropship.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/dropship/dropship.py b/dropship/dropship.py index e1ac2a6..26bf025 100644 --- a/dropship/dropship.py +++ b/dropship/dropship.py @@ -122,32 +122,32 @@ class DropShip: self.nursery.start_soon(self.wormhole_send, fpath) self.file_chooser.hide() - async def wormhole_send(self, fpath): - """Run `wormhole send` on a local file path.""" - command = ["wormhole", "send", fpath] - process = await open_process(command, stderr=PIPE) - + def _send_spinner_on(self): + """Turn spinner on for sending interaction.""" self.drop_label.set_visible(False) self.drop_label.set_vexpand(False) - self.drop_spinner.set_vexpand(True) self.drop_spinner.set_visible(True) self.drop_spinner.start() - output = await process.stderr.receive_some() - code = output.decode().split()[-1] - - self.clipboard.set_text(code, -1) - self.transfer_code = code - + def _send_spinner_off(self, code): + """Turn spinner off for sending interaction.""" self.drop_label.set_text(code) self.drop_label.set_visible(True) self.drop_label.set_selectable(True) - self.drop_spinner.stop() self.drop_spinner.set_vexpand(False) self.drop_spinner.set_visible(False) + async def wormhole_send(self, fpath): + """Run `wormhole send` on a local file path.""" + command = ["wormhole", "send", fpath] + process = await open_process(command, stderr=PIPE) + self._send_spinner_on() + output = await process.stderr.receive_some() + self.transfer_code = output.decode().split()[-1] + self.clipboard.set_text(self.transfer_code, -1) + self._send_spinner_off(self.transfer_code) await process.wait() async def wormhole_recv(self, code):