[pitivi] Optimize some log statements and prettify others



commit 551358819beda5df6d15c29c47f42294457a3a9a
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Fri Dec 13 21:38:52 2013 +0100

    Optimize some log statements and prettify others

 pitivi/dialogs/filelisterrordialog.py |    2 +-
 pitivi/mainwindow.py                  |    2 +-
 pitivi/medialibrary.py                |    8 ++++----
 pitivi/project.py                     |   14 +++++++-------
 pitivi/render.py                      |    2 +-
 pitivi/timeline/previewers.py         |   12 ++++++------
 pitivi/timeline/timeline.py           |    8 ++++----
 pitivi/titleeditor.py                 |    2 +-
 pitivi/transitions.py                 |    6 +++---
 pitivi/utils/loggable.py              |    2 +-
 pitivi/utils/pipeline.py              |   30 ++++++++++++++++--------------
 pitivi/utils/widgets.py               |    6 +++---
 pitivi/viewer.py                      |    4 ++--
 13 files changed, 50 insertions(+), 48 deletions(-)
---
diff --git a/pitivi/dialogs/filelisterrordialog.py b/pitivi/dialogs/filelisterrordialog.py
index 3d9c833..ca529c8 100644
--- a/pitivi/dialogs/filelisterrordialog.py
+++ b/pitivi/dialogs/filelisterrordialog.py
@@ -60,7 +60,7 @@ class FileListErrorDialog(Signallable, Loggable):
         give a string identifying the reason why the file failed to be
         discovered
         """
-        self.debug("Uri:%s, reason:%s, extra:%s", uri, reason, extra)
+        self.debug("Uri: %s, reason: %s, extra: %s", uri, reason, extra)
         exp = self._createFileExpander(uri, reason, extra)
         self.errorvbox.pack_start(exp, False, False, 0)
         if len(self.errorvbox.get_children()) < 3:
diff --git a/pitivi/mainwindow.py b/pitivi/mainwindow.py
index ae99f92..756dac1 100644
--- a/pitivi/mainwindow.py
+++ b/pitivi/mainwindow.py
@@ -1034,7 +1034,7 @@ class PitiviMainWindow(Gtk.Window, Loggable):
         thumb_dir = os.path.expanduser("~/.thumbnails/normal/")
         thumb_path_normal = thumb_dir + thumbnail_hash + ".png"
         if os.path.exists(thumb_path_normal):
-            self.debug("A thumbnail file was found for %s" % uri)
+            self.debug("A thumbnail file was found for %s", uri)
             thumbnail = Gtk.Image.new_from_file(thumb_path_normal)
             thumbnail.set_padding(0, SPACING)
             hbox.pack_start(thumbnail, False, False, 0)
diff --git a/pitivi/medialibrary.py b/pitivi/medialibrary.py
index c40648d..b16e61d 100644
--- a/pitivi/medialibrary.py
+++ b/pitivi/medialibrary.py
@@ -615,7 +615,7 @@ class MediaLibraryWidget(Gtk.VBox, Loggable):
                 break
         if not len(model):
             self._welcome_infobar.show_all()
-        self.debug("Removing %s", uri)
+        self.debug("Removing: %s", uri)
 
     def _errorCreatingAssetCb(self, unsued_project, error, id, type):
         """ The given uri isn't a media file """
@@ -630,7 +630,7 @@ class MediaLibraryWidget(Gtk.VBox, Loggable):
         self._progressbar.show()
 
     def _sourcesStoppedImportingCb(self, unsued_project):
-        self.debug("Importing took %.3f seconds" % (time.time() - self.import_start_time))
+        self.debug("Importing took %.3f seconds", time.time() - self.import_start_time)
         self.flush_pending_rows()
         self._progressbar.hide()
         if self._errors:
@@ -659,7 +659,7 @@ class MediaLibraryWidget(Gtk.VBox, Loggable):
     ## Import Sources Dialog Box callbacks
 
     def _dialogBoxResponseCb(self, dialogbox, response):
-        self.debug("response:%r", response)
+        self.debug("response: %r", response)
         if response == Gtk.ResponseType.OK:
             lastfolder = dialogbox.get_current_folder()
             self.app.settings.lastImportFolder = lastfolder
