PK!| 66sysfacts/__init__.py__version__ = "0.1.2" from .api import collect_facts PK!dGsysfacts/api.py# from __future__ import annotations import platform import cpuinfo # type: ignore import distro # type: ignore import pendulum # type: ignore import psutil # type: ignore # TODO @##@#$! mypy def _to_dict(named_tuple) -> dict: return dict(named_tuple._asdict()) def get_timestamp() -> str: return str(pendulum.now()) def get_os_release() -> dict: return distro.os_release_info() def get_lsb_release() -> dict: return distro.lsb_release_info() def get_distro_release() -> dict: return distro.distro_release_info() def get_uname() -> dict: return _to_dict(platform.uname()) def get_cpuinfo() -> dict: return cpuinfo.get_cpu_info() def get_memory_info() -> dict: return _to_dict(psutil.virtual_memory()) def get_swap_info() -> dict: return _to_dict(psutil.swap_memory()) def get_cpu_usage() -> dict: return _to_dict(psutil.cpu_times_percent()) def collect_facts() -> dict: """ Return a dictionary with data collected from various source. """ data: dict = { "timestamp": get_timestamp(), "os_release": get_os_release(), "lsb_release": get_lsb_release(), "distro_release": get_distro_release(), "uname": get_uname(), "cpu_info": get_cpuinfo(), "memory_info": get_memory_info(), "swap_info": get_swap_info(), "cpu_usage": get_cpu_usage(), } return data __all__ = ["collect_facts"] PK!O^ sysfacts/cli.pyimport io import json import click import ruamel.yaml # type: ignore from pygments import highlight, lexers, formatters # type: ignore from .api import collect_facts from . import __version__ # https://yaml.readthedocs.io/en/latest/example.html#output-of-dump-as-a-string class StringYAML(ruamel.yaml.YAML): def dump(self, data, stream=None, **kw): inefficient = False if stream is None: inefficient = True stream = io.StringIO() ruamel.yaml.YAML.dump(self, data, stream, **kw) if inefficient: return stream.getvalue() syaml = StringYAML(typ="safe", pure=True) def colorize(string: str, lexer) -> str: colored = highlight(string, lexer, formatters.TerminalFormatter()) return colored @click.command() @click.option("-c", "--color", is_flag=True, help="Colorizes output") @click.option("-p", "--pretty", is_flag=True, help="Pretty prints json output") @click.option("-y", "--yaml", is_flag=True, help="Returns facts as yaml") @click.version_option(version=__version__) def main(color, pretty, yaml): """Gather facts about the system.""" facts = collect_facts() if yaml: out = syaml.dump(facts) if color: out = colorize(out, lexers.YamlLexer()) else: if pretty: out = json.dumps(facts, indent=2) if color: out = colorize(out, lexers.JsonLexer()) else: out = json.dumps(facts) click.echo(out) PK!HmQ).)sysfacts-0.1.2.dist-info/entry_points.txtN+I/N.,()*,NKL.)1s2r3PK!:h   sysfacts-0.1.2.dist-info/LICENSEMIT License Copyright (c) 2019 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK!HnHTUsysfacts-0.1.2.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!H L !sysfacts-0.1.2.dist-info/METADATAVr6}WF-7֍NM-Ws%yŕgww/uf! Ζ[pi.e.3ɏ?Ύ{cUN wfI~)6:k5s)qnLkZ]*2*̟>^Lj(=X<6:8'@>UYz:>{&Rg{`.uڊ g?K_ܸBOVu/MIރ5^{)}\'E{5L{ Ԍl[=[Tu2''ڗ+Yy#mn;GMS<{_5q)cWBѣ_|ђ;˵)W x0\䕂5 F~̷Y, X #˯(05BE B0FzkP:8@&~jZeN$wGG V$o$toE5GZD7I9 j[㟢\;IW4)zʅ(j.5Zx "4r_ɺfĤK1 P]XDo}!%HXGtXmwWP$E빓"HgouJNX-%#a 4ݖl.j^|<8|tSx kPH@x a^) I:vu dBܓ:o;u֢T8=X#kZcZ&=h4'RIo(ӓt'cYSйѵ1X7q-Nj\QAW8a)%XhD.ƐA&)Lb1z}Ȍ{ا!\tyX?ezW<ږ|u}BΙ]')_V*0dBtܰQ(?g]o(jw2֯G65x~2Z7 AQ/#+L"*;O hoըZl IXmV1$t{ۃj15μsg*W&:"Kޓ. [90%)(!j W m]XZptC'(gPK!Ho"esysfacts-0.1.2.dist-info/RECORD}Iz@@}JZDl6|@XLldcGfiO^h>6L[ xLo6BjdI4ߠc1>^J]CCB EצsԵEӓM?QzR AQaTXtMHG3'. pOh^7lƸ8Ob &fu ̏.ұbwD 粍T(PK!| 66sysfacts/__init__.pyPK!dGhsysfacts/api.pyPK!O^ 7sysfacts/cli.pyPK!HmQ).)= sysfacts-0.1.2.dist-info/entry_points.txtPK!:h   sysfacts-0.1.2.dist-info/LICENSEPK!HnHTU sysfacts-0.1.2.dist-info/WHEELPK!H L !sysfacts-0.1.2.dist-info/METADATAPK!Ho"esysfacts-0.1.2.dist-info/RECORDPKI