def check_prebuilt_distribution_version(self) -> None: def delayed() -> None: # See check_plugin_version(). time.sleep(120) variants = ['nompi', 'mpi'] def on_succeeded() -> None: dist_root_dir = os.path.normpath(self.options.distributions_dir) old_found = None for dist_name, current_dir in [('WPS', self.options.wps_dir), ('WRF', self.options.wrf_dir)]: if current_dir is None: continue for old_version in WRF_WPS_DIST_OLD_VERSIONS: for variant in variants: # We assume that a match of this folder path would only happen # if the user downloaded a pre-built distribution via the settings interface. old_dir = os.path.join(dist_root_dir, f'{dist_name}-{old_version}-{variant}') if os.path.normpath(old_dir) == os.path.normpath(current_dir): old_found = old_version if old_found: QMessageBox.information(self.iface.mainWindow(), PLUGIN_NAME, f'<html>Pre-built WRF/WPS {WRF_WPS_DIST_VERSION} distributions are available. ' + f'You are currently using version {old_found}. Please update. ' 'See the <a href="https://gis4wrf.github.io/configuration/">online documentation</a> for details.</html>', QMessageBox.Ok) thread = TaskThread(delayed) thread.succeeded.connect(on_succeeded) thread.start()
def on_download_button_clicked(self) -> None: datasets_to_download = [] for name, item in self.get_items().items(): if item.checkState(0) == Qt.Checked: datasets_to_download.append(name) # TODO report progress thread = TaskThread( lambda: self.download_datasets(datasets_to_download)) thread.started.connect(self.on_started_download) thread.finished.connect(self.on_finished_download) thread.succeeded.connect(self.on_successful_download) thread.failed.connect(reraise) thread.start()
def download_dist(self, name: str, mpi: bool, url: str, on_success: Callable[[str], None]) -> None: mpi = self.mpi_enabled.isChecked() # TODO check if mpiexec/mpirun etc is installed and if not prompt user to install it if not self.confirm_dist_download(name, mpi, url): return wait_dialog = WaitDialog(self, 'Downloading...') folder = self.get_dist_download_folder(name, mpi) thread = TaskThread(lambda: download_and_extract_dist(url, folder)) thread.finished.connect(lambda: wait_dialog.accept()) thread.succeeded.connect(lambda: on_success(folder)) thread.failed.connect(reraise) thread.start()
def on_download_button_clicked(self): param_names = [] for index in range(self.tree.count()): item = self.tree.item(index) if item.checkState() == Qt.Checked: param_name = item.data(Qt.UserRole) param_names.append(param_name) dataset_name = self.cbox_dataset.currentData() product_name = self.cbox_product.currentData() start_date = self.dedit_start_date.dateTime().toPyDateTime() end_date = self.dedit_end_date.dateTime().toPyDateTime() if dataset_name is None or product_name is None: raise UserError('Dataset/Product not selected') args = [ self.options.met_dir, dataset_name, product_name, start_date, end_date ] if is_met_dataset_downloaded(*args): reply = QMessageBox.question(self.iface.mainWindow( ), 'Existing dataset', ( 'You already downloaded data with the selected dataset/product/date/time combination. ' 'If you continue, this data will be removed.\n' 'Location: {}'.format(get_met_dataset_path(*args))), QMessageBox.Ok, QMessageBox.Cancel) if reply == QMessageBox.Cancel: return lat_north = self.top.value() lat_south = self.bottom.value() lon_west = self.left.value() lon_east = self.right.value() auth = (self.options.rda_username, self.options.rda_password) thread = TaskThread(lambda: download_met_dataset( self.options.met_dir, auth, dataset_name, product_name, param_names, start_date, end_date, lat_south, lat_north, lon_west, lon_east), yields_progress=True) thread.started.connect(self.on_started_download) thread.progress.connect(self.on_progress_download) thread.finished.connect(self.on_finished_download) thread.succeeded.connect(self.on_successful_download) thread.failed.connect(reraise) thread.start()
def check_version(self) -> None: def get_latest_delayed() -> str: # When QGIS is started, display messages after QGIS # is fully loaded by waiting for 2 mins as plugins # are activated whilst QGIS is loading. time.sleep(120) return get_latest_gis4wrf_version() def on_succeeded(latest: str) -> None: installed = get_installed_gis4wrf_version() if is_newer_version(latest, installed): QMessageBox.information(self.iface.mainWindow(), PLUGIN_NAME, 'Your ' + PLUGIN_NAME + ' version is outdated, please update.\n' + \ 'Installed: ' + installed + ', Latest: ' + latest, QMessageBox.Ok) thread = TaskThread(get_latest_delayed) thread.succeeded.connect(on_succeeded) thread.start()
def on_delete(): thread = TaskThread(dispose) thread.failed.connect(reraise) thread.start()