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): ...@@ -321,7 +321,7 @@ def ssh(request):
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
) )
can_generate = (ret == 0 and not os.path.exists(RSA_KEY_FILE)) can_generate = (ret == 0 and not os.path.exists(RSA_KEY_FILE))
except: except subprocess.CalledProcessError:
can_generate = False can_generate = False
# Grab action type # Grab action type
......
...@@ -671,7 +671,7 @@ class PoFormat(FileFormat): ...@@ -671,7 +671,7 @@ class PoFormat(FileFormat):
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
) )
cls.msginit_found = (ret == 0) cls.msginit_found = (ret == 0)
except: except subprocess.CalledProcessError:
cls.msginit_found = False cls.msginit_found = False
return cls.msginit_found return cls.msginit_found
...@@ -683,7 +683,7 @@ class PoFormat(FileFormat): ...@@ -683,7 +683,7 @@ class PoFormat(FileFormat):
try: try:
pofile.parsefile(base) pofile.parsefile(base)
return True return True
except: except Exception:
return False return False
@staticmethod @staticmethod
......
...@@ -389,7 +389,7 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin): ...@@ -389,7 +389,7 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
path = self.get_path() path = self.get_path()
try: try:
self._git_repo = git.Repo(path) self._git_repo = git.Repo(path)
except: except Exception:
# Fallback to initializing the repository # Fallback to initializing the repository
self._git_repo = git.Repo.init(path) self._git_repo = git.Repo.init(path)
......
...@@ -30,6 +30,7 @@ from django.core.urlresolvers import reverse ...@@ -30,6 +30,7 @@ from django.core.urlresolvers import reverse
import os import os
import git import git
import traceback import traceback
import ConfigParser
from translate.storage import poheader from translate.storage import poheader
from datetime import datetime, timedelta from datetime import datetime, timedelta
...@@ -807,7 +808,7 @@ class Translation(models.Model, URLMixin, PercentMixin): ...@@ -807,7 +808,7 @@ class Translation(models.Model, URLMixin, PercentMixin):
value = cnf.get(section, key) value = cnf.get(section, key)
if value == expected: if value == expected:
return return
except: except ConfigParser.Error:
pass pass
# Add section if it does not exist # Add section if it does not exist
...@@ -1217,7 +1218,7 @@ class Translation(models.Model, URLMixin, PercentMixin): ...@@ -1217,7 +1218,7 @@ class Translation(models.Model, URLMixin, PercentMixin):
fileobj, fileobj,
self.subproject.template_store self.subproject.template_store
) )
except: except Exception:
# Fallback to automatic detection # Fallback to automatic detection
fileobj.seek(0) fileobj.seek(0)
store = AutoFormat(fileobj) store = AutoFormat(fileobj)
......
...@@ -189,7 +189,7 @@ def check_name(check): ...@@ -189,7 +189,7 @@ def check_name(check):
''' '''
try: try:
return CHECKS[check].name return CHECKS[check].name
except: except KeyError:
return check return check
...@@ -200,7 +200,7 @@ def check_description(check): ...@@ -200,7 +200,7 @@ def check_description(check):
''' '''
try: try:
return CHECKS[check].description return CHECKS[check].description
except: except KeyError:
return check return check
......
...@@ -260,7 +260,7 @@ def export_stats(request, project, subproject): ...@@ -260,7 +260,7 @@ def export_stats(request, project, subproject):
try: try:
indent = int(request.GET['indent']) indent = int(request.GET['indent'])
except: except (ValueError, KeyError):
indent = None indent = None
response = [] response = []
......
...@@ -101,7 +101,7 @@ def try_set_language(lang): ...@@ -101,7 +101,7 @@ def try_set_language(lang):
try: try:
django.utils.translation.activate(lang) django.utils.translation.activate(lang)
except: except Exception:
# Ignore failure on activating language # Ignore failure on activating language
pass pass
try: 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