Skip to content

Commit

Permalink
Adding logging for empty exception handlers, such as Except: pass
Browse files Browse the repository at this point in the history
  • Loading branch information
jonoomph committed Jun 1, 2020
1 parent 96cf186 commit 669ca71
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 48 deletions.
8 changes: 4 additions & 4 deletions src/classes/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(self, *args, mode=None):
log.info("qt5 version: %s" % QT_VERSION_STR)
log.info("pyqt5 version: %s" % PYQT_VERSION_STR)
except Exception:
pass
log.warning("Failed to read version info from dependencies and platform")

# Setup application
self.setApplicationName('openshot')
Expand Down Expand Up @@ -271,12 +271,12 @@ def run(self):
@atexit.register
def onLogTheEnd():
""" Log when the primary Qt event loop ends """
from classes.logger import log
import time

try:
from classes.logger import log
import time
log.info('OpenShot\'s session ended'.center(48))
log.info(time.asctime().center(48))
log.info("================================================")
except Exception:
pass
log.warning('Failed to write session ended log')
4 changes: 2 additions & 2 deletions src/classes/importers/edl.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

from classes import info
from classes.app import get_app
from classes.logger import log
from classes.image_types import is_image
from classes.query import Clip, Track, File
from classes.time_parts import timecodeToSeconds
Expand Down Expand Up @@ -95,8 +96,7 @@ def create_clip(context, track):
# Save file
file.save()
except:
# Ignore errors for now
pass
log.warning('Failed to create File object for %s' % clip_path)

if (file.data["media_type"] == "video" or file.data["media_type"] == "image"):
# Determine thumb path
Expand Down
4 changes: 2 additions & 2 deletions src/classes/importers/final_cut_pro.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

from classes import info
from classes.app import get_app
from classes.logger import log
from classes.image_types import is_image
from classes.query import Clip, Track, File
from windows.views.find_file import find_missing_file
Expand Down Expand Up @@ -141,8 +142,7 @@ def import_xml():
# Save file
file.save()
except Exception:
# Ignore errors for now
pass
log.warning('Failed to create File object for %s' % clip_path)

