os
This commit is contained in:
parent
047ccc2bb8
commit
d599b19833
2 changed files with 39 additions and 19 deletions
30
pubnix.py
30
pubnix.py
|
@ -32,16 +32,30 @@ class PubNix:
|
|||
self.url.append(self.context)
|
||||
self.url = '/'.join(self.url)
|
||||
|
||||
def run(self, *args):
|
||||
subprocess.call(['ssh',
|
||||
'-o', 'LogLevel Error',
|
||||
'-p', str(self.port),
|
||||
f'{self.user}@{self.ssh}',
|
||||
'--',
|
||||
*args])
|
||||
def capturun(self, *args):
|
||||
return self.run(*args, capture_output=True)
|
||||
|
||||
def run(self, *args, **kwargs):
|
||||
return subprocess.run(['ssh',
|
||||
'-o', 'LogLevel Error',
|
||||
'-p', str(self.port),
|
||||
f'{self.user}@{self.ssh}',
|
||||
'--',
|
||||
*args,
|
||||
], **kwargs)
|
||||
|
||||
def disk_free(self):
|
||||
self.run('df', '-h', os.curdir)
|
||||
process = self.capturun('df', '-h', os.curdir)
|
||||
return process.stdout.decode('UTF-8').strip()
|
||||
|
||||
def os(self):
|
||||
ps = self.capturun('cat', '/etc/os-release')
|
||||
if ps.returncode == 0:
|
||||
for line in ps.stdout.decode('UTF-8').strip().split(os.linesep):
|
||||
if 'PRETTY_NAME' in line:
|
||||
return line.split('=')[1].split('"')[1]
|
||||
else:
|
||||
return self.capturun('uname', '-sr').stdout.decode('UTF-8').strip()
|
||||
|
||||
def __str__(self):
|
||||
return os.linesep.join([self.target, self.url])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue