2nd pass of dos2unix and flake8

pull/354/head
Alessio Sergi 2014-03-11 10:22:44 +01:00
parent f10c9a3e7d
commit d9a2bcadc6
6 changed files with 280 additions and 318 deletions

View File

@ -22,6 +22,7 @@
# Note: others Glances libs will be imported optionnaly
from .core.glances_main import GlancesMain
def main(argv=None):
# Create the Glances main instance
core = GlancesMain()

View File

@ -67,7 +67,6 @@ class GlancesClient():
# Init screen
self.screen = glancesCurses(args=args)
def login(self):
try:
client_version = self.client.init()
@ -84,7 +83,6 @@ class GlancesClient():
# print "Server version: {}\nClient version: {}\n".format(__version__, client_version)
return __version__[:3] == client_version[:3]
# def client_get_limits(self):
# try:
# serverlimits = json.loads(self.client.getAllLimits())
@ -93,7 +91,6 @@ class GlancesClient():
# else:
# return serverlimits
# def client_get_monitored(self):
# try:
# servermonitored = json.loads(self.client.getAllMonitored())
@ -102,7 +99,6 @@ class GlancesClient():
# else:
# return servermonitored
def update(self):
# Get stats from server
try:
@ -113,7 +109,6 @@ class GlancesClient():
# Put it in the internal dict
self.stats.update(server_stats)
def serve_forever(self):
while True:
# Update the stats

View File

@ -18,26 +18,17 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Import system libs
import sys
import socket
import json
# Import Glances libs
from ..core.glances_limits import glancesLimits
from ..core.glances_stats import GlancesStats
from ..outputs.glances_curses import glancesCurses
class GlancesStandalone():
"""
This class creates and manages the Glances standalone session
"""
def __init__(self,
config=None,
args=None,
refresh_time=3,
use_bold=True):
def __init__(self, config=None, args=None, refresh_time=3, use_bold=True):
# Init stats
self.stats = GlancesStats(config)
@ -64,7 +55,6 @@ class GlancesStandalone():
# Init screen
self.screen = glancesCurses(args=args)
def serve_forever(self):
while True:
# Update system informations

View File

@ -19,8 +19,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Import system libs
import sys
import os
import sys
import collections
# Import Glances libs
@ -35,7 +35,6 @@ class GlancesStats(object):
# Internal dictionnary with all plugins instances
_plugins = {}
def __init__(self, config=None):
"""
Init the stats
@ -47,7 +46,6 @@ class GlancesStats(object):
# Load the limits
self.load_limits(config)
def __getattr__(self, item):
"""
Overwrite the getattr in case of attribute is not found
@ -71,7 +69,6 @@ class GlancesStats(object):
# Default behavior
raise AttributeError(item)
def load_plugins(self):
"""
Load all plugins in the "plugins" folder
@ -93,7 +90,6 @@ class GlancesStats(object):
plugname = os.path.basename(plug)[len(header):-3].lower()
self._plugins[plugname] = m.Plugin()
def load_limits(self, config):
"""
Load the stats limits
@ -103,7 +99,6 @@ class GlancesStats(object):
for p in self._plugins:
self._plugins[p].load_limits(config)
def __update__(self, input_stats):
"""
Update the stats
@ -123,18 +118,15 @@ class GlancesStats(object):
# print "Plugins: %s" % self._plugins
self._plugins[p].set(input_stats[p])
def update(self, input_stats={}):
# !!! Why __update__ and update method ?
# Update the stats
self.__update__(input_stats)
def get_plugin_list(self):
# Return the plugin list
self._plugins
def get_plugin(self, plugin_name):
# Return the plugin name
if (plugin_name in self._plugins):
@ -153,8 +145,7 @@ class GlancesStatsServer(GlancesStats):
# all_stats is a dict of dicts filled by the server
self.all_stats = collections.defaultdict(dict)
def update(self, input_stats = {}):
def update(self, input_stats={}):
"""
Update the stats
"""
@ -166,7 +157,6 @@ class GlancesStatsServer(GlancesStats):
for p in self._plugins:
self.all_stats[p] = self._plugins[p].get_raw()
def getAll(self):
return self.all_stats
@ -182,8 +172,7 @@ class GlancesStatsClient(GlancesStats):
# all_stats is a dict of dicts filled by the server
self.all_stats = collections.defaultdict(dict)
def update(self, input_stats = {}):
def update(self, input_stats={}):
"""
Update the stats
"""
@ -195,6 +184,5 @@ class GlancesStatsClient(GlancesStats):
for p in self._plugins:
self.all_stats[p] = self._plugins[p].get_raw()
def getAll(self):
return self.all_stats

View File

@ -148,7 +148,6 @@ class glancesCurses:
self.term_window.nodelay(1)
self.pressedkey = -1
def __getkey(self, window):
"""
A getKey function to catch ESC key AND Numlock key (issue #163)
@ -163,7 +162,6 @@ class glancesCurses:
else:
return keycode[0]
def __catchKey(self):
# Get key
#~ self.pressedkey = self.term_window.getch()
@ -235,7 +233,6 @@ class glancesCurses:
# Return the key code
return self.pressedkey
def end(self):
# Shutdown the curses window
curses.echo()
@ -243,7 +240,6 @@ class glancesCurses:
curses.curs_set(1)
curses.endwin()
def display(self, stats, cs_status="None"):
"""
Display stats on the screen
@ -318,10 +314,7 @@ class glancesCurses:
self.display_plugin(stats_processlist, max_y=(screen_y - self.get_curse_height(stats_alert) - 3))
self.display_plugin(stats_alert)
def display_plugin(self, plugin_stats,
display_optional=True,
max_y=65535):
def display_plugin(self, plugin_stats, display_optional=True, max_y=65535):
"""
Display the plugin_stats on the screen
If display_optional=True display the optional stats
@ -389,12 +382,10 @@ class glancesCurses:
if (plugin_stats['line'] > -1):
self.line_to_y[plugin_stats['line'] + 1] = y + self.space_between_line
def erase(self):
# Erase the content of the screen
self.term_window.erase()
def flush(self, stats, cs_status="None"):
"""
Clear and update screen
@ -407,7 +398,6 @@ class glancesCurses:
self.erase()
self.display(stats, cs_status=cs_status)
def update(self, stats, cs_status="None"):
"""
Update the screen and wait __refresh_time sec / catch key every 100 ms
@ -430,7 +420,6 @@ class glancesCurses:
# Wait 100ms...
curses.napms(100)
def get_curse_width(self, curse_msg, without_option=False):
# Return the width of the formated curses message
# The height is defined by the maximum line
@ -438,24 +427,23 @@ class glancesCurses:
try:
if (without_option):
# Size without options
c = len(max(''.join([ (i['msg'] if not i['optional'] else "")
for i in curse_msg['msgdict'] ]).split('\n'), key=len))
c = len(max(''.join([(i['msg'] if not i['optional'] else "")
for i in curse_msg['msgdict']]).split('\n'), key=len))
else:
# Size with all options
c = len(max(''.join([ i['msg']
for i in curse_msg['msgdict'] ]).split('\n'), key=len))
c = len(max(''.join([i['msg']
for i in curse_msg['msgdict']]).split('\n'), key=len))
except:
return 0
else:
return c
def get_curse_height(self, curse_msg):
# Return the height of the formated curses message
# The height is defined by the number of '\n'
try:
c = [ i['msg'] for i in curse_msg['msgdict']].count('\n')
c = [i['msg'] for i in curse_msg['msgdict']].count('\n')
except:
return 0
else: