def process_kmp(self, url, downloadfile): logging.info("Downloading kmp file to %s", downloadfile) if download_kmp_file(url, downloadfile): logging.info("File downloaded") w = InstallKmpWindow(downloadfile, online=True, viewkmp=self.viewwindow, downloadwindow=self) if w.checkcontinue: w.show_all() return True return False
def _install_package(packageFile, bcp47): if not os.path.isfile(packageFile): return False w = InstallKmpWindow(packageFile, language=bcp47) w.run() w.destroy() return True
def on_installfile_clicked(self, button): logging.debug("Install from file clicked") dlg = Gtk.FileChooserDialog("Choose a kmp file..", self, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) dlg.resize(640, 480) filter_text = Gtk.FileFilter() filter_text.set_name("KMP files") filter_text.add_pattern("*.kmp") dlg.add_filter(filter_text) response = dlg.run() if response == Gtk.ResponseType.OK: kmpfile = dlg.get_filename() w = InstallKmpWindow(kmpfile, viewkmp=self) w.resize(800, 450) if w.checkcontinue: w.show_all() else: w.destroy() dlg.destroy()
if parsed.path.startswith('/keyboards/install/'): qs = urllib.parse.parse_qs(parsed.query) package_id = parsed.path.split('/')[-1] downloadfile = os.path.join(get_download_folder(), package_id) download_url = KeymanComUrl + '/go/package/download/' + package_id + \ '?platform=linux&tier=' + __tier__ if 'bcp47' in qs: self.language = qs['bcp47'][0] download_url += '&bcp47=' + qs['bcp47'][0] else: self.language = None if self._process_kmp(download_url, downloadfile): decision.ignore() return True return False if __name__ == '__main__': logging.basicConfig(level=logging.INFO) w = DownloadKmpWindow() result = w.run() file = None if result == Gtk.ResponseType.OK: file = w.downloadfile w.destroy() if file is not None: installDlg = InstallKmpWindow(file) installDlg.run() installDlg.destroy()
def install_file(self, kmpfile, language=None): installDlg = InstallKmpWindow(kmpfile, viewkmp=self, language=language) result = installDlg.run() installDlg.destroy() return result