diff --git a/docs/README.html b/docs/README.html index 94aa6b2..7eb3199 100644 --- a/docs/README.html +++ b/docs/README.html @@ -4,7 +4,7 @@ - + PyNinja — PyNinja documentation diff --git a/docs/index.html b/docs/index.html index fb258dc..7d7be40 100644 --- a/docs/index.html +++ b/docs/index.html @@ -4,7 +4,7 @@ - + Welcome to PyNinja’s documentation! — PyNinja documentation @@ -914,35 +914,20 @@

PyNinja - Features

CPU

-pyninja.features.cpu._darwin(lib_path: Path) str
+pyninja.features.cpu._darwin() str

Get processor information for macOS.

-
-
Parameters:
-

lib_path – Path to the library executable.

-
-
-pyninja.features.cpu._linux(lib_path: Path) str
+pyninja.features.cpu._linux() str

Get processor information for Linux.

-
-
Parameters:
-

lib_path – Path to the library file.

-
-
-pyninja.features.cpu._windows(lib_path: Path) str
+pyninja.features.cpu._windows() str

Get processor information for Windows.

-
-
Parameters:
-

lib_path – Path to the library file.

-
-
@@ -973,17 +958,14 @@

PyNinja - Features

Disks - Linux

-pyninja.features.disks.linux.drive_info(lib_path: Path) List[Dict[str, str]]
+pyninja.features.disks.linux.drive_info() List[Dict[str, str]]

Get disks attached to Linux devices.

-
Parameters:
-

lib_path – Returns the library path for disk information.

-
-
Returns:
-

Returns disks information for Linux distros.

+
Returns:
+

Returns disks information for Linux distros.

-
Return type:
-

List[Dict[str, str]]

+
Return type:
+

List[Dict[str, str]]

@@ -1047,17 +1029,14 @@

PyNinja - Features
-pyninja.features.disks.macOS.drive_info(lib_path: Path) List[Dict[str, str]]
+pyninja.features.disks.macOS.drive_info() List[Dict[str, str]]

Get disks attached to macOS devices.

-
Parameters:
-

lib_path – Returns the library path for disk information.

-
-
Returns:
-

Returns disks information for macOS devices.

+
Returns:
+

Returns disks information for macOS devices.

-
Return type:
-

List[Dict[str, str]]

+
Return type:
+

List[Dict[str, str]]

@@ -1084,17 +1063,14 @@

PyNinja - Features
-pyninja.features.disks.windows.get_drives(lib_path: Path) List[Dict[str, str]]
+pyninja.features.disks.windows.get_drives() List[Dict[str, str]]

Get physical drives connected to a Windows machine.

-
Parameters:
-

lib_path – Library path for disk information.

-
-
Returns:
-

Returns the formatted data for all the drives as a list of key-value pairs.

+
Returns:
+

Returns the formatted data for all the drives as a list of key-value pairs.

-
Return type:
-

List[Dict[str, str]]

+
Return type:
+

List[Dict[str, str]]

@@ -1118,51 +1094,42 @@

PyNinja - Features
-pyninja.features.disks.windows.get_physical_disks_and_partitions(lib_path: Path) List[Tuple[str, str, str]]
+pyninja.features.disks.windows.get_physical_disks_and_partitions() List[Tuple[str, str, str]]

Powershell Core command to get physical disks and their partitions with drive letters (mount points).

-
Parameters:
-

lib_path – Library path for disk information.

-
-
Returns:
-

List of tuples with disk_number, partition_number, mount_point.

+
Returns:
+

List of tuples with disk_number, partition_number, mount_point.

-
Return type:
-

List[Tuple[str, str, str]]

+
Return type:
+

List[Tuple[str, str, str]]

-pyninja.features.disks.windows.get_disk_usage(lib_path: Path) Dict[str, List[str]]
+pyninja.features.disks.windows.get_disk_usage() Dict[str, List[str]]

Get all physical disks and their partitions with mount points.

-
Parameters:
-

lib_path – Library path for disk information.

-
-
Returns:
-

Returns a dictionary of DeviceID as key and mount paths as value.

+
Returns:
+

Returns a dictionary of DeviceID as key and mount paths as value.

-
Return type:
-

Dict[str, List[str]]

+
Return type:
+

Dict[str, List[str]]

-pyninja.features.disks.windows.drive_info(lib_path: Path) List[Dict[str, str]]
+pyninja.features.disks.windows.drive_info() List[Dict[str, str]]

Get disks attached to Windows devices.

-
Parameters:
-

lib_path – Library path for disk information.

-
-
Returns:
-

Returns disks information for Windows machines.

+
Returns:
+

Returns disks information for Windows machines.

-
Return type:
-

List[Dict[str, str]]

+
Return type:
+

List[Dict[str, str]]

@@ -1245,51 +1212,42 @@

PyNinja - Features

GPU

-pyninja.features.gpu._darwin(lib_path) Optional[List[Dict[str, str]]]
+pyninja.features.gpu._darwin() Optional[List[Dict[str, str]]]

Get GPU model and vendor information for Linux operating system.

-
Parameters:
-

lib_path – Library path to get GPU information.

-
-
Returns:
-

Returns a list of GPU model and vendor information.

+
Returns:
+

Returns a list of GPU model and vendor information.

-
Return type:
-

List[Dict[str, str]]

+
Return type:
+

List[Dict[str, str]]

-pyninja.features.gpu._linux(lib_path) Optional[List[Dict[str, str]]]
+pyninja.features.gpu._linux() Optional[List[Dict[str, str]]]

Get GPU model and vendor information for Linux operating system.

-
Parameters:
-

lib_path – Library path to get GPU information.

-
-
Returns:
-

Returns a list of GPU model and vendor information.

+
Returns:
+

Returns a list of GPU model and vendor information.

-
Return type:
-

List[Dict[str, str]]

+
Return type:
+

List[Dict[str, str]]

-pyninja.features.gpu._windows(lib_path: Path) Optional[List[Dict[str, str]]]
+pyninja.features.gpu._windows() Optional[List[Dict[str, str]]]

Get GPU model and vendor information for Windows operating system.

-
Parameters:
-

lib_path – Library path to get GPU information.

-
-
Returns:
-

Returns a list of GPU model and vendor information.

+
Returns:
+

Returns a list of GPU model and vendor information.

-
Return type:
-

List[Dict[str, str]]

+
Return type:
+

List[Dict[str, str]]

