Replace list creation with list literal

pull/532/head^2
Alessio Sergi 2015-03-23 00:35:53 +01:00
parent 576883822e
commit 6a8de48502
3 changed files with 20 additions and 30 deletions

View File

@ -118,24 +118,23 @@ class GlancesLogs(object):
# Create the new log item # Create the new log item
# Time is stored in Epoch format # Time is stored in Epoch format
# Epoch -> DMYHMS = datetime.fromtimestamp(epoch) # Epoch -> DMYHMS = datetime.fromtimestamp(epoch)
item = [] item = [
# START DATE time.mktime(datetime.now().timetuple()), # START DATE
item.append(time.mktime(datetime.now().timetuple())) -1, # END DATE
item.append(-1) # END DATE item_state, # STATE: WARNING|CRITICAL
item.append(item_state) # STATE: WARNING|CRITICAL item_type, # TYPE: CPU, LOAD, MEM...
item.append(item_type) # TYPE: CPU, LOAD, MEM... item_value, # MAX
item.append(item_value) # MAX item_value, # AVG
item.append(item_value) # AVG item_value, # MIN
item.append(item_value) # MIN item_value, # SUM
item.append(item_value) # SUM 1, # COUNT
item.append(1) # COUNT # Process list is sorted automatically
# Process list is sorted automaticaly # Overwrite the user choice
# Overwrite the user choise # topprocess = sorted(proc_list, key=lambda process: process[process_auto_by],
# topprocess = sorted(proc_list, key=lambda process: process[process_auto_by], # reverse=True)
# reverse=True) # topprocess[0:3], # TOP 3 PROCESS LIST
# item.append(topprocess[0:3]) # TOP 3 PROCESS LIST [], # TOP 3 PROCESS LIST
item.append([]) # TOP 3 PROCESS LIST proc_desc] # MONITORED PROCESSES DESC
item.append(proc_desc) # MONITORED PROCESSES DESC
# Add the item to the list # Add the item to the list
self.logs_list.insert(0, item) self.logs_list.insert(0, item)

View File

@ -154,8 +154,7 @@ class Plugin(GlancesPlugin):
def get_process_curses_data(self, p, first, args): def get_process_curses_data(self, p, first, args):
""" Get curses data to display for a process. """ """ Get curses data to display for a process. """
ret = [] ret = [self.curse_new_line()]
ret.append(self.curse_new_line())
# CPU # CPU
if 'cpu_percent' in p and p['cpu_percent'] is not None and p['cpu_percent'] != '': if 'cpu_percent' in p and p['cpu_percent'] is not None and p['cpu_percent'] != '':
msg = '{0:>6.1f}'.format(p['cpu_percent']) msg = '{0:>6.1f}'.format(p['cpu_percent'])

View File

@ -63,8 +63,7 @@ class Plugin(GlancesPlugin):
if self.input_method == 'local': if self.input_method == 'local':
# Update stats using the standard system lib # Update stats using the standard system lib
uptime = datetime.now() - \ uptime = datetime.now() - datetime.fromtimestamp(psutil.boot_time())
datetime.fromtimestamp(psutil.boot_time())
# Convert uptime to string (because datetime is not JSONifi) # Convert uptime to string (because datetime is not JSONifi)
self.stats = str(uptime).split('.')[0] self.stats = str(uptime).split('.')[0]
@ -82,11 +81,4 @@ class Plugin(GlancesPlugin):
def msg_curse(self, args=None): def msg_curse(self, args=None):
"""Return the string to display in the curse interface.""" """Return the string to display in the curse interface."""
# Init the return message return [self.curse_add_line(_("Uptime: {0}").format(self.stats))]
ret = []
# Add the line with decoration
ret.append(self.curse_add_line(_("Uptime: {0}").format(self.stats)))
# Return the message with decoration
return ret