@@ -959,7 +959,7 @@ class MediaLibraryWidget(Gtk.VBox, Loggable):
     ## Drag and Drop
     def _dndDataReceivedCb(self, unused_widget, unused_context, unused_x,
                            unused_y, selection, targettype, unused_time):
-        self.debug("targettype:%d, selection.data:%r", targettype, selection.get_data())
+        self.debug("targettype: %d, selection.data: %r", targettype, selection.get_data())
 
         directories = []
         filenames = []
diff --git a/pitivi/project.py b/pitivi/project.py
index 5942d9e..9735ee5 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -145,16 +145,16 @@ class ProjectManager(Signallable, Loggable):
         use_backup = False
         try:
             time_diff = os.path.getmtime(backup_path) - os.path.getmtime(path)
-            self.debug('Backup file "%s" is %d secs newer' % (backup_path, time_diff))
+            self.debug('Backup file is %d secs newer: %s', time_diff, backup_path)
         except OSError:
-            self.debug('Backup file "%s" does not exist' % backup_path)
+            self.debug('Backup file does not exist: %s', backup_path)
         else:
             if time_diff > 0:
                 use_backup = self._restoreFromBackupDialog(time_diff)
 
         if use_backup:
             uri = self._makeBackupURI(uri)
-            self.debug('Loading project from backup "%s"' % uri)
+            self.debug('Loading project from backup: %s', uri)
 
         # Load the project:
         self.current_project = Project(uri=uri)
@@ -292,14 +292,14 @@ class ProjectManager(Signallable, Loggable):
                 # Do not emit the signal when autosaving a backup file
                 self.current_project.setModificationState(False)
                 self.emit("project-saved", self.current_project, uri)
-                self.debug('Saved project "%s"' % uri)
+                self.debug('Saved project: %s', uri)
                 # Update the project instance's uri,
                 # otherwise, subsequent saves will be to the old uri.
-                self.info("Setting the project instance's URI to %s" % uri)
+                self.info("Setting the project instance's URI to: %s", uri)
                 self.current_project.uri = uri
                 self.disable_save = False
             else:
-                self.debug('Saved backup "%s"' % uri)
+                self.debug('Saved backup: %s', uri)
 
         return saved
 
@@ -478,7 +478,7 @@ class ProjectManager(Signallable, Loggable):
         path = path_from_uri(self._makeBackupURI(uri))
         if os.path.exists(path):
             os.remove(path)
