Skip to content
This repository has been archived by the owner on Dec 18, 2019. It is now read-only.

Commit

Permalink
cleanup: Fix flake8 warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Jerome Flesch <[email protected]>
  • Loading branch information
jflesch committed May 27, 2018
1 parent 011f9f7 commit 2e5d721
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
6 changes: 3 additions & 3 deletions paperwork-gtk/src/paperwork/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
gi.require_version('Poppler', '0.18')
gi.require_version('PangoCairo', '1.0')
gi.require_version('Notify', '0.7')
except:
except: # noqa: E722
pass

g_gtk_available = False
Expand Down Expand Up @@ -199,7 +199,7 @@ def find_missing_dict(lang):
missing = []
try:
enchant.request_dict(lang['aspell'])
except:
except: # noqa: E722
missing.append(
(
'Dictionary', '(none)',
Expand Down Expand Up @@ -285,7 +285,7 @@ def check_sane():
try:
pyinsane2.init()
pyinsane2.exit()
except:
except: # noqa: E722
missing.append(
(
'libsane', '(none)',
Expand Down
11 changes: 6 additions & 5 deletions paperwork-gtk/src/paperwork/frontend/diag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def _get_sysinfo(self):
if hasattr(os, 'uname'):
try:
logger.info("os.uname: {}".format(os.uname()))
except:
pass
except Exception as exc:
logger.info("os.uname: {}".format(str(exc)))
try:
logger.info("platform.architecture: {}".format(
platform.architecture()
Expand Down Expand Up @@ -110,9 +110,10 @@ def _get_paperwork_info(self):
try:
max_pages = max(max_pages, doc.nb_pages)
doc_idx += 1
except:
logger.exception(
"Exception while examining document {}".format(doc.docid)
except Exception as exc:
logger.error(
"Exception while examining document {}".format(doc.docid),
exc_info=exc
)

logger.info("Total number of documents: {}".format(nb_docs))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ def do(self):
self.emit("rendered",
self.page.page_nb, self.page.doc.nb_pages,
self.page.img, self.page.boxes)
except:
except: # noqa: E722
# TODO(Jflesch)
# We get "MemoryError" sometimes ? oO
self.emit("rendering-error")
Expand Down
14 changes: 7 additions & 7 deletions paperwork-gtk/src/paperwork/frontend/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,23 +238,23 @@ def get_documentation(doc_name):
lang = "en"
try:
lang = locale.getdefaultlocale()[0][:2]
except:
logger.exception(
except Exception as exc:
logger.error(
"get_documentation(): Failed to figure out locale. Will default"
" to English"
" to English",
exc_info=exc
)
pass

default = doc_name + ".pdf"
localized = "{}_{}.pdf".format(doc_name, lang)
try:
return _get_resource_path(localized, pkg="paperwork.frontend.doc")
except:
except: # noqa: E722
pass

try:
return _get_resource_path(default, pkg="paperwork.frontend.doc")
except:
except: # noqa: E722
pass

if os.path.exists(localized):
Expand Down Expand Up @@ -344,7 +344,7 @@ def connect_actions(actions):
logger.error("MISSING BUTTON: %s" % (action))
try:
actions[action][1].connect(actions[action][0])
except:
except: # noqa: E722
logger.error("Failed to connect action '%s'" % action)
raise

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def __on_button_pressed(self, _, event):
try:
mouse_cursor = Gdk.Cursor.new_from_name(display, "all-scroll")
origin_cursor = Gdk.Cursor.new_from_name(display, "crosshair")
except:
except: # noqa: E722
mouse_cursor = Gdk.Cursor.new_for_display(
display, Gdk.CursorType.FLEUR
)
Expand Down

0 comments on commit 2e5d721

Please sign in to comment.