def open_url(self, url): original_url = url hash_part = "" parts = url.split("#", 1) if len(parts) > 1: url = parts[0] hash_part = "#" + parts[1] if not Downloader.cache_file_from_url(url, download=False): license_code = self.get_license_code_for_url(original_url) license_status = {"accepted": False, "done": False} def show_license_code(): try: try: license_status["accepted"] = self.show_license_code( license_code) except Exception: traceback.print_exc() finally: license_status["done"] = True if license_code: print("URL", url, "has license code", license_code) # FIXME: remove direct dependency on fsui import fsui as fsui fsui.call_after(show_license_code) while not license_status["done"]: time.sleep(0.1) if not license_status["accepted"]: # FIXME: custom exception here raise Exception("Usage terms \"{0}\" was not " "accepted".format(license_code)) path = Downloader.cache_file_from_url(url) return path + hash_part
def run_dialog(self): def run_in_dialog(): self.dialog.end_modal(True) fsui.call_after(run_in_dialog) self.dialog.show_modal() self.dialog.destroy()
def scan_thread(cls): try: with Database.get_instance() as database: cls._scan_thread(database) except Exception as e: cls.error = str(e) traceback.print_exc() # else: # if cls.on_status: # cls.on_status(("", _("Committing data..."))) # database.commit() def on_done(): # FIXME: these should be removed soon LauncherSettings.set("last_scan", str(time.time())) LauncherSettings.set("__config_refresh", str(time.time())) # this must be called from main, since callbacks are broadcast # when settings are changed LauncherSignal.broadcast("scan_done") LauncherConfig.update_kickstart() # call on_done from main thread fsui.call_after(on_done) cls.running = False
def run(self): if self.type: self.log(gettext("Amiga Forever import task started")) else: self.log(gettext("Kickstart import task started")) self.log("") print("ImportTask.run") try: count = self.run_task() except Exception as e: self.log("") self.log(repr(e)) traceback.print_exc() else: if count == 0: self.log(gettext("Warning: No ROM files were found!")) else: self.log("") self.log(gettext("{} ROM files were imported").format(count)) self.done = True print("ImportTask.run is done") self.log("") self.log(gettext("Import task is done")) def run_in_main(): LauncherSignal.broadcast("scan_done") fsui.call_after(run_in_main)
def run(self): if self.type: self.log(gettext("Amiga Forever import task started")) else: self.log(gettext("Kickstart import task started")) self.log("") print("ImportTask.run") try: count = self.run_task() except Exception as e: self.log("") self.log(repr(e)) traceback.print_exc() else: if count == 0: self.log(gettext("Warning: No ROM files were found!")) else: self.log("") self.log(gettext("{} ROM files were imported").format(count)) self.done = True print("ImportTask.run is done") self.log("") self.log(gettext("Import task is done")) def run_in_main(): LauncherSignal.broadcast("scan_done") fsui.call_after(run_in_main)
def scan_thread(cls): try: with Database.get_instance() as database: cls._scan_thread(database) except Exception as e: cls.error = str(e) traceback.print_exc() # else: # if cls.on_status: # cls.on_status(("", _("Committing data..."))) # database.commit() def on_done(): # FIXME: these should be removed soon LauncherSettings.set("last_scan", str(time.time())) LauncherSettings.set("__config_refresh", str(time.time())) # this must be called from main, since callbacks are broadcast # when settings are changed LauncherSignal.broadcast("scan_done") LauncherConfig.update_kickstart() # call on_done from main thread fsui.call_after(on_done) cls.running = False
def onNext(self, value): import threading print("on_next", value, threading.currentThread()) self.errorLabel.set_text(value) def disp(): self.disposable.dispose() fsui.call_after(disp)
def on_progress(self, progress): # def hide_function(): # self.visible = False def function(): if progress == "__run__": self.cancel_button.disable() # Hide dialog after 1.5 seconds. The reason for delaying it # is to avoid "confusing" flickering if/when the dialog is # only shown for a split second. # fsui.call_later(1500, hide_function) LauncherConfig.set( "__progress", gettext("Running: Emulator")) else: self.sub_title_label.set_text(progress) LauncherConfig.set( "__progress", "Preparing: {}".format(progress)) fsui.call_after(function)
def open_url(self, url): original_url = url hash_part = "" parts = url.split("#", 1) if len(parts) > 1: url = parts[0] hash_part = "#" + parts[1] if not Downloader.cache_file_from_url(url, download=False): license_code = self.get_license_code_for_url(original_url) license_status = {"accepted": False, "done": False} def show_license_code(): try: try: license_status["accepted"] = self.show_license_code( license_code ) except Exception: traceback.print_exc() finally: license_status["done"] = True if license_code: print("URL", url, "has license code", license_code) # FIXME: remove direct dependency on fsui import fsui as fsui fsui.call_after(show_license_code) while not license_status["done"]: time.sleep(0.1) if not license_status["accepted"]: # FIXME: custom exception here raise Exception( 'Usage terms "{0}" was not ' "accepted".format(license_code) ) path = Downloader.cache_file_from_url(url) return path + hash_part
def on_progress(self, progress): def hide_function(): self.set_visible(False) def function(): if progress == "__run__": self.cancel_button.set_enabled(False) # Hide dialog after 1.5 seconds. The reason for delaying it # is to avoid "confusing" flickering if/when the dialog is # only shown for a split second. if self.visible(): fsui.call_later(1500, hide_function) get_config(self).set("__progress", gettext("Running: Emulator")) else: if self.no_gui: print("[PROGRESS]", progress) else: self.sub_title_label.set_text(progress) get_config(self).set("__progress", "Preparing: {}".format(progress)) fsui.call_after(function)
def on_complete(self): def function(): self.complete() fsui.call_after(function)
def update(self): self.dirty = True fsui.call_after(self.do_update)
def notify(self): def on_load_function(): self.on_load(self) fsui.call_after(on_load_function)
def notify(self): def on_load_function(): self.on_load(self) fsui.call_after(on_load_function)