-            self.debug('Removed backup file "%s"' % path)
+            self.debug('Removed backup file: %s', path)
 
     def _makeBackupURI(self, uri):
         """
diff --git a/pitivi/render.py b/pitivi/render.py
index dd1164a..63d28e0 100644
--- a/pitivi/render.py
+++ b/pitivi/render.py
@@ -844,7 +844,7 @@ class RenderDialog(Loggable):
             self._last_timestamp_when_pausing = time.time()
         else:
             self._time_spent_paused += time.time() - self._last_timestamp_when_pausing
-            self.debug("Resuming render after %d seconds in pause" % self._time_spent_paused)
+            self.debug("Resuming render after %d seconds in pause", self._time_spent_paused)
         self.app.current_project.pipeline.togglePlayback()
 
     def _destroyProgressWindow(self):
diff --git a/pitivi/timeline/previewers.py b/pitivi/timeline/previewers.py
index c882c84..1789c88 100644
--- a/pitivi/timeline/previewers.py
+++ b/pitivi/timeline/previewers.py
@@ -259,14 +259,14 @@ class VideoPreviewer(Clutter.ScrollActor, PreviewGenerator, Zoomable, Loggable):
         self._thumb_cb_id = GLib.timeout_add(self.interval, self._create_next_thumb)
 
     def _startThumbnailingWhenIdle(self):
-        self.debug('Waiting for UI to become idle for "%s"' % filename_from_uri(self.uri))
+        self.debug('Waiting for UI to become idle for: %s', filename_from_uri(self.uri))
         GLib.idle_add(self._startThumbnailing, priority=GLib.PRIORITY_LOW)
 
     def _startThumbnailing(self):
-        self.debug('Now generating thumbnails for "%s"' % filename_from_uri(self.uri))
+        self.debug('Now generating thumbnails for: %s', filename_from_uri(self.uri))
         query_success, duration = self.pipeline.query_duration(Gst.Format.TIME)
         if not query_success or duration == -1:
-            self.debug("Could not determine duration of %s" % self.uri)
+            self.debug("Could not determine duration of: %s", self.uri)
             duration = self.duration
         else:
             self.duration = duration
@@ -616,7 +616,7 @@ class ThumbnailCache(Loggable):
         self._cur.execute("INSERT INTO Thumbs VALUES (?,?)", (key, blob,))
 
     def commit(self):
-        self.debug('Saving thumbnail cache file to disk for "%s"' % self._filename)
+        self.debug('Saving thumbnail cache file to disk for: %s', self._filename)
         self._db.commit()
         self.log("Saved thumbnail cache file: %s" % self._filehash)
 
@@ -748,7 +748,7 @@ class AudioPreviewer(Clutter.Actor, PreviewGenerator, Zoomable, Loggable):
         self._callback_id = 0
 
     def startLevelsDiscoveryWhenIdle(self):
-        self.debug('Waiting for UI to become idle for "%s"' % filename_from_uri(self._uri))
+        self.debug('Waiting for UI to become idle for: %s', filename_from_uri(self._uri))
         GLib.idle_add(self._startLevelsDiscovery, priority=GLib.PRIORITY_LOW)
 
     def _startLevelsDiscovery(self):
@@ -765,7 +765,7 @@ class AudioPreviewer(Clutter.Actor, PreviewGenerator, Zoomable, Loggable):
             self._launchPipeline()
 
     def _launchPipeline(self):
-        self.debug('Now generating waveforms for "%s"' % filename_from_uri(self._uri))
+        self.debug('Now generating waveforms for: %s', filename_from_uri(self._uri))
         self.peaks = None
         self.pipeline = Gst.parse_launch("uridecodebin name=decode uri=" + self._uri + " ! audioconvert ! 
level name=wavelevel interval=10000000 post-messages=true ! fakesink qos=false name=faked")
         faked = self.pipeline.get_by_name("faked")
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 2554755..16df105 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -863,11 +863,11 @@ class Timeline(Gtk.VBox, Zoomable, Loggable):
         This sets the sensitivity of all actiongroups that might interfere.
         """
         self.playhead_actions.set_sensitive(sensitive)
-        self.debug("Playback shortcuts sensitivity set to %s" % sensitive)
+        self.debug("Playback shortcuts sensitivity set to %s", sensitive)
         selected = self.timeline.selection.getSelectedTrackElements()
         if not sensitive or (sensitive and selected):
             self.selection_actions.set_sensitive(sensitive)
-            self.debug("Editing shortcuts sensitivity set to %s" % sensitive)
+            self.debug("Editing shortcuts sensitivity set to %s", sensitive)
 
     # Internal API
 
@@ -1073,7 +1073,7 @@ class Timeline(Gtk.VBox, Zoomable, Loggable):
 
         timeline_duration = duration + Gst.SECOND - 1
         timeline_duration_s = int(timeline_duration / Gst.SECOND)
-        self.debug("Adjusting zoom to a timeline duration of %s secs" % duration)
+        self.debug("Adjusting zoom to a timeline duration of %s secs", duration)
 
         ideal_zoom_ratio = float(ruler_width) / timeline_duration_s
         nearest_zoom_level = Zoomable.computeZoomLevel(ideal_zoom_ratio)
@@ -1126,7 +1126,7 @@ class Timeline(Gtk.VBox, Zoomable, Loggable):
         try:
             new_pos = Zoomable.nsToPixel(self.app.current_project.pipeline.getPosition())
         except PipelineError, e:
-            self.info("Pipeline error: %s" % e)
+            self.info("Pipeline error: %s", e)
             return
         except AttributeError:  # Standalone, no pipeline.
             return
