-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Software Architecture major rework (#41)
* Moved constants and logo ascii art out of the main file * Moved Configuration class to separate file * Moved Output class to a separate file * Moved hostname class definition to it's own separate file * Moved Model class definition to it's own file * Moved Kernel class to its own file * Moved uptime class definition to it's own file * Moved Disk class definition to its own file * Moved RAM class definition to it's own file * Moved CPU class definition to it's own file * Moved LanIp class definition to it's own file * Moved WanIp class definition to a separate file * Moved Packages class definition to separate file * Moved User class definition to its own file * Moved entry class definitions to their own directory * Moved GPU entry class definition to a separate file * Moved temperature entry class definition to a separate file * Moved terminal entry class definition to separate file * Moved shell entry class definition to separate file * Rewrited the `LanIp` module to handle more cases and optimizations * Moved window manager and desktop environment class definitions to separate files * Moved distro class definition to separate file * Removed direct use of COLOR_DICT in disk.py and ram.py * Moved unit tests and modified import paths * Moved {DE,WM}_DICT constants to their respective modules * Made `Configuration` & `Processes` (new class) act as singletons * Set the `Configuration` internal `config` dictionary to "private" attribute + Now relies on a `.pylintrc` file for Pylint (now almost fully-compliant) + Fixed typos + Added another dependency on `netifaces`, but this should remove the assumption about tools available in the user's environment + The project may now be run as a Python module + Marked Python 3.8 as supported for SetupTools + Added instructions (and tests) to build a standalone version of Archey + Adds @lannuttia to COPYRIGHT (initiator of the major rework) - Removed the dependency to `net-tools` Co-authored-by: Samuel FORESTIER <dev@samuel.domains>
- Loading branch information
1 parent
d104613
commit 4dcf479
Showing
79 changed files
with
2,493 additions
and
1,960 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[MASTER] | ||
# Required hook as we use absolute imports within the code. | ||
init-hook='import sys; sys.path.append("archey/")' | ||
|
||
# C sources of the `netifaces` module won't be available. | ||
# Let's ignore it during linting please. | ||
extension-pkg-whitelist=netifaces | ||
|
||
# Automatically detects the number of CPU available to use. | ||
jobs=0 | ||
|
||
|
||
[DESIGN] | ||
# For entries classes, we only use the `__init__` magic method. | ||
min-public-methods=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,34 @@ | ||
dist: xenial | ||
language: python | ||
python: | ||
- "3.4" | ||
- "3.5" | ||
- "3.6" | ||
- "3.7-dev" | ||
#- "3.8-dev" | ||
|
||
install: | ||
# Archey package installation (and dependencies). | ||
- pip3 install . | ||
- pip3 install pylint | ||
|
||
# Pylint, Stickytape and PyInstaller external dependencies (see below). | ||
- pip3 install pylint stickytape pyinstaller | ||
|
||
script: | ||
# Simple execution. | ||
- python3 -m archey | ||
|
||
# Tests suite. | ||
- python3 setup.py test | ||
- python3 archey/archey.py | ||
- pylint archey/ --jobs=2 --disable=missing-docstring,too-few-public-methods,too-many-lines | ||
- pylint test/ --jobs=2 --disable=missing-docstring,too-few-public-methods,unused-argument,protected-access,no-value-for-parameter | ||
- python3 -m unittest | ||
|
||
# Lint all the things ! | ||
- pylint archey/ | ||
|
||
# Build a standalone script from sources (Stickytape). | ||
- stickytape --add-python-path . --output-file dist/archey archey/__main__.py | ||
- python3 dist/archey | ||
|
||
# Build a standalone script from sources (PyInstaller). | ||
- pyinstaller --distpath dist --specpath dist --name archey --onefile archey/__main__.py | ||
- ./dist/archey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/usr/bin/env python3 | ||
|
||
""" | ||
Archey main file. | ||
It loads each entry as a different class coming from the `entries` module. | ||
Logos are stored under the `logos` module. | ||
""" | ||
|
||
from enum import Enum | ||
|
||
from archey.output import Output | ||
from archey.configuration import Configuration | ||
from archey.processes import Processes | ||
from archey.entries.user import User as e_User | ||
from archey.entries.hostname import Hostname as e_Hostname | ||
from archey.entries.model import Model as e_Model | ||
from archey.entries.distro import Distro as e_Distro | ||
from archey.entries.kernel import Kernel as e_Kernel | ||
from archey.entries.uptime import Uptime as e_Uptime | ||
from archey.entries.window_manager import WindowManager as e_WindowManager | ||
from archey.entries.desktop_environment import DesktopEnvironment as e_DesktopEnvironment | ||
from archey.entries.shell import Shell as e_Shell | ||
from archey.entries.terminal import Terminal as e_Terminal | ||
from archey.entries.packages import Packages as e_Packages | ||
from archey.entries.temperature import Temperature as e_Temperature | ||
from archey.entries.cpu import CPU as e_CPU | ||
from archey.entries.gpu import GPU as e_GPU | ||
from archey.entries.ram import RAM as e_RAM | ||
from archey.entries.disk import Disk as e_Disk | ||
from archey.entries.lan_ip import LanIp as e_LanIp | ||
from archey.entries.wan_ip import WanIp as e_WanIp | ||
|
||
|
||
class Entries(Enum): | ||
""" | ||
An enumeration to store and declare each one of our entries. | ||
The string representation of keys will act as entries names. | ||
Values will be set under the `value` attribute of each obtained objects. | ||
""" | ||
User = e_User | ||
Hostname = e_Hostname | ||
Model = e_Model | ||
Distro = e_Distro | ||
Kernel = e_Kernel | ||
Uptime = e_Uptime | ||
WindowManager = e_WindowManager | ||
DesktopEnvironment = e_DesktopEnvironment | ||
Shell = e_Shell | ||
Terminal = e_Terminal | ||
Packages = e_Packages | ||
Temperature = e_Temperature | ||
CPU = e_CPU | ||
GPU = e_GPU | ||
RAM = e_RAM | ||
Disk = e_Disk | ||
LAN_IP = e_LanIp | ||
WAN_IP = e_WanIp | ||
|
||
|
||
def main(): | ||
"""Simple entry point""" | ||
|
||
# `Processes` is a singleton, let's populate the internal list here. | ||
Processes() | ||
|
||
# `Configuration` is a singleton, let's populate the internal object here. | ||
configuration = Configuration() | ||
|
||
output = Output() | ||
for entry in Entries: | ||
if configuration.get('entries', {}).get(entry.name, True): | ||
output.append(entry.name, entry.value().value) | ||
|
||
output.output() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.