diff --git a/cozy/architecture/observable.py b/cozy/architecture/observable.py index 5aa6e833..9380d4f7 100644 --- a/cozy/architecture/observable.py +++ b/cozy/architecture/observable.py @@ -33,7 +33,7 @@ def remove_bind(self, prop: str, callback: Callable): if callback in self._observers[prop]: self._observers[prop].remove(callback) else: - log.info("Callback not found in prop's {} observers. Skipping remove bind...".format(prop)) + log.info("Callback not found in prop's %s observers. Skipping remove bind...", prop) else: log.info("Prop not found in observers. Skipping remove bind...") diff --git a/cozy/control/artwork_cache.py b/cozy/control/artwork_cache.py index 462e7ddd..e2bbdf23 100644 --- a/cozy/control/artwork_cache.py +++ b/cozy/control/artwork_cache.py @@ -129,7 +129,7 @@ def _load_pixbuf_from_cache(self, book, size): else: pixbuf = None except Exception as e: - log.warning("Failed to load pixbuf from path: {}. Deleting file.".format(path)) + log.warning("Failed to load pixbuf from path: %s. Deleting file.", path) log.debug(e) os.remove(path) return None diff --git a/cozy/control/db.py b/cozy/control/db.py index 935c7168..247dc618 100644 --- a/cozy/control/db.py +++ b/cozy/control/db.py @@ -25,7 +25,7 @@ def init_db(): _connect_db(_db) sqlite_version = ".".join([str(num) for num in _db.server_version]) - log.info("SQLite version: {}".format(sqlite_version)) + log.info("SQLite version: %s", sqlite_version) if Settings.table_exists(): update_db() diff --git a/cozy/control/db_updater.py b/cozy/control/db_updater.py index bd973110..ec66d02c 100644 --- a/cozy/control/db_updater.py +++ b/cozy/control/db_updater.py @@ -136,7 +136,7 @@ def _update_db_9(db): file = next((f for f in files if f.path == path), None) if File.select().where(File.path == path).count() > 0: - log.info("Path already existing in db: {}".format(path)) + log.info("Path already existing in db: %s", path) file = File.select().where(File.path == path).get() elif not file: file = File(path=path, modified=track.modified, id=file_id) @@ -144,7 +144,7 @@ def _update_db_9(db): file_id += 1 if TrackToFile.select().join(Track).where(TrackToFile.track.id == track.id).count() > 0: - log.info("TrackToFile already existing in db: {}".format(path)) + log.info("TrackToFile already existing in db: %s", path) continue track_to_file = TrackToFile(track=track.id, file=file, start_at=0) diff --git a/cozy/control/filesystem_monitor.py b/cozy/control/filesystem_monitor.py index bc826f9c..cfdf7a1f 100644 --- a/cozy/control/filesystem_monitor.py +++ b/cozy/control/filesystem_monitor.py @@ -100,10 +100,10 @@ def is_external(self, directory: str) -> bool: return False if path in directory and mount.can_unmount(): - log.info("Storage location {} is external".format(directory)) + log.info("Storage location %s is external", directory) return True - log.info("Storage location {} is not external".format(directory)) + log.info("Storage location %s is not external", directory) return False def __on_mount_added(self, monitor, mount): diff --git a/cozy/control/mpris.py b/cozy/control/mpris.py index 42e0746d..28cce9d3 100644 --- a/cozy/control/mpris.py +++ b/cozy/control/mpris.py @@ -106,17 +106,17 @@ def on_method_call( result = getattr(self, snake_method)(*args) except AttributeError: invocation.return_dbus_error( - "{}.Error.NotSupported".format(interface_name), "Unsupported property" + f"{interface_name}.Error.NotSupported", "Unsupported property" ) except Exception as e: log.error(e) reporter.exception("mpris", e) reporter.error( "mpris", - "MPRIS method call failed with method name: {}".format(method_name), + f"MPRIS method call failed with method name: {method_name}", ) invocation.return_dbus_error( - "{}.Error.Failed".format(interface_name), "Internal exception occurred" + f"{interface_name}.Error.Failed", "Internal exception occurred" ) else: # out_args is at least (signature1). @@ -409,3 +409,4 @@ def _on_current_changed(self) -> None: def _on_status_changed(self, status: str) -> None: properties = {"PlaybackStatus": GLib.Variant("s", status)} self.properties_changed(self.MEDIA_PLAYER2_PLAYER_INTERFACE, properties, []) + diff --git a/cozy/media/files.py b/cozy/media/files.py index f31efb69..c4d9092a 100644 --- a/cozy/media/files.py +++ b/cozy/media/files.py @@ -52,7 +52,7 @@ def _copy_all(self, sources, destination: str): self._copy_file(path, file_copy_destination) def _copy_file(self, source_path: str, dest_path: str): - log.info("Copy file {} to {}".format(source_path, dest_path)) + log.info("Copy file %s to %s", source_path, dest_path) source = Gio.File.new_for_path(source_path) destination = Gio.File.new_for_path(dest_path) @@ -72,7 +72,7 @@ def _copy_file(self, source_path: str, dest_path: str): else: reporter.exception("files", e) - log.error("Failed to copy file: {}".format(e)) + log.error("Failed to copy file: %s", e) self._file_progess += 1 def _copy_directory(self, path, destination): diff --git a/cozy/media/gst_player.py b/cozy/media/gst_player.py index 27396c40..75083a1a 100644 --- a/cozy/media/gst_player.py +++ b/cozy/media/gst_player.py @@ -94,12 +94,13 @@ def state(self) -> GstPlayerState: return GstPlayerState.STOPPED _, state, __ = self._player.get_state(Gst.CLOCK_TIME_NONE) + print(type(state)) if state == Gst.State.PLAYING: return GstPlayerState.PLAYING elif state == Gst.State.PAUSED: return GstPlayerState.PAUSED else: - log.debug("GST player state was not playing or paused but {}.".format(state)) + log.debug("GST player state was not playing or paused but %s", state) return GstPlayerState.STOPPED @property @@ -268,7 +269,7 @@ def _on_gst_message(self, _, message: Gst.Message): reporter.warning("gst_player", "gst: Resource not found. Stopping player.") return - reporter.error("player", "{}: {}".format(error.code, error)) - log.error("{}: {}".format(error.code, error)) + reporter.error("player", f"{error.code}: {error}") + log.error(f"{error.code}: {error}") log.debug(debug_msg) self.emit_event("error", error) diff --git a/cozy/media/importer.py b/cozy/media/importer.py index d5429372..884c55e6 100644 --- a/cozy/media/importer.py +++ b/cozy/media/importer.py @@ -198,7 +198,7 @@ def _filter_unchanged_files(self, files: List[str]) -> List[str]: yield file except Exception as e: log.debug(e) - log.info("Could not get modified timestamp for file {}".format(file)) + log.info("Could not get modified timestamp for file %s", file) continue continue diff --git a/cozy/media/media_detector.py b/cozy/media/media_detector.py index c5f3fb19..cfb1a6d4 100644 --- a/cozy/media/media_detector.py +++ b/cozy/media/media_detector.py @@ -34,7 +34,7 @@ def get_media_data(self) -> MediaFile: try: discoverer_info: GstPbutils.DiscovererInfo = self.discoverer.discover_uri(self.uri) except Exception as e: - log.info("Skipping file because it couldn't be detected: {}".format(self.uri)) + log.info("Skipping file because it couldn't be detected: %s", self.uri) raise AudioFileCouldNotBeDiscovered(self.uri) is_valid_audio_file = self._is_valid_audio_file(discoverer_info) diff --git a/cozy/media/player.py b/cozy/media/player.py index e018a4b0..472c5563 100644 --- a/cozy/media/player.py +++ b/cozy/media/player.py @@ -380,7 +380,7 @@ def _emit_tick(self): position_for_ui = self.position - self.loaded_chapter.start_position self.emit_event_main_thread("position", position_for_ui) except Exception as e: - log.warning("Could not emit position event: {}".format(e)) + log.warning("Could not emit position event: %s", e) def _fadeout_playback(self): duration = self._app_settings.sleep_timer_fadeout_duration * 20 diff --git a/cozy/model/book.py b/cozy/model/book.py index 9e4d5bc2..a5b62775 100644 --- a/cozy/model/book.py +++ b/cozy/model/book.py @@ -216,7 +216,7 @@ def _fetch_chapters(self): except TrackInconsistentData: log.warning("Skipping inconsistent model") except Exception as e: - log.error("Could not create chapter object: {}".format(e)) + log.error("Could not create chapter object: %s", e) for chapter in self._chapters: chapter.add_listener(self._on_chapter_event) diff --git a/cozy/model/database_importer.py b/cozy/model/database_importer.py index 8629b14d..29aa10d8 100644 --- a/cozy/model/database_importer.py +++ b/cozy/model/database_importer.py @@ -81,7 +81,7 @@ def _prepare_track_db_objects(self, media_files: Set[MediaFile]) -> Set[TrackIns book = next((book for book in book_db_objects if is_same_book(book.name, media_file.book_name)), None) file_query = File.select().where(File.path == media_file.path) if not file_query.exists(): - log.error("No file object with path present: {}".format(media_file.path)) + log.error("No file object with path present: %s", media_file.path) continue file = file_query.get() diff --git a/cozy/model/track.py b/cozy/model/track.py index 971be6b0..983fccbe 100644 --- a/cozy/model/track.py +++ b/cozy/model/track.py @@ -35,7 +35,7 @@ def name(self): if self._db_object.name: return self._db_object.name - return "{} {}".format(_("Chapter"), self.number) + return f"{_('Chapter')} {self.number}" @name.setter def name(self, new_name: str): diff --git a/cozy/report/report_to_loki.py b/cozy/report/report_to_loki.py index 6b779065..6720a100 100644 --- a/cozy/report/report_to_loki.py +++ b/cozy/report/report_to_loki.py @@ -61,7 +61,7 @@ def report(component: str, type: LogLevel, message: str, exception: Exception): labels = __append_label(labels, "distro_version", distro.version()) labels = __append_label(labels, "desktop_environment", os.environ.get('DESKTOP_SESSION')) - line = "[{}] {}".format(LOG_LEVEL_MAP[type], message) + line = f"[{LOG_LEVEL_MAP[type]}] {message}" headers = { 'Content-type': 'application/json' diff --git a/cozy/view_model/library_view_model.py b/cozy/view_model/library_view_model.py index 71079633..05eb56b2 100644 --- a/cozy/view_model/library_view_model.py +++ b/cozy/view_model/library_view_model.py @@ -240,11 +240,11 @@ def delete_book_files(self, book: Book): try: os.remove(chapter.file) except Exception as e: - log.error("Failed to delete file: {}".format(chapter.file)) + log.error("Failed to delete file: %s", chapter.file) log.debug(e) reporter.warning("library_view_model", "Failed to delete a file.") else: - log.info("Deleted file: {}".format(chapter.file)) + log.info("Deleted file: %s", chapter.file) def play_book(self, book: Book): self._player.play_pause_book(book) diff --git a/cozy/view_model/settings_view_model.py b/cozy/view_model/settings_view_model.py index 28251f8a..716aa524 100644 --- a/cozy/view_model/settings_view_model.py +++ b/cozy/view_model/settings_view_model.py @@ -62,7 +62,7 @@ def add_storage_location(self): def remove_storage_location(self, model: Storage): if model.default: - log.error("deleting the default storage location {} is not possible".format(model.path)) + log.error("deleting the default storage location %s is not possible", model.path) reporter.error("settings_view_model", "deleting the default storage location is not possible") return