Skip to content

Commit

Permalink
Specify exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Linkid committed Nov 23, 2017
1 parent 243fb65 commit 7afe2ab
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 48 deletions.
2 changes: 1 addition & 1 deletion fofix/core/Config.py
Expand Up @@ -148,7 +148,7 @@ def _convertValue(value, type, default=False):
else:
try:
return type(value)
except:
except Exception:
return None

class Config(object):
Expand Down
2 changes: 1 addition & 1 deletion fofix/core/GameEngine.py
Expand Up @@ -264,7 +264,7 @@ def __init__(self, config = None):
# GNU/Linux) as the Viewport was not set yet.
try:
viewport = glGetIntegerv(GL_VIEWPORT)
except:
except Exception:
viewport = [0, 0, width, height]
h = viewport[3] - viewport[1]
w = viewport[2] - viewport[0]
Expand Down
12 changes: 6 additions & 6 deletions fofix/core/Player.py
Expand Up @@ -53,7 +53,7 @@ def __cmp__(self, other):
return 0
else:
return -1
except:
except Exception:
return -1

def sortOptionsByKey(dict):
Expand Down Expand Up @@ -248,7 +248,7 @@ def _makePlayerIniName(name):
v = _playerDB.execute("SELECT `value` FROM `config` WHERE `key` = 'version'").fetchone()[0]
if int(v) != _SCHEMA_VERSION:
_updateTables = 2 #an old version. We don't want to just burn old tables.
except:
except Exception:
_updateTables = 1 #no good table
if _updateTables > 0: #needs to handle old versions eventually.
for tbl in _playerDB.execute("SELECT `name` FROM `sqlite_master` WHERE `type` = 'table'").fetchall():
Expand Down Expand Up @@ -325,7 +325,7 @@ def savePlayers():
c.set("player","controller",int(pref[11]))
del c
_playerDB.execute('UPDATE `players` SET `changed` = 0 WHERE `name` = ?', [pref[0]])
except:
except Exception:
c = VFS.open(_makePlayerIniName(str(pref[0])), "w")
c.close()
c = Config.load(VFS.resolveWrite(_makePlayerIniName(str(pref[0]))), type = 2)
Expand All @@ -349,7 +349,7 @@ def updatePlayer(player, pref):
a = _playerDB.execute('SELECT * FROM `players` WHERE `name` = ?', [player]).fetchone()
try:
a = a[0]
except:
except Exception:
a = None
if a is not None:
_playerDB.execute('UPDATE `players` SET `name` = ?, `lefty` = ?, `drumflip` = ?, `autokick` = ?, `assist` = ?, `twochord` = ?, `necktype` = ?, `neck` = ?, \
Expand Down Expand Up @@ -556,7 +556,7 @@ def keycode(name, config):
return "None"
try:
return int(k)
except:
except Exception:
return getattr(pygame, k)

self.controlMapping = {}
Expand Down Expand Up @@ -806,7 +806,7 @@ def keycode(name, config):
return None
try:
return int(k)
except:
except Exception:
return getattr(pygame, k)

# list of keys to look for
Expand Down
6 changes: 3 additions & 3 deletions fofix/core/Resource.py
Expand Up @@ -113,7 +113,7 @@ def load(self):
start = time.time()
self.result = self.function()
self.time = time.time() - start
except:
except Exception:
self.exception = sys.exc_info()

def finish(self):
Expand Down Expand Up @@ -204,7 +204,7 @@ def fileName(self, *name, **args):
# If the original file does not exist, see if we can write to its directory
if not os.path.isfile(readOnlyPath) and os.access(os.path.dirname(readOnlyPath), os.W_OK):
pass
except:
except Exception:
raise
# If the resource exists in the read-only path, make a copy to the
# read-write path.
Expand All @@ -213,7 +213,7 @@ def fileName(self, *name, **args):
log.info("Copying '%s' to writable data directory." % "/".join(name))
try:
os.makedirs(os.path.dirname(readWritePath))
except:
except Exception:
pass
shutil.copy(readOnlyPath, readWritePath)
self.makeWritable(readWritePath)
Expand Down
4 changes: 2 additions & 2 deletions fofix/core/Settings.py
Expand Up @@ -178,7 +178,7 @@ def __init__(self, engine, config, section, option, noneOK = False, shift = None
def keycode(k):
try:
return int(k)
except:
except Exception:
return getattr(pygame, k)

if self.shift:
Expand All @@ -198,7 +198,7 @@ def getText(self, selected):
def keycode(k):
try:
return int(k)
except:
except Exception:
return getattr(pygame, k)
o = self.config.prototype[self.section][self.option]
v = self.config.get(self.section, self.option)
Expand Down
24 changes: 13 additions & 11 deletions fofix/core/Shader.py
Expand Up @@ -135,8 +135,10 @@ def getVars(self, fname, program, sArray):
break
if aline[0] == "uniform":
value = None
try: n = int(aline[1][-1])
except: n = 4
try:
n = int(aline[1][-1])
except Exception:
n = 4
if aline[1] == "bool": value = False
elif aline[1] == "int": value = 0
elif aline[1] == "float": value = 0.0
Expand Down Expand Up @@ -499,7 +501,7 @@ def checkIfEnabled(self):
continue
return True
return False

def defineConfig(self):
for name in self.shaders.keys():
for key in self[name].keys():
Expand Down Expand Up @@ -534,7 +536,7 @@ def set(self, dir):
try:
self.noise3D = self.loadTex3D("noise3d.dds")
self.outline = self.loadTex2D("outline.tga")
except:
except Exception:
log.error('Could not load shader textures - shaders disabled: ')
return

Expand All @@ -546,7 +548,7 @@ def set(self, dir):
# Also set uniform shader variables to default values.
try:
self.make("lightning","stage")
except:
except Exception:
log.error("Error compiling lightning shader: ")
else:
self.enable("stage")
Expand All @@ -566,7 +568,7 @@ def set(self, dir):

try:
self.make("lightning","sololight")
except:
except Exception:
log.error("Error compiling lightning shader: ")
else:
self.enable("sololight")
Expand All @@ -588,7 +590,7 @@ def set(self, dir):

try:
self.make("lightning","tail")
except:
except Exception:
log.error("Error compiling lightning shader: ")
else:
self.enable("tail")
Expand All @@ -611,7 +613,7 @@ def set(self, dir):

try:
self.make("rockbandtail","tail2")
except:
except Exception:
log.error("Error compiling rockbandtail shader: ")
else:
self.enable("tail2")
Expand All @@ -624,20 +626,20 @@ def set(self, dir):

try:
self.make("metal","notes")
except:
except Exception:
log.error("Error compiling metal shader: ")
else:
self.enable("notes")
self.disable()

try:
self.make("neck","neck")
except:
except Exception:
log.error("Error compiling neck shader: ")

try:
self.make("cd","cd")
except:
except Exception:
log.error("Error compiling cd shader: ")

def mixColors(c1,c2,blend=0.5):
Expand Down
2 changes: 1 addition & 1 deletion fofix/core/Texture.py
Expand Up @@ -88,7 +88,7 @@ def loadImage(self, image):
log.warn("Unsupported image mode '%s' converted to 'RGB'. May have unexpected results." % image.mode)
string = image.tobytes('raw', 'RGB', 0, -1)
self.loadRaw(image.size, string, GL_RGB, 3)
except:
except Exception:
raise TextureException("Unsupported image mode '%s'" % image.mode)

def nextPowerOfTwo(self, n):
Expand Down
4 changes: 2 additions & 2 deletions fofix/core/Video.py
Expand Up @@ -54,7 +54,7 @@ def setMode(self, resolution, fullscreen = False, flags = pygame.OPENGL | pygame

try:
pygame.display.quit()
except:
except Exception:
pass

pygame.display.init()
Expand Down Expand Up @@ -140,7 +140,7 @@ def setMode(self, resolution, fullscreen = False, flags = pygame.OPENGL | pygame
if multisamples:
try:
glEnable(GL_MULTISAMPLE_ARB)
except:
except Exception:
pass

return bool(self.screen)
Expand Down
2 changes: 1 addition & 1 deletion fofix/game/Dialogs.py
Expand Up @@ -1142,7 +1142,7 @@ def render(self, visibility, topMost):

try:
font = self.engine.data.fontDict[self.engine.theme.avatarSelectFont]
except:
except Exception:
font = self.engine.data.font
if self.avText:
drawImage(self.avText, scale = (self.engine.theme.avatarSelectTextScale, -self.engine.theme.avatarSelectTextScale), coord = (self.engine.theme.avatarSelectTextX, self.engine.theme.avatarSelectTextY - v))
Expand Down

0 comments on commit 7afe2ab

Please sign in to comment.