diff --git a/pitivi/titleeditor.py b/pitivi/titleeditor.py
index 0cbb521..063bd36 100644
--- a/pitivi/titleeditor.py
+++ b/pitivi/titleeditor.py
@@ -775,7 +775,7 @@ class TitleEditor(Loggable):
         This can be called either from the title editor in _createCb, or by
         track.py to set the source to None.
         """
-        self.debug("Source set to %s", str(source))
+        self.debug("Source set to %s", source)
         self.source = source
         self._reset()
         self.created = created
diff --git a/pitivi/transitions.py b/pitivi/transitions.py
index 3435452..437e4cb 100644
--- a/pitivi/transitions.py
+++ b/pitivi/transitions.py
@@ -151,7 +151,7 @@ class TransitionsListWidget(Signallable, Gtk.VBox, Loggable):
             # The user clicked between icons
             return False
 
-        self.debug("New transition type selected: %s" % transition_asset.get_id())
+        self.debug("New transition type selected: %s", transition_asset.get_id())
         if transition_asset.get_id() == "crossfade":
             self.props_widgets.set_sensitive(False)
         else:
@@ -164,13 +164,13 @@ class TransitionsListWidget(Signallable, Gtk.VBox, Loggable):
 
     def _borderScaleCb(self, range_changed):
         value = range_changed.get_value()
-        self.debug("User changed the border property to %s" % value)
+        self.debug("User changed the border property to %s", value)
         self.element.set_border(int(value))
         self.app.current_project.seeker.flush(True)
 
     def _invertCheckboxCb(self, widget):
         value = widget.get_active()
-        self.debug("User changed the invert property to %s" % value)
+        self.debug("User changed the invert property to %s", value)
         self.element.set_inverted(value)
         self.app.current_project.seeker.flush()
 
diff --git a/pitivi/utils/loggable.py b/pitivi/utils/loggable.py
index 00716c0..27020ea 100644
--- a/pitivi/utils/loggable.py
+++ b/pitivi/utils/loggable.py
@@ -1160,7 +1160,7 @@ class TwistedLogObserver(BaseLoggable):
                 for failureType in self._ignoreErrors:
                     r = f.check(failureType)
                     if r:
-                        self.debug("Failure of type %r, ignoring" % failureType)
+                        self.debug("Failure of type %r, ignoring", failureType)
                         return
 
                 self.log("Failure %r" % f)
diff --git a/pitivi/utils/pipeline.py b/pitivi/utils/pipeline.py
index ee6f06f..d5c0089 100644
--- a/pitivi/utils/pipeline.py
+++ b/pitivi/utils/pipeline.py
@@ -208,7 +208,7 @@ class SimplePipeline(Signallable, Loggable):
         @raises PipelineError: If the C{Gst.Pipeline} could not be changed to
         the requested state.
         """
-        self.debug("state:%r" % state)
+        self.debug("state set to: %r", state)
         res = self._pipeline.set_state(state)
         if res == Gst.StateChangeReturn.FAILURE:
             # reset to NULL
@@ -226,7 +226,7 @@ class SimplePipeline(Signallable, Loggable):
         @rtype: C{State}
         """
         change, state, pending = self._pipeline.get_state(0)
-        self.debug("change:%r, state:%r, pending:%r" % (change, state, pending))
+        self.debug("change: %r, state: %r, pending: %r", change, state, pending)
         return state
 
     def play(self):
@@ -275,7 +275,7 @@ class SimplePipeline(Signallable, Loggable):
         @rtype: L{long}
         @raise PipelineError: If the position couldn't be obtained.
         """
-        self.log("format %r" % format)
+        self.log("format %r", format)
         try:
             res, cur = self._pipeline.query_position(format)
         except Exception, e:
@@ -285,20 +285,20 @@ class SimplePipeline(Signallable, Loggable):
         if not res:
             raise PipelineError("Couldn't get position")
 
-        self.log("Got position %s" % format_ns(cur))
+        self.log("Got position %s", format_ns(cur))
         return cur
 
     def getDuration(self, format=Gst.Format.TIME):
         """
         Get the duration of the C{Pipeline}.
         """
-        self.log("format %r" % format)
+        self.log("format %r", format)
 
         dur = self._getDuration(format)
         if dur is None:
             self.info("Invalid duration: None")
         else:
-            self.log("Got duration %s" % format_ns(dur))
+            self.log("Got duration %s", format_ns(dur))
         if self._duration != dur:
             self.emit("duration-changed", dur)
 
