示例#1
0
文件: password.py 项目: zysr/glances
    def save_password(self, hashed_password):
        """Save the hashed password to the Glances folder."""
        # Create the glances directory
        safe_makedirs(self.password_dir)

        # Create/overwrite the password file
        with open(self.password_file, 'wb') as file_pwd:
            file_pwd.write(b(hashed_password))
示例#2
0
    def _save_cache(self):
        """Save data to the cache file."""
        # Create the cache directory
        safe_makedirs(self.cache_dir)

        # Create/overwrite the cache file
        with open(self.cache_file, 'wb') as f:
            pickle.dump(self.data, f)
示例#3
0
    def save_password(self, hashed_password):
        """Save the hashed password to the Glances folder."""
        # Create the glances directory
        safe_makedirs(self.password_dir)

        # Create/overwrite the password file
        with open(self.password_file, 'wb') as file_pwd:
            file_pwd.write(b(hashed_password))
示例#4
0
    def _save_cache(self):
        """Save data to the cache file."""
        # Create the cache directory
        safe_makedirs(self.cache_dir)

        # Create/overwrite the cache file
        try:
            with open(self.cache_file, 'wb') as f:
                pickle.dump(self.data, f)
        except Exception as e:
            logger.error("Cannot write version to cache file {} ({})".format(self.cache_file, e))
示例#5
0
    def _save_cache(self):
        """Save data to the cache file."""
        # Create the cache directory
        safe_makedirs(self.cache_dir)

        # Create/overwrite the cache file
        try:
            with open(self.cache_file, 'wb') as f:
                pickle.dump(self.data, f)
        except Exception as e:
            logger.error("Cannot write version to cache file {} ({})".format(self.cache_file, e))
示例#6
0
import logging.config

from glances.globals import BSD, LINUX, MACOS, SUNOS, WINDOWS, WSL
from glances.globals import safe_makedirs

# Choose the good place for the log file (see issue #1575)
# Default root path
if 'HOME' in os.environ:
    _XDG_CACHE_HOME = os.path.join(os.environ['HOME'], '.local', 'share')
else:
    _XDG_CACHE_HOME = ''
# Define the glances log file
if 'XDG_CACHE_HOME' in os.environ \
        and os.path.isdir(os.environ['XDG_CACHE_HOME']) \
        and os.access(os.environ['XDG_CACHE_HOME'], os.W_OK):
    safe_makedirs(os.path.join(os.environ['XDG_CACHE_HOME'], 'glances'))
    LOG_FILENAME = os.path.join(os.environ['XDG_CACHE_HOME'], 'glances', 'glances.log')
elif os.path.isdir(_XDG_CACHE_HOME) and os.access(_XDG_CACHE_HOME, os.W_OK):
    safe_makedirs(os.path.join(_XDG_CACHE_HOME, 'glances'))
    LOG_FILENAME = os.path.join(_XDG_CACHE_HOME, 'glances', 'glances.log')
else:
    LOG_FILENAME = os.path.join(tempfile.gettempdir(),
                                'glances-{}.log'.format(getpass.getuser()))

# Define the logging configuration
LOGGING_CFG = {
    "version": 1,
    "disable_existing_loggers": "False",
    "root": {
        "level": "INFO",
        "handlers": ["file", "console"]