common: Stop translating a bunch of printed messages and exceptions
Change-Id: I666758fd153cf36a4a2314b5bd50f6cbdb8d7f07
This commit is contained in:
@@ -13,16 +13,13 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from swift import gettext_ as _
|
||||
|
||||
|
||||
class ProfileException(Exception):
|
||||
|
||||
def __init__(self, msg):
|
||||
self.msg = msg
|
||||
|
||||
def __str__(self):
|
||||
return _('Profiling Error: %s') % self.msg
|
||||
return 'Profiling Error: %s' % self.msg
|
||||
|
||||
|
||||
class NotFoundException(ProfileException):
|
||||
|
||||
@@ -19,7 +19,6 @@ import re
|
||||
import string
|
||||
import tempfile
|
||||
|
||||
from swift import gettext_ as _
|
||||
from swift.common.middleware.x_profile.exceptions import PLOTLIBNotInstalled
|
||||
from swift.common.middleware.x_profile.exceptions import ODFLIBNotInstalled
|
||||
from swift.common.middleware.x_profile.exceptions import NotFoundException
|
||||
@@ -307,7 +306,7 @@ class HTMLViewer(object):
|
||||
nfl_filter, download_format)
|
||||
headers.append(('Access-Control-Allow-Origin', '*'))
|
||||
else:
|
||||
raise MethodNotAllowed(_('method %s is not allowed.') % method)
|
||||
raise MethodNotAllowed('method %s is not allowed.' % method)
|
||||
return content, headers
|
||||
|
||||
def index_page(self, log_files=None, sort='time', limit=-1,
|
||||
@@ -318,7 +317,7 @@ class HTMLViewer(object):
|
||||
try:
|
||||
stats = Stats2(*log_files)
|
||||
except (IOError, ValueError):
|
||||
raise DataLoadFailure(_('Can not load profile data from %s.')
|
||||
raise DataLoadFailure('Can not load profile data from %s.'
|
||||
% log_files)
|
||||
if not fulldirs:
|
||||
stats.strip_dirs()
|
||||
@@ -369,7 +368,7 @@ class HTMLViewer(object):
|
||||
def download(self, log_files, sort='time', limit=-1, nfl_filter='',
|
||||
output_format='default'):
|
||||
if len(log_files) == 0:
|
||||
raise NotFoundException(_('no log file found'))
|
||||
raise NotFoundException('no log file found')
|
||||
try:
|
||||
nfl_esc = nfl_filter.replace(r'(', r'\(').replace(r')', r'\)')
|
||||
# remove the slash that is intentionally added in the URL
|
||||
@@ -392,14 +391,14 @@ class HTMLViewer(object):
|
||||
except ODFLIBNotInstalled:
|
||||
raise
|
||||
except Exception as ex:
|
||||
raise ProfileException(_('Data download error: %s') % ex)
|
||||
raise ProfileException('Data download error: %s' % ex)
|
||||
|
||||
def plot(self, log_files, sort='time', limit=10, nfl_filter='',
|
||||
metric_selected='cc', plot_type='bar'):
|
||||
if not PLOTLIB_INSTALLED:
|
||||
raise PLOTLIBNotInstalled(_('python-matplotlib not installed.'))
|
||||
raise PLOTLIBNotInstalled('python-matplotlib not installed.')
|
||||
if len(log_files) == 0:
|
||||
raise NotFoundException(_('no log file found'))
|
||||
raise NotFoundException('no log file found')
|
||||
try:
|
||||
stats = Stats2(*log_files)
|
||||
stats.sort_stats(sort)
|
||||
@@ -433,7 +432,7 @@ class HTMLViewer(object):
|
||||
data = profile_img.read()
|
||||
return data, [('content-type', 'image/jpg')]
|
||||
except Exception as ex:
|
||||
raise ProfileException(_('plotting results failed due to %s') % ex)
|
||||
raise ProfileException('plotting results failed due to %s' % ex)
|
||||
|
||||
def format_source_code(self, nfl):
|
||||
nfls = re.split('[:()]', nfl)
|
||||
@@ -444,7 +443,7 @@ class HTMLViewer(object):
|
||||
lineno = 0
|
||||
# for security reason, this need to be fixed.
|
||||
if not file_path.endswith('.py'):
|
||||
return _('The file type are forbidden to access!')
|
||||
return 'The file type are forbidden to access!'
|
||||
try:
|
||||
data = []
|
||||
i = 0
|
||||
@@ -465,7 +464,7 @@ class HTMLViewer(object):
|
||||
data.append(fmt % (i, i, i, el))
|
||||
data = ''.join(data)
|
||||
except Exception:
|
||||
return _('Can not access the file %s.') % file_path
|
||||
return 'Can not access the file %s.' % file_path
|
||||
return '<pre>%s</pre>' % data
|
||||
|
||||
def generate_stats_html(self, stats, app_path, profile_id, *selection):
|
||||
|
||||
@@ -20,7 +20,6 @@ import pstats
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
from swift import gettext_ as _
|
||||
from swift.common.middleware.x_profile.exceptions import ODFLIBNotInstalled
|
||||
|
||||
|
||||
@@ -125,7 +124,7 @@ class Stats2(pstats.Stats):
|
||||
|
||||
def to_ods(self, *selection):
|
||||
if not ODFLIB_INSTALLED:
|
||||
raise ODFLIBNotInstalled(_('odfpy not installed.'))
|
||||
raise ODFLIBNotInstalled('odfpy not installed.')
|
||||
if self.fcn_list:
|
||||
stat_list = self.fcn_list[:]
|
||||
order_text = " Ordered by: " + self.sort_type + '\n'
|
||||
|
||||
@@ -83,7 +83,6 @@ import eventlet.green.profile as eprofile
|
||||
import six
|
||||
from six.moves import urllib
|
||||
|
||||
from swift import gettext_ as _
|
||||
from swift.common.utils import get_logger, config_true_value
|
||||
from swift.common.swob import Request
|
||||
from swift.common.middleware.x_profile.exceptions import MethodNotAllowed
|
||||
@@ -227,7 +226,7 @@ class ProfileMiddleware(object):
|
||||
return '%s' % pf
|
||||
except Exception as ex:
|
||||
start_response('500 Internal Server Error', [])
|
||||
return _('Error on render profiling results: %s') % ex
|
||||
return 'Error on render profiling results: %s' % ex
|
||||
else:
|
||||
_locals = locals()
|
||||
code = self.unwind and PROFILE_EXEC_EAGER or\
|
||||
|
||||
Reference in New Issue
Block a user