lint
This commit is contained in:
parent
6a985e0b89
commit
8b49d6958c
1 changed files with 11 additions and 4 deletions
15
pubnix.py
15
pubnix.py
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import annotations
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -13,13 +14,13 @@ class PubNix:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
dn,
|
dn,
|
||||||
ssh: str = None,
|
ssh: str | None = None,
|
||||||
port: int = PORT,
|
port: int = PORT,
|
||||||
user: str = USER,
|
user: str = USER,
|
||||||
root: str = ROOT,
|
root: str = ROOT,
|
||||||
dir: bool = DIR,
|
dir: bool = DIR,
|
||||||
web: str = None,
|
web: str | None = None,
|
||||||
sub: bool = None,
|
sub: bool | None = None,
|
||||||
):
|
):
|
||||||
self.dn = dn
|
self.dn = dn
|
||||||
self.ssh = f"{ssh}.{self.dn}" if ssh else self.dn
|
self.ssh = f"{ssh}.{self.dn}" if ssh else self.dn
|
||||||
|
@ -59,15 +60,21 @@ class PubNix:
|
||||||
)
|
)
|
||||||
|
|
||||||
def disk_free(self) -> str:
|
def disk_free(self) -> str:
|
||||||
|
"""Fetch free space information."""
|
||||||
process = self.capturun("df", "-h", os.curdir)
|
process = self.capturun("df", "-h", os.curdir)
|
||||||
return process.stdout.decode("UTF-8").strip()
|
return process.stdout.decode("UTF-8").strip()
|
||||||
|
|
||||||
def os(self) -> str:
|
def os(self) -> str:
|
||||||
|
"""Fetch Operating System release information."""
|
||||||
ps = self.capturun("cat", "/etc/os-release")
|
ps = self.capturun("cat", "/etc/os-release")
|
||||||
if ps.returncode == 0:
|
if ps.returncode == 0:
|
||||||
for line in ps.stdout.decode("UTF-8").strip().split(os.linesep):
|
for line in ps.stdout.decode("UTF-8").strip().split(os.linesep):
|
||||||
if "PRETTY_NAME" in line:
|
if "PRETTY_NAME" in line:
|
||||||
return line.split("=")[1].split('"')[1]
|
text = line.split("=")[1].split('"')[1]
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
text = ""
|
||||||
|
return text
|
||||||
else:
|
else:
|
||||||
return self.capturun("uname", "-sr").stdout.decode("UTF-8").strip()
|
return self.capturun("uname", "-sr").stdout.decode("UTF-8").strip()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue