mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-22 16:51:35 +03:00
Merge branch 'develop' of github.com:nicolargo/glances into issue1985
This commit is contained in:
commit
2fb510afb0
@ -173,11 +173,7 @@ class Config(object):
|
||||
if not self.parser.has_section('global'):
|
||||
self.parser.add_section('global')
|
||||
self.set_default('global', 'strftime_format', '')
|
||||
|
||||
# check_update
|
||||
if not self.parser.has_section('global'):
|
||||
self.parser.add_section('global')
|
||||
self.set_default('global', 'check_update', 'false')
|
||||
self.set_default('global', 'check_update', 'true')
|
||||
|
||||
# Quicklook
|
||||
if not self.parser.has_section('quicklook'):
|
||||
|
@ -111,7 +111,6 @@ class Export(GlancesExport):
|
||||
|
||||
# Write input to the Cassandra table
|
||||
try:
|
||||
|
||||
stmt = "INSERT INTO {} (plugin, time, stat) VALUES (?, ?, ?)".format(self.table)
|
||||
query = self.session.prepare(stmt)
|
||||
self.session.execute(query, (name, uuid_from_time(datetime.now()), data))
|
||||
|
@ -47,10 +47,7 @@ class Export(GlancesExport):
|
||||
if not self.export_enable:
|
||||
return None
|
||||
|
||||
server_uri = 'mongodb://%s:%s@%s:%s' % (quote_plus(self.user),
|
||||
quote_plus(self.password),
|
||||
self.host,
|
||||
self.port)
|
||||
server_uri = 'mongodb://%s:%s@%s:%s' % (quote_plus(self.user), quote_plus(self.password), self.host, self.port)
|
||||
|
||||
try:
|
||||
client = pymongo.MongoClient(server_uri)
|
||||
|
@ -49,10 +49,15 @@ class Outdated(object):
|
||||
|
||||
# Set default value...
|
||||
self.data = {u'installed_version': __version__, u'latest_version': '0.0', u'refresh_date': datetime.now()}
|
||||
# Read the configuration file
|
||||
self.load_config(config)
|
||||
|
||||
# Disable update check if `packaging` is not installed
|
||||
if not PACKAGING_IMPORT:
|
||||
self.args.disable_check_update = True
|
||||
|
||||
# Read the configuration file only if update check is not explicitly disabled
|
||||
if not self.args.disable_check_update:
|
||||
self.load_config(config)
|
||||
|
||||
logger.debug("Check Glances version up-to-date: {}".format(not self.args.disable_check_update))
|
||||
|
||||
# And update !
|
||||
|
@ -127,10 +127,8 @@ class GlancesBottle(object):
|
||||
if username == self.args.username:
|
||||
from glances.password import GlancesPassword
|
||||
|
||||
pwd = GlancesPassword(username=username,
|
||||
config=self.config)
|
||||
return pwd.check_password(self.args.password,
|
||||
pwd.get_hash(password))
|
||||
pwd = GlancesPassword(username=username, config=self.config)
|
||||
return pwd.check_password(self.args.password, pwd.get_hash(password))
|
||||
else:
|
||||
return False
|
||||
|
||||
@ -162,7 +160,9 @@ class GlancesBottle(object):
|
||||
'/api/%s/<plugin>/<item>/history/<nb:int>' % self.API_VERSION, method="GET", callback=self._api_item_history
|
||||
)
|
||||
self._app.route('/api/%s/<plugin>/<item>/<value>' % self.API_VERSION, method="GET", callback=self._api_value)
|
||||
self._app.route('/api/%s/<plugin>/<item>/<value:path>' % self.API_VERSION, method="GET", callback=self._api_value)
|
||||
self._app.route(
|
||||
'/api/%s/<plugin>/<item>/<value:path>' % self.API_VERSION, method="GET", callback=self._api_value
|
||||
)
|
||||
bindmsg = 'Glances RESTful API Server started on {}api/{}/'.format(self.bind_url, self.API_VERSION)
|
||||
logger.info(bindmsg)
|
||||
|
||||
|
@ -45,17 +45,12 @@ class GlancesPassword(object):
|
||||
|
||||
def get_hash(self, plain_password, salt=''):
|
||||
"""Return the hashed password, salt + pbkdf2_hmac."""
|
||||
return to_hex(hashlib.pbkdf2_hmac('sha256',
|
||||
plain_password.encode(),
|
||||
salt.encode(),
|
||||
100000,
|
||||
dklen=128))
|
||||
return to_hex(hashlib.pbkdf2_hmac('sha256', plain_password.encode(), salt.encode(), 100000, dklen=128))
|
||||
|
||||
def hash_password(self, plain_password):
|
||||
"""Hash password with a salt based on UUID (universally unique identifier)."""
|
||||
salt = uuid.uuid4().hex
|
||||
encrypted_password = self.get_hash(plain_password,
|
||||
salt=salt)
|
||||
encrypted_password = self.get_hash(plain_password, salt=salt)
|
||||
return salt + '$' + encrypted_password
|
||||
|
||||
def check_password(self, hashed_password, plain_password):
|
||||
@ -64,8 +59,7 @@ class GlancesPassword(object):
|
||||
Return the comparison with the encrypted_password.
|
||||
"""
|
||||
salt, encrypted_password = hashed_password.split('$')
|
||||
re_encrypted_password = self.get_hash(plain_password,
|
||||
salt = salt)
|
||||
re_encrypted_password = self.get_hash(plain_password, salt=salt)
|
||||
return encrypted_password == re_encrypted_password
|
||||
|
||||
def get_password(self, description='', confirm=False, clear=False):
|
||||
|
@ -51,7 +51,7 @@ def __secure_popen(cmd):
|
||||
for sub_cmd in cmd.split('|'):
|
||||
# Split by space character, but do no split spaces within quotes (remove surrounding quotes, though)
|
||||
tmp_split = [_ for _ in list(filter(None, re.split(r'(\s+)|(".*?"+?)|(\'.*?\'+?)', sub_cmd))) if _ != ' ']
|
||||
sub_cmd_split = [_[1:-1] if (_[0]==_[-1]=='"') or (_[0]==_[-1]=='\'') else _ for _ in tmp_split]
|
||||
sub_cmd_split = [_[1:-1] if (_[0] == _[-1] == '"') or (_[0] == _[-1] == '\'') else _ for _ in tmp_split]
|
||||
p = Popen(sub_cmd_split, shell=False, stdin=sub_cmd_stdin, stdout=PIPE, stderr=PIPE)
|
||||
if p_last is not None:
|
||||
# Allow p_last to receive a SIGPIPE if p exits.
|
||||
|
@ -94,7 +94,6 @@ class GlancesXMLRPCServer(SimpleXMLRPCServer, object):
|
||||
finished = False
|
||||
|
||||
def __init__(self, bind_address, bind_port=61209, requestHandler=GlancesXMLRPCHandler, config=None):
|
||||
|
||||
self.bind_address = bind_address
|
||||
self.bind_port = bind_port
|
||||
self.config = config
|
||||
|
@ -24,7 +24,6 @@ class GlancesSNMPClient(object):
|
||||
"""SNMP client class (based on pysnmp library)."""
|
||||
|
||||
def __init__(self, host='localhost', port=161, version='2c', community='public', user='private', auth=''):
|
||||
|
||||
super(GlancesSNMPClient, self).__init__()
|
||||
self.cmdGen = cmdgen.CommandGenerator()
|
||||
|
||||
|
@ -14,7 +14,6 @@ import time
|
||||
|
||||
from glances.globals import WINDOWS
|
||||
from glances.logger import logger
|
||||
from glances.outputs.glances_stdout_json import GlancesStdoutJson
|
||||
from glances.processes import glances_processes
|
||||
from glances.stats import GlancesStats
|
||||
from glances.outputs.glances_curses import GlancesCursesStandalone
|
||||
@ -193,3 +192,6 @@ class GlancesStandalone(object):
|
||||
)
|
||||
)
|
||||
print("You should consider upgrading using: pip install --upgrade glances")
|
||||
print("Disable this warning temporarily using: glances --disable-check-update")
|
||||
print("To disable it permanently, refer config reference at "
|
||||
"https://glances.readthedocs.io/en/latest/config.html#syntax")
|
||||
|
Loading…
Reference in New Issue
Block a user