Commit 59cd7bb3 authored by Michal Čihař's avatar Michal Čihař

Catch only specific exceptions when possible

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 10ada6cc
......@@ -321,7 +321,7 @@ def ssh(request):
stderr=subprocess.STDOUT,
)
can_generate = (ret == 0 and not os.path.exists(RSA_KEY_FILE))
except:
except subprocess.CalledProcessError:
can_generate = False
# Grab action type
......
......@@ -671,7 +671,7 @@ class PoFormat(FileFormat):
stderr=subprocess.STDOUT,
)
cls.msginit_found = (ret == 0)
except:
except subprocess.CalledProcessError:
cls.msginit_found = False
return cls.msginit_found
......@@ -683,7 +683,7 @@ class PoFormat(FileFormat):
try:
pofile.parsefile(base)
return True
except:
except Exception:
return False
@staticmethod
......
......@@ -389,7 +389,7 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
path = self.get_path()
try:
self._git_repo = git.Repo(path)
except:
except Exception:
# Fallback to initializing the repository
self._git_repo = git.Repo.init(path)
......
......@@ -30,6 +30,7 @@ from django.core.urlresolvers import reverse
import os
import git
import traceback
import ConfigParser
from translate.storage import poheader
from datetime import datetime, timedelta
......@@ -807,7 +808,7 @@ class Translation(models.Model, URLMixin, PercentMixin):
value = cnf.get(section, key)
if value == expected:
return
except:
except ConfigParser.Error:
pass
# Add section if it does not exist
......@@ -1217,7 +1218,7 @@ class Translation(models.Model, URLMixin, PercentMixin):
fileobj,
self.subproject.template_store
)
except:
except Exception:
# Fallback to automatic detection
fileobj.seek(0)
store = AutoFormat(fileobj)
......
......@@ -189,7 +189,7 @@ def check_name(check):
'''
try:
return CHECKS[check].name
except:
except KeyError:
return check
......@@ -200,7 +200,7 @@ def check_description(check):
'''
try:
return CHECKS[check].description
except:
except KeyError:
return check
......
......@@ -260,7 +260,7 @@ def export_stats(request, project, subproject):
try:
indent = int(request.GET['indent'])
except:
except (ValueError, KeyError):
indent = None
response = []
......
......@@ -101,7 +101,7 @@ def try_set_language(lang):
try:
django.utils.translation.activate(lang)
except:
except Exception:
# Ignore failure on activating language
pass
try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment