[pitivi] Fix pylint bare-except



commit 21c682b13462ac128353c292af8dd77c58703d39
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Mon Oct 28 21:43:32 2019 +0100

    Fix pylint bare-except

 pitivi/application.py    |  2 +-
 pitivi/settings.py       |  6 +++---
 pitivi/utils/loggable.py |  2 +-
 pitivi/utils/threads.py  | 14 ++++++++------
 pitivi/utils/widgets.py  |  2 +-
 pre-commit.hook          |  1 -
 6 files changed, 14 insertions(+), 13 deletions(-)
---
diff --git a/pitivi/application.py b/pitivi/application.py
index 47beea41..4d523e13 100644
--- a/pitivi/application.py
+++ b/pitivi/application.py
@@ -236,7 +236,7 @@ class Pitivi(Gtk.Application, Loggable):
             return False
         if self.gui:
             self.gui.destroy()
-        self.threads.stopAllThreads()
+        self.threads.wait_all_threads()
         self.settings.storeSettings()
         self.quit()
         return True
diff --git a/pitivi/settings.py b/pitivi/settings.py
index 5c6e5e28..bba0cfae 100644
--- a/pitivi/settings.py
+++ b/pitivi/settings.py
@@ -219,13 +219,13 @@ class GlobalSettings(GObject.Object, Loggable):
                 # We don't know the value type in advance, just try them all.
                 try:
                     value = cls._config.getfloat(section, option)
-                except:
+                except ValueError:
                     try:
                         value = cls._config.getint(section, option)
-                    except:
+                    except ValueError:
                         try:
                             value = cls._config.getboolean(section, option)
-                        except:
+                        except ValueError:
                             value = cls._config.get(section, option)
 
                 setattr(cls, section + option, value)
diff --git a/pitivi/utils/loggable.py b/pitivi/utils/loggable.py
index cdfedfe3..e384347e 100644
--- a/pitivi/utils/loggable.py
+++ b/pitivi/utils/loggable.py
@@ -165,7 +165,7 @@ class TerminalController:
         # terminal has no capabilities.
         try:
             curses.setupterm()
-        except:
+        except curses.error:
             return
 
         # Look up numeric capabilities.
diff --git a/pitivi/utils/threads.py b/pitivi/utils/threads.py
index 95e07e27..6c7f1e53 100644
--- a/pitivi/utils/threads.py
+++ b/pitivi/utils/threads.py
@@ -86,15 +86,17 @@ class ThreadMaster(Loggable):
         self.log("thread %r is done", thread)
         self.threads.remove(thread)
 
-    def stopAllThreads(self):
-        """Stops all running Threads controlled by this master."""
-        self.log("stopping all threads")
+    def wait_all_threads(self):
+        """Waits until all running Threads controlled by this master stop."""
+        self.log("Waiting for threads to stop")
         joinedthreads = 0
         while joinedthreads < len(self.threads):
             for thread in self.threads:
-                self.log("Trying to stop thread %r", thread)
+                self.log("Waiting for thread to stop: %r", thread)
                 try:
                     thread.join()
                     joinedthreads += 1
-                except:
-                    self.warning("what happened ??")
+                except RuntimeError:
+                    # Tried to join the current thread, or one
+                    # which did not start yet.
+                    pass
diff --git a/pitivi/utils/widgets.py b/pitivi/utils/widgets.py
index bac85969..f2a4e740 100644
--- a/pitivi/utils/widgets.py
+++ b/pitivi/utils/widgets.py
@@ -1430,7 +1430,7 @@ class ColorPickerButton(Gtk.Button):
         # Get color-picker cursor if it exists in the current theme else fallback to generating it ourself
         try:
             cursor = Gdk.Cursor.new_from_name(screen.get_display(), "color-picker")
-        except:
+        except TypeError:
             pixbuf = GdkPixbuf.Pixbuf.new_from_data(DROPPER_BITS, GdkPixbuf.Colorspace.RGB, True, 8, 
DROPPER_WIDTH,
                                                     DROPPER_HEIGHT, DROPPER_WIDTH * 4)
             cursor = Gdk.Cursor.new_from_pixbuf(screen.get_display(), pixbuf, DROPPER_X_HOT, DROPPER_Y_HOT)
diff --git a/pre-commit.hook b/pre-commit.hook
index 8081a335..95a6c033 100755
--- a/pre-commit.hook
+++ b/pre-commit.hook
@@ -39,7 +39,6 @@ pitivi/utils/loggable.py
 pitivi/utils/misc.py
 pitivi/utils/pipeline.py
 pitivi/utils/proxy.py
-pitivi/utils/threads.py
 pitivi/utils/timeline.py
 pitivi/utils/ui.py
 pitivi/utils/validate.py


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