diff --git a/mslib/mscolab/seed.py b/mslib/mscolab/seed.py index d9bc3ff70..8103ac158 100644 --- a/mslib/mscolab/seed.py +++ b/mslib/mscolab/seed.py @@ -88,7 +88,7 @@ def add_all_users_default_operation(path='TEMPLATE', description="Operation to k return True except IntegrityError as err: db.session.rollback() - logging.debug(f"Error writing to db: {err}") + logging.debug("Error writing to db: %s", err) db.session.close() @@ -98,7 +98,7 @@ def delete_user(email): with app.app_context(): user = User.query.filter_by(emailid=str(email)).first() if user: - logging.info(f"User: {email} deleted from db") + logging.info("User: %s deleted from db", email) db.session.delete(user) db.session.commit() db.session.close() @@ -126,11 +126,11 @@ def add_user(email, username, password): db.session.add(db_user) db.session.commit() db.session.close() - logging.info(f"Userdata: {email} {username} {password}") + logging.info("Userdata: %s %s %s", email, username, password) logging.info(template) return True else: - logging.info(f"{user_name_exists} already in db") + logging.info("%s already in db", user_name_exists) return False @@ -199,7 +199,7 @@ def add_user_to_operation(path=None, access_level='admin', emailid=None): return True except IntegrityError as err: db.session.rollback() - logging.debug(f"Error writing to db: {err}") + logging.debug("Error writing to db: %s", err) db.session.close() return False diff --git a/mslib/mscolab/sockets_manager.py b/mslib/mscolab/sockets_manager.py index 4ce4a6d47..12239ed00 100644 --- a/mslib/mscolab/sockets_manager.py +++ b/mslib/mscolab/sockets_manager.py @@ -226,7 +226,7 @@ def handle_file_save(self, json_req): # emit file-changed event to trigger reload of flight track socketio.emit('file-changed', json.dumps({"op_id": op_id, "u_id": user.id})) else: - logging.debug(f'login expired for {user.username}, state unauthorized!') + logging.debug("login expired for %s, state unauthorized!", user.username) def emit_file_change(self, op_id): socketio.emit('file-changed', json.dumps({"op_id": op_id})) diff --git a/mslib/mscolab/utils.py b/mslib/mscolab/utils.py index 44b03deda..094cb7125 100644 --- a/mslib/mscolab/utils.py +++ b/mslib/mscolab/utils.py @@ -64,9 +64,9 @@ def os_fs_create_dir(dir): try: _ = fs.open_fs(dir) except fs.errors.CreateFailed: - logging.error(f'Make sure that the FS url "{dir}" exists') + logging.error('Make sure that the FS url "%s" exists', dir) except fs.opener.errors.UnsupportedProtocol: - logging.error(f'FS url "{dir}" not supported') + logging.error('FS url "%s" not supported', dir) else: _dir = os.path.expanduser(dir) if not os.path.exists(_dir): diff --git a/mslib/msui/constants.py b/mslib/msui/constants.py index b2715dd1e..97eb24bbf 100644 --- a/mslib/msui/constants.py +++ b/mslib/msui/constants.py @@ -40,7 +40,7 @@ except fs.errors.CreateFailed: _fs.makedirs(MSUI_CONFIG_PATH) except fs.opener.errors.UnsupportedProtocol: - logging.error(f'FS url "{MSUI_CONFIG_PATH}" not supported') + logging.error('FS url "%s" not supported', MSUI_CONFIG_PATH) else: _dir = os.path.expanduser(MSUI_CONFIG_PATH) if not os.path.exists(_dir): @@ -60,14 +60,14 @@ with _fs.open(file_name, 'w') as fid: fid.write("{}") except fs.errors.CreateFailed: - logging.error(f'"{MSUI_SETTINGS}" can''t be created') + logging.error('"%s" can''t be created', MSUI_SETTINGS) else: if not os.path.exists(MSUI_SETTINGS): try: with open(MSUI_SETTINGS, 'w') as fid: fid.write("{}") except IOError: - logging.error(f'"{MSUI_SETTINGS}" can''t be created') + logging.error('"%s" can''t be created', MSUI_SETTINGS) # ToDo refactor to a function MSS_AUTOPLOT = os.getenv('MSS_AUTOPLOT', os.path.join(MSUI_CONFIG_PATH, "mssautoplot.json")) @@ -82,14 +82,14 @@ with _fs.open(file_name, 'w') as fid: fid.write("{}") except fs.errors.CreateFailed: - logging.error(f'"{MSS_AUTOPLOT}" can''t be created') + logging.error('"%s" can''t be created', MSS_AUTOPLOT) else: if not os.path.exists(MSS_AUTOPLOT): try: with open(MSS_AUTOPLOT, 'w') as fid: fid.write("{}") except IOError: - logging.error(f'"{MSS_AUTOPLOT}" can''t be created') + logging.error('"%s" can''t be created', MSS_AUTOPLOT) WMS_LOGIN_CACHE = {} MSC_LOGIN_CACHE = {} diff --git a/mslib/msui/editor.py b/mslib/msui/editor.py index 9585452ee..195a30ab0 100644 --- a/mslib/msui/editor.py +++ b/mslib/msui/editor.py @@ -400,7 +400,7 @@ def add_option_handler(self): self.view.scrollTo(proxy_index) self.view.selectionModel().select( proxy_index, QtCore.QItemSelectionModel.ClearAndSelect | QtCore.QItemSelectionModel.Rows) - logging.debug(f"Added new value for {option}") + logging.debug("Added new value for %s", option) self.update_view() break @@ -442,7 +442,7 @@ def remove_option_handler(self): # ToDo add confirmation dialog here options = "\n".join([index.data() for index in removable_indexes]) - logging.debug(f"Attempting to remove the following options\n{options}") + logging.debug("Attempting to remove the following options\n%s", options) self.view.selectionModel().clearSelection() for index in removable_indexes: @@ -499,7 +499,7 @@ def update(data, option, value): # ToDo add confirmation dialog here options = "\n".join([index.data() for index in selected_indexes]) - logging.debug(f"Attempting to restore defaults for the following options\n{options}") + logging.debug("Attempting to restore defaults for the following options\n%s", options) for index in selected_indexes: # check if root option and present in mss_default.key_value_options @@ -557,11 +557,11 @@ def import_config(self): json_file_data = json.loads(file_content, object_pairs_hook=dict_raise_on_duplicates_empty) except json.JSONDecodeError as e: show_popup(self, "Error while loading file", e) - logging.error(f"Error while loading json file {e}") + logging.error("Error while loading json file %s", e) return except ValueError as e: show_popup(self, "Invalid keys detected", e) - logging.error(f"Error while loading json file {e}") + logging.error("Error while loading json file %s", e) return if json_file_data: @@ -679,7 +679,7 @@ def save_config(self): QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, QtWidgets.QMessageBox.No) if ret == QtWidgets.QMessageBox.Yes: - logging.debug(f"saving config file to: {self.path} and restarting MSS") + logging.debug("saving config file to: %s and restarting MSS", self.path) self._save_to_path(self.path) self.restartApplication.emit() self.restart_on_save = False @@ -687,7 +687,7 @@ def save_config(self): else: return self.restart_on_save = True - logging.debug(f"saving config file to: {self.path}") + logging.debug("saving config file to: %s", self.path) self._save_to_path(self.path) else: self.statusbar.showMessage("No values changed") diff --git a/mslib/msui/mpl_qtwidget.py b/mslib/msui/mpl_qtwidget.py index 970a2689a..7d2f284b5 100644 --- a/mslib/msui/mpl_qtwidget.py +++ b/mslib/msui/mpl_qtwidget.py @@ -506,7 +506,7 @@ def draw_vertical_lines(self, highlight, lats, lons): try: self.ax.lines.remove(line) except ValueError as e: - logging.debug(f"Vertical line was somehow already removed:\n{e}") + logging.debug("Vertical line was somehow already removed:\n%s", e) self.vertical_lines.remove(line) # Add vertical lines @@ -655,7 +655,7 @@ def redraw_xaxis(self, lats, lons): try: self.ax.lines.remove(line) except ValueError as e: - logging.debug(f"Vertical line was somehow already removed:\n{e}") + logging.debug("Vertical line was somehow already removed:\n%s", e) self.vertical_lines = [] def draw_vertical_lines(self, highlight, lats, lons): diff --git a/mslib/msui/mscolab.py b/mslib/msui/mscolab.py index 0fc615086..b9e3686b4 100644 --- a/mslib/msui/mscolab.py +++ b/mslib/msui/mscolab.py @@ -363,7 +363,7 @@ def new_user_handler(self): try: error_msg = json.loads(r.text)["message"] except Exception as e: - logging.debug(f"Unexpected error occured {e}") + logging.debug("Unexpected error occured %s", e) error_msg = "Unexpected error occured. Please try again." self.set_status("Error", error_msg) @@ -392,7 +392,7 @@ def newuser_server_auth(self): try: error_msg = json.loads(r.text)["message"] except Exception as e: - logging.debug(f"Unexpected error occured {e}") + logging.debug("Unexpected error occured %s", e) error_msg = "Unexpected error occured. Please try again." self.set_status("Error", error_msg) elif r.status_code == 204: @@ -525,11 +525,11 @@ def create_dir(self): try: _ = fs.open_fs(self.data_dir) except fs.errors.CreateFailed: - logging.error(f'Make sure that the FS url "{self.data_dir}" exists') + logging.error('Make sure that the FS url "%s" exists', self.data_dir) show_popup(self.ui, "Error", f'FS Url: "{self.data_dir}" does not exist!') sys.exit() except fs.opener.errors.UnsupportedProtocol: - logging.error(f'FS url "{self.data_dir}" not supported') + logging.error('FS url "%s" not supported', self.data_dir) show_popup(self.ui, "Error", f'FS Url: "{self.data_dir}" not supported!') sys.exit() else: @@ -573,7 +573,7 @@ def after_login(self, emailid, url, r): try: self.conn = sc.ConnectionManager(self.token, user=self.user, mscolab_server_url=self.mscolab_server_url) except Exception as ex: - logging.debug(f"Couldn't create a socket connection: {ex}") + logging.debug("Couldn't create a socket connection: %s", ex) show_popup(self.ui, "Error", "Couldn't create a socket connection. Maybe the mscolab server is too old." "New Login required!") self.logout() @@ -1384,7 +1384,7 @@ def delete_operation_from_list(self, op_id): remove_item = item break if remove_item is not None: - logging.debug(f"remove_item: {remove_item}") + logging.debug("remove_item: %s", remove_item) self.ui.listOperationsMSC.takeItem(self.ui.listOperationsMSC.row(remove_item)) return remove_item.operation_path diff --git a/mslib/msui/multilayers.py b/mslib/msui/multilayers.py index 0c4352c2d..7219ea9a7 100644 --- a/mslib/msui/multilayers.py +++ b/mslib/msui/multilayers.py @@ -619,7 +619,7 @@ def _parse_itimes(self): self.allowed_init_times = sorted(self.parent.dock_widget.parse_time_extent(values)) self.itimes = [_time.isoformat() + "Z" for _time in self.allowed_init_times] if len(self.allowed_init_times) == 0: - logging.error(f"Cannot determine init time format of {self.header.text(0)} for {self.text(0)}") + logging.error("Cannot determine init time format of %s for %s", self.header.text(0), self.text(0)) self.is_invalid = True else: self.itime = self.itimes[-1] @@ -638,7 +638,7 @@ def _parse_vtimes(self): self.allowed_valid_times = sorted(self.parent.dock_widget.parse_time_extent(values)) self.vtimes = [_time.isoformat() + "Z" for _time in self.allowed_valid_times] if len(self.allowed_valid_times) == 0: - logging.error(f"Cannot determine valid time format of {self.header.text(0)} for {self.text(0)}") + logging.error("Cannot determine valid time format of %s for %s", self.header.text(0), self.text(0)) self.is_invalid = True else: if self.itime: diff --git a/mslib/mswms/gallery_builder.py b/mslib/mswms/gallery_builder.py index cdd31c258..3c01fd88f 100644 --- a/mslib/mswms/gallery_builder.py +++ b/mslib/mswms/gallery_builder.py @@ -43,7 +43,7 @@ else: STATIC_LOCATION = os.path.join(os.path.dirname(os.path.abspath(mswms_settings.__file__)), "gallery") except ImportError as e: - logging.warning(f"{e}. Can't generate gallery.") + logging.warning("%s. Can't generate gallery.", e) DOCS_LOCATION = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "docs", "gallery") @@ -457,7 +457,7 @@ def write_html(path, sphinx=False, plot_types=None): with open(os.path.join(path, "plots.html"), "w+") as file: file.write(html + end) - logging.info(f"plots.html created at {os.path.join(path, 'plots.html')}") + logging.info("plots.html created at %s", os.path.join(path, 'plots.html')) def import_instructions(plot_object, l_type, layer, native_import=None, dataset=""): diff --git a/mslib/mswms/wms.py b/mslib/mswms/wms.py index fe4a4a6ac..2ef697f72 100644 --- a/mslib/mswms/wms.py +++ b/mslib/mswms/wms.py @@ -283,9 +283,10 @@ def generate_gallery(self, create=False, clear=False, generate_code=False, sphin for itime in sorted(init_times): if itime and plot_driver.get_init_times() and itime not in plot_driver.get_init_times(): - logging.warning(f"Requested itime {itime} not present for " - f"{dataset} {plot_object.name}! itimes present: " - f"{plot_driver.get_init_times()}") + logging.warning("Requested itime %s not present for " + "%s %s! itimes present: " + "%s", itime, dataset, plot_object.name, plot_driver.get_init_times() + ) continue elif not plot_driver.get_init_times(): itime = None @@ -309,8 +310,9 @@ def generate_gallery(self, create=False, clear=False, generate_code=False, sphin for vtime in sorted(valid_times): if vtime and i_vtimes and vtime not in i_vtimes: - logging.warning(f"Requested vtime {vtime} at {itime} not present for " - f"{dataset} {plot_object.name}! vtimes present: {i_vtimes}") + logging.warning("Requested vtime %s at %s not present for " + "%s %s! vtimes present: %s", vtime, itime, dataset, + plot_object.name, i_vtimes) continue elif not i_vtimes: vtime = None @@ -372,9 +374,9 @@ def generate_gallery(self, create=False, clear=False, generate_code=False, sphin for level in sorted(rendered_levels): if level and elevations and level \ not in [float(elev) for elev in elevations]: - logging.warning(f"Requested level {level} not present for " - f"{dataset} {plot_object.name}! Levels present: " - f"{elevations}") + logging.warning("Requested level %s not present for " + "%s %s! Levels present: " + "%s", level, dataset, plot_object.name, elevations) continue elif not elevations: level = None diff --git a/mslib/utils/airdata.py b/mslib/utils/airdata.py index 033b5e9db..8043fc1a5 100644 --- a/mslib/utils/airdata.py +++ b/mslib/utils/airdata.py @@ -60,13 +60,13 @@ ] -def download_progress(file_path, url, progress_callback=lambda f: logging.info(f"{int(f)}KB Downloaded")): +def download_progress(file_path, url, progress_callback=lambda f: logging.info("%sKB Downloaded", int(f))): """ Downloads the file at the given url to file_path and keeps track of the progress """ try: with open(file_path, "wb+") as file: - logging.info(f"Downloading to {file_path}. This might take a while.") + logging.info("Downloading to %s. This might take a while.", file_path) response = requests.get(url, stream=True, timeout=5) length = response.headers.get("content-length") if length is None: # no content length header diff --git a/mslib/utils/config.py b/mslib/utils/config.py index 694b8964a..db1fb530b 100644 --- a/mslib/utils/config.py +++ b/mslib/utils/config.py @@ -376,11 +376,11 @@ def read_config_file(path=constants.MSUI_SETTINGS): try: json_file_data = json.loads(file_content, object_pairs_hook=dict_raise_on_duplicates_empty) except json.JSONDecodeError as e: - logging.error(f"Error while loading json file {e}") + logging.error("Error while loading json file %s", e) error_message = f"Unexpected error while loading config\n{e}" raise FatalUserError(error_message) except ValueError as e: - logging.error(f"Error while loading json file {e}") + logging.error("Error while loading json file %s", e) error_message = f"Invalid keys detected in config\n{e}" raise FatalUserError(error_message) else: @@ -424,11 +424,11 @@ def modify_config_file(data, path=constants.MSUI_SETTINGS): _fs.writetext(file_name, json.dumps(modified_data, indent=4)) read_config_file() except json.JSONDecodeError as e: - logging.error(f"Error while loading json file {e}") + logging.error("Error while loading json file %s", e) error_message = f"Unexpected error while loading config\n{e}" raise FatalUserError(error_message) except ValueError as e: - logging.error(f"Error while loading json file {e}") + logging.error("Error while loading json file %s", e) error_message = f"Invalid keys detected in config\n{e}" raise FatalUserError(error_message) else: