fix pep8 E722 failures (no bare except)

* usr/lib/byobu/include/config.py.in: replace all 'except:' instances
  by 'except Exception:'. LP: #1711026.
* usr/lib/byobu/include/config.py.in: same.
This commit is contained in:
root 2017-08-16 04:13:43 +00:00
commit 2b6e2e18e7
2 changed files with 14 additions and 14 deletions

View file

@ -42,7 +42,7 @@ def error(msg):
try: try:
import snack import snack
from snack import * from snack import *
except: except Exception:
error("Could not import the python snack module") error("Could not import the python snack module")
@ -81,7 +81,7 @@ def ioctl_GWINSZ(fd):
import struct import struct
import os import os
cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234')) cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234'))
except: except Exception:
return None return None
return cr return cr
@ -96,7 +96,7 @@ def reload_required():
f.close() f.close()
if BYOBU_BACKEND == "screen": if BYOBU_BACKEND == "screen":
subprocess.call([BYOBU_BACKEND, "-X", "at", "0", "source", "%s/profile" % BYOBU_CONFIG_DIR]) subprocess.call([BYOBU_BACKEND, "-X", "at", "0", "source", "%s/profile" % BYOBU_CONFIG_DIR])
except: except Exception:
True True
@ -110,13 +110,13 @@ def terminal_size():
fd = os.open(os.ctermid(), os.O_RDONLY) fd = os.open(os.ctermid(), os.O_RDONLY)
cr = ioctl_GWINSZ(fd) cr = ioctl_GWINSZ(fd)
os.close(fd) os.close(fd)
except: except Exception:
pass pass
if not cr: if not cr:
# env vars or finally defaults # env vars or finally defaults
try: try:
cr = (env['LINES'], env['COLUMNS']) cr = (env['LINES'], env['COLUMNS'])
except: except Exception:
cr = (25, 80) cr = (25, 80)
# reverse rows, cols # reverse rows, cols
return int(cr[1] - 5), int(cr[0] - 5) return int(cr[1] - 5), int(cr[0] - 5)
@ -173,7 +173,7 @@ def readstatus():
if os.path.exists(f): if os.path.exists(f):
try: try:
exec(open(f).read(), glo, loc) exec(open(f).read(), glo, loc)
except: except Exception:
error("Invalid configuration [%s]" % f) error("Invalid configuration [%s]" % f)
if BYOBU_BACKEND == "tmux": if BYOBU_BACKEND == "tmux":
items = "%s %s" % (loc["tmux_left"], loc["tmux_right"]) items = "%s %s" % (loc["tmux_left"], loc["tmux_right"])
@ -217,13 +217,13 @@ def writestatus(items):
if key.startswith(BYOBU_BACKEND): if key.startswith(BYOBU_BACKEND):
try: try:
f = open(path, "r") f = open(path, "r")
except: except Exception:
f = open(SHARE + '/status/status', "r") f = open(SHARE + '/status/status', "r")
lines = f.readlines() lines = f.readlines()
f.close() f.close()
try: try:
f = open(path, "w") f = open(path, "w")
except: except Exception:
f = open(path, "a+") f = open(path, "a+")
for l in lines: for l in lines:
if l.startswith("%s=" % key): if l.startswith("%s=" % key):
@ -341,7 +341,7 @@ def chgesc(snackScreen, size):
try: try:
dummy = int(esc.value()) dummy = int(esc.value())
esc.set(DEF_ESC) esc.set(DEF_ESC)
except: except Exception:
# do nothing # do nothing
dummy = "foo" dummy = "foo"
else: else:
@ -363,7 +363,7 @@ def autolaunch():
for line in open("%s/.profile" % HOME): for line in open("%s/.profile" % HOME):
if "byobu-launch" in line: if "byobu-launch" in line:
return 1 return 1
except: except Exception:
return 0 return 0
if os.path.exists("/etc/profile.d/Z97-%s.sh" % PKG): if os.path.exists("/etc/profile.d/Z97-%s.sh" % PKG):
return 1 return 1

View file

@ -27,7 +27,7 @@ import subprocess
try: try:
# For Python3, try and import input from builtins # For Python3, try and import input from builtins
from builtins import input from builtins import input
except: except Exception:
# But fall back to using the default input # But fall back to using the default input
True True
@ -156,14 +156,14 @@ if len(sessions) > 1:
try: try:
try: try:
user_input = input("\nChoose 1-%d [1]: " % (i - 1)) user_input = input("\nChoose 1-%d [1]: " % (i - 1))
except: except Exception:
user_input = "" user_input = ""
if not user_input or user_input == "": if not user_input or user_input == "":
choice = 1 choice = 1
break break
try: try:
choice = int(user_input) choice = int(user_input)
except: except Exception:
choice = int(eval(user_input)) choice = int(eval(user_input))
if choice >= 1 and choice < i: if choice >= 1 and choice < i:
break break
@ -174,7 +174,7 @@ if len(sessions) > 1:
except KeyboardInterrupt: except KeyboardInterrupt:
sys.stdout.write("\n") sys.stdout.write("\n")
sys.exit(0) sys.exit(0)
except: except Exception:
if choice == "" or choice == -1: if choice == "" or choice == -1:
choice = 1 choice = 1
break break