mirror of https://github.com/nicolargo/glances
chore: format - missed out black changes
parent
6a0e9b2bf6
commit
0d47356f4c
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue