mirror of https://github.com/nicolargo/glances
Do not use backslash for line continuation
The preferred way of wrapping long lines is by using Python's implied line continuation inside parentheses. Fix wrong indentation too.pull/1044/head
parent
257a5a3d7b
commit
f5bbd9ed4d
|
@ -124,8 +124,8 @@ class GlancesClient(object):
|
|||
self.stats.set_plugins(json.loads(self.client.getAllPlugins()))
|
||||
logger.debug("Client version: {} / Server version: {}".format(__version__, client_version))
|
||||
else:
|
||||
self.log_and_exit("Client and server not compatible: \
|
||||
Client version: {} / Server version: {}".format(__version__, client_version))
|
||||
self.log_and_exit(('Client and server not compatible: '
|
||||
'Client version: {} / Server version: {}'.format(__version__, client_version)))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
|
|
@ -363,30 +363,28 @@ Start the client browser (browser mode):\n\
|
|||
self.args = args
|
||||
|
||||
# Export is only available in standalone or client mode (issue #614)
|
||||
export_tag = args.export_csv or \
|
||||
args.export_elasticsearch or \
|
||||
args.export_statsd or \
|
||||
args.export_influxdb or \
|
||||
args.export_cassandra or \
|
||||
args.export_opentsdb or \
|
||||
args.export_rabbitmq or \
|
||||
export_tag = (
|
||||
args.export_csv or
|
||||
args.export_elasticsearch or
|
||||
args.export_statsd or
|
||||
args.export_influxdb or
|
||||
args.export_cassandra or
|
||||
args.export_opentsdb or
|
||||
args.export_rabbitmq or
|
||||
args.export_couchdb
|
||||
)
|
||||
if WINDOWS and export_tag:
|
||||
# On Windows, export is possible but only in quiet mode
|
||||
# See issue #1038
|
||||
logger.info(
|
||||
"On Windows OS, export disable the Web Interface")
|
||||
logger.info("On Windows OS, export disable the Web interface")
|
||||
self.args.quiet = True
|
||||
self.args.webserver = False
|
||||
elif not (self.is_standalone() or self.is_client()) \
|
||||
and export_tag:
|
||||
logger.critical(
|
||||
"Export is only available in standalone or client mode")
|
||||
elif not (self.is_standalone() or self.is_client()) and export_tag:
|
||||
logger.critical("Export is only available in standalone or client mode")
|
||||
sys.exit(2)
|
||||
|
||||
# Filter is only available in standalone mode
|
||||
if args.process_filter is not None \
|
||||
and not self.is_standalone():
|
||||
if args.process_filter is not None and not self.is_standalone():
|
||||
logger.critical(
|
||||
"Process filter is only available in standalone mode")
|
||||
sys.exit(2)
|
||||
|
@ -394,8 +392,7 @@ Start the client browser (browser mode):\n\
|
|||
# Check graph output path
|
||||
if args.export_graph and args.path_graph is not None:
|
||||
if not os.access(args.path_graph, os.W_OK):
|
||||
logger.critical(
|
||||
"Graphs output path {} doesn't exist or is not writable".format(args.path_graph))
|
||||
logger.critical("Graphs output path {} doesn't exist or is not writable".format(args.path_graph))
|
||||
sys.exit(2)
|
||||
logger.debug(
|
||||
"Graphs output path is set to {}".format(args.path_graph))
|
||||
|
@ -429,30 +426,26 @@ Start the client browser (browser mode):\n\
|
|||
|
||||
def is_standalone(self):
|
||||
"""Return True if Glances is running in standalone mode."""
|
||||
return not self.args.client \
|
||||
and not self.args.browser \
|
||||
and not self.args.server \
|
||||
and not self.args.webserver
|
||||
return (not self.args.client and
|
||||
not self.args.browser and
|
||||
not self.args.server and
|
||||
not self.args.webserver)
|
||||
|
||||
def is_client(self):
|
||||
"""Return True if Glances is running in client mode."""
|
||||
return (self.args.client or self.args.browser) \
|
||||
and not self.args.server
|
||||
return (self.args.client or self.args.browser) and not self.args.server
|
||||
|
||||
def is_client_browser(self):
|
||||
"""Return True if Glances is running in client browser mode."""
|
||||
return self.args.browser \
|
||||
and not self.args.server
|
||||
return self.args.browser and not self.args.server
|
||||
|
||||
def is_server(self):
|
||||
"""Return True if Glances is running in server mode."""
|
||||
return not self.args.client \
|
||||
and self.args.server
|
||||
return not self.args.client and self.args.server
|
||||
|
||||
def is_webserver(self):
|
||||
"""Return True if Glances is running in Web server mode."""
|
||||
return not self.args.client \
|
||||
and self.args.webserver
|
||||
return not self.args.client and self.args.webserver
|
||||
|
||||
def get_config(self):
|
||||
"""Return configuration file object."""
|
||||
|
|
|
@ -135,8 +135,8 @@ class Outdated(object):
|
|||
logger.debug("Cannot read the version cache file: {}".format(e))
|
||||
else:
|
||||
logger.debug("Read the version cache file")
|
||||
if cached_data['installed_version'] != self.installed_version() or \
|
||||
datetime.now() - cached_data['refresh_date'] > self.max_refresh_date:
|
||||
if (cached_data['installed_version'] != self.installed_version() or
|
||||
datetime.now() - cached_data['refresh_date'] > self.max_refresh_date):
|
||||
# Reset the cache if:
|
||||
# - the installed version is different
|
||||
# - the refresh_date is > max_refresh_date
|
||||
|
|
|
@ -515,9 +515,11 @@ class _GlancesCurses(object):
|
|||
__stat_display = self.__get_stat_display(stats, plugin_max_width)
|
||||
|
||||
# Adapt number of processes to the available space
|
||||
max_processes_displayed = self.screen.getmaxyx()[0] - 11 - \
|
||||
self.get_stats_display_height(__stat_display["alert"]) - \
|
||||
max_processes_displayed = (
|
||||
self.screen.getmaxyx()[0] - 11 -
|
||||
self.get_stats_display_height(__stat_display["alert"]) -
|
||||
self.get_stats_display_height(__stat_display["docker"])
|
||||
)
|
||||
try:
|
||||
if self.args.enable_process_extended and not self.args.process_tree:
|
||||
max_processes_displayed -= 4
|
||||
|
@ -618,10 +620,10 @@ class _GlancesCurses(object):
|
|||
# Space between column
|
||||
self.space_between_column = 0
|
||||
self.new_line()
|
||||
l_uptime = self.get_stats_display_width(stat_display["system"]) \
|
||||
+ self.space_between_column \
|
||||
+ self.get_stats_display_width(stat_display["ip"]) + 3 \
|
||||
+ self.get_stats_display_width(stat_display["uptime"])
|
||||
l_uptime = (self.get_stats_display_width(stat_display["system"]) +
|
||||
self.space_between_column +
|
||||
self.get_stats_display_width(stat_display["ip"]) + 3 +
|
||||
self.get_stats_display_width(stat_display["uptime"]))
|
||||
self.display_plugin(
|
||||
stat_display["system"],
|
||||
display_optional=(self.screen.getmaxyx()[1] >= l_uptime))
|
||||
|
@ -722,8 +724,8 @@ class _GlancesCurses(object):
|
|||
if not self.args.disable_left_sidebar:
|
||||
for s in ['network', 'wifi', 'ports', 'diskio', 'fs', 'irq',
|
||||
'folders', 'raid', 'sensors', 'now']:
|
||||
if (hasattr(self.args, 'enable_' + s) or
|
||||
hasattr(self.args, 'disable_' + s)) and s in stat_display:
|
||||
if ((hasattr(self.args, 'enable_' + s) or
|
||||
hasattr(self.args, 'disable_' + s)) and s in stat_display):
|
||||
self.new_line()
|
||||
self.display_plugin(stat_display[s])
|
||||
|
||||
|
|
|
@ -100,9 +100,7 @@ class Plugin(GlancesPlugin):
|
|||
# Init the return message
|
||||
ret = []
|
||||
|
||||
if not self.stats \
|
||||
or self.stats == {} \
|
||||
or self.is_disable():
|
||||
if not self.stats or self.stats == {} or self.is_disable():
|
||||
return ret
|
||||
|
||||
# Generate the output
|
||||
|
|
|
@ -524,9 +524,7 @@ class Plugin(GlancesPlugin):
|
|||
ret = []
|
||||
|
||||
# Only process if stats exist (and non null) and display plugin enable...
|
||||
if not self.stats \
|
||||
or len(self.stats['containers']) == 0 \
|
||||
or self.is_disable():
|
||||
if not self.stats or len(self.stats['containers']) == 0 or self.is_disable():
|
||||
return ret
|
||||
|
||||
# Build the string message
|
||||
|
|
|
@ -229,8 +229,7 @@ class Plugin(GlancesPlugin):
|
|||
mnt_point = i['mnt_point'][-fsname_max_width + 1:]
|
||||
elif len(i['mnt_point']) + len(i['device_name'].split('/')[-1]) <= fsname_max_width - 3:
|
||||
# If possible concatenate mode info... Glances touch inside :)
|
||||
mnt_point = i['mnt_point'] + \
|
||||
' (' + i['device_name'].split('/')[-1] + ')'
|
||||
mnt_point = i['mnt_point'] + ' (' + i['device_name'].split('/')[-1] + ')'
|
||||
elif len(i['mnt_point']) > fsname_max_width:
|
||||
# Cut mount point name if it is too long
|
||||
mnt_point = '_' + i['mnt_point'][-fsname_max_width + 1:]
|
||||
|
|
|
@ -100,9 +100,9 @@ class Plugin(GlancesPlugin):
|
|||
return 'CAREFUL'
|
||||
elif port['status'] == 0:
|
||||
return 'CRITICAL'
|
||||
elif isinstance(port['status'], (float, int)) and \
|
||||
port['rtt_warning'] is not None and \
|
||||
port['status'] > port['rtt_warning']:
|
||||
elif (isinstance(port['status'], (float, int)) and
|
||||
port['rtt_warning'] is not None and
|
||||
port['status'] > port['rtt_warning']):
|
||||
return 'WARNING'
|
||||
|
||||
return 'OK'
|
||||
|
|
Loading…
Reference in New Issue