aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/virtual_sdcard.py
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2021-06-08 17:33:35 +0000
committerKevinOConnor <kevin@koconnor.net>2021-06-22 15:15:03 -0400
commitf1091a484bfbf2cc5676e3a6fcd595172f123f67 (patch)
tree4aca1b8dcbc76464b4c3ebd7cb0486c501ab2f8c /klippy/extras/virtual_sdcard.py
parent478f26cab6c8e73e3970d2b303bc818f6910ae74 (diff)
downloadkutter-f1091a484bfbf2cc5676e3a6fcd595172f123f67.tar.gz
kutter-f1091a484bfbf2cc5676e3a6fcd595172f123f67.tar.xz
kutter-f1091a484bfbf2cc5676e3a6fcd595172f123f67.zip
virtual_sdcard: add `file_path` and `file_size` to `status`
This provides a comprehensive information if currently we have a file loaded. Signed-off-by: Kamil Trzcinski <ayufan@ayufan.eu>
Diffstat (limited to 'klippy/extras/virtual_sdcard.py')
-rw-r--r--klippy/extras/virtual_sdcard.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/klippy/extras/virtual_sdcard.py b/klippy/extras/virtual_sdcard.py
index 3cd77612..d61af0cf 100644
--- a/klippy/extras/virtual_sdcard.py
+++ b/klippy/extras/virtual_sdcard.py
@@ -79,12 +79,22 @@ class VirtualSD:
logging.exception("virtual_sdcard get_file_list")
raise self.gcode.error("Unable to get file list")
def get_status(self, eventtime):
- progress = 0.
+ return {
+ 'file_path': self.file_path(),
+ 'progress': self.progress(),
+ 'is_active': self.is_active(),
+ 'file_position': self.file_position,
+ 'file_size': self.file_size,
+ }
+ def file_path(self):
+ if self.current_file:
+ return self.current_file.name
+ return None
+ def progress(self):
if self.file_size:
- progress = float(self.file_position) / self.file_size
- is_active = self.is_active()
- return {'progress': progress, 'is_active': is_active,
- 'file_position': self.file_position}
+ return float(self.file_position) / self.file_size
+ else:
+ return 0.
def is_active(self):
return self.work_timer is not None
def do_pause(self):