@@ -375,13 +375,13 @@ class SimplePipeline(Signallable, Loggable):
         """
         if self._waiting_for_async_done is True:
             self._next_seek = (position, format)
-            self.info("Setting next seek to %s" % (str(self._next_seek)))
+            self.info("Setting next seek to %s", self._next_seek)
             return
 
         if format == Gst.Format.TIME:
-            self.debug("position : %s" % format_ns(position))
+            self.debug("position: %s", format_ns(position))
         else:
-            self.debug("position : %d , format:%d" % (position, format))
+            self.debug("position: %d, format: %d", position, format)
 
         # clamp between [0, duration]
         if format == Gst.Format.TIME:
@@ -422,7 +422,7 @@ class SimplePipeline(Signallable, Loggable):
             prev, new, pending = message.parse_state_changed()
 
             if message.src == self._pipeline:
-                self.debug("Pipeline change state prev:%r, new:%r, pending:%r" % (prev, new, pending))
+                self.debug("Pipeline change state prev: %r, new: %r, pending: %r", prev, new, pending)
 
                 emit_state_change = pending == Gst.State.VOID_PENDING
                 if prev == Gst.State.READY and new == Gst.State.PAUSED:
@@ -463,7 +463,7 @@ class SimplePipeline(Signallable, Loggable):
                 GLib.source_remove(self._timeout_async_id)
                 self._timeout_async_id = 0
         else:
-            self.log("%s [%r]" % (message.type, message.src))
+            self.log("%s [%r]", message.type, message.src)
 
     def _recover(self):
         if self._attempted_recoveries > MAX_RECOVERIES:
@@ -571,9 +571,11 @@ class Pipeline(GES.Pipeline, SimplePipeline):
         cur_frame = int(round(position * framerate.num / float(Gst.SECOND * framerate.denom), 2))
         new_frame = cur_frame + frames_offset
         new_pos = long(new_frame * Gst.SECOND * framerate.denom / framerate.num)
-        Loggable.info(self, "From frame %d to %d at %f fps, seek to %s s" % (cur_frame,
-                    new_frame, framerate.num / framerate.denom,
-                    new_pos / float(Gst.SECOND)))
+        Loggable.info(self, "From frame %d to %d at %f fps, seek to %s s",
+                    cur_frame,
+                    new_frame,
+                    framerate.num / framerate.denom,
+                    new_pos / float(Gst.SECOND))
         self.simple_seek(new_pos)
 
     def _seekCb(self, ruler, position, format):
diff --git a/pitivi/utils/widgets.py b/pitivi/utils/widgets.py
index 17cf513..8483b81 100644
--- a/pitivi/utils/widgets.py
+++ b/pitivi/utils/widgets.py
@@ -701,7 +701,7 @@ class GstElementSettingsWidget(Gtk.VBox, Loggable):
         """
         Set given element on Widget, with optional properties
         """
-        self.info("element:%s, use properties:%s", element, properties)
+        self.info("element: %s, use properties: %s", element, properties)
         self.element = element
         self.ignore = ignore
         self.properties = {}
@@ -754,7 +754,7 @@ class GstElementSettingsWidget(Gtk.VBox, Loggable):
             if is_effect:
                 result, prop_value = self.element.get_child_property(prop.name)
                 if result is False:
-                    self.debug("Could not get property %s value", prop.name)
+                    self.debug("Could not get value for property: %s", prop.name)
             else:
                 if use_element_props:
                     prop_value = self.element.get_property(prop.name)
@@ -899,7 +899,7 @@ class GstElementSettingsDialog(Loggable):
 
     def __init__(self, elementfactory, properties={}, parent_window=None, isControllable=True):
         Loggable.__init__(self)
-        self.debug("factory:%s, properties:%s", elementfactory, properties)
+        self.debug("factory: %s, properties: %s", elementfactory, properties)
 
         self.builder = Gtk.Builder()
         self.builder.add_from_file(os.path.join(get_ui_dir(), "elementsettingsdialog.ui"))
diff --git a/pitivi/viewer.py b/pitivi/viewer.py
index 53eb7f5..81770ea 100644
--- a/pitivi/viewer.py
+++ b/pitivi/viewer.py
@@ -126,7 +126,7 @@ class PitiviViewer(Gtk.VBox, Loggable):
         @type pipeline: L{Pipeline}.
         @param position: Optional position to seek to initially.
         """
-        self.debug("self.pipeline:%r", self.pipeline)
+        self.debug("self.pipeline: %r", self.pipeline)
 
         self.seeker = Seeker()
         self._disconnectFromPipeline()
@@ -148,7 +148,7 @@ class PitiviViewer(Gtk.VBox, Loggable):
         self._setUiActive()
 
     def _disconnectFromPipeline(self):
-        self.debug("pipeline:%r", self.pipeline)
+        self.debug("pipeline: %r", self.pipeline)
         if self.pipeline is None:
             # silently return, there's nothing to disconnect from
             return


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]