if (file.data["media_type"] == "video" or file.data["media_type"] == "image"):
# Determine thumb path
Expand Down
17 changes: 8 additions & 9 deletions src/classes/language.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
"""
"""
@file
@brief This file loads the current language based on the computer's locale settings
@author Noah Figg <eggmunkee@hotmail.com>
@author Jonathan Thomas <jonathan@openshot.org>
@section LICENSE
Copyright (c) 2008-2018 OpenShot Studios, LLC
(http://www.openshotstudios.com). This file is part of
OpenShot Video Editor (http://www.openshot.org), an open-source project
dedicated to delivering high quality video editing and animation solutions
to the world.
OpenShot Video Editor is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenShot Video Editor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
"""
Expand Down Expand Up @@ -123,7 +123,7 @@ def init_language():
# returns True when a match was found.
# pattern - a string expected to have one pipe to be filled by locale strings
# path - base path for file (pattern may contain more path)
#
#
def find_language_match(prefix, path, translator, locale_name):
""" Match all combinations of locale, language, and country """

Expand All @@ -145,8 +145,7 @@ def get_all_languages():
country_name = QLocale(locale_name).nativeCountryName().title()
all_languages.append((locale_name, native_lang_name, country_name))
except:
# Ignore failed parsing of language
pass
log.warning('Failed to parse language for %s' % locale_name)

# Return list
return all_languages
Expand Down
2 changes: 1 addition & 1 deletion src/classes/thumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def GenerateThumbnail(file_path, thumb_path, thumbnail_frame, width, height, mas
if reader.info.metadata.count("rotate"):
rotate = float(reader.info.metadata.find("rotate").value()[1])
except Exception:
pass
log.warning('Failed to parse rotation data as float')

# Create thumbnail folder (if needed)
parent_path = os.path.dirname(thumb_path)
Expand Down
12 changes: 4 additions & 8 deletions src/windows/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ def __init__(self):
self.btnchangelog.setVisible(True)
break
except:
# Ignore decoding errors
pass
log.warning('Failed to parse log file %s with encoding %s' % (changelog_path, encoding_name))

create_text = _('Create &amp; Edit Amazing Videos and Movies')
description_text = _('OpenShot Video Editor 2.x is the next generation of the award-winning <br/>OpenShot video editing platform.')
Expand Down Expand Up @@ -270,8 +269,7 @@ def __init__(self):
'subject': line[45:].strip() })
break
except:
# Ignore decoding errors
pass
log.warning('Failed to parse log file %s with encoding %s' % (changelog_path, encoding_name))
self.openshot_qt_ListView = ChangelogTreeView(commits=changelog_list, commit_url="https://github.com/OpenShot/openshot-qt/commit/%s/")
self.vbox_openshot_qt.addWidget(self.openshot_qt_ListView)
self.txtChangeLogFilter_openshot_qt.textChanged.connect(partial(self.Filter_Triggered, self.txtChangeLogFilter_openshot_qt, self.openshot_qt_ListView))
Expand All @@ -291,8 +289,7 @@ def __init__(self):
'subject': line[45:].strip() })
break
except:
# Ignore decoding errors
pass
log.warning('Failed to parse log file %s with encoding %s' % (changelog_path, encoding_name))
self.libopenshot_ListView = ChangelogTreeView(commits=changelog_list, commit_url="https://github.com/OpenShot/libopenshot/commit/%s/")
self.vbox_libopenshot.addWidget(self.libopenshot_ListView)
self.txtChangeLogFilter_libopenshot.textChanged.connect(partial(self.Filter_Triggered, self.txtChangeLogFilter_libopenshot, self.libopenshot_ListView))
Expand All @@ -312,8 +309,7 @@ def __init__(self):
'subject': line[45:].strip() })
break
except:
# Ignore decoding errors
pass
log.warning('Failed to parse log file %s with encoding %s' % (changelog_path, encoding_name))
self.libopenshot_audio_ListView = ChangelogTreeView(commits=changelog_list, commit_url="https://github.com/OpenShot/libopenshot-audio/commit/%s/")
self.vbox_libopenshot_audio.addWidget(self.libopenshot_audio_ListView)
self.txtChangeLogFilter_libopenshot_audio.textChanged.connect(partial(self.Filter_Triggered, self.txtChangeLogFilter_libopenshot_audio, self.libopenshot_audio_ListView))
2 changes: 1 addition & 1 deletion src/windows/animated_title.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ def clear_effect_controls(self):
self.settingsContainer.layout().removeWidget(child)
child.deleteLater()
except:
pass
log.warning('Failed to remove child widget for effect controls')
2 changes: 1 addition & 1 deletion src/windows/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ def convert_to_bytes(self, BitRateString):
bit_rate_bytes = raw_number

except:
pass
log.warning('Failed to convert bitrate string to bytes: %s' % BitRateString)

# return the bit rate in bytes
return str(int(bit_rate_bytes))
Expand Down
10 changes: 5 additions & 5 deletions src/windows/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ def create_lock_file(self):
f.write(lock_value)
break
except Exception:
log.warning('Failed to write lock file (attempt: %s)' % attempts)
attempts -= 1
sleep(0.25)

Expand All @@ -306,6 +307,7 @@ def destroy_lock_file(self):
os.remove(lock_path)
break
except Exception:
log.warning('Failed to destroy lock file (attempt: %s)' % attempts)
attempts -= 1
sleep(0.25)

Expand Down Expand Up @@ -2589,8 +2591,7 @@ def FrameExported(self, title_message, start_frame, end_frame, current_frame):
self.unity_launcher.set_property("progress", current_frame / (end_frame - start_frame))
self.unity_launcher.set_property("progress_visible", True)
except Exception:
# Just ignore
pass
log.warning('Failed to notify unity launcher of export progress. Frame: %s' % current_frame)

def ExportFinished(self, path):
"""Show completion in Unity Launcher (if connected)"""
Expand All @@ -2599,7 +2600,7 @@ def ExportFinished(self, path):
self.unity_launcher.set_property("progress", 0.0)
self.unity_launcher.set_property("progress_visible", False)
except Exception:
pass
log.warning('Failed to notify unity launcher of export progress. Completed.')

def __init__(self, mode=None):

Expand Down Expand Up @@ -2864,8 +2865,7 @@ def __init__(self, mode=None):
from gi.repository import Unity
self.unity_launcher = Unity.LauncherEntry.get_for_desktop_id(info.DESKTOP_ID)
except Exception:
# Guess we're not on Ubuntu
pass
log.warning('Failed to connect to Unity launcher (Linux only) for updating export progress.')
else:
self.ExportFrame.connect(self.FrameExported)
self.ExportEnded.connect(self.ExportFinished)
Expand Down
2 changes: 1 addition & 1 deletion src/windows/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def text_value_changed(self, widget, param, value=None):
if not value:
value = widget.toPlainText()
except:
pass
log.warning('Failed to get plain text from widget')

# If this setting is a keyboard mapping, parse it first
if param.get("category") == "Keyboard":
Expand Down
6 changes: 3 additions & 3 deletions src/windows/title_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def load_svg_template(self):
self.settingsContainer.layout().removeWidget(child)
child.deleteLater()
except Exception:
pass
log.warning('Failed to delete child settings widget')

# Get text nodes and rect nodes
self.text_node = self.xmldoc.getElementsByTagName('text')
Expand Down Expand Up @@ -441,7 +441,7 @@ def update_font_color_button(self):
color = txt[5:]
except Exception:
# If the color was in an invalid format, try the next text element
continue
log.warning('Failed to parse color value from text element')

opacity = self.find_in_list(ar, "opacity:")

Expand All @@ -450,7 +450,7 @@ def update_font_color_button(self):
txt = ar[opacity]
opacity = float(txt[8:])
except Exception:
pass
log.warning('Failed to parse opacity value from text element')

# Default the font color to white if non-existing
if color is None:
Expand Down
1 change: 1 addition & 0 deletions src/windows/views/blender_listview.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def text_value_changed(self, widget, param, value=None):
if not value:
value = widget.toPlainText()
except Exception:
log.warning('Failed to read plain text value from widget')
return
self.params[param["name"]] = value.replace("\n", "\\n")
# XXX: This will log every individual KEYPRESS in the text field.
Expand Down
14 changes: 7 additions & 7 deletions src/windows/views/changelog_treeview.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
"""
"""
@file
@brief This file contains the changelog treeview, used by the about window
@author Noah Figg <eggmunkee@hotmail.com>
@author Jonathan Thomas <jonathan@openshot.org>
@section LICENSE
Copyright (c) 2008-2018 OpenShot Studios, LLC
(http://www.openshotstudios.com). This file is part of
OpenShot Video Editor (http://www.openshot.org), an open-source project
dedicated to delivering high quality video editing and animation solutions
to the world.
OpenShot Video Editor is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenShot Video Editor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
"""
Expand Down Expand Up @@ -84,7 +84,7 @@ def ChangelogMenuTriggered(self, hash=""):
try:
webbrowser.open(self.commit_url % hash)
except:
pass
log.warning('Failed to launch web browser to %s' % self.commit_url)

def __init__(self, commits, commit_url, *args):
# Invoke parent init
Expand Down
2 changes: 1 addition & 1 deletion src/windows/views/properties_tableview.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def mouseMoveEvent(self, event):
except Exception:
# If item is deleted during this drag... an exception can occur
# Just ignore, since this is harmless
return
log.warning('Failed to access data on selected label widget')

property_key = cur_property[0]
property_name = cur_property[1]["name"]
Expand Down
2 changes: 1 addition & 1 deletion src/windows/views/timeline_webview.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def update_clip_data(self, clip_json, only_basic_props=True, ignore_reader=False
clip_data = clip_json
except Exception:
# Failed to parse json, do nothing
return
log.warning('Failed to parse clip JSON data')

# Search for matching clip in project data (if any)
existing_clip = Clip.get(id=clip_data["id"])
Expand Down
3 changes: 1 addition & 2 deletions src/windows/views/tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,7 @@ def exit_manager(self):
self.win.dockProperties.visibilityChanged.disconnect()
self.win.dockVideo.visibilityChanged.disconnect()
except Exception:
# Ignore errors from this
pass
log.warning('Failed to properly disconnect from dock signals')

# Close dialog window
self.close_dialogs()
Expand Down

0 comments on commit 669ca71

Please sign in to comment.