Test Failed
Push — develop ( 66c9ff...e21229 )
by Nicolas
05:06
created

glances/globals.py (3 issues)

1
# -*- coding: utf-8 -*-
2
#
3
# This file is part of Glances.
4
#
5
# Copyright (C) 2019 Nicolargo <[email protected]>
6
#
7
# Glances is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU Lesser General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Glances is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU Lesser General Public License for more details.
16
#
17
# You should have received a copy of the GNU Lesser General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20
"""Common objects shared by all Glances modules."""
21
22
import errno
23
import os
24
import sys
25
import platform
26
27
# OS constants (some libraries/features are OS-dependent)
28
BSD = sys.platform.find('bsd') != -1
29
LINUX = sys.platform.startswith('linux')
30
MACOS = sys.platform.startswith('darwin')
31
SUNOS = sys.platform.startswith('sunos')
32
WINDOWS = sys.platform.startswith('win')
33
WSL = "linux" in platform.system().lower() and "microsoft" in platform.uname()[3].lower()
0 ignored issues
show
This line is too long as per the coding-style (89/80).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
34
35
# Set the AMPs, plugins and export modules path
36
work_path = os.path.realpath(os.path.dirname(__file__))
37
amps_path = os.path.realpath(os.path.join(work_path, 'amps'))
0 ignored issues
show
Coding Style Naming introduced by
The name amps_path does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
38
plugins_path = os.path.realpath(os.path.join(work_path, 'plugins'))
39
exports_path = os.path.realpath(os.path.join(work_path, 'exports'))
40
sys_path = sys.path[:]
0 ignored issues
show
Coding Style Naming introduced by
The name sys_path does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
41
sys.path.insert(1, exports_path)
42
sys.path.insert(1, plugins_path)
43
sys.path.insert(1, amps_path)
44
45
46
def safe_makedirs(path):
47
    """A safe function for creating a directory tree."""
48
    try:
49
        os.makedirs(path)
50
    except OSError as err:
51
        if err.errno == errno.EEXIST:
52
            if not os.path.isdir(path):
53
                raise
54
        else:
55
            raise
56