in operators.py [0:0]
def modal(self, context, event):
if event.type == "TIMER":
prefs = context.preferences.addons[__package__].preferences
if not prefs.downloading:
self.report({"INFO"}, "Download canceled")
self.cleanup(context)
return {"CANCELLED"}
while not self._progress_queue.empty():
item = self._progress_queue.get()
if isinstance(item, (int, float)):
prefs.download_progress = item
for window in context.window_manager.windows:
for area in window.screen.areas:
if area.type == "PREFERENCES":
area.tag_redraw()
elif isinstance(item, str):
if item == "finished":
prefs.downloading = False
if len(get_available_models()) == 1:
prefs.current_model = get_available_models()[0]
self.report(
{"INFO"},
f"Successfully downloaded {self.filename} from {self.repo_id}",
)
self.cleanup(context)
return {"FINISHED"}
else:
self.report({"ERROR"}, item)
prefs.downloading = False
self.cleanup(context)
return {"CANCELLED"}
return {"RUNNING_MODAL"}
else:
return {"PASS_THROUGH"}