diff --git a/docs/searchindex.js b/docs/searchindex.js index b611a1a..aec0453 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({"docnames": ["README", "index"], "filenames": ["README.md", "index.rst"], "titles": ["PyNinja", "Welcome to PyNinja\u2019s documentation!"], "terms": {"lightweight": 0, "o": [0, 1], "agnost": [0, 1], "servic": 0, "monitor": 0, "api": 0, "platform": 0, "support": [0, 1], "deploy": 0, "recommend": 0, "instal": [0, 1], "python": 0, "3": [0, 1], "10": [0, 1], "11": [0, 1], "us": [0, 1], "dedic": [0, 1], "virtual": [0, 1], "m": 0, "pip": 0, "initi": 0, "id": [0, 1], "import": 0, "__name__": 0, "__main__": 0, "start": [0, 1], "cli": 0, "help": 0, "usag": [0, 1], "instruct": 0, "sourc": 0, "from": [0, 1], "an": [0, 1], "env": [0, 1], "file": [0, 1], "By": 0, "default": [0, 1], "look": 0, "current": [0, 1], "work": [0, 1], "directori": [0, 1], "apikei": [0, 1], "kei": [0, 1], "authent": 0, "ninja": 0, "_": 0, "host": [0, 1], "hostnam": [0, 1], "server": [0, 1], "port": [0, 1], "number": [0, 1], "remot": [0, 1], "execut": [0, 1], "boolean": [0, 1], "flag": [0, 1], "enabl": [0, 1], "secret": [0, 1], "access": [0, 1], "run": [0, 1], "command": [0, 1], "disk": 0, "report": [0, 1], "featur": 0, "pyudisk": [0, 1], "usernam": [0, 1], "page": [0, 1], "password": [0, 1], "session": [0, 1], "timeout": [0, 1], "NO": 0, "auth": [0, 1], "without": 0, "max": [0, 1], "connect": [0, 1], "maximum": [0, 1], "allow": [0, 1], "parallel": 0, "process": 0, "list": [0, 1], "name": [0, 1], "includ": [0, 1], "gpu": 0, "lib": [0, 1], "librari": [0, 1], "filepath": [0, 1], "memori": [0, 1], "processor": [0, 1], "databas": 0, "store": [0, 1], "handl": [0, 1], "error": [0, 1], "rate": [0, 1], "limit": [0, 1], "dictionari": [0, 1], "max_request": [0, 1], "second": [0, 1], "appli": [0, 1], "log": [0, 1], "config": [0, 1], "configur": 0, "path": [0, 1], "can": [0, 1], "extrem": 0, "riski": 0, "major": 0, "secur": 0, "threat": 0, "so": [0, 1], "caution": 0, "set": [0, 1], "strong": [0, 1], "valu": [0, 1], "refer": [0, 1], "sampl": 0, "exampl": [0, 1], "docstr": 0, "format": [0, 1], "googl": 0, "style": 0, "convent": 0, "pep": 0, "8": 0, "isort": 0, "requir": [0, 1], "gitvers": 0, "revers": 0, "f": 0, "release_not": 0, "rst": 0, "t": [0, 1], "pre": 0, "commit": 0, "ensur": [0, 1], "pytest": 0, "gener": [0, 1], "valid": [0, 1], "hyperlink": 0, "all": [0, 1], "markdown": 0, "wiki": 0, "sphinx": 0, "5": [0, 1], "1": [0, 1], "recommonmark": 0, "http": [0, 1], "org": 0, "project": 0, "thevickypedia": 0, "github": 0, "io": 0, "vignesh": 0, "rao": 0, "under": 0, "mit": 0, "kick": 1, "off": 1, "environ": 1, "variabl": 1, "code": 1, "standard": 1, "releas": 1, "note": 1, "lint": 1, "pypi": 1, "packag": 1, "runbook": 1, "licens": 1, "copyright": 1, "get_desc": 1, "remote_flag": 1, "bool": 1, "monitor_flag": 1, "str": 1, "construct": 1, "detail": 1, "descript": 1, "doc": 1, "paramet": 1, "state": 1, "return": 1, "string": 1, "type": 1, "async": 1, "redirect_exception_handl": 1, "request": 1, "redirectexcept": 1, "jsonrespons": 1, "custom": 1, "handler": 1, "redirect": 1, "take": 1, "object": 1, "argument": 1, "inherit": 1, "statu": 1, "cooki": 1, "kwarg": 1, "none": 1, "starter": 1, "function": 1, "which": 1, "uvicorn": 1, "trigger": 1, "keyword": 1, "env_fil": 1, "load": 1, "ninja_host": 1, "ninja_port": 1, "remote_execut": 1, "api_secret": 1, "monitor_usernam": 1, "monitor_password": 1, "monitor_sess": 1, "service_manag": 1, "manag": 1, "rate_limit": 1, "log_config": 1, "dict": 1, "yaml": 1, "yml": 1, "json": 1, "ini": 1, "epoch": 1, "forbidden": 1, "i": 1, "part": 1, "fastapi": 1, "rais": 1, "apirespons": 1, "403": 1, "If": 1, "address": 1, "level_1": 1, "httpauthorizationcredenti": 1, "httpbearer": 1, "author": 1, "header": 1, "token": 1, "basic": 1, "401": 1, "invalid": 1, "level_2": 1, "addition": 1, "addit": 1, "critic": 1, "increment": 1, "attempt": 1, "int": 1, "block": 1, "time": 1, "base": 1, "fail": 1, "login": 1, "appropri": 1, "minut": 1, "handle_auth_error": 1, "filebrows": 1, "The": 1, "incom": 1, "get_record": 1, "get": 1, "particular": 1, "until": 1, "when": 1, "should": 1, "put_record": 1, "block_until": 1, "insert": 1, "remove_record": 1, "delet": 1, "record": 1, "relat": 1, "fullaccess": 1, "run_command": 1, "runcommand": 1, "depend": 1, "option": 1, "machin": 1, "arg": 1, "receiv": 1, "bodi": 1, "httpstatu": 1, "respons": 1, "list_fil": 1, "listfil": 1, "fileio": 1, "download": 1, "upload": 1, "get_fil": 1, "getfil": 1, "filerespons": 1, "put_fil": 1, "uploadfil": 1, "overwrit": 1, "fals": 1, "th": 1, "param": 1, "ipaddr": 1, "get_ip_address": 1, "public": 1, "local": 1, "ip": 1, "devic": 1, "privat": 1, "metric": 1, "get_cpu_util": 1, "interv": 1, "float": 1, "2": 1, "per_cpu": 1, "true": 1, "util": 1, "each": 1, "get_memory_util": 1, "get_cpu_load_avg": 1, "system": 1, "queue": 1, "averag": 1, "over": 1, "last": 1, "15": 1, "respect": 1, "get_disk_util": 1, "get_all_disk": 1, "attach": 1, "namespac": 1, "get_process_statu": 1, "process_nam": 1, "cpu_interv": 1, "union": 1, "check": 1, "get_service_usag": 1, "service_nam": 1, "get_process_usag": 1, "get_service_statu": 1, "get_processor_nam": 1, "inform": 1, "orchestr": 1, "get_docker_contain": 1, "container_nam": 1, "get_al": 1, "get_run": 1, "contain": 1, "get_docker_imag": 1, "imag": 1, "get_docker_volum": 1, "volum": 1, "get_docker_stat": 1, "stat": 1, "router": 1, "redirectrespons": 1, "user": 1, "health": 1, "200": 1, "get_all_rout": 1, "apirout": 1, "ad": 1, "public_ip_address": 1, "differ": 1, "endpoint": 1, "private_ip_address": 1, "simpl": 1, "network": 1, "see": 1, "format_no": 1, "input_": 1, "remov": 1, "0": 1, "integ": 1, "end": 1, "found": 1, "els": 1, "format_timedelta": 1, "td": 1, "timedelta": 1, "convert": 1, "human": 1, "readabl": 1, "non": 1, "zero": 1, "alwai": 1, "output": 1, "two": 1, "identifi": 1, "dai": 1, "hour": 1, "23": 1, "size_convert": 1, "byte_s": 1, "consum": 1, "friendli": 1, "byte": 1, "size": 1, "understand": 1, "process_command": 1, "result": 1, "stdout": 1, "stderr": 1, "pair": 1, "envfile_load": 1, "filenam": 1, "pathlik": 1, "envconfig": 1, "filetyp": 1, "where": 1, "var": 1, "have": 1, "load_env": 1, "merg": 1, "give": 1, "prioriti": 1, "thi": 1, "partial": 1, "through": 1, "keygen": 1, "ar": 1, "forc": 1, "restart": 1, "url": 1, "safe": 1, "64": 1, "bit": 1, "dynamic_numb": 1, "dynam": 1, "assert_pyudisk": 1, "disk_report": 1, "onli": 1, "udiskctl": 1, "comma_separ": 1, "list_": 1, "separ": 1, "comma": 1, "join": 1, "input": 1, "length": 1, "element": 1, "convert_second": 1, "n_elem": 1, "calcul": 1, "year": 1, "month": 1, "given": 1, "notion": 1, "_darwin": 1, "lib_path": 1, "_linux": 1, "_window": 1, "get_nam": 1, "__init__": 1, "drive_info": 1, "distro": 1, "parse_s": 1, "input_str": 1, "extract": 1, "diskutil": 1, "update_mountpoint": 1, "device_id": 1, "defaultdict": 1, "updat": 1, "mount": 1, "point": 1, "physic": 1, "data": 1, "info": 1, "mountpoint": 1, "parse_diskutil_output": 1, "pars": 1, "structur": 1, "reformat_window": 1, "reformat": 1, "get_driv": 1, "clean_ansi_escape_sequ": 1, "text": 1, "regular": 1, "express": 1, "ansi": 1, "escap": 1, "sequenc": 1, "charact": 1, "clean": 1, "get_physical_disks_and_partit": 1, "tupl": 1, "powershel": 1, "core": 1, "partit": 1, "letter": 1, "disk_numb": 1, "partition_numb": 1, "mount_point": 1, "get_disk_usag": 1, "deviceid": 1, "get_container_statu": 1, "get_running_contain": 1, "yield": 1, "correspond": 1, "get_all_contain": 1, "get_all_imag": 1, "get_all_volum": 1, "vendor": 1, "get_process_info": 1, "proc": 1, "psutil": 1, "statist": 1, "process_monitor": 1, "case": 1, "sensit": 1, "thei": 1, "strictli": 1, "match": 1, "top": 1, "grep": 1, "task": 1, "service_monitor": 1, "follow": 1, "right": 1, "launchctl": 1, "systemctl": 1, "show": 1, "properti": 1, "mainpid": 1, "sc": 1, "queri": 1, "get_service_pid": 1, "retriev": 1, "pid": 1, "get_service_pid_linux": 1, "get_service_pid_maco": 1, "get_service_pid_window": 1, "perform": 1, "get_perform": 1, "thread": 1, "open": 1, "servicestatu": 1, "stop": 1, "501": 1, "unknown": 1, "503": 1, "unavail": 1, "404": 1, "instanc": 1, "timed_cach": 1, "max_ag": 1, "maxsiz": 1, "128": 1, "least": 1, "recent": 1, "decor": 1, "live": 1, "functool": 1, "lru_cach": 1, "distinct": 1, "creat": 1, "even": 1, "one": 1, "chang": 1, "map": 1, "new": 1, "entri": 1, "thu": 1, "refresh": 1, "just": 1, "trick": 1, "provid": 1, "ttl": 1, "monoton": 1, "sinc": 1, "reli": 1, "clock": 1, "mai": 1, "guarante": 1, "increas": 1, "fact": 1, "decreas": 1, "sync": 1, "its": 1, "class": 1, "operatingsystem": 1, "qualnam": 1, "boundari": 1, "darwin": 1, "apiendpoint": 1, "root": 1, "redoc": 1, "put": 1, "get_processor": 1, "service_usag": 1, "process_usag": 1, "process_statu": 1, "service_statu": 1, "ws_system": 1, "w": 1, "get_disk": 1, "get_memori": 1, "docker_imag": 1, "docker_stat": 1, "docker_volum": 1, "docker_contain": 1, "get_ip": 1, "get_cpu": 1, "get_cpu_load": 1, "logout": 1, "applic": 1, "session_token": 1, "templat": 1, "html": 1, "index": 1, "unauthor": 1, "status_cod": 1, "ani": 1, "httpexcept": 1, "wrap": 1, "unsupportedo": 1, "unsupport": 1, "locat": 1, "within": 1, "doesn": 1, "demand": 1, "solut": 1, "There": 1, "altern": 1, "our": 1, "javascript": 1, "wai": 1, "come": 1, "handi": 1, "mani": 1, "unexpect": 1, "scenario": 1, "tiangolo": 1, "com": 1, "tutori": 1, "sessionerror": 1, "raise_os_error": 1, "operating_system": 1, "noreturn": 1, "validationerror": 1, "overridden": 1, "pydant": 1, "basemodel": 1, "disklib": 1, "servicelib": 1, "processorlib": 1, "auth_count": 1, "forbid": 1, "rp": 1, "allowed_origin": 1, "udisk_lib": 1, "max_connect": 1, "no_auth": 1, "gpu_lib": 1, "disk_lib": 1, "service_lib": 1, "processor_lib": 1, "classmethod": 1, "parse_api_secret": 1, "complex": 1, "from_env_fil": 1, "extra": 1, "ignor": 1, "hide_input_in_error": 1, "complexity_check": 1, "verifi": 1, "strength": 1, "A": 1, "consid": 1, "ha": 1, "32": 1, "digit": 1, "symbol": 1, "uppercas": 1, "lowercas": 1, "assertionerror": 1, "abov": 1, "condit": 1, "gpulib": 1, "usr": 1, "bin": 1, "lspci": 1, "sbin": 1, "system_profil": 1, "c": 1, "system32": 1, "wbem": 1, "wmic": 1, "ex": 1, "_abc_impl": 1, "_abc": 1, "_abc_data": 1, "model_computed_field": 1, "classvar": 1, "computedfieldinfo": 1, "comput": 1, "field": 1, "model_config": 1, "configdict": 1, "conform": 1, "model_field": 1, "fieldinfo": 1, "annot": 1, "metadata": 1, "pathtyp": 1, "path_typ": 1, "about": 1, "defin": 1, "replac": 1, "__fields__": 1, "v1": 1, "wssession": 1, "client_auth": 1, "websocket": 1, "default_factori": 1, "get_librari": 1, "referenc": 1, "datastor": 1, "sqlite3": 1, "create_t": 1, "table_nam": 1, "column": 1, "show_hidden_fil": 1, "include_directori": 1, "deep_scan": 1, "implement": 1, "init": 1, "call": 1, "exce": 1, "429": 1, "too": 1, "calculate_hash": 1, "hash": 1, "base64_encod": 1, "base64": 1, "encod": 1, "base64_decod": 1, "decod": 1, "hex_decod": 1, "hex": 1, "hex_encod": 1, "failed_auth_count": 1, "keep": 1, "track": 1, "more": 1, "raise_error": 1, "bad": 1, "credenti": 1, "extract_credenti": 1, "befor": 1, "verify_login": 1, "generate_cooki": 1, "auth_payload": 1, "timestamp": 1, "session_error": 1, "htmlrespons": 1, "render": 1, "messag": 1, "jinja2": 1, "validate_sess": 1, "cookie_str": 1, "summari": 1, "clear_sess": 1, "clear": 1, "get_expiri": 1, "lease_start": 1, "lease_dur": 1, "expiri": 1, "datetim": 1, "ag": 1, "wa": 1, "made": 1, "date": 1, "gmt": 1, "ctx": 1, "500": 1, "after": 1, "context": 1, "enter": 1, "landing_pag": 1, "land": 1, "jinja": 1, "container_cpu_limit": 1, "nanocpu": 1, "map_docker_stat": 1, "json_data": 1, "get_cpu_perc": 1, "percentag": 1, "asynchron": 1, "get_system_metr": 1, "swap": 1, "nest": 1, "pyudisk_metr": 1, "mean": 1, "60": 1, "avoid": 1, "gather": 1, "everi": 1, "improv": 1, "latenc": 1, "overhead": 1, "system_resourc": 1, "error_endpoint": 1, "logout_endpoint": 1, "out": 1, "login_endpoint": 1, "redirect_url": 1, "monitor_endpoint": 1, "ui": 1, "websocket_endpoint": 1, "fetch": 1, "search": 1}, "objects": {"pyninja.executors": [[1, 0, 0, "-", "auth"], [1, 0, 0, "-", "database"], [1, 0, 0, "-", "routers"], [1, 0, 0, "-", "squire"]], "pyninja.executors.auth": [[1, 1, 1, "", "EPOCH"], [1, 1, 1, "", "forbidden"], [1, 1, 1, "", "handle_auth_error"], [1, 1, 1, "", "incrementer"], [1, 1, 1, "", "level_1"], [1, 1, 1, "", "level_2"]], "pyninja.executors.database": [[1, 1, 1, "", "get_record"], [1, 1, 1, "", "put_record"], [1, 1, 1, "", "remove_record"]], "pyninja.executors.routers": [[1, 1, 1, "", "docs"], [1, 1, 1, "", "get_all_routes"], [1, 1, 1, "", "health"]], "pyninja.executors.squire": [[1, 1, 1, "", "assert_pyudisk"], [1, 1, 1, "", "comma_separator"], [1, 1, 1, "", "convert_seconds"], [1, 1, 1, "", "dynamic_numbers"], [1, 1, 1, "", "envfile_loader"], [1, 1, 1, "", "format_nos"], [1, 1, 1, "", "format_timedelta"], [1, 1, 1, "", "keygen"], [1, 1, 1, "", "load_env"], [1, 1, 1, "", "private_ip_address"], [1, 1, 1, "", "process_command"], [1, 1, 1, "", "public_ip_address"], [1, 1, 1, "", "size_converter"]], "pyninja.features": [[1, 0, 0, "-", "cpu"], [1, 0, 0, "-", "dockerized"], [1, 0, 0, "-", "gpu"], [1, 0, 0, "-", "operations"], [1, 0, 0, "-", "process"], [1, 0, 0, "-", "service"]], "pyninja.features.cpu": [[1, 1, 1, "", "_darwin"], [1, 1, 1, "", "_linux"], [1, 1, 1, "", "_windows"], [1, 1, 1, "", "get_name"]], "pyninja.features.disks": [[1, 0, 0, "-", "__init__"], [1, 0, 0, "-", "linux"], [1, 0, 0, "-", "macOS"], [1, 0, 0, "-", "windows"]], "pyninja.features.disks.__init__": [[1, 1, 1, "", "get_all_disks"]], "pyninja.features.disks.linux": [[1, 1, 1, "", "drive_info"]], "pyninja.features.disks.macOS": [[1, 1, 1, "", "drive_info"], [1, 1, 1, "", "parse_diskutil_output"], [1, 1, 1, "", "parse_size"], [1, 1, 1, "", "update_mountpoints"]], "pyninja.features.disks.windows": [[1, 1, 1, "", "clean_ansi_escape_sequences"], [1, 1, 1, "", "drive_info"], [1, 1, 1, "", "get_disk_usage"], [1, 1, 1, "", "get_drives"], [1, 1, 1, "", "get_physical_disks_and_partitions"], [1, 1, 1, "", "reformat_windows"]], "pyninja.features.dockerized": [[1, 1, 1, "", "get_all_containers"], [1, 1, 1, "", "get_all_images"], [1, 1, 1, "", "get_all_volumes"], [1, 1, 1, "", "get_container_status"], [1, 1, 1, "", "get_running_containers"]], "pyninja.features.gpu": [[1, 1, 1, "", "_darwin"], [1, 1, 1, "", "_linux"], [1, 1, 1, "", "_windows"], [1, 1, 1, "", "get_names"]], "pyninja.features.operations": [[1, 1, 1, "", "default"], [1, 1, 1, "", "get_process_info"], [1, 1, 1, "", "get_service_pid"], [1, 1, 1, "", "get_service_pid_linux"], [1, 1, 1, "", "get_service_pid_macos"], [1, 1, 1, "", "get_service_pid_windows"], [1, 1, 1, "", "process_monitor"], [1, 1, 1, "", "service_monitor"]], "pyninja.features.process": [[1, 1, 1, "", "get_performance"], [1, 1, 1, "", "get_process_status"]], "pyninja.features.service": [[1, 1, 1, "", "get_service_status"], [1, 1, 1, "", "running"], [1, 1, 1, "", "stopped"], [1, 1, 1, "", "unavailable"], [1, 1, 1, "", "unknown"]], "pyninja": [[1, 0, 0, "-", "main"]], "pyninja.main": [[1, 1, 1, "", "get_desc"], [1, 1, 1, "", "redirect_exception_handler"], [1, 1, 1, "", "start"]], "pyninja.modules": [[1, 0, 0, "-", "cache"], [1, 0, 0, "-", "enums"], [1, 0, 0, "-", "exceptions"], [1, 0, 0, "-", "models"], [1, 0, 0, "-", "rate_limit"], [1, 0, 0, "-", "secure"]], "pyninja.modules.cache": [[1, 1, 1, "", "timed_cache"]], "pyninja.modules.enums": [[1, 2, 1, "", "APIEndpoints"], [1, 2, 1, "", "Cookies"], [1, 2, 1, "", "OperatingSystem"], [1, 2, 1, "", "Templates"]], "pyninja.modules.enums.APIEndpoints": [[1, 3, 1, "", "docker_container"], [1, 3, 1, "", "docker_image"], [1, 3, 1, "", "docker_stats"], [1, 3, 1, "", "docker_volume"], [1, 3, 1, "", "docs"], [1, 3, 1, "", "error"], [1, 3, 1, "", "get_all_disks"], [1, 3, 1, "", "get_cpu"], [1, 3, 1, "", "get_cpu_load"], [1, 3, 1, "", "get_disk"], [1, 3, 1, "", "get_file"], [1, 3, 1, "", "get_ip"], [1, 3, 1, "", "get_memory"], [1, 3, 1, "", "get_processor"], [1, 3, 1, "", "health"], [1, 3, 1, "", "list_files"], [1, 3, 1, "", "login"], [1, 3, 1, "", "logout"], [1, 3, 1, "", "monitor"], [1, 3, 1, "", "process_status"], [1, 3, 1, "", "process_usage"], [1, 3, 1, "", "put_file"], [1, 3, 1, "", "redoc"], [1, 3, 1, "", "root"], [1, 3, 1, "", "run_command"], [1, 3, 1, "", "service_status"], [1, 3, 1, "", "service_usage"], [1, 3, 1, "", "ws_system"]], "pyninja.modules.enums.Cookies": [[1, 3, 1, "", "drive"], [1, 3, 1, "", "monitor"], [1, 3, 1, "", "session_token"]], "pyninja.modules.enums.OperatingSystem": [[1, 3, 1, "", "darwin"], [1, 3, 1, "", "linux"], [1, 3, 1, "", "windows"]], "pyninja.modules.enums.Templates": [[1, 3, 1, "", "disk_report"], [1, 3, 1, "", "index"], [1, 3, 1, "", "logout"], [1, 3, 1, "", "main"], [1, 3, 1, "", "session"], [1, 3, 1, "", "unauthorized"]], "pyninja.modules.exceptions": [[1, 4, 1, "", "APIResponse"], [1, 4, 1, "", "RedirectException"], [1, 4, 1, "", "SessionError"], [1, 4, 1, "", "UnSupportedOS"], [1, 1, 1, "", "raise_os_error"]], "pyninja.modules.models": [[1, 2, 1, "", "Database"], [1, 2, 1, "", "DiskLib"], [1, 2, 1, "", "EnvConfig"], [1, 2, 1, "", "GPULib"], [1, 2, 1, "", "ProcessorLib"], [1, 2, 1, "", "RateLimit"], [1, 2, 1, "", "ServiceLib"], [1, 2, 1, "", "ServiceStatus"], [1, 2, 1, "", "Session"], [1, 2, 1, "", "WSSession"], [1, 1, 1, "", "complexity_checker"], [1, 1, 1, "", "get_library"]], "pyninja.modules.models.Database": [[1, 5, 1, "", "create_table"]], "pyninja.modules.models.DiskLib": [[1, 3, 1, "", "darwin"], [1, 3, 1, "", "linux"], [1, 3, 1, "", "windows"]], "pyninja.modules.models.EnvConfig": [[1, 2, 1, "", "Config"], [1, 3, 1, "", "api_secret"], [1, 3, 1, "", "apikey"], [1, 3, 1, "", "database"], [1, 3, 1, "", "disk_lib"], [1, 3, 1, "", "disk_report"], [1, 5, 1, "", "from_env_file"], [1, 3, 1, "", "gpu_lib"], [1, 3, 1, "", "log_config"], [1, 3, 1, "", "max_connections"], [1, 3, 1, "", "monitor_password"], [1, 3, 1, "", "monitor_session"], [1, 3, 1, "", "monitor_username"], [1, 3, 1, "", "ninja_host"], [1, 3, 1, "", "ninja_port"], [1, 3, 1, "", "no_auth"], [1, 5, 1, "", "parse_api_secret"], [1, 3, 1, "", "processes"], [1, 3, 1, "", "processor_lib"], [1, 3, 1, "", "rate_limit"], [1, 3, 1, "", "remote_execution"], [1, 3, 1, "", "service_lib"], [1, 3, 1, "", "services"], [1, 3, 1, "", "udisk_lib"]], "pyninja.modules.models.EnvConfig.Config": [[1, 3, 1, "", "extra"], [1, 3, 1, "", "hide_input_in_errors"]], "pyninja.modules.models.GPULib": [[1, 3, 1, "", "_abc_impl"], [1, 3, 1, "", "darwin"], [1, 3, 1, "", "linux"], [1, 3, 1, "", "model_computed_fields"], [1, 3, 1, "", "model_config"], [1, 3, 1, "", "model_fields"], [1, 3, 1, "", "windows"]], "pyninja.modules.models.ProcessorLib": [[1, 3, 1, "", "darwin"], [1, 3, 1, "", "linux"], [1, 3, 1, "", "windows"]], "pyninja.modules.models.RateLimit": [[1, 3, 1, "", "max_requests"], [1, 3, 1, "", "seconds"]], "pyninja.modules.models.ServiceLib": [[1, 3, 1, "", "darwin"], [1, 3, 1, "", "linux"], [1, 3, 1, "", "windows"]], "pyninja.modules.models.ServiceStatus": [[1, 3, 1, "", "description"], [1, 3, 1, "", "status_code"]], "pyninja.modules.models.Session": [[1, 3, 1, "", "allowed_origins"], [1, 3, 1, "", "auth_counter"], [1, 3, 1, "", "forbid"], [1, 3, 1, "", "info"], [1, 3, 1, "", "rps"]], "pyninja.modules.models.WSSession": [[1, 3, 1, "", "_abc_impl"], [1, 3, 1, "", "client_auth"], [1, 3, 1, "", "invalid"], [1, 3, 1, "", "model_computed_fields"], [1, 3, 1, "", "model_config"], [1, 3, 1, "", "model_fields"]], "pyninja.modules.payloads": [[1, 2, 1, "", "GetFile"], [1, 2, 1, "", "ListFiles"], [1, 2, 1, "", "RunCommand"]], "pyninja.modules.payloads.GetFile": [[1, 3, 1, "", "filepath"]], "pyninja.modules.payloads.ListFiles": [[1, 3, 1, "", "deep_scan"], [1, 3, 1, "", "directory"], [1, 3, 1, "", "include_directories"], [1, 3, 1, "", "show_hidden_files"]], "pyninja.modules.payloads.RunCommand": [[1, 3, 1, "", "command"], [1, 3, 1, "", "timeout"]], "pyninja.modules.rate_limit": [[1, 2, 1, "", "RateLimiter"]], "pyninja.modules.rate_limit.RateLimiter": [[1, 5, 1, "", "init"]], "pyninja.modules.secure": [[1, 1, 1, "", "base64_decode"], [1, 1, 1, "", "base64_encode"], [1, 1, 1, "", "calculate_hash"], [1, 1, 1, "", "hex_decode"], [1, 1, 1, "", "hex_encode"]], "pyninja.monitor": [[1, 0, 0, "-", "authenticator"], [1, 0, 0, "-", "config"], [1, 0, 0, "-", "drive"], [1, 0, 0, "-", "resources"], [1, 0, 0, "-", "routes"]], "pyninja.monitor.authenticator": [[1, 1, 1, "", "extract_credentials"], [1, 1, 1, "", "failed_auth_counter"], [1, 1, 1, "", "generate_cookie"], [1, 1, 1, "", "raise_error"], [1, 1, 1, "", "session_error"], [1, 1, 1, "", "validate_session"], [1, 1, 1, "", "verify_login"]], "pyninja.monitor.config": [[1, 1, 1, "", "clear_session"], [1, 1, 1, "", "get_expiry"]], "pyninja.monitor.drive": [[1, 1, 1, "", "invalidate"], [1, 1, 1, "", "report"]], "pyninja.monitor.resources": [[1, 1, 1, "", "container_cpu_limit"], [1, 1, 1, "", "containers"], [1, 1, 1, "", "get_cpu_percent"], [1, 1, 1, "", "get_docker_stats"], [1, 1, 1, "", "get_system_metrics"], [1, 1, 1, "", "landing_page"], [1, 1, 1, "", "map_docker_stats"], [1, 1, 1, "", "pyudisk_metrics"], [1, 1, 1, "", "system_resources"]], "pyninja.monitor.routes": [[1, 1, 1, "", "error_endpoint"], [1, 1, 1, "", "login_endpoint"], [1, 1, 1, "", "logout_endpoint"], [1, 1, 1, "", "monitor_endpoint"], [1, 1, 1, "", "websocket_endpoint"]], "pyninja.routes": [[1, 0, 0, "-", "fullaccess"], [1, 0, 0, "-", "ipaddr"], [1, 0, 0, "-", "metrics"], [1, 0, 0, "-", "namespace"], [1, 0, 0, "-", "orchestration"]], "pyninja.routes.fullaccess": [[1, 1, 1, "", "get_file"], [1, 1, 1, "", "list_files"], [1, 1, 1, "", "put_file"], [1, 1, 1, "", "run_command"]], "pyninja.routes.ipaddr": [[1, 1, 1, "", "get_ip_address"]], "pyninja.routes.metrics": [[1, 1, 1, "", "get_all_disks"], [1, 1, 1, "", "get_cpu_load_avg"], [1, 1, 1, "", "get_cpu_utilization"], [1, 1, 1, "", "get_disk_utilization"], [1, 1, 1, "", "get_memory_utilization"]], "pyninja.routes.namespace": [[1, 1, 1, "", "get_process_status"], [1, 1, 1, "", "get_process_usage"], [1, 1, 1, "", "get_processor_name"], [1, 1, 1, "", "get_service_status"], [1, 1, 1, "", "get_service_usage"]], "pyninja.routes.orchestration": [[1, 1, 1, "", "get_docker_containers"], [1, 1, 1, "", "get_docker_images"], [1, 1, 1, "", "get_docker_stats"], [1, 1, 1, "", "get_docker_volumes"]]}, "objtypes": {"0": "py:module", "1": "py:function", "2": "py:class", "3": "py:attribute", "4": "py:exception", "5": "py:method"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "function", "Python function"], "2": ["py", "class", "Python class"], "3": ["py", "attribute", "Python attribute"], "4": ["py", "exception", "Python exception"], "5": ["py", "method", "Python method"]}, "titleterms": {"pyninja": [0, 1], "kick": 0, "off": 0, "environ": 0, "variabl": 0, "code": 0, "standard": 0, "releas": 0, "note": 0, "lint": 0, "pypi": 0, "packag": 0, "runbook": 0, "licens": 0, "copyright": 0, "welcom": 1, "": 1, "document": 1, "content": 1, "main": 1, "executor": 1, "api": 1, "authent": 1, "databas": 1, "rout": 1, "squir": 1, "featur": 1, "cpu": 1, "disk": 1, "linux": 1, "maco": 1, "window": 1, "docker": 1, "gpu": 1, "oper": 1, "process": 1, "servic": 1, "modul": 1, "cach": 1, "enum": 1, "except": 1, "model": 1, "payload": 1, "ratelimit": 1, "secur": 1, "monitor": 1, "configur": 1, "drive": 1, "resourc": 1, "indic": 1, "tabl": 1}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 6, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx": 56}}) \ No newline at end of file +Search.setIndex({"docnames": ["README", "index"], "filenames": ["README.md", "index.rst"], "titles": ["PyNinja", "Welcome to PyNinja\u2019s documentation!"], "terms": {"lightweight": 0, "o": [0, 1], "agnost": [0, 1], "servic": 0, "monitor": 0, "api": 0, "platform": 0, "support": [0, 1], "deploy": 0, "recommend": 0, "instal": [0, 1], "python": 0, "3": [0, 1], "10": [0, 1], "11": [0, 1], "us": [0, 1], "dedic": [0, 1], "virtual": [0, 1], "m": 0, "pip": 0, "initi": 0, "id": [0, 1], "import": 0, "__name__": 0, "__main__": 0, "start": [0, 1], "cli": 0, "help": 0, "usag": [0, 1], "instruct": 0, "sourc": 0, "from": [0, 1], "an": [0, 1], "env": [0, 1], "file": [0, 1], "By": 0, "default": [0, 1], "look": 0, "current": [0, 1], "work": [0, 1], "directori": [0, 1], "apikei": [0, 1], "kei": [0, 1], "authent": 0, "ninja": 0, "_": 0, "host": [0, 1], "hostnam": [0, 1], "server": [0, 1], "port": [0, 1], "number": [0, 1], "remot": [0, 1], "execut": [0, 1], "boolean": [0, 1], "flag": [0, 1], "enabl": [0, 1], "secret": [0, 1], "access": [0, 1], "run": [0, 1], "command": [0, 1], "disk": 0, "report": [0, 1], "featur": 0, "pyudisk": [0, 1], "usernam": [0, 1], "page": [0, 1], "password": [0, 1], "session": [0, 1], "timeout": [0, 1], "NO": 0, "auth": [0, 1], "without": 0, "max": [0, 1], "connect": [0, 1], "maximum": [0, 1], "allow": [0, 1], "parallel": 0, "process": 0, "list": [0, 1], "name": [0, 1], "includ": [0, 1], "gpu": 0, "lib": [0, 1], "librari": [0, 1], "filepath": [0, 1], "memori": [0, 1], "processor": [0, 1], "databas": 0, "store": [0, 1], "handl": [0, 1], "error": [0, 1], "rate": [0, 1], "limit": [0, 1], "dictionari": [0, 1], "max_request": [0, 1], "second": [0, 1], "appli": [0, 1], "log": [0, 1], "config": [0, 1], "configur": 0, "path": [0, 1], "can": [0, 1], "extrem": 0, "riski": 0, "major": 0, "secur": 0, "threat": 0, "so": [0, 1], "caution": 0, "set": [0, 1], "strong": [0, 1], "valu": [0, 1], "refer": [0, 1], "sampl": 0, "exampl": [0, 1], "docstr": 0, "format": [0, 1], "googl": 0, "style": 0, "convent": 0, "pep": 0, "8": 0, "isort": 0, "requir": [0, 1], "gitvers": 0, "revers": 0, "f": 0, "release_not": 0, "rst": 0, "t": [0, 1], "pre": 0, "commit": 0, "ensur": [0, 1], "pytest": 0, "gener": [0, 1], "valid": [0, 1], "hyperlink": 0, "all": [0, 1], "markdown": 0, "wiki": 0, "sphinx": 0, "5": [0, 1], "1": [0, 1], "recommonmark": 0, "http": [0, 1], "org": 0, "project": 0, "thevickypedia": 0, "github": 0, "io": 0, "vignesh": 0, "rao": 0, "under": 0, "mit": 0, "kick": 1, "off": 1, "environ": 1, "variabl": 1, "code": 1, "standard": 1, "releas": 1, "note": 1, "lint": 1, "pypi": 1, "packag": 1, "runbook": 1, "licens": 1, "copyright": 1, "get_desc": 1, "remote_flag": 1, "bool": 1, "monitor_flag": 1, "str": 1, "construct": 1, "detail": 1, "descript": 1, "doc": 1, "paramet": 1, "state": 1, "return": 1, "string": 1, "type": 1, "async": 1, "redirect_exception_handl": 1, "request": 1, "redirectexcept": 1, "jsonrespons": 1, "custom": 1, "handler": 1, "redirect": 1, "take": 1, "object": 1, "argument": 1, "inherit": 1, "statu": 1, "cooki": 1, "kwarg": 1, "none": 1, "starter": 1, "function": 1, "which": 1, "uvicorn": 1, "trigger": 1, "keyword": 1, "env_fil": 1, "load": 1, "ninja_host": 1, "ninja_port": 1, "remote_execut": 1, "api_secret": 1, "monitor_usernam": 1, "monitor_password": 1, "monitor_sess": 1, "service_manag": 1, "manag": 1, "rate_limit": 1, "log_config": 1, "dict": 1, "yaml": 1, "yml": 1, "json": 1, "ini": 1, "epoch": 1, "forbidden": 1, "i": 1, "part": 1, "fastapi": 1, "rais": 1, "apirespons": 1, "403": 1, "If": 1, "address": 1, "level_1": 1, "httpauthorizationcredenti": 1, "httpbearer": 1, "author": 1, "header": 1, "token": 1, "basic": 1, "401": 1, "invalid": 1, "level_2": 1, "addition": 1, "addit": 1, "critic": 1, "increment": 1, "attempt": 1, "int": 1, "block": 1, "time": 1, "base": 1, "fail": 1, "login": 1, "appropri": 1, "minut": 1, "handle_auth_error": 1, "filebrows": 1, "The": 1, "incom": 1, "get_record": 1, "get": 1, "particular": 1, "until": 1, "when": 1, "should": 1, "put_record": 1, "block_until": 1, "insert": 1, "remove_record": 1, "delet": 1, "record": 1, "relat": 1, "fullaccess": 1, "run_command": 1, "runcommand": 1, "depend": 1, "option": 1, "machin": 1, "arg": 1, "receiv": 1, "bodi": 1, "httpstatu": 1, "respons": 1, "list_fil": 1, "listfil": 1, "fileio": 1, "download": 1, "upload": 1, "get_fil": 1, "getfil": 1, "filerespons": 1, "put_fil": 1, "uploadfil": 1, "overwrit": 1, "fals": 1, "th": 1, "param": 1, "ipaddr": 1, "get_ip_address": 1, "public": 1, "local": 1, "ip": 1, "devic": 1, "privat": 1, "metric": 1, "get_cpu_util": 1, "interv": 1, "float": 1, "2": 1, "per_cpu": 1, "true": 1, "util": 1, "each": 1, "get_memory_util": 1, "get_cpu_load_avg": 1, "system": 1, "queue": 1, "averag": 1, "over": 1, "last": 1, "15": 1, "respect": 1, "get_disk_util": 1, "get_all_disk": 1, "attach": 1, "namespac": 1, "get_process_statu": 1, "process_nam": 1, "cpu_interv": 1, "union": 1, "check": 1, "get_service_usag": 1, "service_nam": 1, "get_process_usag": 1, "get_service_statu": 1, "get_processor_nam": 1, "inform": 1, "orchestr": 1, "get_docker_contain": 1, "container_nam": 1, "get_al": 1, "get_run": 1, "contain": 1, "get_docker_imag": 1, "imag": 1, "get_docker_volum": 1, "volum": 1, "get_docker_stat": 1, "stat": 1, "router": 1, "redirectrespons": 1, "user": 1, "health": 1, "200": 1, "get_all_rout": 1, "apirout": 1, "ad": 1, "public_ip_address": 1, "differ": 1, "endpoint": 1, "private_ip_address": 1, "simpl": 1, "network": 1, "see": 1, "format_no": 1, "input_": 1, "remov": 1, "0": 1, "integ": 1, "end": 1, "found": 1, "els": 1, "format_timedelta": 1, "td": 1, "timedelta": 1, "convert": 1, "human": 1, "readabl": 1, "non": 1, "zero": 1, "alwai": 1, "output": 1, "two": 1, "identifi": 1, "dai": 1, "hour": 1, "23": 1, "size_convert": 1, "byte_s": 1, "consum": 1, "friendli": 1, "byte": 1, "size": 1, "understand": 1, "process_command": 1, "result": 1, "stdout": 1, "stderr": 1, "pair": 1, "envfile_load": 1, "filenam": 1, "pathlik": 1, "envconfig": 1, "filetyp": 1, "where": 1, "var": 1, "have": 1, "load_env": 1, "merg": 1, "give": 1, "prioriti": 1, "thi": 1, "partial": 1, "through": 1, "keygen": 1, "ar": 1, "forc": 1, "restart": 1, "url": 1, "safe": 1, "64": 1, "bit": 1, "dynamic_numb": 1, "dynam": 1, "assert_pyudisk": 1, "disk_report": 1, "onli": 1, "udiskctl": 1, "comma_separ": 1, "list_": 1, "separ": 1, "comma": 1, "join": 1, "input": 1, "length": 1, "element": 1, "convert_second": 1, "n_elem": 1, "calcul": 1, "year": 1, "month": 1, "given": 1, "notion": 1, "_darwin": 1, "_linux": 1, "_window": 1, "get_nam": 1, "__init__": 1, "drive_info": 1, "distro": 1, "parse_s": 1, "input_str": 1, "extract": 1, "diskutil": 1, "update_mountpoint": 1, "device_id": 1, "defaultdict": 1, "updat": 1, "mount": 1, "point": 1, "physic": 1, "data": 1, "info": 1, "mountpoint": 1, "parse_diskutil_output": 1, "pars": 1, "structur": 1, "reformat_window": 1, "reformat": 1, "get_driv": 1, "clean_ansi_escape_sequ": 1, "text": 1, "regular": 1, "express": 1, "ansi": 1, "escap": 1, "sequenc": 1, "charact": 1, "clean": 1, "get_physical_disks_and_partit": 1, "tupl": 1, "powershel": 1, "core": 1, "partit": 1, "letter": 1, "disk_numb": 1, "partition_numb": 1, "mount_point": 1, "get_disk_usag": 1, "deviceid": 1, "get_container_statu": 1, "get_running_contain": 1, "yield": 1, "correspond": 1, "get_all_contain": 1, "get_all_imag": 1, "get_all_volum": 1, "vendor": 1, "get_process_info": 1, "proc": 1, "psutil": 1, "statist": 1, "process_monitor": 1, "case": 1, "sensit": 1, "thei": 1, "strictli": 1, "match": 1, "top": 1, "grep": 1, "task": 1, "service_monitor": 1, "follow": 1, "right": 1, "launchctl": 1, "systemctl": 1, "show": 1, "properti": 1, "mainpid": 1, "sc": 1, "queri": 1, "get_service_pid": 1, "retriev": 1, "pid": 1, "get_service_pid_linux": 1, "get_service_pid_maco": 1, "get_service_pid_window": 1, "perform": 1, "get_perform": 1, "thread": 1, "open": 1, "servicestatu": 1, "stop": 1, "501": 1, "unknown": 1, "503": 1, "unavail": 1, "404": 1, "instanc": 1, "timed_cach": 1, "max_ag": 1, "maxsiz": 1, "128": 1, "least": 1, "recent": 1, "decor": 1, "live": 1, "functool": 1, "lru_cach": 1, "distinct": 1, "creat": 1, "even": 1, "one": 1, "chang": 1, "map": 1, "new": 1, "entri": 1, "thu": 1, "refresh": 1, "just": 1, "trick": 1, "provid": 1, "ttl": 1, "monoton": 1, "sinc": 1, "reli": 1, "clock": 1, "mai": 1, "guarante": 1, "increas": 1, "fact": 1, "decreas": 1, "sync": 1, "its": 1, "class": 1, "operatingsystem": 1, "qualnam": 1, "boundari": 1, "darwin": 1, "apiendpoint": 1, "root": 1, "redoc": 1, "put": 1, "get_processor": 1, "service_usag": 1, "process_usag": 1, "process_statu": 1, "service_statu": 1, "ws_system": 1, "w": 1, "get_disk": 1, "get_memori": 1, "docker_imag": 1, "docker_stat": 1, "docker_volum": 1, "docker_contain": 1, "get_ip": 1, "get_cpu": 1, "get_cpu_load": 1, "logout": 1, "applic": 1, "session_token": 1, "templat": 1, "html": 1, "index": 1, "unauthor": 1, "status_cod": 1, "ani": 1, "httpexcept": 1, "wrap": 1, "unsupportedo": 1, "unsupport": 1, "locat": 1, "within": 1, "doesn": 1, "demand": 1, "solut": 1, "There": 1, "altern": 1, "our": 1, "javascript": 1, "wai": 1, "come": 1, "handi": 1, "mani": 1, "unexpect": 1, "scenario": 1, "tiangolo": 1, "com": 1, "tutori": 1, "sessionerror": 1, "raise_os_error": 1, "operating_system": 1, "noreturn": 1, "validationerror": 1, "overridden": 1, "pydant": 1, "basemodel": 1, "disklib": 1, "servicelib": 1, "processorlib": 1, "auth_count": 1, "forbid": 1, "rp": 1, "allowed_origin": 1, "udisk_lib": 1, "max_connect": 1, "no_auth": 1, "gpu_lib": 1, "disk_lib": 1, "service_lib": 1, "processor_lib": 1, "classmethod": 1, "parse_api_secret": 1, "complex": 1, "from_env_fil": 1, "extra": 1, "ignor": 1, "hide_input_in_error": 1, "complexity_check": 1, "verifi": 1, "strength": 1, "A": 1, "consid": 1, "ha": 1, "32": 1, "digit": 1, "symbol": 1, "uppercas": 1, "lowercas": 1, "assertionerror": 1, "abov": 1, "condit": 1, "gpulib": 1, "usr": 1, "bin": 1, "lspci": 1, "sbin": 1, "system_profil": 1, "c": 1, "system32": 1, "wbem": 1, "wmic": 1, "ex": 1, "_abc_impl": 1, "_abc": 1, "_abc_data": 1, "model_computed_field": 1, "classvar": 1, "computedfieldinfo": 1, "comput": 1, "field": 1, "model_config": 1, "configdict": 1, "conform": 1, "model_field": 1, "fieldinfo": 1, "annot": 1, "metadata": 1, "pathtyp": 1, "path_typ": 1, "about": 1, "defin": 1, "replac": 1, "__fields__": 1, "v1": 1, "wssession": 1, "client_auth": 1, "websocket": 1, "default_factori": 1, "get_librari": 1, "referenc": 1, "datastor": 1, "sqlite3": 1, "create_t": 1, "table_nam": 1, "column": 1, "show_hidden_fil": 1, "include_directori": 1, "deep_scan": 1, "implement": 1, "init": 1, "call": 1, "exce": 1, "429": 1, "too": 1, "calculate_hash": 1, "hash": 1, "base64_encod": 1, "base64": 1, "encod": 1, "base64_decod": 1, "decod": 1, "hex_decod": 1, "hex": 1, "hex_encod": 1, "failed_auth_count": 1, "keep": 1, "track": 1, "more": 1, "raise_error": 1, "bad": 1, "credenti": 1, "extract_credenti": 1, "befor": 1, "verify_login": 1, "generate_cooki": 1, "auth_payload": 1, "timestamp": 1, "session_error": 1, "htmlrespons": 1, "render": 1, "messag": 1, "jinja2": 1, "validate_sess": 1, "cookie_str": 1, "summari": 1, "clear_sess": 1, "clear": 1, "get_expiri": 1, "lease_start": 1, "lease_dur": 1, "expiri": 1, "datetim": 1, "ag": 1, "wa": 1, "made": 1, "date": 1, "gmt": 1, "ctx": 1, "500": 1, "after": 1, "context": 1, "enter": 1, "landing_pag": 1, "land": 1, "jinja": 1, "container_cpu_limit": 1, "nanocpu": 1, "map_docker_stat": 1, "json_data": 1, "get_cpu_perc": 1, "percentag": 1, "asynchron": 1, "get_system_metr": 1, "swap": 1, "nest": 1, "pyudisk_metr": 1, "mean": 1, "60": 1, "avoid": 1, "gather": 1, "everi": 1, "improv": 1, "latenc": 1, "overhead": 1, "system_resourc": 1, "error_endpoint": 1, "logout_endpoint": 1, "out": 1, "login_endpoint": 1, "redirect_url": 1, "monitor_endpoint": 1, "ui": 1, "websocket_endpoint": 1, "fetch": 1, "search": 1}, "objects": {"pyninja.executors": [[1, 0, 0, "-", "auth"], [1, 0, 0, "-", "database"], [1, 0, 0, "-", "routers"], [1, 0, 0, "-", "squire"]], "pyninja.executors.auth": [[1, 1, 1, "", "EPOCH"], [1, 1, 1, "", "forbidden"], [1, 1, 1, "", "handle_auth_error"], [1, 1, 1, "", "incrementer"], [1, 1, 1, "", "level_1"], [1, 1, 1, "", "level_2"]], "pyninja.executors.database": [[1, 1, 1, "", "get_record"], [1, 1, 1, "", "put_record"], [1, 1, 1, "", "remove_record"]], "pyninja.executors.routers": [[1, 1, 1, "", "docs"], [1, 1, 1, "", "get_all_routes"], [1, 1, 1, "", "health"]], "pyninja.executors.squire": [[1, 1, 1, "", "assert_pyudisk"], [1, 1, 1, "", "comma_separator"], [1, 1, 1, "", "convert_seconds"], [1, 1, 1, "", "dynamic_numbers"], [1, 1, 1, "", "envfile_loader"], [1, 1, 1, "", "format_nos"], [1, 1, 1, "", "format_timedelta"], [1, 1, 1, "", "keygen"], [1, 1, 1, "", "load_env"], [1, 1, 1, "", "private_ip_address"], [1, 1, 1, "", "process_command"], [1, 1, 1, "", "public_ip_address"], [1, 1, 1, "", "size_converter"]], "pyninja.features": [[1, 0, 0, "-", "cpu"], [1, 0, 0, "-", "dockerized"], [1, 0, 0, "-", "gpu"], [1, 0, 0, "-", "operations"], [1, 0, 0, "-", "process"], [1, 0, 0, "-", "service"]], "pyninja.features.cpu": [[1, 1, 1, "", "_darwin"], [1, 1, 1, "", "_linux"], [1, 1, 1, "", "_windows"], [1, 1, 1, "", "get_name"]], "pyninja.features.disks": [[1, 0, 0, "-", "__init__"], [1, 0, 0, "-", "linux"], [1, 0, 0, "-", "macOS"], [1, 0, 0, "-", "windows"]], "pyninja.features.disks.__init__": [[1, 1, 1, "", "get_all_disks"]], "pyninja.features.disks.linux": [[1, 1, 1, "", "drive_info"]], "pyninja.features.disks.macOS": [[1, 1, 1, "", "drive_info"], [1, 1, 1, "", "parse_diskutil_output"], [1, 1, 1, "", "parse_size"], [1, 1, 1, "", "update_mountpoints"]], "pyninja.features.disks.windows": [[1, 1, 1, "", "clean_ansi_escape_sequences"], [1, 1, 1, "", "drive_info"], [1, 1, 1, "", "get_disk_usage"], [1, 1, 1, "", "get_drives"], [1, 1, 1, "", "get_physical_disks_and_partitions"], [1, 1, 1, "", "reformat_windows"]], "pyninja.features.dockerized": [[1, 1, 1, "", "get_all_containers"], [1, 1, 1, "", "get_all_images"], [1, 1, 1, "", "get_all_volumes"], [1, 1, 1, "", "get_container_status"], [1, 1, 1, "", "get_running_containers"]], "pyninja.features.gpu": [[1, 1, 1, "", "_darwin"], [1, 1, 1, "", "_linux"], [1, 1, 1, "", "_windows"], [1, 1, 1, "", "get_names"]], "pyninja.features.operations": [[1, 1, 1, "", "default"], [1, 1, 1, "", "get_process_info"], [1, 1, 1, "", "get_service_pid"], [1, 1, 1, "", "get_service_pid_linux"], [1, 1, 1, "", "get_service_pid_macos"], [1, 1, 1, "", "get_service_pid_windows"], [1, 1, 1, "", "process_monitor"], [1, 1, 1, "", "service_monitor"]], "pyninja.features.process": [[1, 1, 1, "", "get_performance"], [1, 1, 1, "", "get_process_status"]], "pyninja.features.service": [[1, 1, 1, "", "get_service_status"], [1, 1, 1, "", "running"], [1, 1, 1, "", "stopped"], [1, 1, 1, "", "unavailable"], [1, 1, 1, "", "unknown"]], "pyninja": [[1, 0, 0, "-", "main"]], "pyninja.main": [[1, 1, 1, "", "get_desc"], [1, 1, 1, "", "redirect_exception_handler"], [1, 1, 1, "", "start"]], "pyninja.modules": [[1, 0, 0, "-", "cache"], [1, 0, 0, "-", "enums"], [1, 0, 0, "-", "exceptions"], [1, 0, 0, "-", "models"], [1, 0, 0, "-", "rate_limit"], [1, 0, 0, "-", "secure"]], "pyninja.modules.cache": [[1, 1, 1, "", "timed_cache"]], "pyninja.modules.enums": [[1, 2, 1, "", "APIEndpoints"], [1, 2, 1, "", "Cookies"], [1, 2, 1, "", "OperatingSystem"], [1, 2, 1, "", "Templates"]], "pyninja.modules.enums.APIEndpoints": [[1, 3, 1, "", "docker_container"], [1, 3, 1, "", "docker_image"], [1, 3, 1, "", "docker_stats"], [1, 3, 1, "", "docker_volume"], [1, 3, 1, "", "docs"], [1, 3, 1, "", "error"], [1, 3, 1, "", "get_all_disks"], [1, 3, 1, "", "get_cpu"], [1, 3, 1, "", "get_cpu_load"], [1, 3, 1, "", "get_disk"], [1, 3, 1, "", "get_file"], [1, 3, 1, "", "get_ip"], [1, 3, 1, "", "get_memory"], [1, 3, 1, "", "get_processor"], [1, 3, 1, "", "health"], [1, 3, 1, "", "list_files"], [1, 3, 1, "", "login"], [1, 3, 1, "", "logout"], [1, 3, 1, "", "monitor"], [1, 3, 1, "", "process_status"], [1, 3, 1, "", "process_usage"], [1, 3, 1, "", "put_file"], [1, 3, 1, "", "redoc"], [1, 3, 1, "", "root"], [1, 3, 1, "", "run_command"], [1, 3, 1, "", "service_status"], [1, 3, 1, "", "service_usage"], [1, 3, 1, "", "ws_system"]], "pyninja.modules.enums.Cookies": [[1, 3, 1, "", "drive"], [1, 3, 1, "", "monitor"], [1, 3, 1, "", "session_token"]], "pyninja.modules.enums.OperatingSystem": [[1, 3, 1, "", "darwin"], [1, 3, 1, "", "linux"], [1, 3, 1, "", "windows"]], "pyninja.modules.enums.Templates": [[1, 3, 1, "", "disk_report"], [1, 3, 1, "", "index"], [1, 3, 1, "", "logout"], [1, 3, 1, "", "main"], [1, 3, 1, "", "session"], [1, 3, 1, "", "unauthorized"]], "pyninja.modules.exceptions": [[1, 4, 1, "", "APIResponse"], [1, 4, 1, "", "RedirectException"], [1, 4, 1, "", "SessionError"], [1, 4, 1, "", "UnSupportedOS"], [1, 1, 1, "", "raise_os_error"]], "pyninja.modules.models": [[1, 2, 1, "", "Database"], [1, 2, 1, "", "DiskLib"], [1, 2, 1, "", "EnvConfig"], [1, 2, 1, "", "GPULib"], [1, 2, 1, "", "ProcessorLib"], [1, 2, 1, "", "RateLimit"], [1, 2, 1, "", "ServiceLib"], [1, 2, 1, "", "ServiceStatus"], [1, 2, 1, "", "Session"], [1, 2, 1, "", "WSSession"], [1, 1, 1, "", "complexity_checker"], [1, 1, 1, "", "get_library"]], "pyninja.modules.models.Database": [[1, 5, 1, "", "create_table"]], "pyninja.modules.models.DiskLib": [[1, 3, 1, "", "darwin"], [1, 3, 1, "", "linux"], [1, 3, 1, "", "windows"]], "pyninja.modules.models.EnvConfig": [[1, 2, 1, "", "Config"], [1, 3, 1, "", "api_secret"], [1, 3, 1, "", "apikey"], [1, 3, 1, "", "database"], [1, 3, 1, "", "disk_lib"], [1, 3, 1, "", "disk_report"], [1, 5, 1, "", "from_env_file"], [1, 3, 1, "", "gpu_lib"], [1, 3, 1, "", "log_config"], [1, 3, 1, "", "max_connections"], [1, 3, 1, "", "monitor_password"], [1, 3, 1, "", "monitor_session"], [1, 3, 1, "", "monitor_username"], [1, 3, 1, "", "ninja_host"], [1, 3, 1, "", "ninja_port"], [1, 3, 1, "", "no_auth"], [1, 5, 1, "", "parse_api_secret"], [1, 3, 1, "", "processes"], [1, 3, 1, "", "processor_lib"], [1, 3, 1, "", "rate_limit"], [1, 3, 1, "", "remote_execution"], [1, 3, 1, "", "service_lib"], [1, 3, 1, "", "services"], [1, 3, 1, "", "udisk_lib"]], "pyninja.modules.models.EnvConfig.Config": [[1, 3, 1, "", "extra"], [1, 3, 1, "", "hide_input_in_errors"]], "pyninja.modules.models.GPULib": [[1, 3, 1, "", "_abc_impl"], [1, 3, 1, "", "darwin"], [1, 3, 1, "", "linux"], [1, 3, 1, "", "model_computed_fields"], [1, 3, 1, "", "model_config"], [1, 3, 1, "", "model_fields"], [1, 3, 1, "", "windows"]], "pyninja.modules.models.ProcessorLib": [[1, 3, 1, "", "darwin"], [1, 3, 1, "", "linux"], [1, 3, 1, "", "windows"]], "pyninja.modules.models.RateLimit": [[1, 3, 1, "", "max_requests"], [1, 3, 1, "", "seconds"]], "pyninja.modules.models.ServiceLib": [[1, 3, 1, "", "darwin"], [1, 3, 1, "", "linux"], [1, 3, 1, "", "windows"]], "pyninja.modules.models.ServiceStatus": [[1, 3, 1, "", "description"], [1, 3, 1, "", "status_code"]], "pyninja.modules.models.Session": [[1, 3, 1, "", "allowed_origins"], [1, 3, 1, "", "auth_counter"], [1, 3, 1, "", "forbid"], [1, 3, 1, "", "info"], [1, 3, 1, "", "rps"]], "pyninja.modules.models.WSSession": [[1, 3, 1, "", "_abc_impl"], [1, 3, 1, "", "client_auth"], [1, 3, 1, "", "invalid"], [1, 3, 1, "", "model_computed_fields"], [1, 3, 1, "", "model_config"], [1, 3, 1, "", "model_fields"]], "pyninja.modules.payloads": [[1, 2, 1, "", "GetFile"], [1, 2, 1, "", "ListFiles"], [1, 2, 1, "", "RunCommand"]], "pyninja.modules.payloads.GetFile": [[1, 3, 1, "", "filepath"]], "pyninja.modules.payloads.ListFiles": [[1, 3, 1, "", "deep_scan"], [1, 3, 1, "", "directory"], [1, 3, 1, "", "include_directories"], [1, 3, 1, "", "show_hidden_files"]], "pyninja.modules.payloads.RunCommand": [[1, 3, 1, "", "command"], [1, 3, 1, "", "timeout"]], "pyninja.modules.rate_limit": [[1, 2, 1, "", "RateLimiter"]], "pyninja.modules.rate_limit.RateLimiter": [[1, 5, 1, "", "init"]], "pyninja.modules.secure": [[1, 1, 1, "", "base64_decode"], [1, 1, 1, "", "base64_encode"], [1, 1, 1, "", "calculate_hash"], [1, 1, 1, "", "hex_decode"], [1, 1, 1, "", "hex_encode"]], "pyninja.monitor": [[1, 0, 0, "-", "authenticator"], [1, 0, 0, "-", "config"], [1, 0, 0, "-", "drive"], [1, 0, 0, "-", "resources"], [1, 0, 0, "-", "routes"]], "pyninja.monitor.authenticator": [[1, 1, 1, "", "extract_credentials"], [1, 1, 1, "", "failed_auth_counter"], [1, 1, 1, "", "generate_cookie"], [1, 1, 1, "", "raise_error"], [1, 1, 1, "", "session_error"], [1, 1, 1, "", "validate_session"], [1, 1, 1, "", "verify_login"]], "pyninja.monitor.config": [[1, 1, 1, "", "clear_session"], [1, 1, 1, "", "get_expiry"]], "pyninja.monitor.drive": [[1, 1, 1, "", "invalidate"], [1, 1, 1, "", "report"]], "pyninja.monitor.resources": [[1, 1, 1, "", "container_cpu_limit"], [1, 1, 1, "", "containers"], [1, 1, 1, "", "get_cpu_percent"], [1, 1, 1, "", "get_docker_stats"], [1, 1, 1, "", "get_system_metrics"], [1, 1, 1, "", "landing_page"], [1, 1, 1, "", "map_docker_stats"], [1, 1, 1, "", "pyudisk_metrics"], [1, 1, 1, "", "system_resources"]], "pyninja.monitor.routes": [[1, 1, 1, "", "error_endpoint"], [1, 1, 1, "", "login_endpoint"], [1, 1, 1, "", "logout_endpoint"], [1, 1, 1, "", "monitor_endpoint"], [1, 1, 1, "", "websocket_endpoint"]], "pyninja.routes": [[1, 0, 0, "-", "fullaccess"], [1, 0, 0, "-", "ipaddr"], [1, 0, 0, "-", "metrics"], [1, 0, 0, "-", "namespace"], [1, 0, 0, "-", "orchestration"]], "pyninja.routes.fullaccess": [[1, 1, 1, "", "get_file"], [1, 1, 1, "", "list_files"], [1, 1, 1, "", "put_file"], [1, 1, 1, "", "run_command"]], "pyninja.routes.ipaddr": [[1, 1, 1, "", "get_ip_address"]], "pyninja.routes.metrics": [[1, 1, 1, "", "get_all_disks"], [1, 1, 1, "", "get_cpu_load_avg"], [1, 1, 1, "", "get_cpu_utilization"], [1, 1, 1, "", "get_disk_utilization"], [1, 1, 1, "", "get_memory_utilization"]], "pyninja.routes.namespace": [[1, 1, 1, "", "get_process_status"], [1, 1, 1, "", "get_process_usage"], [1, 1, 1, "", "get_processor_name"], [1, 1, 1, "", "get_service_status"], [1, 1, 1, "", "get_service_usage"]], "pyninja.routes.orchestration": [[1, 1, 1, "", "get_docker_containers"], [1, 1, 1, "", "get_docker_images"], [1, 1, 1, "", "get_docker_stats"], [1, 1, 1, "", "get_docker_volumes"]]}, "objtypes": {"0": "py:module", "1": "py:function", "2": "py:class", "3": "py:attribute", "4": "py:exception", "5": "py:method"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "function", "Python function"], "2": ["py", "class", "Python class"], "3": ["py", "attribute", "Python attribute"], "4": ["py", "exception", "Python exception"], "5": ["py", "method", "Python method"]}, "titleterms": {"pyninja": [0, 1], "kick": 0, "off": 0, "environ": 0, "variabl": 0, "code": 0, "standard": 0, "releas": 0, "note": 0, "lint": 0, "pypi": 0, "packag": 0, "runbook": 0, "licens": 0, "copyright": 0, "welcom": 1, "": 1, "document": 1, "content": 1, "main": 1, "executor": 1, "api": 1, "authent": 1, "databas": 1, "rout": 1, "squir": 1, "featur": 1, "cpu": 1, "disk": 1, "linux": 1, "maco": 1, "window": 1, "docker": 1, "gpu": 1, "oper": 1, "process": 1, "servic": 1, "modul": 1, "cach": 1, "enum": 1, "except": 1, "model": 1, "payload": 1, "ratelimit": 1, "secur": 1, "monitor": 1, "configur": 1, "drive": 1, "resourc": 1, "indic": 1, "tabl": 1}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 6, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx": 56}}) \ No newline at end of file diff --git a/pyninja/features/cpu.py b/pyninja/features/cpu.py index 9102688..3dc41c9 100644 --- a/pyninja/features/cpu.py +++ b/pyninja/features/cpu.py @@ -1,42 +1,28 @@ import logging import subprocess -from pydantic import FilePath - from pyninja.modules import enums, models LOGGER = logging.getLogger("uvicorn.default") -def _darwin(lib_path: FilePath) -> str: - """Get processor information for macOS. - - Args: - lib_path: Path to the library executable. - """ - command = [lib_path, "-n", "machdep.cpu.brand_string"] +def _darwin() -> str: + """Get processor information for macOS.""" + command = [models.env.processor_lib, "-n", "machdep.cpu.brand_string"] return subprocess.check_output(command).decode().strip() -def _linux(lib_path: FilePath) -> str: - """Get processor information for Linux. - - Args: - lib_path: Path to the library file. - """ - with open(lib_path) as file: +def _linux() -> str: + """Get processor information for Linux.""" + with open(models.env.processor_lib) as file: for line in file: if "model name" in line: return line.split(":")[1].strip() -def _windows(lib_path: FilePath) -> str: - """Get processor information for Windows. - - Args: - lib_path: Path to the library file. - """ - command = f"{lib_path} cpu get name" +def _windows() -> str: + """Get processor information for Windows.""" + command = f"{models.env.processor_lib} cpu get name" output = subprocess.check_output(command, shell=True).decode() return output.strip().split("\n")[1] @@ -54,6 +40,6 @@ def get_name() -> str | None: enums.OperatingSystem.windows: _windows, } try: - return os_map[models.OPERATING_SYSTEM](models.env.processor_lib) + return os_map[models.OPERATING_SYSTEM]() except Exception as error: LOGGER.error(error) diff --git a/pyninja/features/disks/__init__.py b/pyninja/features/disks/__init__.py index 38250b7..2e42cb6 100644 --- a/pyninja/features/disks/__init__.py +++ b/pyninja/features/disks/__init__.py @@ -16,6 +16,6 @@ def get_all_disks() -> List[Dict[str, str]]: enums.OperatingSystem.windows: windows.drive_info, } try: - return os_map[models.OPERATING_SYSTEM](models.env.disk_lib) + return os_map[models.OPERATING_SYSTEM]() except Exception as error: LOGGER.error(error) diff --git a/pyninja/features/disks/linux.py b/pyninja/features/disks/linux.py index 83917a9..7df301b 100644 --- a/pyninja/features/disks/linux.py +++ b/pyninja/features/disks/linux.py @@ -2,22 +2,19 @@ import subprocess from typing import Dict, List -from pydantic import FilePath +from pyninja.modules import models -def drive_info(lib_path: FilePath) -> List[Dict[str, str]]: +def drive_info() -> List[Dict[str, str]]: """Get disks attached to Linux devices. - Args: - lib_path: Returns the library path for disk information. - Returns: List[Dict[str, str]]: Returns disks information for Linux distros. """ # Using -d to list only physical disks, and filtering out loop devices result = subprocess.run( - [lib_path, "-o", "NAME,SIZE,TYPE,MODEL,MOUNTPOINT", "-J"], + [models.env.disk_lib, "-o", "NAME,SIZE,TYPE,MODEL,MOUNTPOINT", "-J"], capture_output=True, text=True, ) diff --git a/pyninja/features/disks/macOS.py b/pyninja/features/disks/macOS.py index 27e2d1b..c35c39b 100644 --- a/pyninja/features/disks/macOS.py +++ b/pyninja/features/disks/macOS.py @@ -4,9 +4,8 @@ from collections import defaultdict from typing import Dict, List -from pydantic import FilePath - from pyninja.executors import squire +from pyninja.modules import models LOGGER = logging.getLogger("uvicorn.default") @@ -75,17 +74,16 @@ def parse_diskutil_output(stdout: str) -> List[Dict[str, str]]: return disks -def drive_info(lib_path: FilePath) -> List[Dict[str, str]]: +def drive_info() -> List[Dict[str, str]]: """Get disks attached to macOS devices. - Args: - lib_path: Returns the library path for disk information. - Returns: List[Dict[str, str]]: Returns disks information for macOS devices. """ - result = subprocess.run([lib_path, "info", "-all"], capture_output=True, text=True) + result = subprocess.run( + [models.env.disk_lib, "info", "-all"], capture_output=True, text=True + ) disks = parse_diskutil_output(result.stdout) device_ids = defaultdict(list) physical_disks = [] diff --git a/pyninja/features/disks/windows.py b/pyninja/features/disks/windows.py index 59ea80b..b8f83e3 100644 --- a/pyninja/features/disks/windows.py +++ b/pyninja/features/disks/windows.py @@ -5,9 +5,8 @@ import subprocess from typing import Dict, List, Tuple -from pydantic import FilePath - from pyninja.executors import squire +from pyninja.modules import models LOGGER = logging.getLogger("uvicorn.default") @@ -31,19 +30,17 @@ def reformat_windows(data: Dict[str, str | int | float]) -> Dict[str, str]: return data -def get_drives(lib_path: FilePath) -> List[Dict[str, str]]: +def get_drives() -> List[Dict[str, str]]: """Get physical drives connected to a Windows machine. - Args: - lib_path: Library path for disk information. - Returns: List[Dict[str, str]]: Returns the formatted data for all the drives as a list of key-value pairs. """ + # noinspection LongLine ps_command = "Get-CimInstance Win32_DiskDrive | Select-Object Caption, DeviceID, Model, Partitions, Size | ConvertTo-Json" # noqa: E501 result = subprocess.run( - [lib_path, "-Command", ps_command], capture_output=True, text=True + [models.env.disk_lib, "-Command", ps_command], capture_output=True, text=True ) disks_info = json.loads(result.stdout) if isinstance(disks_info, list): @@ -65,18 +62,15 @@ def clean_ansi_escape_sequences(text: str) -> str: return ansi_escape.sub("", text) -def get_physical_disks_and_partitions(lib_path: FilePath) -> List[Tuple[str, str, str]]: +def get_physical_disks_and_partitions() -> List[Tuple[str, str, str]]: """Powershell Core command to get physical disks and their partitions with drive letters (mount points). - Args: - lib_path: Library path for disk information. - Returns: List[Tuple[str, str, str]]: List of tuples with disk_number, partition_number, mount_point. """ command_ps = [ - lib_path, + models.env.disk_lib, "-Command", """ Get-PhysicalDisk | ForEach-Object { @@ -100,7 +94,7 @@ def get_physical_disks_and_partitions(lib_path: FilePath) -> List[Tuple[str, str ) if result.stderr: - print("Error:", result.stderr) + LOGGER.error(result.stderr) return [] # Clean the output to remove ANSI escape sequences @@ -126,17 +120,14 @@ def get_physical_disks_and_partitions(lib_path: FilePath) -> List[Tuple[str, str return disks_and_partitions -def get_disk_usage(lib_path: FilePath) -> Dict[str, List[str]]: +def get_disk_usage() -> Dict[str, List[str]]: """Get all physical disks and their partitions with mount points. - Args: - lib_path: Library path for disk information. - Returns: Dict[str, List[str]]: Returns a dictionary of DeviceID as key and mount paths as value. """ - disks_and_partitions = get_physical_disks_and_partitions(lib_path) + disks_and_partitions = get_physical_disks_and_partitions() if not disks_and_partitions: LOGGER.error("No disks or partitions found.") @@ -151,18 +142,15 @@ def get_disk_usage(lib_path: FilePath) -> Dict[str, List[str]]: return output_data -def drive_info(lib_path: FilePath) -> List[Dict[str, str]]: +def drive_info() -> List[Dict[str, str]]: """Get disks attached to Windows devices. - Args: - lib_path: Library path for disk information. - Returns: List[Dict[str, str]]: Returns disks information for Windows machines. """ - data = get_drives(lib_path) - usage = get_disk_usage(lib_path) + data = get_drives() + usage = get_disk_usage() for item in data: device_id = item["ID"] item.pop("ID") diff --git a/pyninja/features/gpu.py b/pyninja/features/gpu.py index 2d47f77..d3e466b 100644 --- a/pyninja/features/gpu.py +++ b/pyninja/features/gpu.py @@ -3,25 +3,20 @@ import subprocess from typing import Dict, List, Optional -from pydantic import FilePath - from pyninja.modules import models LOGGER = logging.getLogger("uvicorn.default") -def _darwin(lib_path) -> Optional[List[Dict[str, str]]]: +def _darwin() -> Optional[List[Dict[str, str]]]: """Get GPU model and vendor information for Linux operating system. - Args: - lib_path: Library path to get GPU information. - Returns: List[Dict[str, str]]: Returns a list of GPU model and vendor information. """ result = subprocess.run( - [lib_path, "SPDisplaysDataType", "-json"], + [models.env.gpu_lib, "SPDisplaysDataType", "-json"], capture_output=True, text=True, ) @@ -45,18 +40,15 @@ def _darwin(lib_path) -> Optional[List[Dict[str, str]]]: return gpu_info -def _linux(lib_path) -> Optional[List[Dict[str, str]]]: +def _linux() -> Optional[List[Dict[str, str]]]: """Get GPU model and vendor information for Linux operating system. - Args: - lib_path: Library path to get GPU information. - Returns: List[Dict[str, str]]: Returns a list of GPU model and vendor information. """ result = subprocess.run( - [lib_path], + [models.env.gpu_lib], capture_output=True, text=True, ) @@ -78,19 +70,16 @@ def _linux(lib_path) -> Optional[List[Dict[str, str]]]: return gpu_info -def _windows(lib_path: FilePath) -> Optional[List[Dict[str, str]]]: +def _windows() -> Optional[List[Dict[str, str]]]: """Get GPU model and vendor information for Windows operating system. - Args: - lib_path: Library path to get GPU information. - Returns: List[Dict[str, str]]: Returns a list of GPU model and vendor information. """ result = subprocess.run( [ - lib_path, + models.env.gpu_lib, "path", "win32_videocontroller", "get", @@ -129,6 +118,6 @@ def get_names() -> List[Dict[str, str]]: """Get list of GPU model and vendor information based on the operating system.""" fn_map = dict(linux=_linux, darwin=_darwin, windows=_windows) try: - return fn_map[models.OPERATING_SYSTEM](models.env.gpu_lib) + return fn_map[models.OPERATING_SYSTEM]() except (subprocess.SubprocessError, FileNotFoundError) as error: LOGGER.debug(error) diff --git a/pyninja/features/operations.py b/pyninja/features/operations.py index 79216ff..2a9bba2 100644 --- a/pyninja/features/operations.py +++ b/pyninja/features/operations.py @@ -173,13 +173,14 @@ def get_service_pid_linux(service_name: str) -> Optional[int]: """ try: output = subprocess.check_output( - ["systemctl", "show", service_name, "--property=MainPID"], text=True + [models.env.service_lib, "show", service_name, "--property=MainPID"], + text=True, ) for line in output.splitlines(): if line.startswith("MainPID="): return int(line.split("=")[1].strip()) except subprocess.CalledProcessError as error: - LOGGER.error("%s - %s", error.returncode, error.stderr) + LOGGER.debug("%s - %s", error.returncode, error.stderr) def get_service_pid_macos(service_name: str) -> Optional[int]: @@ -193,12 +194,12 @@ def get_service_pid_macos(service_name: str) -> Optional[int]: Returns the PID of the service. """ try: - output = subprocess.check_output(["launchctl", "list"], text=True) + output = subprocess.check_output([models.env.service_lib, "list"], text=True) for line in output.splitlines(): if service_name in line: return int(line.split()[0]) # Assuming PID is the first column except subprocess.CalledProcessError as error: - LOGGER.error("%s - %s", error.returncode, error.stderr) + LOGGER.debug("%s - %s", error.returncode, error.stderr) def get_service_pid_windows(service_name: str) -> Optional[int]: @@ -212,9 +213,11 @@ def get_service_pid_windows(service_name: str) -> Optional[int]: Returns the PID of the service. """ try: - output = subprocess.check_output(["sc", "query", service_name], text=True) + output = subprocess.check_output( + [models.env.service_lib, "query", service_name], text=True + ) for line in output.splitlines(): if "PID" in line: return int(line.split(":")[1].strip()) except subprocess.CalledProcessError as error: - LOGGER.error("%s - %s", error.returncode, error.stderr) + LOGGER.debug("%s - %s", error.returncode, error.stderr)