mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-24 01:35:23 +03:00
Miscellaneous fixes and improvements
Rules of thumb: - setup.py only <=, >= - requirements.txt only ==
This commit is contained in:
parent
6fa10b5a2b
commit
3687321b30
@ -8,5 +8,6 @@ include glances/outputs/static/css/*.css
|
||||
include glances/outputs/static/js/*.js
|
||||
include man/glances.1
|
||||
recursive-include docs images/*.png glances-doc.html
|
||||
recursive-include glances *.py
|
||||
recursive-include i18n *.mo
|
||||
prune docs/_build
|
||||
|
@ -21,11 +21,14 @@ Init the Glances software
|
||||
"""
|
||||
|
||||
# Import system lib
|
||||
import gettext
|
||||
import locale
|
||||
import signal
|
||||
import sys
|
||||
|
||||
# Import Glances libs
|
||||
# Note: others Glances libs will be imported optionally
|
||||
from glances.core.glances_globals import gettext_domain, locale_dir
|
||||
from glances.core.glances_main import GlancesMain
|
||||
|
||||
|
||||
@ -58,9 +61,13 @@ def end():
|
||||
def main():
|
||||
"""
|
||||
Main entry point for Glances
|
||||
|
||||
Select the mode (standalone, client or server)
|
||||
Run it...
|
||||
"""
|
||||
# Setup translations
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
gettext.install(gettext_domain, locale_dir)
|
||||
|
||||
# Share global var
|
||||
global core, standalone, client, server
|
||||
|
@ -30,11 +30,12 @@ except ImportError: # Python 2
|
||||
# Import Glances lib
|
||||
from glances.core.glances_globals import (
|
||||
__appname__,
|
||||
is_BSD,
|
||||
is_Linux,
|
||||
is_Mac,
|
||||
is_Windows,
|
||||
is_python3,
|
||||
is_bsd,
|
||||
is_linux,
|
||||
is_mac,
|
||||
is_py3,
|
||||
is_windows,
|
||||
sys_prefix,
|
||||
work_path
|
||||
)
|
||||
|
||||
@ -62,7 +63,7 @@ class Config(object):
|
||||
for path in self.get_paths_list():
|
||||
if os.path.isfile(path) and os.path.getsize(path) > 0:
|
||||
try:
|
||||
if is_python3:
|
||||
if is_py3:
|
||||
self.parser.read(path, encoding='utf-8')
|
||||
else:
|
||||
self.parser.read(path)
|
||||
@ -105,26 +106,23 @@ class Config(object):
|
||||
if os.path.exists(conf_path):
|
||||
paths.append(os.path.join(conf_path, self.filename))
|
||||
|
||||
if is_Linux or is_BSD:
|
||||
if is_linux or is_bsd:
|
||||
paths.append(os.path.join(
|
||||
os.environ.get('XDG_CONFIG_HOME') or os.path.expanduser('~/.config'),
|
||||
__appname__, self.filename))
|
||||
elif is_Mac:
|
||||
if is_linux:
|
||||
paths.append(os.path.join('/etc', __appname__, self.filename))
|
||||
else:
|
||||
paths.append(os.path.join(sys.prefix, 'etc', __appname__, self.filename))
|
||||
elif is_mac:
|
||||
paths.append(os.path.join(
|
||||
os.path.expanduser('~/Library/Application Support/'),
|
||||
__appname__, self.filename))
|
||||
elif is_Windows:
|
||||
paths.append(os.path.join(
|
||||
os.environ.get('APPDATA'), __appname__, self.filename))
|
||||
|
||||
if is_Linux:
|
||||
paths.append(os.path.join('/etc', __appname__, self.filename))
|
||||
elif is_BSD:
|
||||
paths.append(os.path.join(
|
||||
sys.prefix, 'etc', __appname__, self.filename))
|
||||
elif is_Mac:
|
||||
paths.append(os.path.join(
|
||||
sys_prefix, 'etc', __appname__, self.filename))
|
||||
elif is_windows:
|
||||
paths.append(os.path.join(
|
||||
os.environ.get('APPDATA'), __appname__, self.filename))
|
||||
|
||||
return paths
|
||||
|
||||
|
@ -24,8 +24,6 @@ __author__ = 'Nicolas Hennion <nicolas@nicolargo.com>'
|
||||
__license__ = 'LGPL'
|
||||
|
||||
# Import system libs
|
||||
import gettext
|
||||
import locale
|
||||
import os
|
||||
import sys
|
||||
|
||||
@ -36,11 +34,9 @@ except ImportError:
|
||||
print('psutil module not found. Glances cannot start.')
|
||||
sys.exit(1)
|
||||
|
||||
# psutil version
|
||||
psutil_version = tuple([int(num) for num in __psutil_version__.split('.')])
|
||||
|
||||
# Check psutil version
|
||||
psutil_min_version = (2, 0, 0)
|
||||
psutil_version = tuple([int(num) for num in __psutil_version__.split('.')])
|
||||
if psutil_version < psutil_min_version:
|
||||
print('psutil version %s detected.' % __psutil_version__)
|
||||
print('psutil 2.0 or higher is needed. Glances cannot start.')
|
||||
@ -51,20 +47,18 @@ work_path = os.path.realpath(os.path.dirname(__file__))
|
||||
appname_path = os.path.split(sys.argv[0])[0]
|
||||
sys_prefix = os.path.realpath(os.path.dirname(appname_path))
|
||||
|
||||
# Is this Python 3?
|
||||
is_python3 = sys.version_info >= (3, 2)
|
||||
# PY3?
|
||||
is_py3 = sys.version_info >= (3, 2)
|
||||
|
||||
# Operating system flag
|
||||
# Note: Somes libs depends of OS
|
||||
is_BSD = sys.platform.find('bsd') != -1
|
||||
is_Linux = sys.platform.startswith('linux')
|
||||
is_Mac = sys.platform.startswith('darwin')
|
||||
is_Windows = sys.platform.startswith('win')
|
||||
is_bsd = sys.platform.find('bsd') != -1
|
||||
is_linux = sys.platform.startswith('linux')
|
||||
is_mac = sys.platform.startswith('darwin')
|
||||
is_windows = sys.platform.startswith('win')
|
||||
|
||||
# i18n
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
gettext_domain = 'glances'
|
||||
# get locale directory
|
||||
gettext_domain = __appname__
|
||||
i18n_path = os.path.realpath(os.path.join(work_path, '..', '..', 'i18n'))
|
||||
sys_i18n_path = os.path.join(sys_prefix, 'share', 'locale')
|
||||
if os.path.exists(i18n_path):
|
||||
@ -73,7 +67,6 @@ elif os.path.exists(sys_i18n_path):
|
||||
locale_dir = sys_i18n_path
|
||||
else:
|
||||
locale_dir = None
|
||||
gettext.install(gettext_domain, locale_dir)
|
||||
|
||||
# Instances shared between all Glances' scripts
|
||||
# ===============================================
|
||||
|
@ -20,7 +20,7 @@
|
||||
import psutil
|
||||
|
||||
# Import Glances lib
|
||||
from glances.core.glances_globals import is_BSD, is_Mac, is_Windows
|
||||
from glances.core.glances_globals import is_bsd, is_mac, is_windows
|
||||
from glances.core.glances_timer import Timer, getTimeSinceLastUpdate
|
||||
|
||||
|
||||
@ -130,7 +130,7 @@ class glancesProcesses:
|
||||
# If io_tag = 0 > Access denied (display "?")
|
||||
# If io_tag = 1 > No access denied (display the IO rate)
|
||||
# Note Disk IO stat not available on Mac OS
|
||||
if not is_Mac:
|
||||
if not is_mac:
|
||||
try:
|
||||
# Get the process IO counters
|
||||
proc_io = proc.io_counters()
|
||||
@ -182,9 +182,9 @@ class glancesProcesses:
|
||||
# ignore the 'idle' process on Windows and *BSD
|
||||
# ignore the 'kernel_task' process on OS X
|
||||
# waiting for upstream patch from psutil
|
||||
if (is_BSD and procstat['name'] == 'idle' or
|
||||
is_Windows and procstat['name'] == 'System Idle Process' or
|
||||
is_Mac and procstat['name'] == 'kernel_task'):
|
||||
if (is_bsd and procstat['name'] == 'idle' or
|
||||
is_windows and procstat['name'] == 'System Idle Process' or
|
||||
is_mac and procstat['name'] == 'kernel_task'):
|
||||
continue
|
||||
# Update processcount (global statistics)
|
||||
try:
|
||||
|
@ -21,11 +21,11 @@
|
||||
import sys
|
||||
|
||||
# Import Glances lib
|
||||
from glances.core.glances_globals import glances_logs, glances_processes, is_Windows
|
||||
from glances.core.glances_globals import glances_logs, glances_processes, is_windows
|
||||
from glances.core.glances_timer import Timer
|
||||
|
||||
# Import curses lib for "normal" operating system and consolelog for Windows
|
||||
if not is_Windows:
|
||||
if not is_windows:
|
||||
try:
|
||||
import curses
|
||||
import curses.panel
|
||||
|
@ -90,7 +90,7 @@ class Plugin(GlancesPlugin):
|
||||
msg = "{0:8}".format(_("LOAD"))
|
||||
ret.append(self.curse_add_line(msg, "TITLE"))
|
||||
# Core number
|
||||
msg = "{0:>6}".format(str(self.core_plugin.update()["log"])+_("core"))
|
||||
msg = "{0:>6}".format(str(self.core_plugin.update()["log"]) + _("-core"))
|
||||
ret.append(self.curse_add_line(msg))
|
||||
# New line
|
||||
ret.append(self.curse_new_line())
|
||||
|
@ -25,7 +25,7 @@ except ImportError:
|
||||
pass
|
||||
|
||||
# Import Glances lib
|
||||
from glances.core.glances_globals import is_python3
|
||||
from glances.core.glances_globals import is_py3
|
||||
from glances.plugins.glances_hddtemp import Plugin as HddTempPlugin
|
||||
from glances.plugins.glances_plugin import GlancesPlugin
|
||||
|
||||
@ -124,7 +124,7 @@ class Plugin(GlancesPlugin):
|
||||
# Header
|
||||
msg = "{0:18}".format(_("SENSORS"))
|
||||
ret.append(self.curse_add_line(msg, "TITLE"))
|
||||
if is_python3:
|
||||
if is_py3:
|
||||
msg = "{0:>5}".format(_("°C"))
|
||||
else:
|
||||
msg = "{0:>6}".format(_("°C"))
|
||||
|
@ -1 +1 @@
|
||||
psutil>=2.1.0
|
||||
psutil==2.1.1
|
||||
|
56
setup.py
56
setup.py
@ -1,38 +1,44 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import glob
|
||||
import os
|
||||
import sys
|
||||
import glob
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
data_files = [
|
||||
('share/doc/glances', ['AUTHORS', 'COPYING', 'NEWS', 'README.rst',
|
||||
'conf/glances.conf', 'docs/glances-doc.html']),
|
||||
('share/doc/glances/images', glob.glob('docs/images/*.png')),
|
||||
('share/man/man1', ['man/glances.1'])
|
||||
]
|
||||
|
||||
if hasattr(sys, 'real_prefix') or 'bsd' in sys.platform:
|
||||
conf_path = os.path.join(sys.prefix, 'etc', 'glances')
|
||||
elif not hasattr(sys, 'real_prefix') and 'linux' in sys.platform:
|
||||
conf_path = os.path.join('/etc', 'glances')
|
||||
elif 'darwin' in sys.platform:
|
||||
conf_path = os.path.join('/usr/local', 'etc', 'glances')
|
||||
elif 'win32' in sys.platform:
|
||||
conf_path = os.path.join(os.environ.get('APPDATA'), 'glances')
|
||||
data_files.append((conf_path, ['conf/glances.conf']))
|
||||
def get_data_files():
|
||||
data_files = [
|
||||
('share/doc/glances', ['AUTHORS', 'COPYING', 'NEWS', 'README.rst',
|
||||
'conf/glances.conf', 'docs/glances-doc.html']),
|
||||
('share/doc/glances/images', glob.glob('docs/images/*.png')),
|
||||
('share/man/man1', ['man/glances.1'])
|
||||
]
|
||||
|
||||
for mo in glob.glob('i18n/*/LC_MESSAGES/*.mo'):
|
||||
data_files.append((os.path.dirname(mo).replace('i18n/', 'share/locale/'), [mo]))
|
||||
if hasattr(sys, 'real_prefix') or 'bsd' in sys.platform:
|
||||
conf_path = os.path.join(sys.prefix, 'etc', 'glances')
|
||||
elif not hasattr(sys, 'real_prefix') and 'linux' in sys.platform:
|
||||
conf_path = os.path.join('/etc', 'glances')
|
||||
elif 'darwin' in sys.platform:
|
||||
conf_path = os.path.join('/usr/local', 'etc', 'glances')
|
||||
elif 'win32' in sys.platform:
|
||||
conf_path = os.path.join(os.environ.get('APPDATA'), 'glances')
|
||||
data_files.append((conf_path, ['conf/glances.conf']))
|
||||
|
||||
if sys.platform.startswith('win'):
|
||||
requires = ['psutil>=2.0.0', 'colorconsole==0.6']
|
||||
else:
|
||||
for mo in glob.glob('i18n/*/LC_MESSAGES/*.mo'):
|
||||
data_files.append((os.path.dirname(mo).replace('i18n/', 'share/locale/'), [mo]))
|
||||
|
||||
return data_files
|
||||
|
||||
|
||||
def get_requires():
|
||||
requires = ['psutil>=2.0.0']
|
||||
if sys.platform.startswith('win'):
|
||||
requires += ['colorconsole']
|
||||
if sys.version_info < (2, 7):
|
||||
requires += ['argparse']
|
||||
|
||||
if sys.version_info < (2, 7):
|
||||
requires += ['argparse']
|
||||
return requires
|
||||
|
||||
setup(
|
||||
name='Glances',
|
||||
@ -45,7 +51,7 @@ setup(
|
||||
# download_url='https://s3.amazonaws.com/glances/glances-2.0.tar.gz',
|
||||
license="LGPL",
|
||||
keywords="cli curses monitoring system",
|
||||
install_requires=requires,
|
||||
install_requires=get_requires(),
|
||||
extras_require={
|
||||
'WEB': ['bottle'],
|
||||
'SENSORS': ['py3sensors'],
|
||||
@ -53,7 +59,7 @@ setup(
|
||||
},
|
||||
packages=['glances'],
|
||||
include_package_data=True,
|
||||
data_files=data_files,
|
||||
data_files=get_data_files(),
|
||||
test_suite="glances.tests",
|
||||
entry_points={"console_scripts": ["glances=glances.glances:main"]},
|
||||
classifiers=[
|
||||
|
Loading…
Reference in New Issue
Block a user