mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-29 20:21:35 +03:00
Replace list creation with list literal
This commit is contained in:
parent
576883822e
commit
6a8de48502
@ -118,24 +118,23 @@ class GlancesLogs(object):
|
||||
# Create the new log item
|
||||
# Time is stored in Epoch format
|
||||
# Epoch -> DMYHMS = datetime.fromtimestamp(epoch)
|
||||
item = []
|
||||
# START DATE
|
||||
item.append(time.mktime(datetime.now().timetuple()))
|
||||
item.append(-1) # END DATE
|
||||
item.append(item_state) # STATE: WARNING|CRITICAL
|
||||
item.append(item_type) # TYPE: CPU, LOAD, MEM...
|
||||
item.append(item_value) # MAX
|
||||
item.append(item_value) # AVG
|
||||
item.append(item_value) # MIN
|
||||
item.append(item_value) # SUM
|
||||
item.append(1) # COUNT
|
||||
# Process list is sorted automaticaly
|
||||
# Overwrite the user choise
|
||||
# topprocess = sorted(proc_list, key=lambda process: process[process_auto_by],
|
||||
# reverse=True)
|
||||
# item.append(topprocess[0:3]) # TOP 3 PROCESS LIST
|
||||
item.append([]) # TOP 3 PROCESS LIST
|
||||
item.append(proc_desc) # MONITORED PROCESSES DESC
|
||||
item = [
|
||||
time.mktime(datetime.now().timetuple()), # START DATE
|
||||
-1, # END DATE
|
||||
item_state, # STATE: WARNING|CRITICAL
|
||||
item_type, # TYPE: CPU, LOAD, MEM...
|
||||
item_value, # MAX
|
||||
item_value, # AVG
|
||||
item_value, # MIN
|
||||
item_value, # SUM
|
||||
1, # COUNT
|
||||
# Process list is sorted automatically
|
||||
# Overwrite the user choice
|
||||
# topprocess = sorted(proc_list, key=lambda process: process[process_auto_by],
|
||||
# reverse=True)
|
||||
# topprocess[0:3], # TOP 3 PROCESS LIST
|
||||
[], # TOP 3 PROCESS LIST
|
||||
proc_desc] # MONITORED PROCESSES DESC
|
||||
|
||||
# Add the item to the list
|
||||
self.logs_list.insert(0, item)
|
||||
|
@ -154,8 +154,7 @@ class Plugin(GlancesPlugin):
|
||||
|
||||
def get_process_curses_data(self, p, first, args):
|
||||
""" Get curses data to display for a process. """
|
||||
ret = []
|
||||
ret.append(self.curse_new_line())
|
||||
ret = [self.curse_new_line()]
|
||||
# CPU
|
||||
if 'cpu_percent' in p and p['cpu_percent'] is not None and p['cpu_percent'] != '':
|
||||
msg = '{0:>6.1f}'.format(p['cpu_percent'])
|
||||
|
@ -63,8 +63,7 @@ class Plugin(GlancesPlugin):
|
||||
|
||||
if self.input_method == 'local':
|
||||
# Update stats using the standard system lib
|
||||
uptime = datetime.now() - \
|
||||
datetime.fromtimestamp(psutil.boot_time())
|
||||
uptime = datetime.now() - datetime.fromtimestamp(psutil.boot_time())
|
||||
|
||||
# Convert uptime to string (because datetime is not JSONifi)
|
||||
self.stats = str(uptime).split('.')[0]
|
||||
@ -82,11 +81,4 @@ class Plugin(GlancesPlugin):
|
||||
|
||||
def msg_curse(self, args=None):
|
||||
"""Return the string to display in the curse interface."""
|
||||
# Init the return message
|
||||
ret = []
|
||||
|
||||
# Add the line with decoration
|
||||
ret.append(self.curse_add_line(_("Uptime: {0}").format(self.stats)))
|
||||
|
||||
# Return the message with decoration
|
||||
return ret
|
||||
return [self.curse_add_line(_("Uptime: {0}").format(self.stats))]
|
||||
|
Loading…
Reference in New Issue
Block a user