提交 5da624c2 编写于 作者: A Alessio Sergi

Remove i18n from log messages

上级 d398cf0f
......@@ -143,8 +143,7 @@ def main():
# Test if client and server are in the same major version
if not client.login():
logger.critical(
_("The server version is not compatible with the client"))
logger.critical("The server version is not compatible with the client")
sys.exit(2)
# Start the client loop
......@@ -164,8 +163,7 @@ def main():
server = GlancesServer(cached_time=core.cached_time,
config=core.get_config(),
args=args)
print(_("Glances server is running on {0}:{1}").format(
args.bind_address, args.port))
print(_("Glances server is running on {0}:{1}").format(args.bind_address, args.port))
# Set the server login/password (if -P/--password tag)
if args.password != "":
......
......@@ -75,7 +75,7 @@ class GlancesClient(object):
try:
self.client = ServerProxy(uri, transport=transport)
except Exception as e:
msg = _("Client couldn't create socket {0}: {1}").format(uri, e)
msg = "Client couldn't create socket {0}: {1}".format(uri, e)
if not return_to_browser:
logger.critical(msg)
sys.exit(2)
......@@ -121,9 +121,9 @@ class GlancesClient(object):
except ProtocolError as err:
# Others errors
if str(err).find(" 401 ") > 0:
msg = _("Connection to server failed (Bad password)")
msg = "Connection to server failed (bad password)"
else:
msg = _("Connection to server failed ({0})").format(err)
msg = "Connection to server failed ({0})".format(err)
if not return_to_browser:
logger.critical(msg)
sys.exit(2)
......@@ -178,7 +178,7 @@ class GlancesClient(object):
return self.update_snmp()
else:
self.end()
logger.critical(_("Unknown server mode: {0}").format(self.get_mode()))
logger.critical("Unknown server mode: {0}".format(self.get_mode()))
sys.exit(2)
def update_glances(self):
......
......@@ -70,10 +70,9 @@ class Config(object):
self.parser.read(config_file, encoding='utf-8')
else:
self.parser.read(config_file)
logger.info(_("Read configuration file %s") % config_file)
logger.info("Read configuration file '{0}'".format(config_file))
except UnicodeDecodeError as e:
logger.error(
_("Cannot decode configuration file '{0}': {1}").format(config_file, e))
logger.error("Cannot decode configuration file '{0}': {1}".format(config_file, e))
sys.exit(1)
# Save the loaded configuration file path (issue #374)
self._loaded_config_file = config_file
......
......@@ -207,18 +207,15 @@ class GlancesMain(object):
# Filter is only available in standalone mode
if args.process_filter is not None and not self.is_standalone():
logger.critical(
_("Process filter is only available in standalone mode"))
logger.critical("Process filter is only available in standalone mode")
sys.exit(2)
# Check graph output path
if args.enable_history and args.path_history is not None:
if not os.access(args.path_history, os.W_OK):
logger.critical(
_("History output path (%s) do not exist or is not writable") % args.path_history)
logger.critical("History output path {0} do not exist or is not writable".format(args.path_history))
sys.exit(2)
logger.debug(_("History output path is set to %s") %
args.path_history)
logger.debug("History output path is set to {0}".format(args.path_history))
return args
......
......@@ -72,7 +72,7 @@ class MonitorList(object):
countmin = self.config.get_raw_option(section, key + "countmin")
countmax = self.config.get_raw_option(section, key + "countmax")
except Exception as e:
logger.error(_("Cannot read monitored list: {0}").format(e))
logger.error("Cannot read monitored list: {0}".format(e))
pass
else:
if description is not None and regex is not None:
......
......@@ -107,7 +107,7 @@ class GlancesPassword(object):
"""
if os.path.exists(self.password_filepath) and not clear:
# If the password file exist then use it
logger.info(_("Read password from file: {0}").format(self.password_filepath))
logger.info("Read password from file {0}".format(self.password_filepath))
password = self.load_password()
else:
# Else enter the password from the command line
......@@ -123,7 +123,7 @@ class GlancesPassword(object):
password_confirm = hashlib.sha256(getpass.getpass(_("Password (confirm): ")).encode('utf-8')).hexdigest()
if not self.check_password(password_hashed, password_confirm):
logger.critical(_("Sorry, but passwords did not match..."))
logger.critical("Sorry, passwords do not match. Exit.")
sys.exit(1)
# Return the plain or hashed password
......@@ -148,7 +148,7 @@ class GlancesPassword(object):
try:
os.makedirs(self.password_path)
except OSError as e:
logger.error(_("Cannot create Glances directory: {0}").format(e))
logger.error("Cannot create Glances directory: {0}".format(e))
return
# Create/overwrite the password file
......
......@@ -283,16 +283,14 @@ class GlancesProcesses(object):
def set_process_filter(self, value):
"""Set the process filter"""
logger.info(_("Set process filter to %s") % value)
logger.info("Set process filter to {0}".format(value))
self.process_filter = value
if value is not None:
try:
self.process_filter_re = re.compile(value)
logger.debug(
_("Process filter regular expression compilation OK: %s") % self.get_process_filter())
logger.debug("Process filter regex compilation OK: {0}".format(self.get_process_filter()))
except Exception:
logger.error(
_("Can not compile process filter regular expression: %s") % value)
logger.error("Cannot compile process filter regex: {0}".format(value))
self.process_filter_re = None
else:
self.process_filter_re = None
......
......@@ -114,7 +114,7 @@ class GlancesXMLRPCServer(SimpleXMLRPCServer):
try:
self.address_family = socket.getaddrinfo(bind_address, bind_port)[0][0]
except socket.error as e:
logger.error(_("Couldn't open socket: {0}").format(e))
logger.error("Couldn't open socket: {0}".format(e))
sys.exit(1)
SimpleXMLRPCServer.__init__(self, (bind_address, bind_port),
......@@ -202,7 +202,7 @@ class GlancesServer(object):
try:
self.server = GlancesXMLRPCServer(args.bind_address, args.port, requestHandler)
except Exception as e:
logger.critical(_("Cannot start Glances server: {0}").format(e))
logger.critical("Cannot start Glances server: {0}".format(e))
sys.exit(2)
# The users dict
......
......@@ -26,8 +26,7 @@ from glances.core.glances_globals import logger
try:
from pysnmp.entity.rfc3413.oneliner import cmdgen
except ImportError:
logger.critical(_("PySNMP library not found."))
print(_("Install it using pip: # pip install pysnmp"))
logger.critical("PySNMP library not found. To install it: pip install pysnmp")
sys.exit(2)
......
......@@ -38,10 +38,10 @@ class GlancesStandalone(object):
# If process extended stats is disabled by user
if not args.enable_process_extended:
logger.info(_("Extended stats for top process are disabled (default behavior)"))
logger.info("Extended stats for top process are disabled (default behavior)")
glances_processes.disable_extended()
else:
logger.debug(_("Extended stats for top process are enabled"))
logger.debug("Extended stats for top process are enabled")
glances_processes.enable_extended()
# Manage optionnal process filter
......
......@@ -98,7 +98,7 @@ class GlancesStats(object):
# Restoring system path
sys.path = sys_path
# Log plugins list
logger.debug(_("Available plugins list: %s"), self.getAllPlugins())
logger.debug("Available plugins list: {0}".format(self.getAllPlugins()))
def getAllPlugins(self):
"""Return the plugins list."""
......@@ -108,7 +108,7 @@ class GlancesStats(object):
"""Load the stats limits."""
# For each plugins, call the init_limits method
for p in self._plugins:
# logger.debug(_("Load limits for %s") % p)
# logger.debug("Load limits for %s" % p)
self._plugins[p].load_limits(config)
def __update__(self, input_stats):
......@@ -117,7 +117,7 @@ class GlancesStats(object):
# For standalone and server modes
# For each plugins, call the update method
for p in self._plugins:
# logger.debug(_("Update %s stats") % p)
# logger.debug("Update %s stats" % p)
self._plugins[p].update()
else:
# For Glances client mode
......@@ -215,7 +215,7 @@ class GlancesStatsClient(GlancesStats):
# The key is the plugin name
# for example, the file glances_xxx.py
# generate self._plugins_list["xxx"] = ...
logger.debug(_("Init %s plugin") % item)
logger.debug("Init {0} plugin".format(item))
self._plugins[item] = plugin.Plugin()
# Restoring system path
sys.path = sys_path
......@@ -261,10 +261,10 @@ class GlancesStatsClientSNMP(GlancesStats):
oid_os_name = clientsnmp.get_by_oid("1.3.6.1.2.1.1.1.0")
try:
self.system_name = self.get_system_name(oid_os_name['1.3.6.1.2.1.1.1.0'])
logger.info(_('SNMP system name detected: {0}').format(self.system_name))
logger.info("SNMP system name detected: {0}".format(self.system_name))
except KeyError:
self.system_name = None
logger.warning(_('Can not detect SNMP system name'))
logger.warning("Cannot detect SNMP system name")
return ret
......@@ -297,4 +297,4 @@ class GlancesStatsClientSNMP(GlancesStats):
try:
self._plugins[p].update()
except Exception as e:
logger.error(_("Error: Update {0} failed: {1}").format(p, e))
logger.error("Update {0} failed: {1}".format(p, e))
......@@ -22,11 +22,14 @@ import threading
import time
import msvcrt
from glances.core.glances_globals import logger
try:
import colorconsole
import colorconsole.terminal
except ImportError:
logger.critical(_('Colorconsole module not found. Glances cannot start in standalone mode.'))
logger.critical("Colorconsole module not found. Glances cannot start in standalone mode.")
sys.exit(1)
try:
......
......@@ -46,10 +46,10 @@ class GlancesCSV(object):
self.csv_file = open(self.csv_filename, 'wb')
self.writer = csv.writer(self.csv_file)
except IOError as e:
logger.critical(_("Error: Cannot create the CSV file: {0}").format(e))
logger.critical("Cannot create the CSV file: {0}".format(e))
sys.exit(2)
logger.info(_("Stats dumped to CSV file: {0}").format(self.csv_filename))
logger.info("Stats dumped to CSV file: {0}".format(self.csv_filename))
def exit(self):
"""Close the CSV file."""
......
......@@ -33,8 +33,7 @@ if not is_windows:
import curses.panel
from curses.textpad import Textbox
except ImportError:
logger.critical(
'Curses module not found. Glances cannot start in standalone mode.')
logger.critical("Curses module not found. Glances cannot start in standalone mode.")
sys.exit(1)
else:
from glances.outputs.glances_colorconsole import WCurseLight
......@@ -63,7 +62,7 @@ class _GlancesCurses(object):
# Init the curses screen
self.screen = curses.initscr()
if not self.screen:
logger.critical(_("Error: Cannot init the curses library.\n"))
logger.critical("Cannot init the curses library.\n")
sys.exit(1)
# Set curses options
......
......@@ -27,7 +27,8 @@ from glances.plugins.glances_plugin import GlancesPlugin
try:
import batinfo
except ImportError:
logger.debug(_("Cannot grab battery sensor. Missing BatInfo library."))
logger.debug("Batinfo library not found. Glances cannot grab battery info.")
pass
class Plugin(GlancesPlugin):
......
......@@ -42,7 +42,7 @@ class Plugin(GlancesPlugin):
def load_limits(self, config):
"""Load the monitored list from the conf file."""
logger.debug(_("Monitor plugin configuration detected in the configuration file"))
logger.debug("Monitor plugin configuration detected in the configuration file")
self.glances_monitors = glancesMonitorList(config)
def update(self):
......
......@@ -40,7 +40,7 @@ class GlancesPlugin(object):
"""Init the plugin of plugins class."""
# Plugin name (= module name without glances_)
self.plugin_name = self.__class__.__module__[len('glances_'):]
# logger.debug(_("Init plugin %s") % self.plugin_name)
# logger.debug("Init plugin %s" % self.plugin_name)
# Init the args
self.args = args
......@@ -82,8 +82,7 @@ class GlancesPlugin(object):
ret = None
if self.args is not None and self.args.enable_history and self.get_items_history_list() is not None:
iList = [i['name'] for i in self.get_items_history_list()]
logger.debug(_("Stats history activated for plugin %s (items: %s)") % (
self.plugin_name, iList))
logger.debug("Stats history activated for plugin {0} (items: {0})".format(self.plugin_name, iList))
ret = {}
return ret
......@@ -91,8 +90,7 @@ class GlancesPlugin(object):
"""Reset the stats history (dict of list)"""
if self.args is not None and self.args.enable_history and self.get_items_history_list() is not None:
iList = [i['name'] for i in self.get_items_history_list()]
logger.debug(
_("Reset history for plugin %s (items: %s)") % (self.plugin_name, iList))
logger.debug("Reset history for plugin {0} (items: {0})".format(self.plugin_name, iList))
self.stats_history = {}
return self.stats_history
......@@ -219,7 +217,7 @@ class GlancesPlugin(object):
try:
return json.dumps({item: self.stats[item]})
except KeyError as e:
logger.error(_("Can not get item %s (%s)") % (item, e))
logger.error("Cannot get item {0} ({1})".format(item, e))
else:
return None
else:
......@@ -228,7 +226,7 @@ class GlancesPlugin(object):
# http://stackoverflow.com/questions/4573875/python-get-index-of-dictionary-item-in-list
return json.dumps({item: map(itemgetter(item), self.stats)})
except (KeyError, ValueError) as e:
logger.error(_("Can not get item %s (%s)") % (item, e))
logger.error("Cannot get item {0} ({1})".format(item, e))
return None
def get_stats_value(self, item, value):
......@@ -244,8 +242,7 @@ class GlancesPlugin(object):
try:
return json.dumps({value: [i for i in self.stats if i[item] == value]})
except (KeyError, ValueError) as e:
logger.error(
_("Can not get item(%s)=value(%s) (%s)") % (item, value, e))
logger.error("Cannot get item({0})=value({1}) ({2})".format(item, value, e))
return None
def load_limits(self, config):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册